Updated Branches: refs/heads/master 31f196497 -> db3afaa85
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/db3afaa8/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java ---------------------------------------------------------------------- diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java index ec17c63..38a4236 100644 --- a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java +++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/expr/ExpressionTest.java @@ -3,6 +3,7 @@ package org.apache.drill.exec.expr; import static org.junit.Assert.assertEquals; import mockit.Expectations; import mockit.Injectable; +import mockit.NonStrict; import mockit.NonStrictExpectations; import org.antlr.runtime.ANTLRStringStream; @@ -23,8 +24,10 @@ import org.apache.drill.common.types.Types; import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry; import org.apache.drill.exec.physical.impl.project.Projector; import org.apache.drill.exec.record.RecordBatch; -import org.apache.drill.exec.record.RecordBatch.TypedFieldId; +import org.apache.drill.exec.record.TypedFieldId; +import org.apache.drill.exec.record.VectorWrapper; import org.apache.drill.exec.vector.IntVector; +import org.apache.drill.exec.vector.ValueVector; import org.junit.AfterClass; import org.junit.Test; @@ -37,15 +40,18 @@ public class ExpressionTest { } @Test - public void testSpecial(final @Injectable RecordBatch batch) throws Exception { - final TypedFieldId tfid = new TypedFieldId(Types.optional(MinorType.INT),0); - + public void testSpecial(final @Injectable RecordBatch batch, @Injectable ValueVector vector) throws Exception { + final TypedFieldId tfid = new TypedFieldId(Types.optional(MinorType.INT),0, false); + new NonStrictExpectations() { + @NonStrict VectorWrapper<?> wrapper; { batch.getValueVectorId(new SchemaPath("alpha", ExpressionPosition.UNKNOWN)); result = tfid; - batch.getValueVectorById(tfid.getFieldId(), IntVector.class); - result = new IntVector(null, null); + batch.getValueAccessorById(tfid.getFieldId(), IntVector.class); + result = wrapper; + wrapper.getValueVector(); + result = new IntVector(null, null); } }; @@ -54,7 +60,7 @@ public class ExpressionTest { @Test public void testSchemaExpression(final @Injectable RecordBatch batch) throws Exception { - final TypedFieldId tfid = new TypedFieldId(Types.optional(MinorType.BIGINT), 0); + final TypedFieldId tfid = new TypedFieldId(Types.optional(MinorType.BIGINT), 0, false); new Expectations() { { @@ -89,7 +95,7 @@ public class ExpressionTest { } CodeGenerator<Projector> cg = new CodeGenerator<Projector>(Projector.TEMPLATE_DEFINITION, new FunctionImplementationRegistry(DrillConfig.create())); - cg.addExpr(new ValueVectorWriteExpression(-1, materializedExpr)); + cg.addExpr(new ValueVectorWriteExpression(new TypedFieldId(materializedExpr.getMajorType(), -1), materializedExpr)); return cg.generate(); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/db3afaa8/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/SimpleRootExec.java ---------------------------------------------------------------------- diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/SimpleRootExec.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/SimpleRootExec.java index 5e7c599..dddd322 100644 --- a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/SimpleRootExec.java +++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/SimpleRootExec.java @@ -1,15 +1,19 @@ package org.apache.drill.exec.physical.impl; import java.util.Iterator; +import java.util.List; import org.apache.drill.common.expression.SchemaPath; import org.apache.drill.exec.physical.impl.ScreenCreator.ScreenRoot; import org.apache.drill.exec.record.RecordBatch; import org.apache.drill.exec.record.RecordBatch.IterOutcome; -import org.apache.drill.exec.record.RecordBatch.TypedFieldId; +import org.apache.drill.exec.record.TypedFieldId; +import org.apache.drill.exec.record.VectorWrapper; import org.apache.drill.exec.record.selection.SelectionVector2; import org.apache.drill.exec.vector.ValueVector; +import com.beust.jcommander.internal.Lists; + public class SimpleRootExec implements RootExec, Iterable<ValueVector>{ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(SimpleRootExec.class); @@ -28,9 +32,10 @@ public class SimpleRootExec implements RootExec, Iterable<ValueVector>{ return incoming.getSelectionVector2(); } + @SuppressWarnings("unchecked") public <T extends ValueVector> T getValueVectorById(SchemaPath path, Class<?> vvClass){ TypedFieldId tfid = incoming.getValueVectorId(path); - return incoming.getValueVectorById(tfid.getFieldId(), vvClass); + return (T) incoming.getValueAccessorById(tfid.getFieldId(), vvClass).getValueVector(); } @Override @@ -40,11 +45,16 @@ public class SimpleRootExec implements RootExec, Iterable<ValueVector>{ @Override public void stop() { + incoming.kill(); } @Override public Iterator<ValueVector> iterator() { - return incoming.iterator(); + List<ValueVector> vv = Lists.newArrayList(); + for(VectorWrapper<?> vw : incoming){ + vv.add(vw.getValueVector()); + } + return vv.iterator(); } public int getRecordCount(){ http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/db3afaa8/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFragmentRun.java ---------------------------------------------------------------------- diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFragmentRun.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFragmentRun.java index 7b002ea..e21289c 100644 --- a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFragmentRun.java +++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestSimpleFragmentRun.java @@ -17,7 +17,7 @@ ******************************************************************************/ package org.apache.drill.exec.physical.impl; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import java.util.List; @@ -26,6 +26,7 @@ import org.apache.drill.exec.client.DrillClient; import org.apache.drill.exec.pop.PopUnitTestBase; import org.apache.drill.exec.proto.UserProtos.QueryType; import org.apache.drill.exec.record.RecordBatchLoader; +import org.apache.drill.exec.record.VectorWrapper; import org.apache.drill.exec.rpc.user.QueryResultBatch; import org.apache.drill.exec.server.Drillbit; import org.apache.drill.exec.server.RemoteServiceSet; @@ -53,14 +54,14 @@ public class TestSimpleFragmentRun extends PopUnitTestBase { RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator()); int recordCount = 0; for (QueryResultBatch batch : results) { - if(!batch.hasData()) continue; + boolean schemaChanged = batchLoader.load(batch.getHeader().getDef(), batch.getData()); boolean firstColumn = true; // print headers. if (schemaChanged) { System.out.println("\n\n========NEW SCHEMA=========\n\n"); - for (ValueVector value : batchLoader) { + for (VectorWrapper<?> value : batchLoader) { if (firstColumn) { firstColumn = false; @@ -79,13 +80,13 @@ public class TestSimpleFragmentRun extends PopUnitTestBase { for (int i = 0; i < batchLoader.getRecordCount(); i++) { boolean first = true; recordCount++; - for (ValueVector value : batchLoader) { + for (VectorWrapper<?> value : batchLoader) { if (first) { first = false; } else { System.out.print("\t"); } - System.out.print(value.getAccessor().getObject(i)); + System.out.print(value.getValueVector().getAccessor().getObject(i)); } if(!first) System.out.println(); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/db3afaa8/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSimpleSort.java ---------------------------------------------------------------------- diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSimpleSort.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSimpleSort.java new file mode 100644 index 0000000..af5ec06 --- /dev/null +++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/sort/TestSimpleSort.java @@ -0,0 +1,145 @@ +package org.apache.drill.exec.physical.impl.sort; + +import static org.junit.Assert.assertTrue; +import mockit.Injectable; +import mockit.NonStrictExpectations; + +import org.apache.drill.common.config.DrillConfig; +import org.apache.drill.common.expression.ExpressionPosition; +import org.apache.drill.common.expression.SchemaPath; +import org.apache.drill.common.util.FileUtils; +import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry; +import org.apache.drill.exec.memory.BufferAllocator; +import org.apache.drill.exec.ops.FragmentContext; +import org.apache.drill.exec.physical.PhysicalPlan; +import org.apache.drill.exec.physical.base.FragmentRoot; +import org.apache.drill.exec.physical.impl.ImplCreator; +import org.apache.drill.exec.physical.impl.SimpleRootExec; +import org.apache.drill.exec.planner.PhysicalPlanReader; +import org.apache.drill.exec.proto.CoordinationProtos; +import org.apache.drill.exec.proto.ExecProtos.FragmentHandle; +import org.apache.drill.exec.rpc.user.UserServer.UserClientConnection; +import org.apache.drill.exec.server.DrillbitContext; +import org.apache.drill.exec.vector.BigIntVector; +import org.apache.drill.exec.vector.IntVector; +import org.junit.AfterClass; +import org.junit.Test; + +import com.google.common.base.Charsets; +import com.google.common.io.Files; +import com.yammer.metrics.MetricRegistry; + +public class TestSimpleSort { + static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestSimpleSort.class); + DrillConfig c = DrillConfig.create(); + + + @Test + public void sortOneKeyAscending(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable{ + + + new NonStrictExpectations(){{ + bitContext.getMetrics(); result = new MetricRegistry("test"); + bitContext.getAllocator(); result = BufferAllocator.getAllocator(c); + }}; + + + PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance()); + PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/sort/one_key_sort.json"), Charsets.UTF_8)); + FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c); + FragmentContext context = new FragmentContext(bitContext, FragmentHandle.getDefaultInstance(), connection, null, registry); + SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next())); + + int previousInt = Integer.MIN_VALUE; + + int recordCount = 0; + int batchCount = 0; + + while(exec.next()){ + batchCount++; + IntVector c1 = exec.getValueVectorById(new SchemaPath("blue", ExpressionPosition.UNKNOWN), IntVector.class); + IntVector c2 = exec.getValueVectorById(new SchemaPath("green", ExpressionPosition.UNKNOWN), IntVector.class); + + IntVector.Accessor a1 = c1.getAccessor(); + IntVector.Accessor a2 = c2.getAccessor(); + + for(int i =0; i < c1.getAccessor().getValueCount(); i++){ + recordCount++; + assert previousInt <= a1.get(i); + previousInt = a1.get(i); + assert previousInt == a2.get(i); + } + + + } + + System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount)); + + if(context.getFailureCause() != null){ + throw context.getFailureCause(); + } + assertTrue(!context.isFailed()); + } + + @Test + public void sortTwoKeysOneAscendingOneDescending(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) throws Throwable{ + + + new NonStrictExpectations(){{ + bitContext.getMetrics(); result = new MetricRegistry("test"); + bitContext.getAllocator(); result = BufferAllocator.getAllocator(c); + }}; + + + PhysicalPlanReader reader = new PhysicalPlanReader(c, c.getMapper(), CoordinationProtos.DrillbitEndpoint.getDefaultInstance()); + PhysicalPlan plan = reader.readPhysicalPlan(Files.toString(FileUtils.getResourceAsFile("/sort/two_key_sort.json"), Charsets.UTF_8)); + FunctionImplementationRegistry registry = new FunctionImplementationRegistry(c); + FragmentContext context = new FragmentContext(bitContext, FragmentHandle.getDefaultInstance(), connection, null, registry); + SimpleRootExec exec = new SimpleRootExec(ImplCreator.getExec(context, (FragmentRoot) plan.getSortedOperators(false).iterator().next())); + + int previousInt = Integer.MIN_VALUE; + long previousLong = Long.MAX_VALUE; + + int recordCount = 0; + int batchCount = 0; + + while(exec.next()){ + batchCount++; + IntVector c1 = exec.getValueVectorById(new SchemaPath("blue", ExpressionPosition.UNKNOWN), IntVector.class); + BigIntVector c2 = exec.getValueVectorById(new SchemaPath("alt", ExpressionPosition.UNKNOWN), BigIntVector.class); + + IntVector.Accessor a1 = c1.getAccessor(); + BigIntVector.Accessor a2 = c2.getAccessor(); + + for(int i =0; i < c1.getAccessor().getValueCount(); i++){ + recordCount++; + assert previousInt <= a1.get(i); + + if(previousInt != a1.get(i)){ + previousLong = Long.MAX_VALUE; + previousInt = a1.get(i); + } + + assert previousLong >= a2.get(i); + + //System.out.println(previousInt + "\t" + a2.get(i)); + + } + + + } + + System.out.println(String.format("Sorted %,d records in %d batches.", recordCount, batchCount)); + + if(context.getFailureCause() != null){ + throw context.getFailureCause(); + } + assertTrue(!context.isFailed()); + } + + @AfterClass + public static void tearDown() throws Exception{ + // pause to get logger to catch up. + Thread.sleep(1000); + } +} http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/db3afaa8/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java ---------------------------------------------------------------------- diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java index dae5f78..8a1736c 100644 --- a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java +++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/record/ExpressionTreeMaterializerTest.java @@ -28,7 +28,6 @@ import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.expr.ExpressionTreeMaterializer; import org.apache.drill.exec.proto.SchemaDefProtos.FieldDef; import org.apache.drill.exec.proto.SchemaDefProtos.NamePart; -import org.apache.drill.exec.record.RecordBatch.TypedFieldId; import org.junit.Test; import com.google.common.collect.Lists; http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/db3afaa8/sandbox/prototype/exec/java-exec/src/test/resources/sort/one_key_sort.json ---------------------------------------------------------------------- diff --git a/sandbox/prototype/exec/java-exec/src/test/resources/sort/one_key_sort.json b/sandbox/prototype/exec/java-exec/src/test/resources/sort/one_key_sort.json new file mode 100644 index 0000000..3bd0b71 --- /dev/null +++ b/sandbox/prototype/exec/java-exec/src/test/resources/sort/one_key_sort.json @@ -0,0 +1,44 @@ +{ + head:{ + type:"APACHE_DRILL_PHYSICAL", + version:"1", + generator:{ + type:"manual" + } + }, + graph:[ + { + @id:1, + pop:"mock-scan", + url: "http://apache.org", + entries:[ + {records: 1000000, types: [ + {name: "blue", type: "INT", mode: "REQUIRED"}, + {name: "green", type: "INT", mode: "REQUIRED"} + ]}, + {records: 1000000, types: [ + {name: "blue", type: "INT", mode: "REQUIRED"}, + {name: "green", type: "INT", mode: "REQUIRED"} + ]} + ] + }, + { + @id:2, + child: 1, + pop:"sort", + orderings: [ + {expr: "blue"} + ] + }, + { + @id:3, + child: 2, + pop:"selection-vector-remover" + }, + { + @id: 4, + child: 3, + pop: "screen" + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/db3afaa8/sandbox/prototype/exec/java-exec/src/test/resources/sort/two_key_sort.json ---------------------------------------------------------------------- diff --git a/sandbox/prototype/exec/java-exec/src/test/resources/sort/two_key_sort.json b/sandbox/prototype/exec/java-exec/src/test/resources/sort/two_key_sort.json new file mode 100644 index 0000000..2394626 --- /dev/null +++ b/sandbox/prototype/exec/java-exec/src/test/resources/sort/two_key_sort.json @@ -0,0 +1,54 @@ +{ + head:{ + type:"APACHE_DRILL_PHYSICAL", + version:"1", + generator:{ + type:"manual" + } + }, + graph:[ + { + @id:1, + pop:"mock-scan", + url: "http://apache.org", + entries:[ + {records: 100, types: [ + {name: "blue", type: "INT", mode: "REQUIRED"}, + {name: "green", type: "INT", mode: "REQUIRED"} + ]}, + {records: 100, types: [ + {name: "blue", type: "INT", mode: "REQUIRED"}, + {name: "green", type: "INT", mode: "REQUIRED"} + ]} + ] + }, + { + @id:2, + child: 1, + pop:"project", + exprs: [ + { ref: "blue", expr:"blue" }, + { ref: "alt", expr:"alternate3()" } + ] + }, + { + @id:3, + child: 2, + pop:"sort", + orderings: [ + {expr: "blue"}, + {expr: "alt", order: "DESC"} + ] + }, + { + @id:4, + child: 3, + pop:"selection-vector-remover" + }, + { + @id: 5, + child: 4, + pop: "screen" + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/db3afaa8/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/sql/client/full/BatchListener.java ---------------------------------------------------------------------- diff --git a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/sql/client/full/BatchListener.java b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/sql/client/full/BatchListener.java index b3a7e35..2209b45 100644 --- a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/sql/client/full/BatchListener.java +++ b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/sql/client/full/BatchListener.java @@ -2,6 +2,7 @@ package org.apache.drill.sql.client.full; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; +import java.util.concurrent.TimeUnit; import org.apache.drill.exec.rpc.RpcException; import org.apache.drill.exec.rpc.user.QueryResultBatch; @@ -11,7 +12,7 @@ public class BatchListener implements UserResultsListener { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(BatchListener.class); - private RpcException ex; + private volatile RpcException ex; private volatile boolean completed = false; final BlockingQueue<QueryResultBatch> queue = new ArrayBlockingQueue<>(100); @@ -36,11 +37,15 @@ public class BatchListener implements UserResultsListener { } public QueryResultBatch getNext() throws RpcException, InterruptedException{ - if(ex != null) throw ex; - if(completed && queue.isEmpty()){ - return null; - }else{ - return queue.take(); + while(true){ + if(ex != null) throw ex; + if(completed && queue.isEmpty()){ + return null; + }else{ + QueryResultBatch q = queue.poll(50, TimeUnit.MILLISECONDS); + if(q != null) return q; + } + } } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/db3afaa8/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/sql/client/full/BatchLoaderMap.java ---------------------------------------------------------------------- diff --git a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/sql/client/full/BatchLoaderMap.java b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/sql/client/full/BatchLoaderMap.java index 4eb243d..a60f92b 100644 --- a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/sql/client/full/BatchLoaderMap.java +++ b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/sql/client/full/BatchLoaderMap.java @@ -10,6 +10,7 @@ import jline.internal.Preconditions; import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.record.RecordBatchLoader; +import org.apache.drill.exec.record.VectorWrapper; import org.apache.drill.exec.rpc.RpcException; import org.apache.drill.exec.rpc.user.QueryResultBatch; import org.apache.drill.exec.server.DrillbitContext; @@ -46,8 +47,8 @@ public class BatchLoaderMap implements Map<String, Object> { boolean schemaChanged = loader.load(batch.getHeader().getDef(), batch.getData()); if (schemaChanged) { fields.clear(); - for (ValueVector v : loader) { - fields.put(v.getField().getName(), v); + for (VectorWrapper<?> v : loader) { + fields.put(v.getField().getName(), v.getValueVector()); } } else { logger.debug("Schema didn't change. {}", batch); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/db3afaa8/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java ---------------------------------------------------------------------- diff --git a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java index 281871e..79b8ef8 100644 --- a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java +++ b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/FullEngineTest.java @@ -3,7 +3,11 @@ package org.apache.drill.jdbc.test; import java.io.IOException; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestName; +import org.junit.rules.TestRule; +import org.junit.rules.Timeout; import com.google.common.base.Charsets; import com.google.common.io.Resources; @@ -13,6 +17,12 @@ public class FullEngineTest { private static String MODEL_FULL_ENGINE; + // Determine if we are in Eclipse Debug mode. + static final boolean IS_DEBUG = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().toString().indexOf("-agentlib:jdwp") > 0; + + // Set a timeout unless we're debugging. + @Rule public TestRule globalTimeout = IS_DEBUG ? new TestName() : new Timeout(10000); + @BeforeClass public static void setupFixtures() throws IOException { MODEL_FULL_ENGINE = Resources.toString(Resources.getResource("full-model.json"), Charsets.UTF_8); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/db3afaa8/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java ---------------------------------------------------------------------- diff --git a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java index 1900dc3..3bde4ed 100644 --- a/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java +++ b/sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java @@ -25,7 +25,11 @@ import java.sql.Statement; import org.apache.drill.exec.ref.ReferenceInterpreter; import org.junit.BeforeClass; import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestName; +import org.junit.rules.TestRule; +import org.junit.rules.Timeout; import com.google.common.base.Charsets; import com.google.common.base.Function; @@ -36,6 +40,7 @@ public class JdbcTest { private static String MODEL; private static String EXPECTED; + @BeforeClass public static void setupFixtures() throws IOException { MODEL = Resources.toString(Resources.getResource("test-models.json"), Charsets.UTF_8);
