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);
}
}
}
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());
}
}
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;
}
}
Aggregations