}
}
@Override
public void partitionBatch(RecordBatch incoming) throws IOException {
SelectionVectorMode svMode = incoming.getSchema().getSelectionVectorMode();
// Keeping the for loop inside the case to avoid case evaluation for each record.
switch(svMode) {
case NONE:
for (int recordId = 0; recordId < incoming.getRecordCount(); ++recordId) {
OutgoingRecordBatch outgoingBatch = outgoingBatches.get(doEval(recordId));
if (!outgoingBatch.copy(recordId)) {
logger.trace(REWRITE_MSG, recordId);
outgoingBatch.flush();
if (!outgoingBatch.copy(recordId)) {
logger.debug(RECORD_TOO_BIG_MSG, recordId);
throw new IOException(RECORD_TOO_BIG_MSG);
}
}
}
break;
case TWO_BYTE:
for (int recordId = 0; recordId < incoming.getRecordCount(); ++recordId) {
int svIndex = sv2.getIndex(recordId);
OutgoingRecordBatch outgoingBatch = outgoingBatches.get(doEval(svIndex));
if (!outgoingBatch.copy(svIndex)) {
logger.trace(REWRITE_MSG, svIndex);
outgoingBatch.flush();
if (!outgoingBatch.copy(svIndex)) {
logger.debug(RECORD_TOO_BIG_MSG, recordId);
throw new IOException(RECORD_TOO_BIG_MSG);
}
}
}
break;
case FOUR_BYTE:
for (int recordId = 0; recordId < incoming.getRecordCount(); ++recordId) {
int svIndex = sv4.get(recordId);
OutgoingRecordBatch outgoingBatch = outgoingBatches.get(doEval(svIndex));
if (!outgoingBatch.copy(svIndex)) {
logger.trace(REWRITE_MSG, svIndex);
outgoingBatch.flush();
if (!outgoingBatch.copy(svIndex)) {
logger.debug(RECORD_TOO_BIG_MSG, recordId);
throw new IOException(RECORD_TOO_BIG_MSG);
}
}
}
break;
default:
throw new UnsupportedOperationException("Unknown selection vector mode: " + svMode.toString());
}
}