diff options
author | Aditya Kishore <aditya@maprtech.com> | 2014-09-11 10:43:08 -0700 |
---|---|---|
committer | Aditya Kishore <aditya@maprtech.com> | 2014-09-11 19:25:28 -0700 |
commit | 676f5df6b14b10ccc3603360e0efee9c745c5b97 (patch) | |
tree | 592b02f84e8a6da2ace67f8e6c0e46d4237af20b /exec/java-exec/src/test/java/org/apache/drill/exec/physical | |
parent | 7ae257c42b2eb4e1db778dca9ba64e2516078b38 (diff) |
DRILL-1402: Add check-style rules for trailing space, TABs and blocks without braces
Diffstat (limited to 'exec/java-exec/src/test/java/org/apache/drill/exec/physical')
18 files changed, 400 insertions, 325 deletions
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/SimpleRootExec.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/SimpleRootExec.java index a15b50386..f878bcb69 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/SimpleRootExec.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/SimpleRootExec.java @@ -39,37 +39,37 @@ public class SimpleRootExec implements RootExec, Iterable<ValueVector>{ private RecordBatch incoming; private ScreenRoot screenRoot; - public SimpleRootExec(RootExec e){ - if(e instanceof ScreenRoot){ + public SimpleRootExec(RootExec e) { + if (e instanceof ScreenRoot) { incoming = ((ScreenRoot)e).getIncoming(); screenRoot = (ScreenRoot) e; - }else{ + } else { throw new UnsupportedOperationException(); } } - public FragmentContext getContext(){ + public FragmentContext getContext() { return incoming.getContext(); } - public SelectionVector2 getSelectionVector2(){ + public SelectionVector2 getSelectionVector2() { return incoming.getSelectionVector2(); } - public SelectionVector4 getSelectionVector4(){ + public SelectionVector4 getSelectionVector4() { return incoming.getSelectionVector4(); } @SuppressWarnings("unchecked") - public <T extends ValueVector> T getValueVectorById(SchemaPath path, Class<?> vvClass){ + public <T extends ValueVector> T getValueVectorById(SchemaPath path, Class<?> vvClass) { TypedFieldId tfid = incoming.getValueVectorId(path); return (T) incoming.getValueAccessorById(vvClass, tfid.getFieldIds()).getValueVector(); } @Override public boolean next() { - switch(incoming.next()){ + switch (incoming.next()) { case NONE: case STOP: incoming.cleanup(); @@ -92,19 +92,19 @@ public class SimpleRootExec implements RootExec, Iterable<ValueVector>{ @Override public Iterator<ValueVector> iterator() { List<ValueVector> vv = Lists.newArrayList(); - for(VectorWrapper<?> vw : incoming){ + for (VectorWrapper<?> vw : incoming) { vv.add(vw.getValueVector()); } return vv.iterator(); } - public int getRecordCount(){ + public int getRecordCount() { return incoming.getRecordCount(); } /// Temporary: for exposing the incoming batch to TestHashTable public RecordBatch getIncoming() { - return incoming; + return incoming; } } diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestBroadcastExchange.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestBroadcastExchange.java index 826ebf532..521212519 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestBroadcastExchange.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestBroadcastExchange.java @@ -38,7 +38,7 @@ public class TestBroadcastExchange extends PopUnitTestBase { public void TestSingleBroadcastExchangeWithTwoScans() 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())) { @@ -52,8 +52,10 @@ public class TestBroadcastExchange extends PopUnitTestBase { .replace("#{RIGHT_FILE}", FileUtils.getResourceAsFile("/join/merge_single_batch.right.json").toURI().toString()); List<QueryResultBatch> results = client.runQuery(QueryType.PHYSICAL, physicalPlan); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) count += b.getHeader().getRowCount(); + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { + count += b.getHeader().getRowCount(); + } b.release(); } assertEquals(25, count); @@ -64,7 +66,7 @@ public class TestBroadcastExchange extends PopUnitTestBase { public void TestMultipleSendLocationBroadcastExchange() 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())) { @@ -76,11 +78,14 @@ public class TestBroadcastExchange extends PopUnitTestBase { FileUtils.getResourceAsFile("/sender/broadcast_exchange_long_run.json"), Charsets.UTF_8); List<QueryResultBatch> results = client.runQuery(QueryType.PHYSICAL, physicalPlan); int count = 0; - for(QueryResultBatch b : results) { - if (b.getHeader().getRowCount() != 0) count += b.getHeader().getRowCount(); + for (QueryResultBatch b : results) { + if (b.getHeader().getRowCount() != 0) { + count += b.getHeader().getRowCount(); + } b.release(); } System.out.println(count); } } + } diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestComparisonFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestComparisonFunctions.java index 421c3f59f..609bc14c3 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestComparisonFunctions.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestComparisonFunctions.java @@ -53,7 +53,7 @@ public class TestComparisonFunctions extends ExecTest { public void runTest(@Injectable final DrillbitContext bitContext, @Injectable UserServer.UserClientConnection connection, String expression, int expectedResults) throws Throwable { - new NonStrictExpectations(){{ + new NonStrictExpectations() {{ bitContext.getMetrics(); result = new MetricRegistry(); bitContext.getAllocator(); result = new TopLevelAllocator(); bitContext.getOperatorCreatorRegistry(); result = new OperatorCreatorRegistry(c); @@ -62,13 +62,19 @@ public class TestComparisonFunctions extends ExecTest { }}; String planString = Resources.toString(Resources.getResource(COMPARISON_TEST_PHYSICAL_PLAN), Charsets.UTF_8).replaceAll("EXPRESSION", expression); - 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()) { assertEquals(String.format("Expression: %s;", expression), expectedResults, exec.getSelectionVector2().getCount()); // for (ValueVector vv: exec) { // vv.close(); @@ -79,8 +85,7 @@ public class TestComparisonFunctions extends ExecTest { context.close(); - - if(context.getFailureCause() != null){ + if (context.getFailureCause() != null) { throw context.getFailureCause(); } diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java index 5111a499a..c64c7a330 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestConvertFunctions.java @@ -306,7 +306,7 @@ public class TestConvertFunctions extends BaseTestQuery { List<QueryResultBatch> results = testLogicalWithResults(logicalPlan); int count = 0; RecordBatchLoader loader = new RecordBatchLoader(getAllocator()); - for(QueryResultBatch result : results){ + for (QueryResultBatch result : results){ count += result.getHeader().getRowCount(); loader.load(result.getHeader().getDef(), result.getData()); if (loader.getRecordCount() > 0) { @@ -365,7 +365,9 @@ public class TestConvertFunctions extends BaseTestQuery { protected <T> void verifyPhysicalPlan(String expression, T expectedResults) throws Throwable { expression = expression.replace("\\", "\\\\\\\\"); // "\\\\\\\\" => Java => "\\\\" => JsonParser => "\\" => AntlrParser "\" - if (textFileContent == null) textFileContent = Resources.toString(Resources.getResource(CONVERSION_TEST_PHYSICAL_PLAN), Charsets.UTF_8); + if (textFileContent == null) { + textFileContent = Resources.toString(Resources.getResource(CONVERSION_TEST_PHYSICAL_PLAN), Charsets.UTF_8); + } String planString = textFileContent.replace("__CONVERT_EXPRESSION__", expression); verifyResults(expression, expectedResults, getRunResult(QueryType.PHYSICAL, planString)); @@ -432,4 +434,5 @@ public class TestConvertFunctions extends BaseTestQuery { expected.getClass().getName(), (actual == null ? "null" : actual.getClass().getName()))); } } + } 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 e3fca8576..10ee46a01 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); 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 13c9364cf..141c9cd64 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"); + } } 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 5dd64e10f..68e211264 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(); 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 a48510fa1..aa3548d74 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"); } + } 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 4ad215d9a..271af72b1 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); 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 430c5056b..ccc052dad 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)); } - } - } 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 1f0d89e35..f46617186 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 +} 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 86584bb2e..a6a186639 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); 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 a3a7aced8..996b6751b 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); } } + } 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 e8553ca5c..d61c1230a 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); } } + } 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 28d2897e6..43c430a88 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()); 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 af4afa48c..ac5673db8 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); } + } 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 c8790a8d1..530883b34 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(); 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 16b1f4055..a96c5076c 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)); } } + } |