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