}
return size;
}
private SelectionVector2 newSV2() throws OutOfMemoryException {
SelectionVector2 sv2 = new SelectionVector2(oContext.getAllocator());
if (!sv2.allocateNew(incoming.getRecordCount())) {
try {
mergeAndSpill();
} catch (SchemaChangeException e) {
throw new RuntimeException();
}
batchesSinceLastSpill = 0;
int waitTime = 1;
while (true) {
try {
Thread.sleep(waitTime * 1000);
} catch (InterruptedException e) {
throw new OutOfMemoryException(e);
}
waitTime *= 2;
if (sv2.allocateNew(incoming.getRecordCount())) {
break;
}
if (waitTime >= 32) {
throw new OutOfMemoryException("Unable to allocate sv2 buffer after repeated attempts");
}
}
}
for (int i = 0; i < incoming.getRecordCount(); i++) {
sv2.setIndex(i, (char) i);
}
sv2.setRecordCount(incoming.getRecordCount());
return sv2;
}