private bool FindIndexKey(Stream AKey, object ACompareContext, out IndexNode AIndexNode, out int AEntryNumber) { SearchPath LSearchPath = new SearchPath(); try { bool LResult = FAccessPath.FindKey(FProcess, AKey, ACompareContext, LSearchPath, out AEntryNumber); AIndexNode = LSearchPath.DisownAt(LSearchPath.Count - 1); return(LResult); } finally { LSearchPath.Dispose(); } }
/// <summary>Updates the entry given by AOldKey to the entry given by ANewKey and ANewData. If AOldKey == ANewKey, the data for the entry is updated in place, otherwise it is moved to the location given by ANewKey.</summary> public void Update(ServerProcess AProcess, Stream AOldKey, Stream ANewKey, Stream ANewData) { int LEntryNumber; using (SearchPath LSearchPath = new SearchPath()) { bool LResult = FindKey(AProcess, AOldKey, null, LSearchPath, out LEntryNumber); if (!LResult) { throw new IndexException(IndexException.Codes.KeyNotFound); } if (Compare(AProcess, AOldKey, null, ANewKey, null) == 0) { if (ANewData != null) { LSearchPath.DataNode.Update(ANewData, LEntryNumber); } } else { if (ANewData == null) { ANewData = new MemoryStream(DataLength); ANewData.SetLength(DataLength); CopyData(AProcess, LSearchPath.DataNode.Data(LEntryNumber), ANewData); } InternalDelete(AProcess, LSearchPath, LEntryNumber); LSearchPath.Dispose(); LResult = FindKey(AProcess, ANewKey, null, LSearchPath, out LEntryNumber); if (LResult) { throw new IndexException(IndexException.Codes.DuplicateKey); } InternalInsert(AProcess, LSearchPath, LEntryNumber, ANewKey, ANewData); } } }