public KeyValuePair <TKey, TValue>[] Decode <TKey, TValue>([NotNull] KeySubspace subspace, [NotNull] IKeyEncoder <TKey> keyEncoder, [NotNull] IValueEncoder <TValue> valueEncoder)
        {
            if (subspace == null)
            {
                throw new ArgumentNullException(nameof(subspace));
            }
            if (keyEncoder == null)
            {
                throw new ArgumentNullException(nameof(keyEncoder));
            }
            if (valueEncoder == null)
            {
                throw new ArgumentNullException(nameof(valueEncoder));
            }

            var chunk   = this.Chunk;
            var results = new KeyValuePair <TKey, TValue> [chunk.Length];

            for (int i = 0; i < chunk.Length; i++)
            {
                results[i] = new KeyValuePair <TKey, TValue>(
                    keyEncoder.DecodeKey(subspace.ExtractKey(chunk[i].Key, boundCheck: true)),
                    valueEncoder.DecodeValue(chunk[i].Value)
                    );
            }

            return(results);
        }
 /// <summary>Return a key range that contains all the keys in a sub-partition of this subspace</summary>
 public static KeyRange ToRange(this KeySubspace subspace, Slice suffix)
 {
     if (suffix.IsNull)
     {
         throw Fdb.Errors.KeyCannotBeNull(nameof(suffix));
     }
     return(subspace.ToRange(suffix.Span));
 }
        public T[] DecodeKeys <T>([NotNull] KeySubspace subspace, [NotNull] IKeyEncoder <T> keyEncoder)
        {
            if (subspace == null)
            {
                throw new ArgumentNullException(nameof(subspace));
            }
            if (keyEncoder == null)
            {
                throw new ArgumentNullException(nameof(keyEncoder));
            }

            var results = new T[this.Count];

            for (int i = 0; i < results.Length; i++)
            {
                results[i] = keyEncoder.DecodeKey(subspace.ExtractKey(this.Chunk[i].Key, boundCheck: true));
            }
            return(results);
        }
        internal static FdbDirectoryLayer.DirectoryDescriptor MakePartition(FdbDirectoryLayer.DirectoryDescriptor descriptor)
        {
            var partition = new FdbDirectoryLayer.PartitionDescriptor(descriptor.Path, KeySubspace.CreateDynamic(descriptor.Prefix), descriptor.Partition);

            return(new FdbDirectoryLayer.DirectoryDescriptor(descriptor.DirectoryLayer, descriptor.Path, descriptor.Prefix, descriptor.Layer, partition, descriptor.ValidationChain));
        }