use of org.apache.drill.exec.server.RemoteServiceSet in project drill by apache.
the class TestHashJoin method hjWithExchange1.
@Test
public void hjWithExchange1(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) 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(FileUtils.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 apache.
the class TestHashJoin method multipleConditionJoin.
@Test
public void multipleConditionJoin(@Injectable final DrillbitContext bitContext, @Injectable UserClientConnection connection) 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(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()));
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 apache.
the class TextRecordReaderTest method testFullExecution.
@Test
public void testFullExecution() throws Exception {
RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
try (Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
bit1.run();
client.connect();
List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.toString(FileUtils.getResourceAsFile("/store/text/test.json"), Charsets.UTF_8).replace("#{DATA_FILE}", FileUtils.getResourceAsFile("/store/text/data/regions.csv").toURI().toString()));
int count = 0;
RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
for (QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
loader.load(b.getHeader().getDef(), b.getData());
VectorUtil.showVectorAccessibleContent(loader);
loader.clear();
b.release();
}
assertEquals(5, count);
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestMergingReceiver method testMultipleProvidersMixedSizes.
@Test
public void testMultipleProvidersMixedSizes() 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/multiple_providers.json"), Charsets.UTF_8));
int count = 0;
final RecordBatchLoader batchLoader = new RecordBatchLoader(client.getAllocator());
// print the results
Long lastBlueValue = null;
for (final QueryDataBatch b : results) {
final QueryData queryData = b.getHeader();
final int batchRowCount = queryData.getRowCount();
count += batchRowCount;
batchLoader.load(queryData.getDef(), b.getData());
for (final VectorWrapper<?> vw : batchLoader) {
@SuppressWarnings("resource") final ValueVector vv = vw.getValueVector();
final ValueVector.Accessor va = vv.getAccessor();
final MaterializedField materializedField = vv.getField();
final int numValues = va.getValueCount();
for (int valueIdx = 0; valueIdx < numValues; ++valueIdx) {
if (materializedField.getName().equals("blue")) {
final long longValue = (Long) va.getObject(valueIdx);
// check that order is ascending
if (lastBlueValue != null) {
assertTrue(longValue >= lastBlueValue);
}
lastBlueValue = longValue;
}
}
}
b.release();
batchLoader.clear();
}
assertEquals(400000, count);
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by axbaretto.
the class TestMergingReceiver method testMultipleProvidersEmptyBatches.
@Test
public void testMultipleProvidersEmptyBatches() 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/multiple_providers_empty_batches.json"), Charsets.UTF_8));
int count = 0;
final RecordBatchLoader batchLoader = new RecordBatchLoader(client.getAllocator());
// print the results
Long lastBlueValue = null;
for (final QueryDataBatch b : results) {
final QueryData queryData = b.getHeader();
final int batchRowCount = queryData.getRowCount();
count += batchRowCount;
batchLoader.load(queryData.getDef(), b.getData());
for (final VectorWrapper<?> vw : batchLoader) {
@SuppressWarnings("resource") final ValueVector vv = vw.getValueVector();
final ValueVector.Accessor va = vv.getAccessor();
final MaterializedField materializedField = vv.getField();
final int numValues = va.getValueCount();
for (int valueIdx = 0; valueIdx < numValues; ++valueIdx) {
if (materializedField.getName().equals("blue")) {
final long longValue = (Long) va.getObject(valueIdx);
// check that order is ascending
if (lastBlueValue != null) {
assertTrue(longValue >= lastBlueValue);
}
lastBlueValue = longValue;
}
}
}
b.release();
batchLoader.clear();
}
assertEquals(300000, count);
}
}
Aggregations