ByteArrayReader ReadObjStart(ulong oid, out TableInfo tableInfo) { var reader = new ByteArrayReader(_keyValueTr.GetValueAsByteArray()); var tableId = reader.ReadVUInt32(); tableInfo = _owner.TablesInfo.FindById(tableId); if (tableInfo == null) { throw new BTDBException($"Unknown TypeId {tableId} of Oid {oid}"); } EnsureClientTypeNotNull(tableInfo); return(reader); }
void FreeContent(IReaderCtx readerCtx, int cfgId) { var config = (ODBDictionaryConfiguration)((IInstanceRegistry)readerCtx).FindInstance(cfgId); var ctx = (DBReaderWithFreeInfoCtx)readerCtx; if (config.FreeContent == null) { var method = ILBuilder.Instance .NewMethod <Action <IInternalObjectDBTransaction, AbstractBufferedReader, IList <ulong> > >( $"IDictFinder_Cfg_{cfgId}"); var ilGenerator = method.Generator; var readerLoc = ilGenerator.DeclareLocal(typeof(IReaderCtx)); ilGenerator .Ldarg(0) .Ldarg(1) .Ldarg(2) .Newobj(() => new DBReaderWithFreeInfoCtx(null, null, null)) .Stloc(readerLoc); Action <IILGen> readerOrCtx; if (_valueHandler.NeedsCtx()) { readerOrCtx = il => il.Ldloc(readerLoc); } else { readerOrCtx = il => il.Ldarg(1); } _valueHandler.FreeContent(ilGenerator, readerOrCtx); ilGenerator.Ret(); config.FreeContent = method.Create(); } var findIDictAction = (Action <IInternalObjectDBTransaction, AbstractBufferedReader, IList <ulong> >)config.FreeContent; long prevProtectionCounter = 0; long pos = 0; while (true) { _keyValueTrProtector.Start(); if (pos == 0) { _keyValueTr.SetKeyPrefix(_prefix); if (!_keyValueTr.FindFirstKey()) { break; } } else { if (_keyValueTrProtector.WasInterupted(prevProtectionCounter)) { _keyValueTr.SetKeyPrefix(_prefix); if (!_keyValueTr.SetKeyIndex(pos)) { break; } } else { if (!_keyValueTr.FindNextKey()) { break; } } } prevProtectionCounter = _keyValueTrProtector.ProtectionCounter; var valueBytes = _keyValueTr.GetValueAsByteArray(); var valueReader = new ByteArrayReader(valueBytes); findIDictAction(ctx.GetTransaction(), valueReader, ctx.DictIds); pos++; } }