Пример #1
0
        protected override IEnumerable <KeyValuePair <TKey, TValue> > FindInternal(byte[] key_prefix)
        {
            var iterator = snapshot.CreateKeyIterator(new byte[] { prefix }, key_prefix);

            for (; iterator.MoveNext();)
            {
            }
            var findder = snapshot.CreateKeyFinder(new byte[] { prefix }, key_prefix);

            findder.GetEnumerator();
            //return db.UseSnapShot().GetValueData(new byte[] { prefix }, key.ToArray(), (k, v) => new KeyValuePair<TKey, TValue>(k.ToArray().AsSerializable<TKey>(1), v.ToArray().AsSerializable<TValue>()));
            return(null);
        }
Пример #2
0
        public static IEnumerable <T> Find <T>(this DB db, LTISnapshot snapshot, Slice prefix, Func <Slice, Slice, T> resultSelector)
        {
            LTIKeyIterator it = snapshot.CreateKeyIterator(new byte[] { }, prefix.buffer);
            {
                while (it.MoveNext())
                {
                    byte[] key = it.Current;
                    byte[] y   = prefix.ToArray();
                    if (key.Length < y.Length)
                    {
                        break;
                    }
                    if (!key.Take(y.Length).SequenceEqual(y))
                    {
                        break;
                    }

                    byte[] value = snapshot.GetValue(new byte[] { }, key).value;

                    yield return(resultSelector(new Slice(key), new Slice(value)));
                }
            }
        }