Search in sources :

Example 6 with ExpandableHyperContainer

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

the class HashJoinBatch method buildSchema.

@Override
protected void buildSchema() throws SchemaChangeException {
    leftUpstream = next(left);
    rightUpstream = next(right);
    if (leftUpstream == IterOutcome.STOP || rightUpstream == IterOutcome.STOP) {
        state = BatchState.STOP;
        return;
    }
    if (leftUpstream == IterOutcome.OUT_OF_MEMORY || rightUpstream == IterOutcome.OUT_OF_MEMORY) {
        state = BatchState.OUT_OF_MEMORY;
        return;
    }
    // Initialize the hash join helper context
    hjHelper = new HashJoinHelper(context, oContext.getAllocator());
    try {
        rightSchema = right.getSchema();
        final VectorContainer vectors = new VectorContainer(oContext);
        for (final VectorWrapper<?> w : right) {
            vectors.addOrGet(w.getField());
        }
        vectors.buildSchema(SelectionVectorMode.NONE);
        vectors.setRecordCount(0);
        hyperContainer = new ExpandableHyperContainer(vectors);
        hjHelper.addNewBatch(0);
        buildBatchIndex++;
        setupHashTable();
        hashJoinProbe = setupHashJoinProbe();
        // Build the container schema and set the counts
        for (final VectorWrapper<?> w : container) {
            w.getValueVector().allocateNew();
        }
        container.buildSchema(BatchSchema.SelectionVectorMode.NONE);
        container.setRecordCount(outputRecords);
    } catch (IOException | ClassTransformationException e) {
        throw new SchemaChangeException(e);
    }
}
Also used : ExpandableHyperContainer(org.apache.drill.exec.record.ExpandableHyperContainer) SchemaChangeException(org.apache.drill.exec.exception.SchemaChangeException) ClassTransformationException(org.apache.drill.exec.exception.ClassTransformationException) IOException(java.io.IOException) VectorContainer(org.apache.drill.exec.record.VectorContainer)

Aggregations

ExpandableHyperContainer (org.apache.drill.exec.record.ExpandableHyperContainer)6 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)4 IOException (java.io.IOException)3 ClassTransformationException (org.apache.drill.exec.exception.ClassTransformationException)3 Stopwatch (com.google.common.base.Stopwatch)2 RecordBatchData (org.apache.drill.exec.physical.impl.sort.RecordBatchData)2 VectorContainer (org.apache.drill.exec.record.VectorContainer)2 DrillBuf (io.netty.buffer.DrillBuf)1 IndexPointer (org.apache.drill.exec.physical.impl.common.IndexPointer)1 BatchSchema (org.apache.drill.exec.record.BatchSchema)1 MaterializedField (org.apache.drill.exec.record.MaterializedField)1 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)1 VectorWrapper (org.apache.drill.exec.record.VectorWrapper)1 SelectionVector2 (org.apache.drill.exec.record.selection.SelectionVector2)1 SelectionVector4 (org.apache.drill.exec.record.selection.SelectionVector4)1