public void Flush() { tree.Flush(); RootPosition = writer.Position; binaryWriter.Write7BitEncodedInt64(currentId); binaryWriter.Write7BitEncodedInt64(tree.RootPosition); }
public void Flush() { foreach (var queue in queuesInMem) { queue.Value.Flush(); queues.Add(queue.Key, queue.Value.RootPosition); } queues.Flush(); }
public void CanAddToTreeAndReadFromAnother() { var buffer = new byte[1024]; var tree = new Tree(new MemoryStream(buffer), new MemoryStream(buffer), StartMode.Create); tree.Add("ayende", 45); tree.Flush(); tree = new Tree(new MemoryStream(buffer) { Position = tree.RootPosition }, new MemoryStream(buffer), StartMode.Open); var doc = tree.FindValue("ayende"); Assert.Equal(45, doc); }
public void Flush() { foreach (var queue in bagsInMem) { queue.Value.Flush(); if (queue.Value.CurrentPosition == null) { bags.Remove(queue.Key); } else { bags.Add(queue.Key, queue.Value.CurrentPosition.Value); } } bags.Flush(); }
private void CreateFromScratch() { binaryWriter.Write(HeaderSignature); binaryWriter.Write7BitEncodedInt(Version); binaryWriter.Write(Guid.NewGuid().ToByteArray()); using (var reader = OpenReader()) { var docs = new Tree(reader, writer, StartMode.Create); var docsInTx = new Tree(reader, writer, StartMode.Create); var docById = new Tree(reader, writer, StartMode.Create); var docByEtag = new Tree(reader, writer, StartMode.Create); var tx = new Tree(reader, writer, StartMode.Create); var attachments = new Tree(reader, writer, StartMode.Create); var tasks = new Queue(reader, writer, StartMode.Create); var tasksByIndex = new Tree(reader, writer, StartMode.Create); var identity = new Tree(reader, writer, StartMode.Create); var indexes = new Tree(reader, writer, StartMode.Create); var queues = new TreeOfQueues(reader, writer, StartMode.Create); var mapResultsByDocId = new TreeOfBags(reader, writer, StartMode.Create); var mapResultsByReduceKey = new TreeOfBags(reader, writer, StartMode.Create); docs.Flush(); docsInTx.Flush(); docById.Flush(); docByEtag.Flush(); tx.Flush(); attachments.Flush(); tasks.Flush(); tasksByIndex.Flush(); identity.Flush(); indexes.Flush(); queues.Flush(); mapResultsByDocId.Flush(); mapResultsByReduceKey.Flush(); WriteTransaction(new StorageTransaction { AttachmentPosition = attachments.RootPosition, AttachmentsCount = 0, DocumentsPosition = docs.RootPosition, DocumentsCount = 0, DocumentsInTransactionPosition = docsInTx.RootPosition, DocumentsByIdPosition = docById.RootPosition, DocumentsByEtagPosition = docByEtag.RootPosition, TasksPosition = tasks.RootPosition, TasksCount = 0, TransactionPosition = tx.RootPosition, IdentityPosition = identity.RootPosition, IndexesPosition = indexes.RootPosition, QueuesPosition = queues.RootPosition, TasksByIndexPosition = tasksByIndex.RootPosition, MappedResultsByDocumentIdPosition = mapResultsByDocId.RootPosition, MappedResultsByReduceKeyPosition = mapResultsByReduceKey.RootPosition }); writer.Flush(true); } }
public void CanRemoveFromTreeAndReadFromAnother() { var buffer = new byte[1024]; var tree = new Tree(new MemoryStream(buffer), new MemoryStream(buffer), StartMode.Create); tree.Add("ayende", 13); tree.Add("oren", 978); tree.Remove("ayende"); tree.Flush(); tree = new Tree(new MemoryStream(buffer) { Position = tree.RootPosition }, new MemoryStream(buffer), StartMode.Open); Assert.Null(tree.FindValue("ayende")); var doc = tree.FindValue("oren"); Assert.Equal(978, doc); }