public RemoteChunksSeries(long mapId, IKeyComparer <K> comparer, // mapId, current map version => map with chunk keys and versions Func <long, long, Task <SortedMap <long, SeriesChunk> > > remoteKeysLoader, // mapId, chunkKey => deserialied chunk Func <long, long, Task <SeriesChunk> > remoteLoader, // mapId, chunkKey, deserialied chunk => whole map version Func <SeriesChunk, Task <long> > remoteSaver, // TODO corresponding updates // mapId, chunkKey, direction => whole map version Func <long, long, long, Lookup, Task <long> > remoteRemover, long version, bool readOnly = false) { _mapId = mapId; _comparer = comparer; _remoteKeysLoader = remoteKeysLoader; _remoteLoader = remoteLoader; _remoteSaver = remoteSaver; _remoteRemover = remoteRemover; _readOnly = readOnly; var renewedKeys = _remoteKeysLoader(_mapId, 0).Result; var sm = renewedKeys.Map((k, ch) => new LazyValue(k, ch.Count, ch.Version, this)).ToSortedMap(); sm.IsSynchronized = true; _chunksCache = sm; var maxChunkVersion = _chunksCache.Values.Max(x => x.ChunkVersion); if (maxChunkVersion != version) { Trace.TraceWarning("Inconsistent series version in chunks and series definition."); } _chunksCache.Version = Math.Max(version, maxChunkVersion); }
public ProjectValuesWrapper(IOrderedMap <K, Vsrc> innerMap, Func <Vsrc, Vdest> srcToDest, Func <Vdest, Vsrc> destToSrc) { _innerMap = innerMap; _srcToDest = srcToDest; _destToSrc = destToSrc; }
public override bool Do(int seed, StochasticControls control) { IOrderedMap <int, float>[] collections = new IOrderedMap <int, float>[] { new ReferenceMap <int, float>(), // must be first new SplayTreeMap <int, float>(), new SplayTreeArrayMap <int, float>(), new AdaptListToMap <int, float>(new SplayTreeList <KeyValue <int, float> >()), new AdaptListToMap <int, float>(new SplayTreeArrayList <KeyValue <int, float> >()), new RedBlackTreeMap <int, float>(), new RedBlackTreeArrayMap <int, float>(), new AdaptListToMap <int, float>(new RedBlackTreeList <KeyValue <int, float> >()), new AdaptListToMap <int, float>(new RedBlackTreeArrayList <KeyValue <int, float> >()), new AVLTreeMap <int, float>(), new AVLTreeArrayMap <int, float>(), new AdaptListToMap <int, float>(new AVLTreeList <KeyValue <int, float> >()), new AdaptListToMap <int, float>(new AVLTreeArrayList <KeyValue <int, float> >()), }; Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >[] actions = new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >[] { new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(100, 100), ContainsKeyAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(200, 200), SetOrAddValueAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(200 - 50, 200 + 50), TryAddAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(300, 300), TryRemoveAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(100, 100), TryGetValueAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(100, 100), TrySetValueAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(200 - 50, 200 + 50), AddAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(300, 300), RemoveAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(100, 100), GetValueAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(100, 100), SetValueAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(50, 50), ConditionalAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(100, 100), LeastAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(100, 100), GreatestAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(100, 100), NearestLessOrEqualAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(100, 100), NearestLessAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(100, 100), NearestGreaterOrEqualAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(100, 100), NearestGreaterAction), new Tuple <Tuple <int, int>, InvokeAction <IOrderedMap <int, float> > >(new Tuple <int, int>(50, 50), EnumerateAction), }; return(StochasticDriver( "Map Stochastic Test", seed, control, collections, actions, delegate(IOrderedMap <int, float> _collection) { return _collection.Count; }, delegate(IOrderedMap <int, float>[] _collections) { Validate <int, float>(_collections); })); }
private static void LoadTree(IOrderedMap <int, int> tree, int count, int[] keys) { for (int i = 0; i < count; i++) { int key = keys[i]; tree.Add(key, key); } }
public override void UntimedPrepare() { if (preparation == null) { preparation = new Preparation(count); } tree = makeTree(count); }
private void EnumerateCore(IOrderedMap <int, float> map, int count, bool fast) { for (int i = 0; i < count; i++) { map.Add(i, i); } foreach (EntryMap <int, float> entry in fast ? map.GetFastEnumerable() : map.GetRobustEnumerable()) { } }
private static void UnloadTree(IOrderedMap <int, int> tree, int?count, int[] keys) { int i = 0; while ((count.HasValue && (i < count.Value)) || (!count.HasValue && (tree.Count != 0))) { int key = keys[i]; tree.NearestGreaterOrEqual(key, out key); tree.Remove(key); i++; } }
private void BasicMapCore(IOrderedMap <int, float> map, int count) { for (int j = 0; j < 2; j++) { for (int i = 0; i < count; i++) { map.Add(i, i); } for (int i = 0; i < count; i++) { map.Remove(i); } } }
private void ConditionalMapCore(IOrderedMap <int, float> map, int count) { for (int j = 0; j < 2; j++) { for (int i = 0; i < count; i++) { map.ConditionalSetOrAdd(i, _ConditionalSetOrAdd); } for (int i = 0; i < count; i++) { map.ConditionalSetOrRemove(i, _ConditionalSetOrRemove); } } }
public void CouldCompleteObserver(IOrderedMap <int, int> map) { var subscriber = new SumValuesObserver(); var series = map as Series <int, int>; var cursor = (series + series).GetCursor(); cursor.Source.Subscribe(subscriber); var expectedSum = 0; for (int i = 0; i < 10; i++) { map.Add(i, i); expectedSum += i; } Assert.IsFalse(subscriber.IsCompleted); map.Complete(); Thread.Sleep(100); Assert.IsTrue(subscriber.IsCompleted); Thread.Sleep(1000); Assert.AreEqual(expectedSum * 2, subscriber.Sum); }
public AllocTestMap(IOrderedMap <int, float> actual) { this.actual = actual; }
public ZonedSeries(IOrderedMap <DateTime, V> map, string originalTimeZone) { _map = map; _tz = originalTimeZone; }
/// <summary> /// Projects values from source to destination and back /// </summary> public static IPersistentOrderedMap <K, VDest> BiMap <K, VSrc, VDest>(this IOrderedMap <K, VSrc> innerMap, Func <VSrc, VDest> srcToDest, Func <VDest, VSrc> destToSrc) { return(new ProjectValuesWrapper <K, VSrc, VDest>(innerMap, srcToDest, destToSrc)); }
public override void Do(IOrderedMap <int, bool> tree, List <KeyValuePair <int, bool> > treeAnalog) { throw new NotImplementedException(); }
public override void Do(IOrderedMap <int, bool> tree) { throw new NotImplementedException(); }