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); }
private KeyComparer(IComparer <T> comparer) { if (comparer != null && !ReferenceEquals(comparer, Comparer <T> .Default)) { // if (IsBuiltInNumericType) { ThrowHelper.ThrowNotSupportedException("Custom IComparer<T> for built-in type is not supported. Create a wrapper struct that implements IComparable<T> and use KeyComparer<T>.Default for it."); } if (IsIComparable) { ThrowHelper.ThrowNotSupportedException("Custom IComparer<T> for a type T that implements IComparable<T> is not supported. Create a wrapper struct that implements a different IComparable<T> logic and use KeyComparer<T>.Default for it."); } if (comparer is IKeyComparer <T> kc) { _keyComparer = kc; } else { _keyComparer = new DummyKeyComparer <T>(comparer); } } else { _keyComparer = null; } }
public KeyDetails(KeyDetails key, IKeyComparer comparer) { Type = key.Type; BaseType = key.BaseType; Fields.AddRange(key.Fields); KeyComparer = comparer; }
public TValue GetOrAdd <TKey, TValue>( TKey key, Func <TKey, TValue> valueFactory, IKeyComparer <TKey> keyComparer = null) { return(CreateScoped <TKey, TValue>(keyComparer).GetOrAdd(key, valueFactory)); }
public IronLeveldbStub(IronLeveldbOptions options, ISeekable <InternalKey, InternalIByteArrayKeyValuePair> dataProvider, Action onDispose = null) { _dataProvider = dataProvider; _onDispose = onDispose; _comparer = options?.Comparer ?? LeveldbDefaultKeyComparer.Comparer; }
public ICache <TKey, TValue> CreateScoped <TKey, TValue>(IKeyComparer <TKey> keyComparer = null) { var cache = _cachesByType.GetOrAdd( typeof(ICache <TKey, TValue>), t => CreateNew <TKey, TValue>(keyComparer)); return((ICache <TKey, TValue>)cache); }
// Constructors. protected KeyedCollectionBase(IKeyComparer comparer, int capacity) { if(comparer == null) { throw new ArgumentNullException("comparer"); } this.comparer = comparer; this.values = new ArrayList(capacity); this.keys = new ArrayList(capacity); }
// Constructors. protected KeyedCollectionBase(IKeyComparer comparer, int capacity) { if (comparer == null) { throw new ArgumentNullException("comparer"); } this.comparer = comparer; this.values = new ArrayList(capacity); this.keys = new ArrayList(capacity); }
/// <summary> /// /// </summary> /// <param name="comparer"></param> internal KeyComparer(IComparer <T> comparer) { if (comparer != null) { _comparer = comparer; if (comparer is IKeyComparer <T> kc) { _keyComparer = kc; } } }
private KeyComparer(IComparer <T> comparer) { if (comparer != null && !ReferenceEquals(comparer, Comparer <T> .Default)) { _comparer = comparer; if (comparer is IKeyComparer <T> kc) { _keyComparer = kc; } } }
/// <summary> /// Get a new or default instance of KeyComparer. /// </summary> public static KeyComparer <T> Create(IKeyComparer <T> comparer) { if (comparer == null) { return(Default); } if (comparer is KeyComparer <T> kc) { return(kc); } return(new KeyComparer <T>(comparer)); }
public ArrayCache(IKeyComparer <TKey> keyComparer) { _capacity = DefaultCapacity; _length = 0; _keyComparer = keyComparer ?? default(DefaultComparer <TKey>); _values = new TValue[DefaultCapacity]; if (UseHashCodes) { _hashCodes = new int[DefaultCapacity]; _keyIndexes = new int[DefaultCapacity]; } else { _keys = new TKey[DefaultCapacity]; } }
/// <summary> /// Get a new or default instance of KeyComparer. /// </summary> public static KeyComparer <T> Create(IKeyComparer <T> comparer) { return(comparer == null ? Default : new KeyComparer <T>(comparer)); }
public InternalKeyComparer(IKeyComparer userComparer) { _userComparer = userComparer; }
public ICache <TKey, TValue> CreateNew <TKey, TValue>(IKeyComparer <TKey> keyComparer = null) => new ArrayCache <TKey, TValue>(keyComparer);
public KeyedCollection(IKeyComparer comparer) : base(comparer) { }
// Constructors. public KeyedCollection(IKeyComparer comparer, int capacity) : base(comparer, capacity) { }
protected KeyedCollectionBase(IKeyComparer comparer) : this(comparer, 16) {}
// Constructors. public KeyedCollection(IKeyComparer comparer, int capacity) : base(comparer, capacity) {}
public Dictionary(int capacity, IKeyComparer comparer) { // TODO }
protected KeyedCollectionBase(IKeyComparer comparer) : this(comparer, 16) { }
public Dictionary(IDictionary<K,V> dictionary, IKeyComparer comparer) { // TODO }
public KeyedCollection(IKeyComparer comparer) : base(comparer) {}
public Dictionary(IKeyComparer comparer) { // TODO }