public static void DoFreeContent(IReaderCtx ctx, ulong id, int cfgId) { var readerCtx = (DBReaderCtx)ctx; var tr = readerCtx.GetTransaction(); var dict = new ODBDictionary <TKey, TValue>(tr, ODBDictionaryConfiguration.Get(cfgId), id); dict.FreeContent(ctx, cfgId); }
// ReSharper disable once UnusedMember.Global public static void DoSave(IWriterCtx ctx, IDictionary <TKey, TValue>?dictionary, int cfgId) { var writerCtx = (IDBWriterCtx)ctx; if (!(dictionary is ODBDictionary <TKey, TValue> goodDict)) { var tr = writerCtx.GetTransaction(); var id = tr.AllocateDictionaryId(); goodDict = new ODBDictionary <TKey, TValue>(tr, (ODBDictionaryConfiguration)writerCtx.FindInstance(cfgId), id); if (dictionary != null) { foreach (var pair in dictionary) { goodDict.Add(pair.Key, pair.Value); } } } ctx.Writer().WriteVUInt64(goodDict._id); }
public KeysCollection(ODBDictionary <TKey, TValue> parent) { _parent = parent; }
public AdvancedEnumerator(ODBDictionary <TKey, TValue> owner, AdvancedEnumeratorParam <TKey> param) { _owner = owner; _keyValueTrProtector = _owner._keyValueTrProtector; _keyValueTr = _owner._keyValueTr; _ascending = param.Order == EnumerationOrder.Ascending; _keyValueTrProtector.Start(); _prevModificationCounter = _owner._modificationCounter; _prevProtectionCounter = _keyValueTrProtector.ProtectionCounter; _keyValueTr.SetKeyPrefix(_owner._prefix); long startIndex; long endIndex; if (param.EndProposition == KeyProposition.Ignored) { endIndex = _keyValueTr.GetKeyValueCount() - 1; } else { var keyBytes = _owner.KeyToByteArray(param.End); switch (_keyValueTr.Find(ByteBuffer.NewSync(keyBytes))) { case FindResult.Exact: endIndex = _keyValueTr.GetKeyIndex(); if (param.EndProposition == KeyProposition.Excluded) { endIndex--; } break; case FindResult.Previous: endIndex = _keyValueTr.GetKeyIndex(); break; case FindResult.Next: endIndex = _keyValueTr.GetKeyIndex() - 1; break; case FindResult.NotFound: endIndex = -1; break; default: throw new ArgumentOutOfRangeException(); } } if (param.StartProposition == KeyProposition.Ignored) { startIndex = 0; } else { var keyBytes = _owner.KeyToByteArray(param.Start); switch (_keyValueTr.Find(ByteBuffer.NewSync(keyBytes))) { case FindResult.Exact: startIndex = _keyValueTr.GetKeyIndex(); if (param.StartProposition == KeyProposition.Excluded) { startIndex++; } break; case FindResult.Previous: startIndex = _keyValueTr.GetKeyIndex() + 1; break; case FindResult.Next: startIndex = _keyValueTr.GetKeyIndex(); break; case FindResult.NotFound: startIndex = 0; break; default: throw new ArgumentOutOfRangeException(); } } _count = (uint)Math.Max(0, endIndex - startIndex + 1); _startPos = (uint)(_ascending ? startIndex : endIndex); _pos = 0; _seekState = SeekState.Undefined; }