//for debugging purposes public Dictionary<string, string> Dump(SnapshotReader snapshot) { using (var iterator = snapshot.Iterate(TableName)) { if (!iterator.Seek(Slice.BeforeAllKeys)) return new Dictionary<string, string>(); var results = new Dictionary<string, string>(); do { bool isMultiTreeKey; using (var multiIterator = snapshot.MultiRead(TableName, iterator.CurrentKey)) { if (!multiIterator.Seek(Slice.BeforeAllKeys)) { isMultiTreeKey = false; } else { isMultiTreeKey = true; const string subtreeKeyPrefix = "[sub tree val: ]"; do { results.Add(subtreeKeyPrefix + iterator.CurrentKey + " " + results.Count , new StreamReader(multiIterator.CreateReaderForCurrent().AsStream()).ReadToEnd()); } while (multiIterator.MoveNext()); } } if(!isMultiTreeKey) results.Add(iterator.CurrentKey.ToString(), new StreamReader(iterator.CreateReaderForCurrent().AsStream()).ReadToEnd()); } while (iterator.MoveNext()); return results; } }
public virtual IIterator MultiRead(SnapshotReader snapshot, Slice key) { return snapshot.MultiRead(TableName, key); }
private void DeleteTermsForIndexEntry(SnapshotReader snapshot, ValueReader reader, long id, int fieldId) { var termBuffer = _bufferPool.Take(reader.Length); _usedBuffers.Add(termBuffer); reader.Read(termBuffer, 0, reader.Length); var termSlice = new Slice(termBuffer, (ushort) reader.Length); var tree = GetTreeName(fieldId); using (var termIt = snapshot.MultiRead(tree, termSlice)) { var currentFieldDocument = _bufferPool.Take(FullTextIndex.FieldDocumentSize); try { if (termIt.Seek(new Slice(currentFieldDocument)) == false) return; do { termIt.CurrentKey.CopyTo(currentFieldDocument); if (EndianBitConverter.Big.ToInt64(currentFieldDocument, 0) != id) break; var valueBuffer = _bufferPool.Take(termIt.CurrentKey.Size); _usedBuffers.Add(valueBuffer); termIt.CurrentKey.CopyTo(valueBuffer); _writeBatch.MultiDelete(termSlice, new Slice(valueBuffer), tree); } while (termIt.MoveNext()); } finally { _bufferPool.Return(currentFieldDocument); } } }