public void DeleteFromIndexRecord(BTreeOnHeapIndex index, HeapID heapID) { int recordIndex = index.GetIndexOfRecord(heapID); index.Records.RemoveAt(recordIndex); if (index.Records.Count > 0) { // will always replace in place (smaller size) ReplaceHeapItem(index.HeapID, index.GetBytes()); } else { if (index.ParentIndex == null) { // this is the root node BTreeHeader.hidRoot = HeapID.EmptyHeapID; BTreeHeader.bIdxLevels = 0; UpdateBTreeHeader(); } else { DeleteFromIndexRecord(index.ParentIndex, index.HeapID); } } }
public void UpdateIndexRecord(BTreeOnHeapIndex index, HeapID oldHeapID, HeapID newHeapID, byte[] newKey) { int recordIndex = index.GetIndexOfRecord(oldHeapID); index.Records[recordIndex].hidNextLevel = newHeapID; index.Records[recordIndex].key = newKey; // will always replace in place (same size) ReplaceHeapItem(index.HeapID, index.GetBytes()); if (recordIndex == 0 && index.ParentIndex != null) { UpdateIndexRecord(index.ParentIndex, index.HeapID, index.HeapID, index.NodeKey); } }