Search in sources :

Example 1 with CloseableRecordBatch

use of org.apache.drill.exec.record.CloseableRecordBatch in project drill by apache.

the class BaseRootExec method close.

@Override
public void close() throws Exception {
    // We want to account for the time spent waiting here as Wait time in the operator profile
    try {
        stats.startProcessing();
        stats.startWait();
        fragmentContext.waitForSendComplete();
    } finally {
        stats.stopWait();
        stats.stopProcessing();
    }
    // close all operators.
    if (operators != null) {
        final DeferredException df = new DeferredException(new Supplier<Exception>() {

            @Override
            public Exception get() {
                return new RuntimeException("Error closing operators");
            }
        });
        for (final CloseableRecordBatch crb : operators) {
            df.suppressingClose(crb);
            if (logger.isDebugEnabled()) {
                logger.debug(String.format("closed operator %d", System.identityHashCode(crb)));
            }
        }
        try {
            df.close();
        } catch (Exception e) {
            fragmentContext.fail(e);
        }
    }
}
Also used : CloseableRecordBatch(org.apache.drill.exec.record.CloseableRecordBatch) DeferredException(org.apache.drill.common.DeferredException) OutOfMemoryException(org.apache.drill.exec.exception.OutOfMemoryException) DeferredException(org.apache.drill.common.DeferredException)

Example 2 with CloseableRecordBatch

use of org.apache.drill.exec.record.CloseableRecordBatch in project drill by apache.

the class BaseRootExec method setOperators.

void setOperators(List<CloseableRecordBatch> operators) {
    this.operators = operators;
    if (logger.isDebugEnabled()) {
        final StringBuilder sb = new StringBuilder();
        sb.append("BaseRootExec(");
        sb.append(Integer.toString(System.identityHashCode(this)));
        sb.append(") operators: ");
        for (final CloseableRecordBatch crb : operators) {
            sb.append(crb.getClass().getName());
            sb.append(' ');
            sb.append(Integer.toString(System.identityHashCode(crb)));
            sb.append(", ");
        }
        // Cut off the last trailing comma and space
        sb.setLength(sb.length() - 2);
        logger.debug(sb.toString());
    }
}
Also used : CloseableRecordBatch(org.apache.drill.exec.record.CloseableRecordBatch)

Example 3 with CloseableRecordBatch

use of org.apache.drill.exec.record.CloseableRecordBatch in project drill by apache.

the class ImplCreator method getRecordBatch.

/** Create a RecordBatch and its children for given PhysicalOperator */
@VisibleForTesting
public RecordBatch getRecordBatch(final PhysicalOperator op, final FragmentContext context) throws ExecutionSetupException {
    Preconditions.checkNotNull(op);
    final List<RecordBatch> childRecordBatches = getChildren(op, context);
    if (context.isImpersonationEnabled()) {
        final UserGroupInformation proxyUgi = ImpersonationUtil.createProxyUgi(op.getUserName(), context.getQueryUserName());
        try {
            return proxyUgi.doAs(new PrivilegedExceptionAction<RecordBatch>() {

                @Override
                public RecordBatch run() throws Exception {
                    final CloseableRecordBatch batch = ((BatchCreator<PhysicalOperator>) getOpCreator(op, context)).getBatch(context, op, childRecordBatches);
                    operators.addFirst(batch);
                    return batch;
                }
            });
        } catch (InterruptedException | IOException e) {
            final String errMsg = String.format("Failed to create RecordBatch for operator with id '%d'", op.getOperatorId());
            logger.error(errMsg, e);
            throw new ExecutionSetupException(errMsg, e);
        }
    } else {
        final CloseableRecordBatch batch = ((BatchCreator<PhysicalOperator>) getOpCreator(op, context)).getBatch(context, op, childRecordBatches);
        operators.addFirst(batch);
        return batch;
    }
}
Also used : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) RecordBatch(org.apache.drill.exec.record.RecordBatch) CloseableRecordBatch(org.apache.drill.exec.record.CloseableRecordBatch) IOException(java.io.IOException) IOException(java.io.IOException) ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) CloseableRecordBatch(org.apache.drill.exec.record.CloseableRecordBatch) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

CloseableRecordBatch (org.apache.drill.exec.record.CloseableRecordBatch)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 DeferredException (org.apache.drill.common.DeferredException)1 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)1 OutOfMemoryException (org.apache.drill.exec.exception.OutOfMemoryException)1 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)1 RecordBatch (org.apache.drill.exec.record.RecordBatch)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1