public List <byte[]> GetValuesNext(ISnapshot snapshot, byte[] key, long limit) { List <byte[]> result = new List <byte[]>(); if (limit <= 0) { return(result); } Dictionary <WrappedByteArray, WrappedByteArray> collection = new Dictionary <WrappedByteArray, WrappedByteArray>(new WrapperdByteArrayEqualComparer()); if (snapshot.GetPrevious() != null) { ((Snapshot)(snapshot)).Collect(collection); } Dictionary <byte[], byte[]> db_dictonary = new Dictionary <byte[], byte[]>((((Common.LevelDB)((SnapshotRoot)snapshot.GetRoot()).DB).DB.GetNext(key, limit))); foreach (KeyValuePair <WrappedByteArray, WrappedByteArray> pair in collection) { db_dictonary.Add(pair.Key.Data, pair.Value.Data); } return(db_dictonary .OrderBy(x => x.Key, new UnsignedByteArrayCompare()) .Where(y => ByteUtil.Compare(y.Key, key) >= 0) .Take((int)limit) .Select(z => z.Value) .ToList()); }
public Snapshot(ISnapshot snapshot) { this.root = snapshot.GetRoot(); this.previous = snapshot; snapshot.SetNext(this); lock (this) { this.db = new HashDB(); } }
private void CreateCheckPoint() { // Do not use compare Dictionary <byte[], byte[]> batch = new Dictionary <byte[], byte[]>(); foreach (RevokingDBWithCaching db in this.databases) { ISnapshot head = db.GetHead(); if (Snapshot.IsRoot(head)) { return; } string db_name = db.DBName; ISnapshot next = head.GetRoot(); for (int i = 0; i < this.flush_count; ++i) { next = next.GetNext(); Snapshot snapshot = (Snapshot)next; IBaseDB <Common.Key, Common.Value> key_value_db = snapshot.DB; foreach (KeyValuePair <Common.Key, Common.Value> pair in key_value_db) { byte[] name = SimpleEncode(db_name); byte[] key = new byte[name.Length + pair.Key.Data.Length]; Array.Copy(name, 0, key, 0, name.Length); Array.Copy(pair.Key.Data, 0, key, name.Length, pair.Key.Data.Length); batch.Add(key, pair.Value.Encode()); } } } // TODO : temp 계속 저장만 하는지 확인해야봐야함 CheckTempStore.Instance.DBSource.UpdateByBatch(batch, new WriteOptions() { Sync = Args.Instance.Storage.Sync }); }