use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestMergingReceiver method handleEmptyBatch.
@Test
public void handleEmptyBatch() throws Exception {
@SuppressWarnings("resource") final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
try (final Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
final Drillbit bit2 = new Drillbit(CONFIG, serviceSet);
final DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
bit1.run();
bit2.run();
client.connect();
final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/mergerecv/empty_batch.json"), Charsets.UTF_8));
int count = 0;
final RecordBatchLoader batchLoader = new RecordBatchLoader(client.getAllocator());
// print the results
for (final QueryDataBatch b : results) {
final QueryData queryData = b.getHeader();
// loaded but not used, for testing
batchLoader.load(queryData.getDef(), b.getData());
count += queryData.getRowCount();
b.release();
batchLoader.clear();
}
assertEquals(100000, count);
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestOrderedPartitionExchange method twoBitTwoExchangeRun.
/**
* Starts two drillbits and runs a physical plan with a Mock scan, project, OrderedParititionExchange, Union Exchange,
* and sort. The final sort is done first on the partition column, and verifies that the partitions are correct, in that
* all rows in partition 0 should come in the sort order before any row in partition 1, etc. Also verifies that the standard
* deviation of the size of the partitions is less than one tenth the mean size of the partitions, because we expect all
* the partitions to be roughly equal in size.
* @throws Exception
*/
@Test
public void twoBitTwoExchangeRun() throws Exception {
RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
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();
List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/sender/ordered_exchange.json"), Charsets.UTF_8));
int count = 0;
List<Integer> partitionRecordCounts = Lists.newArrayList();
for (QueryDataBatch b : results) {
if (b.getData() != null) {
int rows = b.getHeader().getRowCount();
count += rows;
DrillConfig config = DrillConfig.create();
RecordBatchLoader loader = new RecordBatchLoader(new BootStrapContext(config, SystemOptionManager.createDefaultOptionDefinitions(), ClassPathScanner.fromPrescan(config)).getAllocator());
loader.load(b.getHeader().getDef(), b.getData());
BigIntVector vv1 = (BigIntVector) loader.getValueAccessorById(BigIntVector.class, loader.getValueVectorId(new SchemaPath("col1", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();
Float8Vector vv2 = (Float8Vector) loader.getValueAccessorById(Float8Vector.class, loader.getValueVectorId(new SchemaPath("col2", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();
IntVector pVector = (IntVector) loader.getValueAccessorById(IntVector.class, loader.getValueVectorId(new SchemaPath("partition", ExpressionPosition.UNKNOWN)).getFieldIds()).getValueVector();
long previous1 = Long.MIN_VALUE;
double previous2 = Double.MIN_VALUE;
int partPrevious = -1;
long current1 = Long.MIN_VALUE;
double current2 = Double.MIN_VALUE;
int partCurrent = -1;
int partitionRecordCount = 0;
for (int i = 0; i < rows; i++) {
previous1 = current1;
previous2 = current2;
partPrevious = partCurrent;
current1 = vv1.getAccessor().get(i);
current2 = vv2.getAccessor().get(i);
partCurrent = pVector.getAccessor().get(i);
Assert.assertTrue(current1 >= previous1);
if (current1 == previous1) {
Assert.assertTrue(current2 <= previous2);
}
if (partCurrent == partPrevious || partPrevious == -1) {
partitionRecordCount++;
} else {
partitionRecordCounts.add(partitionRecordCount);
partitionRecordCount = 0;
}
}
partitionRecordCounts.add(partitionRecordCount);
loader.clear();
}
b.release();
}
double[] values = new double[partitionRecordCounts.size()];
int i = 0;
for (Integer rc : partitionRecordCounts) {
values[i++] = rc.doubleValue();
}
StandardDeviation stdDev = new StandardDeviation();
Mean mean = new Mean();
double std = stdDev.evaluate(values);
double m = mean.evaluate(values);
System.out.println("mean: " + m + " std dev: " + std);
// Assert.assertTrue(std < 0.1 * m);
assertEquals(31000, count);
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestHashJoin method multipleConditionJoin.
@Test
public void multipleConditionJoin() throws Throwable {
// Function tests hash join with multiple join conditions
try (final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
final Drillbit bit = new Drillbit(CONFIG, serviceSet);
final DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
// run query.
bit.run();
client.connect();
final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/join/hj_multi_condition_join.json"), Charsets.UTF_8).replace("#{TEST_FILE_1}", DrillFileUtils.getResourceAsFile("/build_side_input.json").toURI().toString()).replace("#{TEST_FILE_2}", DrillFileUtils.getResourceAsFile("/probe_side_input.json").toURI().toString()));
final RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
final QueryDataBatch batch = results.get(1);
assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
final Iterator<VectorWrapper<?>> itr = batchLoader.iterator();
// Just test the join key
final long[] colA = { 1, 2, 1 };
final long[] colC = { 100, 200, 500 };
// Check the output of decimal9
final ValueVector.Accessor intAccessor1 = itr.next().getValueVector().getAccessor();
final 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());
batchLoader.clear();
for (final QueryDataBatch result : results) {
result.release();
}
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestHashJoin method hjWithExchange1.
@Test
public void hjWithExchange1() throws Throwable {
// Another test for hash join with exchanges
try (final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
final Drillbit bit = new Drillbit(CONFIG, serviceSet);
final DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
// run query.
bit.run();
client.connect();
final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/join/hj_exchanges1.json"), Charsets.UTF_8));
int count = 0;
for (final QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
System.out.println("Total records: " + count);
assertEquals(272, count);
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestMergeJoin method testMergeJoinLeftEmptyBatch.
@Test
public void testMergeJoinLeftEmptyBatch() throws Exception {
final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
try (final Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
final DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
bit1.run();
client.connect();
final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(DrillFileUtils.getResourceAsFile("/join/merge_join_empty_batch.json"), Charsets.UTF_8).replace("${JOIN_TYPE}", "LEFT"));
int count = 0;
for (final QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
assertEquals(50, count);
}
}
Aggregations