use of org.apache.drill.exec.proto.UserBitShared.QueryData in project drill by axbaretto.
the class PrintingResultsListener method dataArrived.
@Override
@SuppressWarnings("resource")
public void dataArrived(QueryDataBatch result, ConnectionThrottle throttle) {
final QueryData header = result.getHeader();
final DrillBuf data = result.getData();
try {
if (data != null) {
count.addAndGet(header.getRowCount());
try {
loader.load(header.getDef(), data);
// TODO: Clean: DRILL-2933: That load(...) no longer throws
// SchemaChangeException, so check/clean catch clause below.
} catch (SchemaChangeException e) {
submissionFailed(UserException.systemError(e).build(logger));
}
try {
switch(format) {
case TABLE:
VectorUtil.showVectorAccessibleContent(loader, columnWidth);
break;
case TSV:
VectorUtil.showVectorAccessibleContent(loader, "\t");
break;
case CSV:
VectorUtil.showVectorAccessibleContent(loader, ",");
break;
default:
throw new IllegalStateException(format.toString());
}
} finally {
loader.clear();
}
}
} finally {
result.release();
}
}
use of org.apache.drill.exec.proto.UserBitShared.QueryData in project drill by axbaretto.
the class VectorRecordMaterializer method convertNext.
public QueryWritableBatch convertNext() {
// batch.getWritableBatch().getDef().getRecordCount()
WritableBatch w = batch.getWritableBatch().transfer(allocator);
QueryData header = //
QueryData.newBuilder().setQueryId(//
queryId).setRowCount(//
batch.getRecordCount()).setDef(w.getDef()).build();
QueryWritableBatch batch = new QueryWritableBatch(header, w.getBuffers());
return batch;
}
use of org.apache.drill.exec.proto.UserBitShared.QueryData in project drill by axbaretto.
the class QueryResultHandler method batchArrived.
/**
* Maps internal low-level API protocol to {@link UserResultsListener}-level API protocol.
* handles query data messages
*/
public void batchArrived(ConnectionThrottle throttle, ByteBuf pBody, ByteBuf dBody) throws RpcException {
final QueryData queryData = RpcBus.get(pBody, QueryData.PARSER);
// Current batch coming in.
final DrillBuf drillBuf = (DrillBuf) dBody;
final QueryDataBatch batch = new QueryDataBatch(queryData, drillBuf);
final QueryId queryId = queryData.getQueryId();
if (logger.isDebugEnabled()) {
logger.debug("batchArrived: queryId = {}", QueryIdHelper.getQueryId(queryId));
}
logger.trace("batchArrived: batch = {}", batch);
final UserResultsListener resultsListener = newUserResultsListener(queryId);
// A data case--pass on via dataArrived
try {
resultsListener.dataArrived(batch, throttle);
// That releases batch if successful.
} catch (Exception e) {
batch.release();
resultsListener.submissionFailed(UserException.systemError(e).build(logger));
}
}
use of org.apache.drill.exec.proto.UserBitShared.QueryData in project drill by axbaretto.
the class TestMergingReceiver method handleEmptyBatchNoSchema.
@Test
public void handleEmptyBatchNoSchema() 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_noschema.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.proto.UserBitShared.QueryData in project drill by axbaretto.
the class TestMergingReceiver method twoBitTwoExchange.
// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestMergingReceiver.class);
@Test
public void twoBitTwoExchange() 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/merging_receiver.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();
final int rowCount = queryData.getRowCount();
count += rowCount;
// loaded but not used, just to test
batchLoader.load(queryData.getDef(), b.getData());
b.release();
batchLoader.clear();
}
assertEquals(200000, count);
}
}
Aggregations