public static SimpleServerDB Open(Setting setting)
        {
            var logger  = new Logger();
            var systemC = PipelineSystem.CreatePipelineSystemV1(logger);
            var db      = new SimpleServerDB(setting);

            systemC.RegistModule("client", db);
            systemC.OpenNetwork(new PeerOption());
            systemC.Start();
            db.actor = systemC.GetPipeline(null, "this/client");
            return(db);
        }
Exemple #2
0
        public static IEnumerable <T> Find <T>(this SimpleServerDB db, byte[] prefix, Func <byte[], byte[], T> resultSelector)
        {
            var snapid = db.UseSnapshot();

            var itid = db.CreateIterator(snapid, prefix);
            {
                while (db.MoveToNext(itid))
                {
                    byte[] key = db.Current(itid);
                    byte[] y   = prefix;
                    if (key.Length < y.Length)
                    {
                        break;
                    }
                    //if (!key.Take(y.Length).SequenceEqual(y)) break;

                    byte[] value = db.Get(prefix, key);

                    yield return(resultSelector(value, value));
                }
            }
        }
Exemple #3
0
 public static IEnumerable <T> Find <T>(this SimpleServerDB db, byte[] beginKey) where T : class, ISerializable, new()
 {
     return(Find(db, beginKey, (k, v) => v.ToArray().AsSerializable <T>()));
 }