use of org.apache.drill.exec.vector.complex.AbstractContainerVector in project drill by apache.
the class ExternalSortBatch method buildSchema.
/**
* Called by {@link AbstractRecordBatch} as a fast-path to obtain
* the first record batch and setup the schema of this batch in order
* to quickly return the schema to the client. Note that this method
* fetches the first batch from upstream which will be waiting for
* us the first time that {@link #innerNext()} is called.
*/
@Override
public void buildSchema() {
IterOutcome outcome = next(incoming);
switch(outcome) {
case OK:
case OK_NEW_SCHEMA:
for (VectorWrapper<?> w : incoming) {
@SuppressWarnings("resource") ValueVector v = container.addOrGet(w.getField());
if (v instanceof AbstractContainerVector) {
// Can we remove this hack?
w.getValueVector().makeTransferPair(v);
v.clear();
}
// Can we remove this? - SVR fails with NPE (TODO)
v.allocateNew();
}
container.buildSchema(SelectionVectorMode.NONE);
container.setRecordCount(0);
break;
case STOP:
state = BatchState.STOP;
break;
case OUT_OF_MEMORY:
state = BatchState.OUT_OF_MEMORY;
break;
case NONE:
state = BatchState.DONE;
break;
default:
throw new IllegalStateException("Unexpected iter outcome: " + outcome);
}
}
Aggregations