Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
 private static Dictionary <string, List <WriteBatch.BatchOperation> > CreateOperations(WriteBatch batch)
 {
     return(batch.Trees.ToDictionary(tree => tree, tree => batch.GetSortedOperations(tree).ToList()));
 }
Exemplo n.º 3
0
        public IIterator Iterate(string treeName, WriteBatch writeBatch = null)
        {
            var tree = GetTree(treeName);

            return(tree.Iterate(writeBatch));
        }