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); } }
internal void Flush() { if (documents != null) { documents.Flush(); } if (documentsById != null) { documentsById.Flush(); } if (documentsByEtag != null) { documentsByEtag.Flush(); } if (documentsInTx != null) { documentsInTx.Flush(); } if (attachments != null) { attachments.Flush(); } if (tasks != null) { tasks.Flush(); } if (transactions != null) { transactions.Flush(); } if (identity != null) { identity.Flush(); } if (indexes != null) { indexes.Flush(); } if (queues != null) { queues.Flush(); } if (tasksByIndex != null) { tasksByIndex.Flush(); } if (mappedResultsByDocumentId != null) { mappedResultsByDocumentId.Flush(); } if (mappedResultsByReduceKey != null) { mappedResultsByReduceKey.Flush(); } }