Search in sources :

Example 1 with BatchHolder

use of org.apache.drill.exec.physical.resultSet.impl.PushResultSetReaderImpl.BatchHolder in project drill by apache.

the class StreamingHttpConnection method sendData.

/**
 * Called from query thread, specifically from the Screen operator,
 * for each batch.
 */
@Override
public void sendData(RpcOutcomeListener<Ack> listener, QueryDataPackage data) {
    VectorContainer batch = data.batch();
    try {
        if (batchCount == 0) {
            batchHolder = new BatchHolder(batch);
            reader = new PushResultSetReaderImpl(batchHolder);
            startSignal.await();
        }
        batchHolder.newBatch();
        RowSetReader batchReader = reader.start();
        emitBatch(batchReader);
        batchCount++;
    } catch (IOException e) {
        throw UserException.dataWriteError(e).addContext("Failed to send JSON results to the REST client").build(logger);
    } catch (InterruptedException e) {
        throw new DrillRuntimeException("Interrupted", e);
    } finally {
        batch.zeroVectors();
        listener.success(Acks.OK, null);
    }
}
Also used : BatchHolder(org.apache.drill.exec.physical.resultSet.impl.PushResultSetReaderImpl.BatchHolder) PushResultSetReaderImpl(org.apache.drill.exec.physical.resultSet.impl.PushResultSetReaderImpl) IOException(java.io.IOException) RowSetReader(org.apache.drill.exec.physical.rowSet.RowSetReader) DrillRuntimeException(org.apache.drill.common.exceptions.DrillRuntimeException) VectorContainer(org.apache.drill.exec.record.VectorContainer)

Aggregations

IOException (java.io.IOException)1 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)1 PushResultSetReaderImpl (org.apache.drill.exec.physical.resultSet.impl.PushResultSetReaderImpl)1 BatchHolder (org.apache.drill.exec.physical.resultSet.impl.PushResultSetReaderImpl.BatchHolder)1 RowSetReader (org.apache.drill.exec.physical.rowSet.RowSetReader)1 VectorContainer (org.apache.drill.exec.record.VectorContainer)1