Example #1
0
        public Dictionary <string, string> Find(ReadOptions options, Slice prefix)
        {
            var result = new Dictionary <string, string>();

            using (Iterator it = NewIterator(options))
            {
                for (it.Seek(prefix); it.Valid(); it.Next())
                {
                    Slice  key = it.Key();
                    byte[] x   = key.ToArray();
                    byte[] y   = prefix.ToArray();
                    if (x.Length < y.Length)
                    {
                        break;
                    }
                    if (!x.Take(y.Length).SequenceEqual(y))
                    {
                        break;
                    }
                    var v = it.Value();
                    var c = ((Slice)(v)).ToString();
                    result.Add(((Slice)key).ToString(), ((Slice)v).ToString());
                }
            }

            return(result);
        }
Example #2
0
 public static IEnumerable <T> Find <T>(this DB db, ReadOptions options, Slice prefix, Func <Slice, Slice, T> resultSelector)
 {
     using (Iterator it = db.NewIterator(options))
     {
         for (it.Seek(prefix); it.Valid(); it.Next())
         {
             Slice  key = it.Key();
             byte[] x   = key.ToArray();
             byte[] y   = prefix.ToArray();
             if (x.Length < y.Length)
             {
                 break;
             }
             if (!x.Take(y.Length).SequenceEqual(y))
             {
                 break;
             }
             yield return(resultSelector(key, it.Value()));
         }
     }
 }