示例#1
0
        protected void AddInvertedIndexPosting(WriteBatch batch, int propertyId, int termId, int docId)
        {
            using var posting1 = RocksDbEncoder.EncodeInvertedIndexPostingWithProperty(termId, propertyId, docId, out var span1);
            using var posting2 = RocksDbEncoder.EncodeInvertedIndexPosting(termId, docId, out var span2);

            batch.Put(span1, ReadOnlySpan <byte> .Empty);
            IncrementCounterValue(batch, Counter.TermFrequencyByTermAndProperty, span1.Slice(1, 8));

            batch.Put(span2, ReadOnlySpan <byte> .Empty);
            //Todo: Slow
            if (Database.Get(span2) == null)
            {
                IncrementCounterValue(batch, Counter.TermFrequencyByTerm, span2.Slice(1, 4));
            }
        }
示例#2
0
        public bool Advance(int target)
        {
            if (!PropertyId.HasValue)
            {
                using var _ = RocksDbEncoder.EncodeInvertedIndexPosting(TermId, target, out var prefix);
                RocksDbIterator.Seek(prefix.ToArray());
            }
            else
            {
                using var _ = RocksDbEncoder.EncodeInvertedIndexPostingWithProperty(TermId, PropertyId.Value, target, out var prefix);
                RocksDbIterator.Seek(prefix.ToArray());
            }

            Positioned = true;
            UpdateIteratorState();
            return(RocksIteratorValid);
        }