http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestHashToRandomExchange.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestHashToRandomExchange.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestHashToRandomExchange.java index e3fca85..10ee46a 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestHashToRandomExchange.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestHashToRandomExchange.java @@ -32,7 +32,6 @@ import org.junit.Test; import com.google.common.base.Charsets; import com.google.common.io.Files; - public class TestHashToRandomExchange extends PopUnitTestBase { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestHashToRandomExchange.class); @@ -40,7 +39,7 @@ public class TestHashToRandomExchange extends PopUnitTestBase { public void twoBitTwoExchangeTwoEntryRun() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); Drillbit bit2 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { @@ -51,9 +50,10 @@ public class TestHashToRandomExchange extends PopUnitTestBase { Files.toString(FileUtils.getResourceAsFile("/sender/hash_exchange.json"), Charsets.UTF_8)); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } b.release(); } assertEquals(200, count);
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestImplicitCastFunctions.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestImplicitCastFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestImplicitCastFunctions.java index 13c9364..141c9cd 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestImplicitCastFunctions.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestImplicitCastFunctions.java @@ -67,7 +67,7 @@ public class TestImplicitCastFunctions extends ExecTest { public void runTest(@Injectable final DrillbitContext bitContext, @Injectable UserServer.UserClientConnection connection, Object[] expectedResults, String planPath) throws Throwable { - new NonStrictExpectations(){{ + new NonStrictExpectations() {{ bitContext.getMetrics(); result = new MetricRegistry(); bitContext.getAllocator(); result = new TopLevelAllocator(); bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c); @@ -76,14 +76,20 @@ public class TestImplicitCastFunctions extends ExecTest { }}; String planString = Resources.toString(Resources.getResource(planPath), Charsets.UTF_8); - if(reader == null) reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance()); - if(registry == null) registry = new FunctionImplementationRegistry(c); - if(context == null) context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry); + if (reader == null) { + reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance()); + } + if (registry == null) { + registry = new FunctionImplementationRegistry(c); + } + if (context == null) { + context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry); + } PhysicalPlan plan = reader.readPhysicalPlan(planString); SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next())); - while(exec.next()){ + while (exec.next()) { Object [] res = getRunResult(exec); assertEquals("return count does not match", res.length, expectedResults.length); @@ -92,7 +98,7 @@ public class TestImplicitCastFunctions extends ExecTest { } } - if(context.getFailureCause() != null){ + if (context.getFailureCause() != null) { throw context.getFailureCause(); } @@ -144,24 +150,24 @@ public class TestImplicitCastFunctions extends ExecTest { runTest(bitContext, connection, expected, "functions/cast/testICastMockCol.json"); } - @Test - public void testImplicitCastWithNullExpression(@Injectable final DrillbitContext bitContext, - @Injectable UserServer.UserClientConnection connection) throws Throwable{ - Object [] expected = new Object[10]; + @Test + public void testImplicitCastWithNullExpression(@Injectable final DrillbitContext bitContext, + @Injectable UserServer.UserClientConnection connection) throws Throwable{ + Object [] expected = new Object[10]; - expected [0] = Boolean.TRUE; - expected [1] = Boolean.FALSE; - expected [2] = Boolean.FALSE; - expected [3] = Boolean.TRUE; + expected [0] = Boolean.TRUE; + expected [1] = Boolean.FALSE; + expected [2] = Boolean.FALSE; + expected [3] = Boolean.TRUE; - expected [4] = null; - expected [5] = null; - expected [6] = null; - expected [7] = null; - expected [8] = null; - expected [9] = null; + expected [4] = null; + expected [5] = null; + expected [6] = null; + expected [7] = null; + expected [8] = null; + expected [9] = null; - runTest(bitContext, connection, expected, "functions/cast/testICastNullExp.json"); - } + runTest(bitContext, connection, expected, "functions/cast/testICastNullExp.json"); + } } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFragmentRun.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFragmentRun.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFragmentRun.java index 5dd64e1..68e2112 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFragmentRun.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFragmentRun.java @@ -44,17 +44,16 @@ public class TestSimpleFragmentRun extends PopUnitTestBase { private static final Charset UTF_8 = Charset.forName("UTF-8"); - @Test public void runNoExchangeFragment() throws Exception { - try(RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); + try (RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); Drillbit bit = new Drillbit(CONFIG, serviceSet); - DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());){ + DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { // run query. bit.run(); client.connect(); - String path = "/physical_test2.json"; + String path = "/physical_test2.json"; // String path = "/filter/test1.json"; List<QueryResultBatch> results = client.runQuery(QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile(path), Charsets.UTF_8)); @@ -62,7 +61,6 @@ public class TestSimpleFragmentRun extends PopUnitTestBase { RecordBatchLoader batchLoader = new RecordBatchLoader(client.getAllocator()); int recordCount = 0; for (QueryResultBatch batch : results) { - boolean schemaChanged = batchLoader.load(batch.getHeader().getDef(), batch.getData()); boolean firstColumn = true; @@ -95,7 +93,9 @@ public class TestSimpleFragmentRun extends PopUnitTestBase { } System.out.print(value.getValueVector().getAccessor().getObject(i)); } - if(!first) System.out.println(); + if (!first) { + System.out.println(); + } } batchLoader.clear(); batch.release(); @@ -170,7 +170,9 @@ public class TestSimpleFragmentRun extends PopUnitTestBase { ValueVector.Accessor accessor = v.getValueVector().getAccessor(); System.out.print(accessor.getObject(r)); } - if (!first) System.out.println(); + if (!first) { + System.out.println(); + } } batchLoader.clear(); batch.release(); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestStringFunctions.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestStringFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestStringFunctions.java index a48510f..aa3548d 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestStringFunctions.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestStringFunctions.java @@ -62,15 +62,16 @@ public class TestStringFunctions extends ExecTest { for (ValueVector v : exec) { if (v instanceof VarCharVector) { res[i++] = new String( ((VarCharVector) v).getAccessor().get(0), Charsets.UTF_8); - } else + } else { res[i++] = v.getAccessor().getObject(0); + } } return res; } public void runTest(@Injectable final DrillbitContext bitContext, @Injectable UserServer.UserClientConnection connection, Object[] expectedResults, String planPath) throws Throwable { - new NonStrictExpectations(){{ + new NonStrictExpectations() {{ bitContext.getMetrics(); result = new MetricRegistry(); bitContext.getAllocator(); result = new TopLevelAllocator(); bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c); @@ -79,14 +80,19 @@ public class TestStringFunctions extends ExecTest { }}; String planString = Resources.toString(Resources.getResource(planPath), Charsets.UTF_8); - if(reader == null) reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance()); - if(registry == null) registry = new FunctionImplementationRegistry(c); - if(context == null) context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry); //new FragmentContext(bitContext, ExecProtos.FragmentHandle.getDefaultInstance(), connection, registry); + if (reader == null) { + reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance()); + } + if (registry == null) { + registry = new FunctionImplementationRegistry(c); + } + if (context == null) { + context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry); //new FragmentContext(bitContext, ExecProtos.FragmentHandle.getDefaultInstance(), connection, registry); + } PhysicalPlan plan = reader.readPhysicalPlan(planString); SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next())); - - while(exec.next()){ + while(exec.next()) { Object [] res = getRunResult(exec); assertEquals("return count does not match", expectedResults.length, res.length); @@ -95,10 +101,9 @@ public class TestStringFunctions extends ExecTest { } } - if(context.getFailureCause() != null){ + if (context.getFailureCause() != null) { throw context.getFailureCause(); } - assertTrue(!context.isFailed()); } @@ -247,4 +252,5 @@ public class TestStringFunctions extends ExecTest { Object [] expected = new Object[] {97, 65, -32, "A", "btrim", "Peace Peace Peace ", "हà¤à¥à¤¨à¤¾ मताता हà¤à¥à¤¨à¤¾ मताता ", "katcit", "\u00C3\u00A2pple", "नदम"}; runTest(bitContext, connection, expected, "functions/string/testStringFuncs.json"); } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestUnionExchange.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestUnionExchange.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestUnionExchange.java index 4ad215d..271af72 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestUnionExchange.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestUnionExchange.java @@ -32,7 +32,6 @@ import org.junit.Test; import com.google.common.base.Charsets; import com.google.common.io.Files; - public class TestUnionExchange extends PopUnitTestBase { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestUnionExchange.class); @@ -40,7 +39,7 @@ public class TestUnionExchange extends PopUnitTestBase { public void twoBitTwoExchangeTwoEntryRun() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); Drillbit bit2 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { @@ -51,9 +50,10 @@ public class TestUnionExchange extends PopUnitTestBase { Files.toString(FileUtils.getResourceAsFile("/sender/union_exchange.json"), Charsets.UTF_8)); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } b.release(); } assertEquals(150, count); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TopN/TestSimpleTopN.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TopN/TestSimpleTopN.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TopN/TestSimpleTopN.java index 430c505..ccc052d 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TopN/TestSimpleTopN.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TopN/TestSimpleTopN.java @@ -42,12 +42,11 @@ public class TestSimpleTopN extends PopUnitTestBase { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestSimpleTopN.class); DrillConfig c = DrillConfig.create(); - @Test public void sortOneKeyAscending() throws Throwable{ RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); Drillbit bit2 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { @@ -58,9 +57,10 @@ public class TestSimpleTopN extends PopUnitTestBase { Files.toString(FileUtils.getResourceAsFile("/topN/one_key_sort.json"), Charsets.UTF_8)); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } } assertEquals(100, count); @@ -70,7 +70,9 @@ public class TestSimpleTopN extends PopUnitTestBase { int batchCount = 0; for (QueryResultBatch b : results) { - if (b.getHeader().getRowCount() == 0) break; + if (b.getHeader().getRowCount() == 0) { + break; + } batchCount++; RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator()); loader.load(b.getHeader().getDef(),b.getData()); @@ -80,7 +82,7 @@ public class TestSimpleTopN extends PopUnitTestBase { BigIntVector.Accessor a1 = c1.getAccessor(); // IntVector.Accessor a2 = c2.getAccessor(); - for(int i =0; i < c1.getAccessor().getValueCount(); i++){ + for (int i =0; i < c1.getAccessor().getValueCount(); i++) { recordCount++; assertTrue(previousBigInt <= a1.get(i)); previousBigInt = a1.get(i); @@ -88,13 +90,10 @@ public class TestSimpleTopN extends PopUnitTestBase { loader.clear(); b.release(); } - System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount)); } - } - } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoin.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoin.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoin.java index 1f0d89e..f466171 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoin.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoin.java @@ -62,181 +62,181 @@ import com.google.common.base.Charsets; import com.google.common.io.Files; -public class TestHashJoin extends PopUnitTestBase{ - static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestMergeJoin.class); - - @Rule public final TestRule TIMEOUT = TestTools.getTimeoutRule(100000); - - DrillConfig c = DrillConfig.create(); - - private void testHJMockScanCommon(final DrillbitContext bitContext, UserServer.UserClientConnection connection, String physicalPlan, int expectedRows) throws Throwable { - final LocalPStoreProvider provider = new LocalPStoreProvider(c); - provider.start(); - final SystemOptionManager opt = new SystemOptionManager(c, provider); - opt.init(); - new NonStrictExpectations(){{ - bitContext.getMetrics(); result = new MetricRegistry(); - bitContext.getAllocator(); result = new TopLevelAllocator(); - bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c); - bitContext.getConfig(); result = c; - bitContext.getOptionManager(); result = opt; - bitContext.getCompiler(); result = CodeCompiler.getTestCompiler(c); - }}; - - PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance()); - PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile(physicalPlan), Charsets.UTF_8)); - FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c); - FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry); - SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next())); - - int totalRecordCount = 0; - while (exec.next()) { - totalRecordCount += exec.getRecordCount(); - } - exec.stop(); - assertEquals(expectedRows, totalRecordCount); - System.out.println("Total Record Count: " + totalRecordCount); - if (context.getFailureCause() != null) - throw context.getFailureCause(); - assertTrue(!context.isFailed()); +public class TestHashJoin extends PopUnitTestBase { + static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestMergeJoin.class); + + @Rule public final TestRule TIMEOUT = TestTools.getTimeoutRule(100000); + + DrillConfig c = DrillConfig.create(); + + private void testHJMockScanCommon(final DrillbitContext bitContext, UserServer.UserClientConnection connection, String physicalPlan, int expectedRows) throws Throwable { + final LocalPStoreProvider provider = new LocalPStoreProvider(c); + provider.start(); + final SystemOptionManager opt = new SystemOptionManager(c, provider); + opt.init(); + new NonStrictExpectations() {{ + bitContext.getMetrics(); result = new MetricRegistry(); + bitContext.getAllocator(); result = new TopLevelAllocator(); + bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c); + bitContext.getConfig(); result = c; + bitContext.getOptionManager(); result = opt; + bitContext.getCompiler(); result = CodeCompiler.getTestCompiler(c); + }}; + + PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance()); + PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile(physicalPlan), Charsets.UTF_8)); + FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c); + FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry); + SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next())); + + int totalRecordCount = 0; + while (exec.next()) { + totalRecordCount += exec.getRecordCount(); } - - @Test - public void multiBatchEqualityJoin(@Injectable final DrillbitContext bitContext, - @Injectable UserServer.UserClientConnection connection) throws Throwable { - - testHJMockScanCommon(bitContext, connection, "/join/hash_join_multi_batch.json", 200000); + exec.stop(); + assertEquals(expectedRows, totalRecordCount); + System.out.println("Total Record Count: " + totalRecordCount); + if (context.getFailureCause() != null) { + throw context.getFailureCause(); } + assertTrue(!context.isFailed()); + } - @Test - public void multiBatchRightOuterJoin(@Injectable final DrillbitContext bitContext, - @Injectable UserServer.UserClientConnection connection) throws Throwable { + @Test + public void multiBatchEqualityJoin(@Injectable final DrillbitContext bitContext, + @Injectable UserServer.UserClientConnection connection) throws Throwable { - testHJMockScanCommon(bitContext, connection, "/join/hj_right_outer_multi_batch.json", 100000); - } + testHJMockScanCommon(bitContext, connection, "/join/hash_join_multi_batch.json", 200000); + } - @Test - public void multiBatchLeftOuterJoin(@Injectable final DrillbitContext bitContext, - @Injectable UserServer.UserClientConnection connection) throws Throwable { + @Test + public void multiBatchRightOuterJoin(@Injectable final DrillbitContext bitContext, + @Injectable UserServer.UserClientConnection connection) throws Throwable { + testHJMockScanCommon(bitContext, connection, "/join/hj_right_outer_multi_batch.json", 100000); + } - testHJMockScanCommon(bitContext, connection, "/join/hj_left_outer_multi_batch.json", 100000); - } + @Test + public void multiBatchLeftOuterJoin(@Injectable final DrillbitContext bitContext, + @Injectable UserServer.UserClientConnection connection) throws Throwable { - @Test - public void simpleEqualityJoin() throws Throwable { + testHJMockScanCommon(bitContext, connection, "/join/hj_left_outer_multi_batch.json", 100000); + } - // Function checks hash join with single equality condition - try (RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - Drillbit bit = new Drillbit(CONFIG, serviceSet); - DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) { + @Test + public void simpleEqualityJoin() throws Throwable { + // Function checks hash join with single equality condition + try (RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); + Drillbit bit = new Drillbit(CONFIG, serviceSet); + DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) { - // run query. - bit.run(); - client.connect(); - List<QueryResultBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, - Files.toString(FileUtils.getResourceAsFile("/join/hash_join.json"), Charsets.UTF_8) - .replace("#{TEST_FILE_1}", FileUtils.getResourceAsFile("/build_side_input.json").toURI().toString()) - .replace("#{TEST_FILE_2}", FileUtils.getResourceAsFile("/probe_side_input.json").toURI().toString())); + // run query. + bit.run(); + client.connect(); + List<QueryResultBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, + Files.toString(FileUtils.getResourceAsFile("/join/hash_join.json"), Charsets.UTF_8) + .replace("#{TEST_FILE_1}", FileUtils.getResourceAsFile("/build_side_input.json").toURI().toString()) + .replace("#{TEST_FILE_2}", FileUtils.getResourceAsFile("/probe_side_input.json").toURI().toString())); - RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator()); + RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator()); - QueryResultBatch batch = results.get(0); - assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData())); + QueryResultBatch batch = results.get(0); + assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData())); - Iterator<VectorWrapper<?>> itr = batchLoader.iterator(); + Iterator<VectorWrapper<?>> itr = batchLoader.iterator(); - // Just test the join key - long colA[] = {1, 1, 2, 2, 1, 1}; + // Just test the join key + long colA[] = {1, 1, 2, 2, 1, 1}; - // Check the output of decimal9 - ValueVector.Accessor intAccessor1 = itr.next().getValueVector().getAccessor(); + // Check the output of decimal9 + ValueVector.Accessor intAccessor1 = itr.next().getValueVector().getAccessor(); - for (int i = 0; i < intAccessor1.getValueCount(); i++) { - assertEquals(intAccessor1.getObject(i), colA[i]); - } - assertEquals(6, intAccessor1.getValueCount()); + for (int i = 0; i < intAccessor1.getValueCount(); i++) { + assertEquals(intAccessor1.getObject(i), colA[i]); + } + assertEquals(6, intAccessor1.getValueCount()); - batchLoader.clear(); - for (QueryResultBatch result : results) { - result.release(); - } - } + batchLoader.clear(); + for (QueryResultBatch result : results) { + result.release(); + } } + } + + @Test + public void hjWithExchange(@Injectable final DrillbitContext bitContext, + @Injectable UserServer.UserClientConnection connection) throws Throwable { + + // Function tests with hash join with exchanges + try (RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); + Drillbit bit = new Drillbit(CONFIG, serviceSet); + DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) { - @Test - public void hjWithExchange(@Injectable final DrillbitContext bitContext, - @Injectable UserServer.UserClientConnection connection) throws Throwable { - - // Function tests with hash join with exchanges - try (RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - Drillbit bit = new Drillbit(CONFIG, serviceSet); - DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) { - - // run query. - bit.run(); - client.connect(); - List<QueryResultBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, - Files.toString(FileUtils.getResourceAsFile("/join/hj_exchanges.json"), Charsets.UTF_8)); - - int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) - count += b.getHeader().getRowCount(); - b.release(); - } - - System.out.println("Total records: " + count); - assertEquals(25, count); + // run query. + bit.run(); + client.connect(); + List<QueryResultBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, + Files.toString(FileUtils.getResourceAsFile("/join/hj_exchanges.json"), Charsets.UTF_8)); + + int count = 0; + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { + count += b.getHeader().getRowCount(); } + b.release(); + } + + System.out.println("Total records: " + count); + assertEquals(25, count); } + } - @Test - public void multipleConditionJoin(@Injectable final DrillbitContext bitContext, - @Injectable UserServer.UserClientConnection connection) throws Throwable { + @Test + public void multipleConditionJoin(@Injectable final DrillbitContext bitContext, + @Injectable UserServer.UserClientConnection connection) throws Throwable { - // Function tests hash join with multiple join conditions - try (RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - Drillbit bit = new Drillbit(CONFIG, serviceSet); - DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) { + // Function tests hash join with multiple join conditions + try (RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); + Drillbit bit = new Drillbit(CONFIG, serviceSet); + DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) { - // run query. - bit.run(); - client.connect(); - List<QueryResultBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, - Files.toString(FileUtils.getResourceAsFile("/join/hj_multi_condition_join.json"), Charsets.UTF_8) - .replace("#{TEST_FILE_1}", FileUtils.getResourceAsFile("/build_side_input.json").toURI().toString()) - .replace("#{TEST_FILE_2}", FileUtils.getResourceAsFile("/probe_side_input.json").toURI().toString())); + // run query. + bit.run(); + client.connect(); + List<QueryResultBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, + Files.toString(FileUtils.getResourceAsFile("/join/hj_multi_condition_join.json"), Charsets.UTF_8) + .replace("#{TEST_FILE_1}", FileUtils.getResourceAsFile("/build_side_input.json").toURI().toString()) + .replace("#{TEST_FILE_2}", FileUtils.getResourceAsFile("/probe_side_input.json").toURI().toString())); - RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator()); + RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator()); - QueryResultBatch batch = results.get(0); - assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData())); + QueryResultBatch batch = results.get(0); + assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData())); - Iterator<VectorWrapper<?>> itr = batchLoader.iterator(); + Iterator<VectorWrapper<?>> itr = batchLoader.iterator(); - // Just test the join key - long colA[] = {1, 2, 1}; - long colC[] = {100, 200, 500}; + // Just test the join key + long colA[] = {1, 2, 1}; + long colC[] = {100, 200, 500}; - // Check the output of decimal9 - ValueVector.Accessor intAccessor1 = itr.next().getValueVector().getAccessor(); - ValueVector.Accessor intAccessor2 = itr.next().getValueVector().getAccessor(); + // Check the output of decimal9 + ValueVector.Accessor intAccessor1 = itr.next().getValueVector().getAccessor(); + ValueVector.Accessor intAccessor2 = itr.next().getValueVector().getAccessor(); - for (int i = 0; i < intAccessor1.getValueCount(); i++) { - assertEquals(intAccessor1.getObject(i), colA[i]); - assertEquals(intAccessor2.getObject(i), colC[i]); - } - assertEquals(3, intAccessor1.getValueCount()); + for (int i = 0; i < intAccessor1.getValueCount(); i++) { + assertEquals(intAccessor1.getObject(i), colA[i]); + assertEquals(intAccessor2.getObject(i), colC[i]); + } + assertEquals(3, intAccessor1.getValueCount()); - batchLoader.clear(); - for (QueryResultBatch result : results) { - result.release(); - } - } + batchLoader.clear(); + for (QueryResultBatch result : results) { + result.release(); + } } + } @Test @@ -255,9 +255,10 @@ public class TestHashJoin extends PopUnitTestBase{ Files.toString(FileUtils.getResourceAsFile("/join/hj_exchanges1.json"), Charsets.UTF_8)); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } b.release(); } @@ -271,7 +272,7 @@ public class TestHashJoin extends PopUnitTestBase{ public void testHashJoinExprInCondition() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { bit1.run(); @@ -279,13 +280,14 @@ public class TestHashJoin extends PopUnitTestBase{ List<QueryResultBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/join/hashJoinExpr.json"), Charsets.UTF_8)); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } b.release(); } assertEquals(10, count); } } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoin.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoin.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoin.java index 86584bb..a6a1866 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoin.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoin.java @@ -69,7 +69,7 @@ public class TestMergeJoin extends PopUnitTestBase { public void simpleEqualityJoin(@Injectable final DrillbitContext bitContext, @Injectable UserServer.UserClientConnection connection) throws Throwable { - new NonStrictExpectations(){{ + new NonStrictExpectations() {{ bitContext.getMetrics(); result = new MetricRegistry(); bitContext.getAllocator(); result = new TopLevelAllocator(); bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c); @@ -86,8 +86,9 @@ public class TestMergeJoin extends PopUnitTestBase { int totalRecordCount = 0; while (exec.next()) { totalRecordCount += exec.getRecordCount(); - for (ValueVector v : exec) + for (ValueVector v : exec) { System.out.print("[" + v.getField().toExpr() + "] "); + } System.out.println("\n"); for (int valueIdx = 0; valueIdx < exec.getRecordCount(); valueIdx++) { List<Object> row = new ArrayList(); @@ -101,8 +102,9 @@ public class TestMergeJoin extends PopUnitTestBase { } int len = cell.toString().length(); System.out.print(cell); - for (int i = 0; i < (14 - len); ++i) + for (int i = 0; i < (14 - len); ++i) { System.out.print(" "); + } } System.out.println(); } @@ -110,8 +112,9 @@ public class TestMergeJoin extends PopUnitTestBase { } assertEquals(100, totalRecordCount); System.out.println("Total Record Count: " + totalRecordCount); - if (context.getFailureCause() != null) + if (context.getFailureCause() != null) { throw context.getFailureCause(); + } assertTrue(!context.isFailed()); } @@ -121,7 +124,7 @@ public class TestMergeJoin extends PopUnitTestBase { public void orderedEqualityLeftJoin(@Injectable final DrillbitContext bitContext, @Injectable UserServer.UserClientConnection connection) throws Throwable { - new NonStrictExpectations(){{ + new NonStrictExpectations() {{ bitContext.getMetrics(); result = new MetricRegistry(); bitContext.getAllocator(); result = new TopLevelAllocator(); bitContext.getConfig(); result = c; @@ -147,8 +150,9 @@ public class TestMergeJoin extends PopUnitTestBase { for (int valueIdx = 0; valueIdx < exec.getRecordCount(); valueIdx++) { List<Object> row = Lists.newArrayList(); - for (ValueVector v : exec) + for (ValueVector v : exec) { row.add(v.getField().toExpr() + ":" + v.getAccessor().getObject(valueIdx)); + } for (Object cell : row) { if (cell == null) { System.out.print("<null> "); @@ -156,8 +160,9 @@ public class TestMergeJoin extends PopUnitTestBase { } int len = cell.toString().length(); System.out.print(cell + " "); - for (int i = 0; i < (10 - len); ++i) + for (int i = 0; i < (10 - len); ++i) { System.out.print(" "); + } } System.out.println(); } @@ -165,8 +170,9 @@ public class TestMergeJoin extends PopUnitTestBase { System.out.println("Total Record Count: " + totalRecordCount); assertEquals(25, totalRecordCount); - if (context.getFailureCause() != null) + if (context.getFailureCause() != null) { throw context.getFailureCause(); + } assertTrue(!context.isFailed()); } @@ -176,7 +182,7 @@ public class TestMergeJoin extends PopUnitTestBase { public void orderedEqualityInnerJoin(@Injectable final DrillbitContext bitContext, @Injectable UserServer.UserClientConnection connection) throws Throwable { - new NonStrictExpectations(){{ + new NonStrictExpectations() {{ bitContext.getMetrics(); result = new MetricRegistry(); bitContext.getAllocator(); result = new TopLevelAllocator(); bitContext.getConfig(); result = c; @@ -202,8 +208,9 @@ public class TestMergeJoin extends PopUnitTestBase { for (int valueIdx = 0; valueIdx < exec.getRecordCount(); valueIdx++) { List<Object> row = Lists.newArrayList(); - for (ValueVector v : exec) + for (ValueVector v : exec) { row.add(v.getField().toExpr() + ":" + v.getAccessor().getObject(valueIdx)); + } for (Object cell : row) { if (cell == null) { System.out.print("<null> "); @@ -211,8 +218,9 @@ public class TestMergeJoin extends PopUnitTestBase { } int len = cell.toString().length(); System.out.print(cell + " "); - for (int i = 0; i < (10 - len); ++i) + for (int i = 0; i < (10 - len); ++i) { System.out.print(" "); + } } System.out.println(); } @@ -220,8 +228,9 @@ public class TestMergeJoin extends PopUnitTestBase { System.out.println("Total Record Count: " + totalRecordCount); assertEquals(23, totalRecordCount); - if (context.getFailureCause() != null) + if (context.getFailureCause() != null) { throw context.getFailureCause(); + } assertTrue(!context.isFailed()); } @@ -231,7 +240,7 @@ public class TestMergeJoin extends PopUnitTestBase { public void orderedEqualityMultiBatchJoin(@Injectable final DrillbitContext bitContext, @Injectable UserServer.UserClientConnection connection) throws Throwable { - new NonStrictExpectations(){{ + new NonStrictExpectations() {{ bitContext.getMetrics(); result = new MetricRegistry(); bitContext.getAllocator(); result = new TopLevelAllocator(); bitContext.getConfig(); result = c; @@ -256,8 +265,9 @@ public class TestMergeJoin extends PopUnitTestBase { for (int valueIdx = 0; valueIdx < exec.getRecordCount(); valueIdx++) { List<Object> row = Lists.newArrayList(); - for (ValueVector v : exec) + for (ValueVector v : exec) { row.add(v.getField().toExpr() + ":" + v.getAccessor().getObject(valueIdx)); + } for (Object cell : row) { if (cell == null) { System.out.print("<null> "); @@ -265,8 +275,9 @@ public class TestMergeJoin extends PopUnitTestBase { } int len = cell.toString().length(); System.out.print(cell + " "); - for (int i = 0; i < (10 - len); ++i) + for (int i = 0; i < (10 - len); ++i) { System.out.print(" "); + } } System.out.println(); } @@ -274,15 +285,16 @@ public class TestMergeJoin extends PopUnitTestBase { System.out.println("Total Record Count: " + totalRecordCount); assertEquals(25, totalRecordCount); - if (context.getFailureCause() != null) + if (context.getFailureCause() != null) { throw context.getFailureCause(); + } assertTrue(!context.isFailed()); } @Test public void testJoinBatchSize(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable{ - new NonStrictExpectations(){{ + new NonStrictExpectations() {{ bitContext.getMetrics(); result = new MetricRegistry(); bitContext.getAllocator(); result = new TopLevelAllocator();; bitContext.getConfig(); result = c; @@ -295,11 +307,11 @@ public class TestMergeJoin extends PopUnitTestBase { FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c); FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry); SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next())); - while(exec.next()){ + while (exec.next()) { assertEquals(100, exec.getRecordCount()); } - if(context.getFailureCause() != null){ + if (context.getFailureCause() != null) { throw context.getFailureCause(); } assertTrue(!context.isFailed()); @@ -310,7 +322,7 @@ public class TestMergeJoin extends PopUnitTestBase { public void testMergeJoinInnerEmptyBatch() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { bit1.run(); @@ -320,9 +332,10 @@ public class TestMergeJoin extends PopUnitTestBase { Charsets.UTF_8) .replace("${JOIN_TYPE}", "INNER")); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } b.release(); } assertEquals(0, count); @@ -333,7 +346,7 @@ public class TestMergeJoin extends PopUnitTestBase { public void testMergeJoinLeftEmptyBatch() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { bit1.run(); @@ -343,9 +356,10 @@ public class TestMergeJoin extends PopUnitTestBase { Charsets.UTF_8) .replace("${JOIN_TYPE}", "LEFT")); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } b.release(); } assertEquals(50, count); @@ -356,7 +370,7 @@ public class TestMergeJoin extends PopUnitTestBase { public void testMergeJoinRightEmptyBatch() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { bit1.run(); @@ -366,9 +380,10 @@ public class TestMergeJoin extends PopUnitTestBase { Charsets.UTF_8) .replace("${JOIN_TYPE}", "RIGHT")); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } b.release(); } assertEquals(0, count); @@ -379,7 +394,7 @@ public class TestMergeJoin extends PopUnitTestBase { public void testMergeJoinExprInCondition() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { bit1.run(); @@ -387,9 +402,10 @@ public class TestMergeJoin extends PopUnitTestBase { List<QueryResultBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/join/mergeJoinExpr.json"), Charsets.UTF_8)); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } b.release(); } assertEquals(10, count); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoinMulCondition.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoinMulCondition.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoinMulCondition.java index a3a7ace..996b675 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoinMulCondition.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestMergeJoinMulCondition.java @@ -50,7 +50,7 @@ public class TestMergeJoinMulCondition extends PopUnitTestBase { public void testMergeJoinMultiKeys() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { bit1.run(); @@ -59,8 +59,8 @@ public class TestMergeJoinMulCondition extends PopUnitTestBase { Files.toString(FileUtils.getResourceAsFile("/join/mj_multi_condition.json"), Charsets.UTF_8)); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0){ + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); } b.release(); @@ -76,17 +76,17 @@ public class TestMergeJoinMulCondition extends PopUnitTestBase { public void testMergeJoinInnerNullKey() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { - bit1.run(); client.connect(); List<QueryResultBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/join/merge_join_nullkey.json"), Charsets.UTF_8).replace("${JOIN_TYPE}", "INNER")); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } b.release(); } assertEquals(0, count); @@ -100,7 +100,7 @@ public class TestMergeJoinMulCondition extends PopUnitTestBase { public void testMergeJoinLeftOuterNullKey() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { bit1.run(); @@ -108,12 +108,14 @@ public class TestMergeJoinMulCondition extends PopUnitTestBase { List<QueryResultBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/join/merge_join_nullkey.json"), Charsets.UTF_8).replace("${JOIN_TYPE}", "LEFT")); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } b.release(); } assertEquals(110, count); } } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/mergereceiver/TestMergingReceiver.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/mergereceiver/TestMergingReceiver.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/mergereceiver/TestMergingReceiver.java index e8553ca..d61c123 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/mergereceiver/TestMergingReceiver.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/mergereceiver/TestMergingReceiver.java @@ -37,7 +37,6 @@ import com.google.common.base.Charsets; import com.google.common.collect.Lists; import com.google.common.io.Files; - public class TestMergingReceiver extends PopUnitTestBase { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestMergingReceiver.class); @@ -45,10 +44,9 @@ public class TestMergingReceiver extends PopUnitTestBase { public void twoBitTwoExchange() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); Drillbit bit2 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { - bit1.run(); bit2.run(); client.connect(); @@ -58,13 +56,14 @@ public class TestMergingReceiver extends PopUnitTestBase { int count = 0; RecordBatchLoader batchLoader = new RecordBatchLoader(client.getAllocator()); // print the results - for(QueryResultBatch b : results) { + for (QueryResultBatch b : results) { count += b.getHeader().getRowCount(); for (int valueIdx = 0; valueIdx < b.getHeader().getRowCount(); valueIdx++) { List<Object> row = Lists.newArrayList(); batchLoader.load(b.getHeader().getDef(), b.getData()); - for (VectorWrapper<?> vw : batchLoader) + for (VectorWrapper<?> vw : batchLoader) { row.add(vw.getValueVector().getField().toExpr() + ":" + vw.getValueVector().getAccessor().getObject(valueIdx)); + } for (Object cell : row) { if (cell == null) { System.out.print("<null> "); @@ -72,8 +71,9 @@ public class TestMergingReceiver extends PopUnitTestBase { } int len = cell.toString().length(); System.out.print(cell + " "); - for (int i = 0; i < (30 - len); ++i) + for (int i = 0; i < (30 - len); ++i) { System.out.print(" "); + } } System.out.println(); } @@ -88,7 +88,7 @@ public class TestMergingReceiver extends PopUnitTestBase { public void testMultipleProvidersMixedSizes() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); Drillbit bit2 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { @@ -102,7 +102,7 @@ public class TestMergingReceiver extends PopUnitTestBase { RecordBatchLoader batchLoader = new RecordBatchLoader(client.getAllocator()); // print the results Long lastBlueValue = null; - for(QueryResultBatch b : results) { + for (QueryResultBatch b : results) { count += b.getHeader().getRowCount(); for (int valueIdx = 0; valueIdx < b.getHeader().getRowCount(); valueIdx++) { List<Object> row = Lists.newArrayList(); @@ -111,17 +111,21 @@ public class TestMergingReceiver extends PopUnitTestBase { row.add(vw.getValueVector().getField().toExpr() + ":" + vw.getValueVector().getAccessor().getObject(valueIdx)); if (vw.getValueVector().getField().getAsSchemaPath().getRootSegment().getPath().equals("blue")) { // assert order is ascending - if (((Long)vw.getValueVector().getAccessor().getObject(valueIdx)).longValue() == 0) continue; // ignore initial 0's from sort - if (lastBlueValue != null) + if (((Long)vw.getValueVector().getAccessor().getObject(valueIdx)).longValue() == 0) { + continue; // ignore initial 0's from sort + } + if (lastBlueValue != null) { assertTrue(((Long)vw.getValueVector().getAccessor().getObject(valueIdx)).longValue() >= ((Long)lastBlueValue).longValue()); + } lastBlueValue = (Long)vw.getValueVector().getAccessor().getObject(valueIdx); } } for (Object cell : row) { int len = cell.toString().length(); System.out.print(cell + " "); - for (int i = 0; i < (30 - len); ++i) + for (int i = 0; i < (30 - len); ++i) { System.out.print(" "); + } } System.out.println(); } @@ -136,7 +140,7 @@ public class TestMergingReceiver extends PopUnitTestBase { public void handleEmptyBatch() throws Exception { RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet(); - try(Drillbit bit1 = new Drillbit(CONFIG, serviceSet); + try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet); Drillbit bit2 = new Drillbit(CONFIG, serviceSet); DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator());) { @@ -149,13 +153,14 @@ public class TestMergingReceiver extends PopUnitTestBase { int count = 0; RecordBatchLoader batchLoader = new RecordBatchLoader(client.getAllocator()); // print the results - for(QueryResultBatch b : results) { + for (QueryResultBatch b : results) { count += b.getHeader().getRowCount(); for (int valueIdx = 0; valueIdx < b.getHeader().getRowCount(); valueIdx++) { List<Object> row = Lists.newArrayList(); batchLoader.load(b.getHeader().getDef(), b.getData()); - for (VectorWrapper vw : batchLoader) + for (VectorWrapper vw : batchLoader) { row.add(vw.getValueVector().getField().toExpr() + ":" + vw.getValueVector().getAccessor().getObject(valueIdx)); + } for (Object cell : row) { if (cell == null) { System.out.print("<null> "); @@ -163,8 +168,9 @@ public class TestMergingReceiver extends PopUnitTestBase { } int len = cell.toString().length(); System.out.print(cell + " "); - for (int i = 0; i < (30 - len); ++i) + for (int i = 0; i < (30 - len); ++i) { System.out.print(" "); + } } System.out.println(); } @@ -174,4 +180,5 @@ public class TestMergingReceiver extends PopUnitTestBase { assertEquals(100, count); } } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/project/TestSimpleProjection.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/project/TestSimpleProjection.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/project/TestSimpleProjection.java index 28d2897..43c430a 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/project/TestSimpleProjection.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/project/TestSimpleProjection.java @@ -53,12 +53,10 @@ public class TestSimpleProjection extends ExecTest { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestSimpleProjection.class); DrillConfig c = DrillConfig.create(); - @Test public void project(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable{ - - new NonStrictExpectations(){{ + new NonStrictExpectations() {{ bitContext.getMetrics(); result = new MetricRegistry(); bitContext.getAllocator(); result = new TopLevelAllocator(); bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c); @@ -66,14 +64,13 @@ public class TestSimpleProjection extends ExecTest { bitContext.getCompiler(); result = CodeCompiler.getTestCompiler(c); }}; - PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance()); PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/project/test1.json"), Charsets.UTF_8)); FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c); FragmentContext context = new FragmentContext(bitContext, PlanFragment.getDefaultInstance(), connection, registry); SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next())); - while(exec.next()){ + while (exec.next()) { VectorUtil.showVectorAccessibleContent(exec.getIncoming(), "\t"); NullableBigIntVector c1 = exec.getValueVectorById(new SchemaPath("col1", ExpressionPosition.UNKNOWN), NullableBigIntVector.class); NullableBigIntVector c2 = exec.getValueVectorById(new SchemaPath("col2", ExpressionPosition.UNKNOWN), NullableBigIntVector.class); @@ -82,13 +79,15 @@ public class TestSimpleProjection extends ExecTest { a1 = c1.getAccessor(); a2 = c2.getAccessor(); - for(int i =0; i < c1.getAccessor().getValueCount(); i++){ - if (!a1.isNull(i)) assertEquals(a1.get(i)+1, a2.get(i)); + for (int i =0; i < c1.getAccessor().getValueCount(); i++) { + if (!a1.isNull(i)) { + assertEquals(a1.get(i)+1, a2.get(i)); + } x += a1.isNull(i) ? 0 : a1.get(i); } } - if(context.getFailureCause() != null){ + if (context.getFailureCause() != null) { throw context.getFailureCause(); } assertTrue(!context.isFailed()); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestParquetWriter.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestParquetWriter.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestParquetWriter.java index af4afa4..ac5673d 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestParquetWriter.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestParquetWriter.java @@ -505,7 +505,9 @@ public class TestParquetWriter extends BaseTestQuery { for (VectorWrapper w : loader) { String field = w.getField().toExpr(); for (int j = 0; j < loader.getRecordCount(); j++) { - if (totalRecords - loader.getRecordCount() + j > 5000000) continue; + if (totalRecords - loader.getRecordCount() + j > 5000000) { + continue; + } Object obj = w.getValueVector().getAccessor().getObject(j); if (obj != null) { if (obj instanceof Text) { @@ -568,7 +570,9 @@ public class TestParquetWriter extends BaseTestQuery { @Override public boolean hasNext() { - if (totalValuesRead == recordLimit) return false; + if (totalValuesRead == recordLimit) { + return false; + } if (indexInVectorList < hyperVector.getValueVectors().length) { return true; } else if ( indexInCurrentVector < currVec.getAccessor().getValueCount()) { @@ -637,15 +641,17 @@ public class TestParquetWriter extends BaseTestQuery { public void compareValues(Object expected, Object actual, int counter, String column) throws Exception { - if ( expected == null ) { - if (actual == null ) { - if (VERBOSE_DEBUG) logger.debug("(1) at position " + counter + " column '" + column + "' matched value: " + expected ); + if (expected == null) { + if (actual == null) { + if (VERBOSE_DEBUG) { + logger.debug("(1) at position " + counter + " column '" + column + "' matched value: " + expected ); + } return; } else { throw new Exception("at position " + counter + " column '" + column + "' mismatched values, expected: " + expected + " but received " + actual); } } - if ( actual == null) { + if (actual == null) { throw new Exception("unexpected null at position " + counter + " column '" + column + "' should have been: " + expected); } if (actual instanceof byte[]) { @@ -653,14 +659,18 @@ public class TestParquetWriter extends BaseTestQuery { throw new Exception("at position " + counter + " column '" + column + "' mismatched values, expected: " + new String((byte[])expected, "UTF-8") + " but received " + new String((byte[])actual, "UTF-8")); } else { - if (VERBOSE_DEBUG) logger.debug("at position " + counter + " column '" + column + "' matched value " + new String((byte[])expected, "UTF-8")); + if (VERBOSE_DEBUG) { + logger.debug("at position " + counter + " column '" + column + "' matched value " + new String((byte[])expected, "UTF-8")); + } return; } } - if ( ! expected.equals(actual)) { + if (!expected.equals(actual)) { throw new Exception("at position " + counter + " column '" + column + "' mismatched values, expected: " + expected + " but received " + actual); } else { - if (VERBOSE_DEBUG) logger.debug("at position " + counter + " column '" + column + "' matched value: " + expected ); + if (VERBOSE_DEBUG) { + logger.debug("at position " + counter + " column '" + column + "' matched value: " + expected ); + } } } @@ -676,7 +686,7 @@ public class TestParquetWriter extends BaseTestQuery { for (String column : record.keySet()) { compareValues(record.get(column), actualRecords.get(i).get(column), counter, column ); } - if ( ! actualRecords.get(i).equals(record)) { + if ( !actualRecords.get(i).equals(record)) { System.out.println("mismatch at position " + counter ); missing.append(missmatch); missing.append(","); @@ -691,4 +701,5 @@ public class TestParquetWriter extends BaseTestQuery { logger.debug(missing.toString()); System.out.println(missing); } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestWriter.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestWriter.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestWriter.java index c8790a8..530883b 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestWriter.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/writer/TestWriter.java @@ -85,7 +85,7 @@ public class TestWriter extends BaseTestQuery { FileStatus[] fileStatuses = fs.globStatus(new Path(path.toString(), "*.csv")); assertTrue(2 == fileStatuses.length); - for(QueryResultBatch b : results){ + for (QueryResultBatch b : results) { b.release(); } batchLoader.clear(); @@ -137,7 +137,7 @@ public class TestWriter extends BaseTestQuery { private void ctasHelper(String tableDir, String testQuery, int expectedOutputCount) throws Exception { Path tableLocation = new Path(tableDir); - if (fs.exists(tableLocation)){ + if (fs.exists(tableLocation)) { fs.delete(tableLocation, true); } @@ -146,11 +146,12 @@ public class TestWriter extends BaseTestQuery { RecordBatchLoader batchLoader = new RecordBatchLoader(getAllocator()); int recordsWritten = 0; - for(QueryResultBatch batch : results) { + for (QueryResultBatch batch : results) { batchLoader.load(batch.getHeader().getDef(), batch.getData()); - if (batchLoader.getRecordCount() <= 0) + if (batchLoader.getRecordCount() <= 0) { continue; + } BigIntVector recordWrittenV = (BigIntVector) batchLoader.getValueAccessorById(BigIntVector.class, 1).getValueVector(); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/xsort/TestSimpleExternalSort.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/xsort/TestSimpleExternalSort.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/xsort/TestSimpleExternalSort.java index 16b1f40..a96c507 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/xsort/TestSimpleExternalSort.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/xsort/TestSimpleExternalSort.java @@ -55,8 +55,9 @@ public class TestSimpleExternalSort extends BaseTestQuery { List<QueryResultBatch> results = testPhysicalFromFileWithResults("xsort/one_key_sort_descending_sv2.json"); int count = 0; for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } } assertEquals(500000, count); @@ -66,7 +67,9 @@ public class TestSimpleExternalSort extends BaseTestQuery { int batchCount = 0; for (QueryResultBatch b : results) { - if (b.getHeader().getRowCount() == 0) break; + if (b.getHeader().getRowCount() == 0) { + break; + } batchCount++; RecordBatchLoader loader = new RecordBatchLoader(allocator); loader.load(b.getHeader().getDef(),b.getData()); @@ -76,7 +79,7 @@ public class TestSimpleExternalSort extends BaseTestQuery { BigIntVector.Accessor a1 = c1.getAccessor(); - for(int i =0; i < c1.getAccessor().getValueCount(); i++){ + for (int i =0; i < c1.getAccessor().getValueCount(); i++) { recordCount++; assertTrue(String.format("%d > %d", previousBigInt, a1.get(i)), previousBigInt >= a1.get(i)); previousBigInt = a1.get(i); @@ -92,9 +95,10 @@ public class TestSimpleExternalSort extends BaseTestQuery { public void sortOneKeyDescendingMergeSort() throws Throwable{ List<QueryResultBatch> results = testPhysicalFromFileWithResults("xsort/one_key_sort_descending.json"); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } } assertEquals(1000000, count); @@ -104,7 +108,9 @@ public class TestSimpleExternalSort extends BaseTestQuery { int batchCount = 0; for (QueryResultBatch b : results) { - if (b.getHeader().getRowCount() == 0) break; + if (b.getHeader().getRowCount() == 0) { + break; + } batchCount++; RecordBatchLoader loader = new RecordBatchLoader(allocator); loader.load(b.getHeader().getDef(),b.getData()); @@ -113,7 +119,7 @@ public class TestSimpleExternalSort extends BaseTestQuery { BigIntVector.Accessor a1 = c1.getAccessor(); - for(int i =0; i < c1.getAccessor().getValueCount(); i++){ + for (int i =0; i < c1.getAccessor().getValueCount(); i++) { recordCount++; assertTrue(String.format("%d > %d", previousBigInt, a1.get(i)), previousBigInt >= a1.get(i)); previousBigInt = a1.get(i); @@ -131,7 +137,7 @@ public class TestSimpleExternalSort extends BaseTestQuery { DrillConfig config = DrillConfig.create("drill-external-sort.conf"); - try(Drillbit bit1 = new Drillbit(config, serviceSet); + try (Drillbit bit1 = new Drillbit(config, serviceSet); Drillbit bit2 = new Drillbit(config, serviceSet); DrillClient client = new DrillClient(config, serviceSet.getCoordinator());) { @@ -142,9 +148,10 @@ public class TestSimpleExternalSort extends BaseTestQuery { Files.toString(FileUtils.getResourceAsFile("/xsort/one_key_sort_descending.json"), Charsets.UTF_8)); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } } assertEquals(1000000, count); @@ -154,7 +161,9 @@ public class TestSimpleExternalSort extends BaseTestQuery { int batchCount = 0; for (QueryResultBatch b : results) { - if (b.getHeader().getRowCount() == 0) break; + if (b.getHeader().getRowCount() == 0) { + break; + } batchCount++; RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator()); loader.load(b.getHeader().getDef(),b.getData()); @@ -163,7 +172,7 @@ public class TestSimpleExternalSort extends BaseTestQuery { BigIntVector.Accessor a1 = c1.getAccessor(); - for(int i =0; i < c1.getAccessor().getValueCount(); i++){ + for (int i =0; i < c1.getAccessor().getValueCount(); i++) { recordCount++; assertTrue(String.format("%d < %d", previousBigInt, a1.get(i)), previousBigInt >= a1.get(i)); previousBigInt = a1.get(i); @@ -171,7 +180,6 @@ public class TestSimpleExternalSort extends BaseTestQuery { loader.clear(); b.release(); } - System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount)); } @@ -183,7 +191,7 @@ public class TestSimpleExternalSort extends BaseTestQuery { DrillConfig config = DrillConfig.create("drill-oom-xsort.conf"); - try(Drillbit bit1 = new Drillbit(config, serviceSet); + try (Drillbit bit1 = new Drillbit(config, serviceSet); DrillClient client = new DrillClient(config, serviceSet.getCoordinator());) { bit1.run(); @@ -192,9 +200,10 @@ public class TestSimpleExternalSort extends BaseTestQuery { Files.toString(FileUtils.getResourceAsFile("/xsort/oom_sort_test.json"), Charsets.UTF_8)); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { count += b.getHeader().getRowCount(); + } } assertEquals(10000000, count); @@ -204,7 +213,9 @@ public class TestSimpleExternalSort extends BaseTestQuery { int batchCount = 0; for (QueryResultBatch b : results) { - if (b.getHeader().getRowCount() == 0) break; + if (b.getHeader().getRowCount() == 0) { + break; + } batchCount++; RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator()); loader.load(b.getHeader().getDef(),b.getData()); @@ -213,7 +224,7 @@ public class TestSimpleExternalSort extends BaseTestQuery { BigIntVector.Accessor a1 = c1.getAccessor(); - for(int i =0; i < c1.getAccessor().getValueCount(); i++){ + for (int i =0; i < c1.getAccessor().getValueCount(); i++) { recordCount++; assertTrue(String.format("%d < %d", previousBigInt, a1.get(i)), previousBigInt >= a1.get(i)); previousBigInt = a1.get(i); @@ -222,9 +233,9 @@ public class TestSimpleExternalSort extends BaseTestQuery { loader.clear(); b.release(); } - System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount)); } } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/pop/TestFragmentChecker.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/pop/TestFragmentChecker.java b/exec/java-exec/src/test/java/org/apache/drill/exec/pop/TestFragmentChecker.java index f6972c3..58ddd06 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/pop/TestFragmentChecker.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/pop/TestFragmentChecker.java @@ -36,14 +36,12 @@ import com.google.common.collect.Lists; public class TestFragmentChecker extends PopUnitTestBase{ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestFragmentChecker.class); - @Test public void checkSimpleExchangePlan() throws Exception{ print("/physical_double_exchange.json", 2, 3); } - private void print(String fragmentFile, int bitCount, int exepectedFragmentCount) throws Exception{ System.out.println(String.format("=================Building plan fragments for [%s]. Allowing %d total Drillbits.==================", fragmentFile, bitCount)); @@ -53,9 +51,11 @@ public class TestFragmentChecker extends PopUnitTestBase{ SimpleParallelizer par = new SimpleParallelizer(1000*1000, 5, 10, 1.2); List<DrillbitEndpoint> endpoints = Lists.newArrayList(); DrillbitEndpoint localBit = null; - for(int i =0; i < bitCount; i++){ + for(int i =0; i < bitCount; i++) { DrillbitEndpoint b1 = DrillbitEndpoint.newBuilder().setAddress("localhost").setControlPort(1234+i).build(); - if(i ==0) localBit = b1; + if (i == 0) { + localBit = b1; + } endpoints.add(b1); } @@ -64,12 +64,10 @@ public class TestFragmentChecker extends PopUnitTestBase{ System.out.print(qwu.getRootFragment().getFragmentJson()); - - for(PlanFragment f : qwu.getFragments()){ + for(PlanFragment f : qwu.getFragments()) { System.out.println(String.format("=========Fragment [%d:%d]=====", f.getHandle().getMajorFragmentId(), f.getHandle().getMinorFragmentId())); System.out.print(f.getFragmentJson()); } - //assertEquals(exepectedFragmentCount, qwu.getFragments().size()); logger.debug("Planning Set {}", planningSet); @@ -80,4 +78,5 @@ public class TestFragmentChecker extends PopUnitTestBase{ print("/physical_single_exchange.json", 1, 2); } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java index c294aee..c01f5d8 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java @@ -126,8 +126,9 @@ public class ExpressionTreeMaterializerTest extends ExecTest { //ifCondition = newIfExpr.conditions.get(0); assertEquals(bigIntType, ifCondition.expression.getMajorType()); assertEquals(true, ((ValueExpressions.BooleanExpression) ((IfExpression)(newIfExpr.elseExpression)).ifCondition.condition).value); - if (ec.hasErrors()) + if (ec.hasErrors()) { System.out.println(ec.toErrorString()); + } assertFalse(ec.hasErrors()); } @@ -204,4 +205,5 @@ public class ExpressionTreeMaterializerTest extends ExecTest { assertEquals(1, ec.getErrorCount()); System.out.println(ec.toErrorString()); } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestLoad.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestLoad.java b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestLoad.java index 831bf74..f57e765 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestLoad.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestLoad.java @@ -105,15 +105,18 @@ public class TestLoad extends ExecTest { ValueVector.Accessor accessor = v.getValueVector().getAccessor(); if (v.getField().getType().getMinorType() == TypeProtos.MinorType.VARCHAR) { Object obj = accessor.getObject(r); - if (obj != null) + if (obj != null) { System.out.print(accessor.getObject(r)); - else + } else { System.out.print("NULL"); + } } else { System.out.print(accessor.getObject(r)); } } - if (!first) System.out.println(); + if (!first) { + System.out.println(); + } } assertEquals(100, recordCount); batchLoader.clear(); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java b/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java index a5de832..d408773 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/server/TestBitRpc.java @@ -73,21 +73,18 @@ public class TestBitRpc extends ExecTest { final BootStrapContext c = new BootStrapContext(DrillConfig.create()); BootStrapContext c2 = new BootStrapContext(DrillConfig.create()); - - new NonStrictExpectations(){{ + new NonStrictExpectations() {{ workBus.getOrCreateFragmentManager((FragmentHandle) any); result = fman; workBus.getFragmentManager( (FragmentHandle) any); result = fman; fman.getFragmentContext(); result = fcon; fcon.getAllocator(); result = c.getAllocator(); - }}; - + }}; int port = 1234; DataResponseHandler drp = new BitComTestHandler(); DataServer server = new DataServer(c, workBus, drp); - port = server.bind(port, false); DrillbitEndpoint ep = DrillbitEndpoint.newBuilder().setAddress("localhost").setDataPort(port).build(); DataConnectionManager manager = new DataConnectionManager(FragmentHandle.getDefaultInstance(), ep, c2); @@ -139,8 +136,9 @@ public class TestBitRpc extends ExecTest { while (true) { long nowMax = max.get(); if (nowMax < micros) { - if (max.compareAndSet(nowMax, micros)) + if (max.compareAndSet(nowMax, micros)) { break; + } } else { break; } @@ -175,4 +173,5 @@ public class TestBitRpc extends ExecTest { } } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/676f5df6/exec/java-exec/src/test/java/org/apache/drill/exec/store/ByteArrayUtil.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/ByteArrayUtil.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/ByteArrayUtil.java index bc678e2..cd29f7c 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/ByteArrayUtil.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/ByteArrayUtil.java @@ -21,12 +21,19 @@ package org.apache.drill.exec.store; public class ByteArrayUtil { public static byte[] toByta(Object data) throws Exception { - if (data instanceof Integer) return toByta((int) data); - else if (data instanceof Double) return toByta((double) data); - else if (data instanceof Float) return toByta((float) data); - else if (data instanceof Boolean) return toByta((boolean) data); - else if (data instanceof Long) return toByta((long) data); - else throw new Exception("Cannot convert that type to a byte array."); + if (data instanceof Integer) { + return toByta((int) data); + } else if (data instanceof Double) { + return toByta((double) data); + } else if (data instanceof Float) { + return toByta((float) data); + } else if (data instanceof Boolean) { + return toByta((boolean) data); + } else if (data instanceof Long) { + return toByta((long) data); + } else { + throw new Exception("Cannot convert that type to a byte array."); + } } // found at http://www.daniweb.com/software-development/java/code/216874/primitive-types-as-byte-arrays @@ -51,11 +58,14 @@ public class ByteArrayUtil { } public static byte[] toByta(short[] data) { - if (data == null) return null; + if (data == null) { + return null; + } // ---------- byte[] byts = new byte[data.length * 2]; - for (int i = 0; i < data.length; i++) + for (int i = 0; i < data.length; i++) { System.arraycopy(toByta(data[i]), 0, byts, i * 2, 2); + } return byts; } @@ -68,11 +78,14 @@ public class ByteArrayUtil { } public static byte[] toByta(char[] data) { - if (data == null) return null; + if (data == null) { + return null; + } // ---------- byte[] byts = new byte[data.length * 2]; - for (int i = 0; i < data.length; i++) + for (int i = 0; i < data.length; i++) { System.arraycopy(toByta(data[i]), 0, byts, i * 2, 2); + } return byts; } @@ -87,11 +100,14 @@ public class ByteArrayUtil { } public static byte[] toByta(int[] data) { - if (data == null) return null; + if (data == null) { + return null; + } // ---------- byte[] byts = new byte[data.length * 4]; - for (int i = 0; i < data.length; i++) + for (int i = 0; i < data.length; i++) { System.arraycopy(toByta(data[i]), 0, byts, i * 4, 4); + } return byts; } @@ -110,11 +126,14 @@ public class ByteArrayUtil { } public static byte[] toByta(long[] data) { - if (data == null) return null; + if (data == null) { + return null; + } // ---------- byte[] byts = new byte[data.length * 8]; - for (int i = 0; i < data.length; i++) + for (int i = 0; i < data.length; i++) { System.arraycopy(toByta(data[i]), 0, byts, i * 8, 8); + } return byts; } @@ -124,11 +143,14 @@ public class ByteArrayUtil { } public static byte[] toByta(float[] data) { - if (data == null) return null; + if (data == null) { + return null; + } // ---------- byte[] byts = new byte[data.length * 4]; - for (int i = 0; i < data.length; i++) + for (int i = 0; i < data.length; i++) { System.arraycopy(toByta(data[i]), 0, byts, i * 4, 4); + } return byts; } @@ -138,11 +160,14 @@ public class ByteArrayUtil { } public static byte[] toByta(double[] data) { - if (data == null) return null; + if (data == null) { + return null; + } // ---------- byte[] byts = new byte[data.length * 8]; - for (int i = 0; i < data.length; i++) + for (int i = 0; i < data.length; i++) { System.arraycopy(toByta(data[i]), 0, byts, i * 8, 8); + } return byts; } @@ -156,7 +181,9 @@ public class ByteArrayUtil { // about how many boolean values are involved, so the exact // array is returned when later decoded. // ---------- - if (data == null) return null; + if (data == null) { + return null; + } // ---------- int len = data.length; byte[] lena = toByta(len); // int conversion; length array = lena