예제 #1
0
        public override void Merge(ISnapshot snapshot)
        {
            Dictionary <WrappedByteArray, WrappedByteArray> batch = new Dictionary <WrappedByteArray, WrappedByteArray>(new WrapperdByteArrayEqualComparer());

            IEnumerator <KeyValuePair <byte[], byte[]> > datas = (IEnumerator <KeyValuePair <byte[], byte[]> >)((Snapshot)snapshot).GetEnumerator();

            while (datas.MoveNext())
            {
                batch.Put(WrappedByteArray.Of(datas.Current.Key), WrappedByteArray.Of(datas.Current.Value));
            }
            ((Flusher)this.db).Flush(batch);
        }
예제 #2
0
        public override IEnumerator <KeyValuePair <byte[], byte[]> > GetEnumerator()
        {
            Dictionary <WrappedByteArray, WrappedByteArray> all =
                new Dictionary <WrappedByteArray, WrappedByteArray>(new WrapperdByteArrayEqualComparer());

            Collect(all);
            all = all.Where(item => item.Value != null && item.Value.Data != null).ToDictionary(p => p.Key, p => p.Value);

            return(Enumerable.Concat(
                       Enumerable.Select(all, val => new KeyValuePair <byte[], byte[]>(val.Key.Data, val.Value.Data)),
                       Enumerable.Where(GetRoot(), val => !all.Keys.Contains(WrappedByteArray.Of(val.Key)))
                       ).GetEnumerator());
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        public void Merge(List <ISnapshot> snapshots, string db_name)
        {
            Dictionary <WrappedByteArray, WrappedByteArray> batch = new Dictionary <WrappedByteArray, WrappedByteArray>(new WrapperdByteArrayEqualComparer());

            foreach (ISnapshot snapshot in snapshots)
            {
                Snapshot from = (Snapshot)snapshot;
                IEnumerator <KeyValuePair <Key, Value> > it = from.DB.GetEnumerator();
                while (it.MoveNext())
                {
                    batch.Put(WrappedByteArray.Of(it.Current.Key.Data), WrappedByteArray.Of(it.Current.Value.Data));
                }
            }

            ((Flusher)this.db).Flush(batch);
        }