public async Task ReadIntoAsync(FullTextIndex <TKey> index) { await this.FillBufferAsync().ConfigureAwait(false); var itemCount = this.reader.ReadInt32(); for (var i = 0; i < itemCount; i++) { var id = this.reader.ReadInt32(); var key = this.keySerializer.Read(this.reader); var fieldStatCount = this.reader.ReadInt32(); var fieldTokenCounts = ImmutableDictionary.CreateBuilder <byte, int>(); var totalTokenCount = 0; for (var fieldIndex = 0; fieldIndex < fieldStatCount; fieldIndex++) { var fieldId = this.reader.ReadByte(); var wordCount = this.reader.ReadInt32(); fieldTokenCounts.Add(fieldId, wordCount); totalTokenCount += wordCount; } index.IdPool.Add( id, key, new DocumentStatistics(fieldTokenCounts.ToImmutable(), totalTokenCount)); } index.SetRootWithLock(this.DeserializeNode(index.IndexNodeFactory, 0)); if (this.reader.ReadInt32() != -1) { throw new DeserializationException(ExceptionMessages.MissingIndexTerminator); } }
public async Task ReadIntoAsync(FullTextIndex <TKey> index) { await this.FillBufferAsync().ConfigureAwait(false); var itemCount = this.reader.ReadInt32(); for (var i = 0; i < itemCount; i++) { var id = this.reader.ReadInt32(); var key = this.keySerializer.Read(this.reader); index.IdPool.Add(id, key); } index.SetRootWithLock(this.DeserializeNode(index.IndexNodeFactory, 0)); if (this.reader.ReadInt32() != -1) { throw new DeserializationException(ExceptionMessages.MissingIndexTerminator); } }