Search in sources :

Example 6 with AbstractContainerVector

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);
    }
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) AbstractContainerVector(org.apache.drill.exec.vector.complex.AbstractContainerVector)

Aggregations

ValueVector (org.apache.drill.exec.vector.ValueVector)6 AbstractContainerVector (org.apache.drill.exec.vector.complex.AbstractContainerVector)6 MaterializedField (org.apache.drill.exec.record.MaterializedField)3 MajorType (org.apache.drill.common.types.TypeProtos.MajorType)2 JExpression (com.sun.codemodel.JExpression)1 JVar (com.sun.codemodel.JVar)1 IOException (java.io.IOException)1 TypeProtos (org.apache.drill.common.types.TypeProtos)1 ClassTransformationException (org.apache.drill.exec.exception.ClassTransformationException)1 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)1 TypedFieldId (org.apache.drill.exec.record.TypedFieldId)1 VectorContainer (org.apache.drill.exec.record.VectorContainer)1 VectorWrapper (org.apache.drill.exec.record.VectorWrapper)1