public StructReadResult <T> ReadStruct <T>(string treeName, Slice key, StructureSchema <T> schema, WriteBatch writeBatch = null) { Tree tree = null; if (writeBatch != null && writeBatch.IsEmpty == false) { WriteBatch.InBatchValue result; if (writeBatch.TryGetValue(treeName, key, out result)) { if (!result.Version.HasValue) { tree = GetTree(treeName); } switch (result.OperationType) { case WriteBatch.BatchOperationType.AddStruct: return(new StructReadResult <T>(new StructureReader <T>((Structure <T>)result.Struct, schema), result.Version.HasValue ? (ushort)(result.Version.Value + 1) : tree.ReadVersion(key))); case WriteBatch.BatchOperationType.Delete: return(null); } } } if (tree == null) { tree = GetTree(treeName); } return(tree.ReadStruct(key, schema)); }
private static Dictionary <string, List <WriteBatch.BatchOperation> > CreateOperations(WriteBatch batch) { return(batch.Trees.ToDictionary(tree => tree, tree => batch.GetSortedOperations(tree).ToList())); }
public IIterator Iterate(string treeName, WriteBatch writeBatch = null) { var tree = GetTree(treeName); return(tree.Iterate(writeBatch)); }