@Override public void insert(ITupleReference tuple, int tupleIndex) { slotManager.insertSlot(-1, buf.getInt(Constants.FREE_SPACE_OFFSET)); int bytesWritten = tupleWriter.writeTuple(tuple, buf.array(), buf.getInt(Constants.FREE_SPACE_OFFSET)); buf.putInt(Constants.TUPLE_COUNT_OFFSET, buf.getInt(Constants.TUPLE_COUNT_OFFSET) + 1); buf.putInt(Constants.FREE_SPACE_OFFSET, buf.getInt(Constants.FREE_SPACE_OFFSET) + bytesWritten); buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) - bytesWritten - slotManager.getSlotSize()); }
@Override public void insert(ITupleReference tuple, int tupleIndex) { slotManager.insertSlot(tupleIndex, buf.getInt(Constants.FREE_SPACE_OFFSET)); int bytesWritten = tupleWriter.writeTuple(tuple, buf.array(), buf.getInt(Constants.FREE_SPACE_OFFSET)); buf.putInt(Constants.TUPLE_COUNT_OFFSET, buf.getInt(Constants.TUPLE_COUNT_OFFSET) + 1); buf.putInt(Constants.FREE_SPACE_OFFSET, buf.getInt(Constants.FREE_SPACE_OFFSET) + bytesWritten); buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) - bytesWritten - slotManager.getSlotSize()); }
@Override public void insert(ITupleReference tuple, int tupleIndex) { int freeSpace = buf.getInt(Constants.FREE_SPACE_OFFSET); slotManager.insertSlot(tupleIndex, freeSpace); int bytesWritten = tupleWriter.writeTuple(tuple, buf.array(), freeSpace); buf.putInt(Constants.TUPLE_COUNT_OFFSET, buf.getInt(Constants.TUPLE_COUNT_OFFSET) + 1); buf.putInt(Constants.FREE_SPACE_OFFSET, buf.getInt(Constants.FREE_SPACE_OFFSET) + bytesWritten); buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) - bytesWritten - slotManager.getSlotSize()); }
@Override public void insert(ITupleReference tuple, int tupleIndex) { frameTuple.setFieldCount(tuple.getFieldCount()); slotManager.insertSlot(AbstractSlotManager.GREATEST_KEY_INDICATOR, buf.getInt(Constants.FREE_SPACE_OFFSET)); int freeSpace = buf.getInt(Constants.FREE_SPACE_OFFSET); int bytesWritten = tupleWriter.writeTupleFields(tuple, 0, tuple.getFieldCount(), buf.array(), freeSpace); System.arraycopy(tuple.getFieldData(tuple.getFieldCount() - 1), getChildPointerOff(tuple), buf.array(), freeSpace + bytesWritten, childPtrSize); int tupleSize = bytesWritten + childPtrSize; buf.putInt(Constants.TUPLE_COUNT_OFFSET, buf.getInt(Constants.TUPLE_COUNT_OFFSET) + 1); buf.putInt(Constants.FREE_SPACE_OFFSET, buf.getInt(Constants.FREE_SPACE_OFFSET) + tupleSize); buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) - tupleSize - slotManager.getSlotSize()); }
@Override public void insertSorted(ITupleReference tuple) { int freeSpace = buf.getInt(Constants.FREE_SPACE_OFFSET); slotManager.insertSlot(slotManager.getGreatestKeyIndicator(), freeSpace); int bytesWritten = tupleWriter.writeTuple(tuple, buf, freeSpace); System.arraycopy(tuple.getFieldData(tuple.getFieldCount() - 1), getLeftChildPageOff(tuple), buf.array(), freeSpace + bytesWritten, CHILD_PTR_SIZE); int tupleSize = bytesWritten + CHILD_PTR_SIZE; buf.putInt(Constants.TUPLE_COUNT_OFFSET, buf.getInt(Constants.TUPLE_COUNT_OFFSET) + 1); buf.putInt(Constants.FREE_SPACE_OFFSET, buf.getInt(Constants.FREE_SPACE_OFFSET) + tupleSize); buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) - tupleSize - slotManager.getSlotSize()); System.arraycopy(tuple.getFieldData(0), getLeftChildPageOff(tuple) + CHILD_PTR_SIZE, buf.array(), RIGHT_LEAF_OFFSET, CHILD_PTR_SIZE); }
@Override public void insert(ITupleReference tuple, int tupleIndex) { int slotOff = slotManager.insertSlot(tupleIndex, buf.getInt(Constants.FREE_SPACE_OFFSET)); int freeSpace = buf.getInt(Constants.FREE_SPACE_OFFSET); int bytesWritten = tupleWriter.writeTupleFields(tuple, 0, tuple.getFieldCount(), buf.array(), freeSpace); System.arraycopy(tuple.getFieldData(tuple.getFieldCount() - 1), getLeftChildPageOff(tuple), buf.array(), freeSpace + bytesWritten, CHILD_PTR_SIZE); int tupleSize = bytesWritten + CHILD_PTR_SIZE; buf.putInt(Constants.TUPLE_COUNT_OFFSET, buf.getInt(Constants.TUPLE_COUNT_OFFSET) + 1); buf.putInt(Constants.FREE_SPACE_OFFSET, buf.getInt(Constants.FREE_SPACE_OFFSET) + tupleSize); buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) - tupleSize - slotManager.getSlotSize()); // Did we insert into the rightmost slot? if (slotOff == slotManager.getSlotEndOff()) { System.arraycopy(tuple.getFieldData(tuple.getFieldCount() - 1), getLeftChildPageOff(tuple) + CHILD_PTR_SIZE, buf.array(), RIGHT_LEAF_OFFSET, CHILD_PTR_SIZE); } else { // If slotOff has a right (slot-)neighbor then update its child pointer. // The only time when this is NOT the case, is when this is the very first tuple // (or when the splitkey goes into the rightmost slot but that case is handled in the if above). if (buf.getInt(Constants.TUPLE_COUNT_OFFSET) > 1) { int rightNeighborOff = slotOff - slotManager.getSlotSize(); frameTuple.resetByTupleOffset(buf.array(), slotManager.getTupleOff(rightNeighborOff)); System.arraycopy(tuple.getFieldData(0), getLeftChildPageOff(tuple) + CHILD_PTR_SIZE, buf.array(), getLeftChildPageOff(frameTuple), CHILD_PTR_SIZE); } } }