示例#1
0
        void IterateSet(ulong dictId, IFieldHandler keyHandler)
        {
            if (_visitor != null && !_visitor.StartSet())
            {
                return;
            }
            var o      = ObjectDB.AllDictionariesPrefix.Length;
            var prefix = new byte[o + PackUnpack.LengthVUInt(dictId)];

            Array.Copy(ObjectDB.AllDictionariesPrefix, prefix, o);
            PackUnpack.PackVUInt(prefix, ref o, dictId);
            long prevProtectionCounter = 0;
            long pos = 0;

            while (true)
            {
                if (pos == 0)
                {
                    if (!_trkv.FindFirstKey(prefix))
                    {
                        break;
                    }
                }
                else
                {
                    if (_trkv.CursorMovedCounter != prevProtectionCounter)
                    {
                        if (!_trkv.SetKeyIndex(prefix, pos))
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (!_trkv.FindNextKey(prefix))
                        {
                            break;
                        }
                    }
                }
                _fastVisitor.MarkCurrentKeyAsUsed(_trkv);
                prevProtectionCounter = _trkv.CursorMovedCounter;
                if (_visitor == null || _visitor.StartSetKey())
                {
                    var keyReader = new SpanReader(_trkv.GetKey().Slice(prefix.Length));
                    IterateHandler(ref keyReader, keyHandler, false, null);
                    _visitor?.EndSetKey();
                }
                pos++;
            }
            _visitor?.EndSet();
        }