@Override public void deleteGreatest() { int slotOff = slotManager.getSlotEndOff(); int tupleOff = slotManager.getTupleOff(slotOff); frameTuple.resetByTupleOffset(buf.array(), tupleOff); int keySize = tupleWriter.bytesRequired(frameTuple); System.arraycopy(buf.array(), tupleOff + keySize, buf.array(), RIGHT_LEAF_OFFSET, CHILD_PTR_SIZE); // Maintain space information. buf.putInt(Constants.TUPLE_COUNT_OFFSET, buf.getInt(Constants.TUPLE_COUNT_OFFSET) - 1); buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) + keySize + CHILD_PTR_SIZE + slotManager.getSlotSize()); int freeSpace = buf.getInt(Constants.FREE_SPACE_OFFSET); if (freeSpace == tupleOff + keySize + CHILD_PTR_SIZE) { buf.putInt(freeSpace, freeSpace - (keySize + CHILD_PTR_SIZE)); } }
@Override public void delete(ITupleReference tuple, int tupleIndex) { int slotOff = slotManager.getSlotOff(tupleIndex); int tupleOff = slotManager.getTupleOff(slotOff); frameTuple.resetByTupleOffset(buf.array(), tupleOff); int tupleSize = tupleWriter.bytesRequired(frameTuple); // perform deletion (we just do a memcpy to overwrite the slot) int slotStartOff = slotManager.getSlotEndOff(); int length = slotOff - slotStartOff; System.arraycopy(buf.array(), slotStartOff, buf.array(), slotStartOff + slotManager.getSlotSize(), length); // maintain space information buf.putInt(Constants.TUPLE_COUNT_OFFSET, buf.getInt(Constants.TUPLE_COUNT_OFFSET) - 1); buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) + tupleSize + slotManager.getSlotSize()); }
@Override public void delete(int tupleIndex, MultiComparator cmp) { int slotOff = slotManager.getSlotOff(tupleIndex); int tupleOff = slotManager.getTupleOff(slotOff); frameTuple.resetByTupleOffset(buf.array(), tupleOff); int tupleSize = tupleWriter.bytesRequired(frameTuple); // perform deletion (we just do a memcpy to overwrite the slot) int slotStartOff = slotManager.getSlotEndOff(); int length = slotOff - slotStartOff; System.arraycopy(buf.array(), slotStartOff, buf.array(), slotStartOff + slotManager.getSlotSize(), length); // maintain space information buf.putInt(Constants.TUPLE_COUNT_OFFSET, buf.getInt(Constants.TUPLE_COUNT_OFFSET) - 1); buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) + tupleSize + slotManager.getSlotSize()); }
private void growCapacity(IExtraPageBlockHelper extraPageBlockHelper, IBufferCache bufferCache, int deltaPages) throws HyracksDataException { int framePagesOld = page.getFrameSizeMultiplier(); int newMultiplier = framePagesOld + deltaPages; // we need to get the old slot offsets before we grow int oldSlotEnd = slotManager.getSlotEndOff(); int oldSlotStart = slotManager.getSlotStartOff() + slotManager.getSlotSize(); bufferCache.resizePage(getPage(), newMultiplier, extraPageBlockHelper); buf = getPage().getBuffer(); // fixup the slots System.arraycopy(buf.array(), oldSlotEnd, buf.array(), slotManager.getSlotEndOff(), oldSlotStart - oldSlotEnd); // fixup total free space counter buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) + (bufferCache.getPageSize() * deltaPages)); }
@Override public void delete(int tupleIndex, MultiComparator cmp) { frameTuple.setFieldCount(cmp.getKeyFieldCount()); int slotOff = slotManager.getSlotOff(tupleIndex); int tupleOff = slotManager.getTupleOff(slotOff); frameTuple.resetByTupleOffset(buf.array(), tupleOff); int tupleSize = tupleWriter.bytesRequired(frameTuple); // perform deletion (we just do a memcpy to overwrite the slot) int slotStartOff = slotManager.getSlotEndOff(); int length = slotOff - slotStartOff; System.arraycopy(buf.array(), slotStartOff, buf.array(), slotStartOff + slotManager.getSlotSize(), length); // maintain space information buf.putInt(Constants.TUPLE_COUNT_OFFSET, buf.getInt(Constants.TUPLE_COUNT_OFFSET) - 1); buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) + tupleSize + childPtrSize + slotManager.getSlotSize()); }
@Override public void delete(ITupleReference tuple, int tupleIndex) { int slotOff = slotManager.getSlotOff(tupleIndex); int tupleOff; int keySize; if (tupleIndex == slotManager.getGreatestKeyIndicator()) { tupleOff = slotManager.getTupleOff(slotManager.getSlotEndOff()); frameTuple.resetByTupleOffset(buf.array(), tupleOff); keySize = frameTuple.getTupleSize(); // Copy new rightmost pointer. System.arraycopy(buf.array(), tupleOff + keySize, buf.array(), RIGHT_LEAF_OFFSET, CHILD_PTR_SIZE); } else { tupleOff = slotManager.getTupleOff(slotOff); frameTuple.resetByTupleOffset(buf.array(), tupleOff); keySize = frameTuple.getTupleSize(); // Perform deletion (we just do a memcpy to overwrite the slot). int slotStartOff = slotManager.getSlotEndOff(); int length = slotOff - slotStartOff; System.arraycopy(buf.array(), slotStartOff, buf.array(), slotStartOff + slotManager.getSlotSize(), length); } // Maintain space information. buf.putInt(Constants.TUPLE_COUNT_OFFSET, buf.getInt(Constants.TUPLE_COUNT_OFFSET) - 1); buf.putInt(TOTAL_FREE_SPACE_OFFSET, buf.getInt(TOTAL_FREE_SPACE_OFFSET) + keySize + CHILD_PTR_SIZE + slotManager.getSlotSize()); }
@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); } } }
int src = rightFrame.getSlotManager().getSlotEndOff(); int dest = rightFrame.getSlotManager().getSlotEndOff() + tuplesToLeft * rightFrame.getSlotManager().getSlotSize(); int length = rightFrame.getSlotManager().getSlotSize() * tuplesToRight; int tupleOff = slotManager.getTupleOff(slotManager.getSlotEndOff()); frameTuple.resetByTupleOffset(buf.array(), tupleOff); int splitKeySize = tupleWriter.bytesRequired(frameTuple, 0, cmp.getKeyFieldCount()); splitKey.getTuple().resetByTupleOffset(splitKey.getBuffer().array(), 0); int deleteTupleOff = slotManager.getTupleOff(slotManager.getSlotEndOff()); frameTuple.resetByTupleOffset(buf.array(), deleteTupleOff); buf.putInt(RIGHT_LEAF_OFFSET, buf.getInt(getLeftChildPageOff(frameTuple)));
int src = rightFrame.getSlotManager().getSlotEndOff(); int dest = rightFrame.getSlotManager().getSlotEndOff() + tuplesToLeft * rightFrame.getSlotManager().getSlotSize(); int length = rightFrame.getSlotManager().getSlotSize() * tuplesToRight; int tupleOff = slotManager.getTupleOff(slotManager.getSlotEndOff()); frameTuple.resetByTupleOffset(buf.array(), tupleOff); int splitKeySize = tupleWriter.bytesRequired(frameTuple, 0, cmp.getKeyFieldCount());
int tupleOff = slotManager.getTupleOff(slotManager.getSlotEndOff()); frameTuple.resetByTupleOffset(buf.array(), tupleOff); int splitKeySize = tupleWriter.bytesRequired(frameTuple, 0, keyValueProviders.length);
int tupleOff = slotManager.getTupleOff(slotManager.getSlotEndOff()); frameTuple.resetByTupleOffset(buf.array(), tupleOff); int splitKeySize = tupleWriter.bytesRequired(frameTuple, 0, keyValueProviders.length);