public object Get(ulong oid) { WeakReference weakObj; if (_objCache.TryGetValue(oid, out weakObj)) { var o = weakObj.Target; if (o != null) { return(o); } } bool taken = false; try { _keyValueTrProtector.Start(ref taken); _keyValueTr.SetKeyPrefix(ObjectDB.AllObjectsPrefix); if (!_keyValueTr.FindExactKey(BuildKeyFromOid(oid))) { return(null); } TableInfo tableInfo; var reader = ReadObjStart(oid, out tableInfo); return(ReadObjFinish(oid, tableInfo, reader)); } finally { if (taken) { _keyValueTrProtector.Stop(); } } }
object GetDirectlyFromStorage(ulong oid) { _keyValueTrProtector.Start(); _keyValueTr.SetKeyPrefix(ObjectDB.AllObjectsPrefix); if (!_keyValueTr.FindExactKey(BuildKeyFromOid(oid))) { return(null); } TableInfo tableInfo; var reader = ReadObjStart(oid, out tableInfo); return(ReadObjFinish(oid, tableInfo, reader)); }
void MarkLastDictId() { _trkv.SetKeyPrefixUnsafe(null); if (_trkv.FindExactKey(ObjectDB.LastDictIdKey)) { _fastVisitor.MarkCurrentKeyAsUsed(_trkv); } }
public bool ContainsKey(TKey key) { var keyBytes = KeyToByteArray(key); _keyValueTrProtector.Start(); _keyValueTr.SetKeyPrefix(_prefix); return(_keyValueTr.FindExactKey(keyBytes)); }
public void IterateOid(ulong oid) { if (!SkipAlreadyVisitedOidChecks && !_visitedOids.Add(oid)) { return; } if (!_trkv.FindExactKey(Vuint2ByteBuffer(ObjectDB.AllObjectsPrefix, oid))) { return; // Object oid was deleted } _fastVisitor.MarkCurrentKeyAsUsed(_trkv); var reader = new SpanReader(_trkv.GetValue()); var tableId = reader.ReadVUInt32(); var version = reader.ReadVUInt32(); MarkTableIdVersionFieldInfo(tableId, version); if (_visitor != null && !_visitor.StartObject(oid, tableId, _tableId2Name.TryGetValue(tableId, out var tableName) ? tableName : null, version)) { return; } var tvi = GetTableVersionInfo(tableId, version); var knownInlineId = new HashSet <int>(); for (var i = 0; i < tvi.FieldCount; i++) { var fi = tvi[i]; if (_visitor == null || _visitor.StartField(fi.Name)) { IterateHandler(ref reader, fi.Handler !, false, knownInlineId); _visitor?.EndField(); } else { IterateHandler(ref reader, fi.Handler !, true, knownInlineId); } } _visitor?.EndObject(); }
public KeyValuePair <uint, uint> QuerySizeByKey(TKey key) { var keyBytes = KeyToByteArray(key); var found = _keyValueTr.FindExactKey(keyBytes); if (!found) { throw new ArgumentException("Key not found in Set"); } var size = _keyValueTr.GetStorageSizeOfCurrentKey(); return(size); }