public void Collect(Dictionary <WrappedByteArray, WrappedByteArray> collect) { ISnapshot next = GetRoot().GetNext(); while (next != null) { foreach (var data in ((Snapshot)next).DB) { collect.Put(WrappedByteArray.Of(data.Key.Data), WrappedByteArray.Of(data.Value.Data)); } next = next.GetNext(); } }
private static void RefreshOne(object state) { RefreshData data = (RefreshData)state; int flush_count = data.FlushCount; RevokingDBWithCaching db = data.DB; if (Snapshot.IsRoot(db.GetHead())) { return; } List <ISnapshot> snapshots = new List <ISnapshot>(); SnapshotRoot root = (SnapshotRoot)db.GetHead().GetRoot(); ISnapshot next = root; for (int i = 0; i < flush_count; ++i) { next = next.GetNext(); snapshots.Add(next); } root.Merge(snapshots, data.DB.DBName); root.ResetSolidity(); if (db.GetHead() == next) { db.SetHead(root); } else { next.GetNext().SetPrevious(root); root.SetNext(next.GetNext()); } }
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 }); }