Search in sources :

Example 1 with ObjectVector

use of org.apache.drill.exec.vector.ObjectVector in project drill by apache.

the class HashPartition method allocateNewVectorContainer.

/**
 * Allocate a new vector container for either right or left record batch
 * Add an additional special vector for the hash values
 * Note: this call may OOM !!
 * @param rb - either the right or the left record batch
 * @return the new vector container
 */
private VectorContainer allocateNewVectorContainer(RecordBatch rb) {
    VectorContainer newVC = new VectorContainer();
    VectorContainer fromVC = rb.getContainer();
    Iterator<VectorWrapper<?>> vci = fromVC.iterator();
    boolean success = false;
    try {
        while (vci.hasNext()) {
            VectorWrapper<?> vw = vci.next();
            // If processing a spilled container, skip the last column (HV)
            if (cycleNum > 0 && !vci.hasNext()) {
                break;
            }
            ValueVector vv = vw.getValueVector();
            ValueVector newVV = TypeHelper.getNewVector(vv.getField(), allocator);
            // add first to allow dealloc in case of an OOM
            newVC.add(newVV);
            if (newVV instanceof FixedWidthVector) {
                ((FixedWidthVector) newVV).allocateNew(recordsPerBatch);
            } else if (newVV instanceof VariableWidthVector) {
                ((VariableWidthVector) newVV).allocateNew(maxColumnWidth * recordsPerBatch, recordsPerBatch);
            } else if (newVV instanceof ObjectVector) {
                ((ObjectVector) newVV).allocateNew(recordsPerBatch);
            } else {
                newVV.allocateNew();
            }
        }
        newVC.setRecordCount(0);
        success = true;
    } finally {
        if (!success) {
            // in case of an OOM
            newVC.clear();
        }
    }
    return newVC;
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) FixedWidthVector(org.apache.drill.exec.vector.FixedWidthVector) VectorWrapper(org.apache.drill.exec.record.VectorWrapper) VariableWidthVector(org.apache.drill.exec.vector.VariableWidthVector) VectorContainer(org.apache.drill.exec.record.VectorContainer) ObjectVector(org.apache.drill.exec.vector.ObjectVector)

Aggregations

VectorContainer (org.apache.drill.exec.record.VectorContainer)1 VectorWrapper (org.apache.drill.exec.record.VectorWrapper)1 FixedWidthVector (org.apache.drill.exec.vector.FixedWidthVector)1 ObjectVector (org.apache.drill.exec.vector.ObjectVector)1 ValueVector (org.apache.drill.exec.vector.ValueVector)1 VariableWidthVector (org.apache.drill.exec.vector.VariableWidthVector)1