}
}
@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)) {
String msg = composeTooBigMsg(recordId, incoming);
logger.debug(msg);
throw new IOException(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)) {
String msg = composeTooBigMsg(recordId, incoming);
logger.debug(msg);
throw new IOException(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)) {
String msg = composeTooBigMsg(recordId, incoming);
logger.debug(msg);
throw new IOException(msg);
}
}
}
break;
default:
throw new UnsupportedOperationException("Unknown selection vector mode: " + svMode.toString());
}
}