Skip to content

Commit

Permalink
Merge pull request #106 from dsyzhu/app
Browse files Browse the repository at this point in the history
Improve compile option login
  • Loading branch information
dsyzhu authored Apr 18, 2020
2 parents cca9ed8 + 4c346fa commit fc59d35
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public class PlannerCompilerModule extends AbstractModule {

@Override
protected void configure() {
OptionalBinder.newOptionalBinder(binder(), Key.get(PlanProgramCompileOptions.class))
.setDefault().toInstance(PlanProgramCompileOptions.DEFAULT_OPTIONS);
bind(ProgramCompiler.class).to(PlanProgramCompiler.class);
install(new PlanScopedModule());
install(new ASMClassSourceModule());
OptionalBinder.newOptionalBinder(binder(), Key.get(PlanProgramCompileOptions.class))
.setDefault().toInstance(PlanProgramCompileOptions.DEFAULT_OPTIONS);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright (c) 2016 Yahoo Inc.
* Licensed under the terms of the Apache version 2.0 license.
* See LICENSE file for terms.
*/

package com.yahoo.yqlplus.engine.internal.compiler.streams;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public ForkTask plan(Step root) {
*/

public ForkTask plan(Step root, PlanProgramCompileOptions planProgramCompileOptions) {

final boolean keepMergeSequential = planProgramCompileOptions != null && planProgramCompileOptions.isKeepMergeSequential();

Map<Step, Node> nodes = Maps.newIdentityHashMap();

discover(root, nodes);
Expand Down Expand Up @@ -123,7 +126,9 @@ public ForkTask plan(Step root, PlanProgramCompileOptions planProgramCompileOpti
target.available.addAll(node.available);
nodes.remove(key);

if (planProgramCompileOptions != null && !planProgramCompileOptions.isKeepMergeSequential()) {
if (keepMergeSequential) {
modified = true;
} else {
//check if all non-END nodes only have one todo
boolean found = false;
for (Map.Entry<Step, Node> entry : nodes.entrySet()) {
Expand All @@ -137,8 +142,6 @@ public ForkTask plan(Step root, PlanProgramCompileOptions planProgramCompileOpti
}
}
modified = found;
} else {
modified = true;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,17 @@ public void testDeepJoin() throws Exception {
"machines", MachineSource.class));
YQLPlusCompiler compiler = injector.getInstance(YQLPlusCompiler.class);
CompiledProgram program = compiler.compile(
"SELECT p.*" +
"SELECT p.*" +
"FROM zones c " +
" JOIN models i ON c.id = i.zone " +
" JOIN machines p ON p.zone = i.zone AND p.domain = i.domain AND p.service = i.service AND p.name = i.name " +
"OUTPUT AS foo;");
"OUTPUT AS foo;");
ProgramResult myResult = program.run(ImmutableMap.<String, Object>of(), true);
YQLResultSet rez = myResult.getResult("foo").get();
List<Record> foo = rez.getResult();
Assert.assertEquals(foo.size(), 12);
}

@Test
public void testDeepJoinCaseInsensitive() throws Exception {
Injector injector = Guice.createInjector(new JavaTestModule(),
Expand All @@ -284,7 +284,7 @@ public void testDeepJoinCaseInsensitive() throws Exception {
"machines", MachineSource.class));
YQLPlusCompiler compiler = injector.getInstance(YQLPlusCompiler.class);
CompiledProgram program = compiler.compile(
" SELECT p.*" +
" SELECT p.*" +
" FROM zones c " +
" JOIN models i ON c.id = i.zone " +
" JOIN machines p ON p.zone = i.ZoNe AND p.domain = i.Domain AND p.serVice = i.serviCe AND p.NAME = i.NAME " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ public void testPerformanceIssue() throws Exception {
List<SampleExecutionSource.Sample> samples = programResult.getResult("samples").get().getResult();
assertEquals(2, samples.size());
assertFalse(samples.get(0).id.equals(samples.get(1).id));
assertTrue(Math.max(samples.get(0).start, samples.get(1).start) < Math.min(samples.get(0).end, samples.get(1).end));
System.out.println("samples.get(0).start " + samples.get(0).start);
System.out.println("samples.get(1).start " + samples.get(1).start);
System.out.println("samples.get(0).end " + samples.get(0).end);
System.out.println("samples.get(1).end " + samples.get(1).end);
assertTrue(Math.max(samples.get(0).start, samples.get(1).start) <= Math.min(samples.get(0).end, samples.get(1).end));
}

@Test
Expand Down

0 comments on commit fc59d35

Please sign in to comment.