use of org.apache.drill.exec.server.RemoteServiceSet in project drill by apache.
the class TestParquetPhysicalPlan method testParseParquetPhysicalPlan.
@Test
@Ignore
public void testParseParquetPhysicalPlan() throws Exception {
final StringBuilder sb = new StringBuilder();
RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
DrillConfig config = DrillConfig.create();
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, Resources.toString(Resources.getResource(fileName), Charsets.UTF_8));
RecordBatchLoader loader = new RecordBatchLoader(bit1.getContext().getAllocator());
int count = 0;
for (QueryDataBatch b : results) {
sb.append(String.format("Got %d results\n", b.getHeader().getRowCount()));
count += b.getHeader().getRowCount();
loader.load(b.getHeader().getDef(), b.getData());
for (VectorWrapper vw : loader) {
sb.append(vw.getValueVector().getField().getName() + ": ");
ValueVector vv = vw.getValueVector();
for (int i = 0; i < vv.getAccessor().getValueCount(); i++) {
Object o = vv.getAccessor().getObject(i);
if (o instanceof byte[]) {
sb.append(" [" + new String((byte[]) o) + "]");
} else {
sb.append(" [" + vv.getAccessor().getObject(i) + "]");
}
}
sb.append('\n');
}
loader.clear();
b.release();
}
client.close();
sb.append(String.format("Got %d total results\n", count));
}
logger.debug(sb.toString());
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by apache.
the class TestPauseInjection method timedPauseOnSpecificBit.
@Test
public void timedPauseOnSpecificBit() {
final RemoteServiceSet remoteServiceSet = RemoteServiceSet.getLocalServiceSet();
final ZookeeperHelper zkHelper = new ZookeeperHelper();
zkHelper.startZookeeper(1);
final long pauseDuration = 2000L;
final long expectedDuration = pauseDuration;
try {
// Creating two drillbits
final Drillbit drillbit1, drillbit2;
final DrillConfig drillConfig = zkHelper.getConfig();
try {
drillbit1 = Drillbit.start(drillConfig, remoteServiceSet);
drillbit2 = Drillbit.start(drillConfig, remoteServiceSet);
} catch (final DrillbitStartupException e) {
throw new RuntimeException("Failed to start two drillbits.", e);
}
final DrillbitContext drillbitContext1 = drillbit1.getContext();
final DrillbitContext drillbitContext2 = drillbit2.getContext();
final UserSession session = UserSession.Builder.newBuilder().withCredentials(UserCredentials.newBuilder().setUserName("foo").build()).withUserProperties(UserProperties.getDefaultInstance()).withOptionManager(drillbitContext1.getOptionManager()).build();
final DrillbitEndpoint drillbitEndpoint1 = drillbitContext1.getEndpoint();
final String controls = Controls.newBuilder().addTimedPauseOnBit(DummyClass.class, DummyClass.PAUSES, drillbitEndpoint1, 0, pauseDuration).build();
ControlsInjectionUtil.setControls(session, controls);
{
final ExtendedLatch trigger = new ExtendedLatch(1);
final Pointer<Exception> ex = new Pointer<>();
final QueryContext queryContext = new QueryContext(session, drillbitContext1, QueryId.getDefaultInstance());
// test that the pause happens
final DummyClass dummyClass = new DummyClass(queryContext, trigger);
final long actualDuration = dummyClass.pauses();
assertTrue(String.format("Test should stop for at least %d milliseconds.", expectedDuration), expectedDuration <= actualDuration);
assertNull("No exception should be thrown.", ex.value);
try {
queryContext.close();
} catch (final Exception e) {
fail("Failed to close query context: " + e);
}
}
{
final ExtendedLatch trigger = new ExtendedLatch(1);
final QueryContext queryContext = new QueryContext(session, drillbitContext2, QueryId.getDefaultInstance());
// if the resume did not happen, the test would hang
final DummyClass dummyClass = new DummyClass(queryContext, trigger);
dummyClass.pauses();
try {
queryContext.close();
} catch (final Exception e) {
fail("Failed to close query context: " + e);
}
}
} finally {
zkHelper.stopZookeeper();
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by apache.
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.asCharSource(DrillFileUtils.getResourceAsFile("/join/hj_exchanges1.json"), Charsets.UTF_8).read());
int count = 0;
for (final QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
assertEquals(272, count);
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by apache.
the class TestHashJoin method testHashJoinExprInCondition.
@Test
public void testHashJoinExprInCondition() 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.asCharSource(DrillFileUtils.getResourceAsFile("/join/hashJoinExpr.json"), Charsets.UTF_8).read());
int count = 0;
for (final QueryDataBatch b : results) {
if (b.getHeader().getRowCount() != 0) {
count += b.getHeader().getRowCount();
}
b.release();
}
assertEquals(10, count);
}
}
use of org.apache.drill.exec.server.RemoteServiceSet in project drill by apache.
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.asCharSource(DrillFileUtils.getResourceAsFile("/join/hj_multi_condition_join.json"), Charsets.UTF_8).read().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();
}
}
}
Aggregations