public TaskEnumeratorResult GetEnumerator(TaskEnumeratorPointer pointer) { if (this.enumerators == null) { this.enumerators = new HashVector(); } if (this.enumerators.ContainsKey(pointer)) { throw new InvalidTaskEnumeratorException("Enumerator already exists with specified Pointer."); } if (!IsValidPointer(pointer)) { throw new InvalidTaskEnumeratorException("Invalid Enumerator Pointer specified."); } IEnumerator it = this.output.GetEnumerator(); it.MoveNext(); lock (_mutex) { this.enumerators.Add(pointer, it); } return(NextRecord(pointer)); }
public string RegisterReader(string clientId, ReaderResultSet resultset) { string readerId = Guid.NewGuid().ToString(); HashVector recordsets = new HashVector(StringComparer.InvariantCultureIgnoreCase); resultset.ClientID = clientId; lock (_syncRoot) { if (!string.IsNullOrEmpty(clientId)) { if (!_readersList.ContainsKey(clientId)) { recordsets[readerId] = resultset; } else { recordsets = _readersList[clientId]; recordsets[readerId] = null; } _readersList[clientId] = recordsets; } _readers[readerId] = resultset; } return(readerId); }
/// <summary> /// handles case for 'OR' condition [Inverse == true] /// </summary> /// <param name="list"></param> /// <returns></returns> private ClusteredArrayList GetUnion(SortedList list) { HashVector finalTable = new HashVector(); if (list.Count > 0) { ClusteredArrayList finalKeys = list.GetByIndex(0) as ClusteredArrayList; for (int i = 0; i < finalKeys.Count; i++) { finalTable[finalKeys[i]] = null; } for (int i = 1; i < list.Count; i++) { ClusteredArrayList keys = list.GetByIndex(i) as ClusteredArrayList; if (keys != null && keys.Count > 0) { for (int j = 0; j < keys.Count; j++) { finalTable[keys[j]] = null; } } } } return(new ClusteredArrayList(finalTable.Keys)); }
void ICompactSerializable.Deserialize(CompactReader reader) { lock (this) { Value = reader.ReadObject(); _bitset = new BitSet(reader.ReadByte()); _evh = EvictionHint.ReadEvcHint(reader); _exh = ExpirationHint.ReadExpHint(reader); _grpInfo = GroupInfo.ReadGrpInfo(reader); _syncDependency = reader.ReadObject() as CacheSyncDependency; _queryInfo = (Hashtable)reader.ReadObject(); _keysDependingOnMe = (HashVector)reader.ReadObject(); _size = reader.ReadInt64(); lockMetaInfo = reader.ReadObject() as LockMetaInfo; _version = reader.ReadUInt64(); _creationTime = reader.ReadDateTime(); _lastModifiedTime = reader.ReadDateTime(); ResyncProviderName = reader.ReadObject() as string; _priorityValue = (CacheItemPriority)reader.ReadInt32(); ProviderName = reader.ReadObject() as string; _type = reader.ReadObject() as string; _itemUpdateListener = reader.ReadObject() as ArrayList; _itemRemovedListener = reader.ReadObject() as ArrayList; } }
public void DisposeReader(string readerId) { lock (_syncRoot) { if (_readers.ContainsKey(readerId)) { int count = _readers.Count; ReaderResultSet resultset = _readers[readerId]; _readers.Remove(readerId); if (resultset != null) { if (_readersList.Count > 0 && resultset.ClientID != null) { if (_readersList.ContainsKey(resultset.ClientID)) { HashVector clientReaders = _readersList[resultset.ClientID]; if (clientReaders != null) { clientReaders.Remove(readerId); } } } } } } }
public void Merge(IQueryResult other, CollectionOperation mergeType) { HashedQueryResult hashedResult = other as HashedQueryResult; if (hashedResult == null) { throw new Exception("Failed to merge query results. Type mismatch"); } switch (mergeType) { case CollectionOperation.Union: if (this._resultKeys.Count < hashedResult._resultKeys.Count) { HashVector temp = this._resultKeys; this._resultKeys = hashedResult._resultKeys; hashedResult._resultKeys = temp; } break; case CollectionOperation.Intersection: break; case CollectionOperation.Subtract: break; } this.Add(hashedResult._resultKeys, mergeType); this.Mark(mergeType); }
public IList <MessageInfo> GetNeverAcknowledgedMessages(TimeSpan timeAfterAssignment) { IList <MessageInfo> unacknowledgedMessages = new List <MessageInfo>(); HashVector durableSubscriptions = new HashVector(StringComparer.InvariantCultureIgnoreCase); lock (_mutex) { foreach (ClientSubscriptionManager client in _subscribers.Values) { IList <Message> unacknowledgedMessageList = null; unacknowledgedMessageList = client.GetNeverAcknowledgedMessages(timeAfterAssignment); if (unacknowledgedMessageList != null) { foreach (Message message in unacknowledgedMessageList) { if (!durableSubscriptions.ContainsKey(message.MessageId)) { unacknowledgedMessages.Add(GetMessageInfo(message)); durableSubscriptions.Add(message.MessageId, null); } } } } } return(unacknowledgedMessages); }
public static HashVector DeepClone(this HashVector hashVector) { if (hashVector == null) { return(null); } if (hashVector.Count == 0) { return(new HashVector()); } var clonedHashVector = new HashVector(hashVector.Count); foreach (DictionaryEntry entry in hashVector) { if (entry.Value is HashVector innerHashVector) { clonedHashVector[entry.Key] = innerHashVector.DeepClone(); } else if (entry.Value is ICloneable cloneable) { clonedHashVector[entry.Key] = cloneable.Clone(); } else { clonedHashVector[entry.Key] = entry.Value; } } return(clonedHashVector); }
private void GetCombinedKeysFromEveryType(string tag, HashVector finalResult) { if (_indexMap == null) { return; } IDictionaryEnumerator typeEnumerator; lock (_indexMap.SyncRoot) { typeEnumerator = _indexMap.GetEnumerator(); } while (typeEnumerator.MoveNext()) { AttributeIndex index = typeEnumerator.Value as AttributeIndex; IIndexStore store = index.GetStore("$Tag$"); if (store != null) { IKeyFilter keyFilter = _cache != null?_cache.GetBucketFilter() : null; IKeyFilter compoundFilter = _cache != null?_cache.GetCompoundFilter() : null; IQueryResult result = new ListQueryResult(keyFilter, compoundFilter); store.GetData(tag.ToLower(), ComparisonType.EQUALS, result, CollectionOperation.Union); foreach (string key in result) { finalResult[key] = null; } } } }
public void DisposeReader(string readerId) { lock (_syncRoot) { if (_readers.ContainsKey(readerId)) { int count = _readers.Count; ReaderResultSet resultset = _readers[readerId]; _readers.Remove(readerId); if (resultset != null) { if (_readersList.Count > 0 && resultset.ClientID != null) { if (_readersList.ContainsKey(resultset.ClientID)) { HashVector clientReaders = _readersList[resultset.ClientID]; if (clientReaders != null) { clientReaders.Remove(readerId); } } } } if (_context != null && _context.PerfStatsColl != null) { _context.PerfStatsColl.DecrementRunningReaders(); } } } }
public string RegisterReader(string clientId, ReaderResultSet resultset) { string readerId = Guid.NewGuid().ToString(); HashVector recordsets = new HashVector(StringComparer.InvariantCultureIgnoreCase); resultset.ClientID = clientId; resultset.LastAccessTime = DateTime.Now; lock (_syncRoot) { if (!string.IsNullOrEmpty(clientId)) { if (!_readersList.ContainsKey(clientId)) { recordsets[readerId] = resultset; } else { recordsets = _readersList[clientId]; recordsets[readerId] = null; } _readersList[clientId] = recordsets; } if (!_readers.ContainsKey(readerId) && _context != null && _context.PerfStatsColl != null) { _context.PerfStatsColl.IncrementRunningReaders(); } _readers[readerId] = resultset; } return(readerId); }
//public ArrayList PayLoad //{ // get { return _payLoad; } //} //public ArrayList PayLoadCompilationInfo //{ // get { return _payLoadCompilationInformation; } //} #region ICompactSerializable Members void Runtime.Serialization.ICompactSerializable.Deserialize(Runtime.Serialization.IO.CompactReader reader) { data = (HashVector)reader.ReadObject(); transferCompleted = reader.ReadBoolean(); //_payLoadCompilationInformation = reader.ReadObject() as ArrayList; this.sendDataSize = reader.ReadInt64(); }
private void Initialize() { _indexTable = new HashVector(); IIndexStore store = new HashStore(); _indexTable[TAG_INDEX_KEY] = store; }
/// <summary> /// Populates the trees' right list with objects contained in the enumerator. /// </summary> /// <param name="e"></param> public void Populate(IDictionaryEnumerator e) { if (e != null) { if (_rightList == null) { _rightList = new ArrayList(); } if (e is RedBlackEnumerator) { while (e.MoveNext()) { HashVector tbl = e.Value as HashVector; //IDictionaryEnumerator en = tbl.GetEnumerator(); //while (en.MoveNext()) //{ // _rightList[en.Key] = null; //} _rightList.AddRange(tbl.Keys); } } else { while (e.MoveNext()) { //_rightList[e.Key] = null; _rightList.Add(e.Key); } } } }
public QueryIndexManager(IDictionary props, Topologies.Local.IndexedLocalCache cache, string cacheName) { _indexMap = new HashVector(); _cache = cache; _props = props; _cacheName = cacheName; }
void Runtime.Serialization.ICompactSerializable.Deserialize(Runtime.Serialization.IO.CompactReader reader) { data = (HashVector)reader.ReadObject(); transferCompleted = reader.ReadBoolean(); sendDataSize = reader.ReadInt64(); _dataType = (DataType)reader.ReadByte(); }
internal Header(long id) { _id = id; SliceMap = new HashVector <long, long>(); sliceCount = 0; _crc = 0; }
public ICollection GetByTag(string tag, CancellationToken token) { HashVector finalResult = new HashVector(); GetCombinedKeysFromEveryType(tag, finalResult, token); return(new ClusteredArrayList(finalResult.Keys)); }
private IEnumerator <KeyValuePair <AttributeValue, long> > GetValueEnumerator(AttributeValue value) { IDictionary <long, byte> outRowIds, rowIds; if (_tree.TryGetValue(value, out outRowIds)) { rowIds = new HashVector <long, byte>(outRowIds); } else { rowIds = new HashVector <long, byte>(); } IDictionary <IndexOp <long>, byte> ops; if (_transitionTree.TryGetValue(value, out ops)) { foreach (var indexOp in ops.Keys) { indexOp.MergeWith(rowIds); } } foreach (var rowId in rowIds) { yield return(new KeyValuePair <AttributeValue, long>(value, rowId.Key)); } }
public void Dispose() { _keyList = null; _chunkKeys = null; _currentValue = null; _dataWithValue = null; }
public void NodeLeft(Address node, DateTime leaveTime) { HashVector<string, ConnectedClient> deadClients = new HashVector<string, ConnectedClient>(); lock (_lock) { foreach (var connectedClient in _connectedClients) { if (connectedClient.Value.RemoveNode(node) == 0) { deadClients.Add(connectedClient.Key, connectedClient.Value); } } if (deadClients.Count > 0) { foreach (var deadClient in deadClients) { _connectedClients.Remove(deadClient.Key); foreach (var notificationSpecification in _specifications) { var task = new DeadClientNotificationTask(this, deadClient.Key, leaveTime, notificationSpecification.Value, deadClient.Value.Info); notificationSpecification.Value.AddNotificationSpecificationTask(deadClient.Key, task); s_scheduler.AddTask(task); } } } } }
public StateTxfrInfo(HashVector data, bool transferCompleted, long dataSize, Stream st) { this.data = data; this.transferCompleted = transferCompleted; this.sendDataSize = dataSize; this.stream = st; }
public virtual void Deserialize(CompactReader reader) { _className = reader.ReadObject() as string; _perfInst = reader.ReadObject() as string; _upTime = new DateTime(reader.ReadInt64()); _count = reader.ReadInt64(); _hiCount = reader.ReadInt64(); _maxSize = reader.ReadInt64(); _maxCount = reader.ReadInt64(); _hitCount = reader.ReadInt64(); _missCount = reader.ReadInt64(); _localBuckets = new HashVector(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { BucketStatistics tmp = new BucketStatistics(); int bucketId = reader.ReadInt32(); tmp.DeserializeLocal(reader); _localBuckets[bucketId] = tmp; } }
public void Register(ContinuousQuery query, string clientId, string clientUniqueId, bool notifyAdd, bool notifyUpdate, bool notifyRemove, QueryDataFilters datafilters) { lock (this) { if (!Exists(query)) { registeredQueries.Add(query); HashVector refs = new HashVector(); ClusteredList <string> clientUniqueIds = new ClusteredList <string>(); clientUniqueIds.Add(clientUniqueId); refs[clientId] = clientUniqueIds; clientRefs[query.UniqueId] = refs; RegisterNotifications(notifyAdd, clientId, query.UniqueId, clientUniqueId, addNotifications, datafilters.AddDataFilter, maxAddDFAgainstCID, addDFAgainstCUniqueID); RegisterNotifications(notifyUpdate, clientId, query.UniqueId, clientUniqueId, updateNotifications, datafilters.UpdateDataFilter, maxUpdateDFAgainstCID, updateDFAgainstCUniqueID); RegisterNotifications(notifyRemove, clientId, query.UniqueId, clientUniqueId, removeNotifications, datafilters.RemoveDataFilter, maxRemoveDFAgainstCID, removeDFAgainstCUniqueID); } else { Update(query, clientId, clientUniqueId, notifyAdd, notifyUpdate, notifyRemove, datafilters); } } }
internal void DeadClients(ArrayList clients) { if (clients == null) { return; } lock (_syncRoot) { foreach (string client in clients) { HashVector readers = new HashVector(); if (_readersList.ContainsKey(client)) { readers = _readersList[client]; HashVector tempReaders = new HashVector(readers); IDictionaryEnumerator enu = tempReaders.GetEnumerator(); while (enu.MoveNext()) { if (_readers.ContainsKey(enu.Key.ToString())) { readers.Remove(enu.Key.ToString()); } _readersList.Remove(client); } } } } }
public void Update(ContinuousQuery query, string clientId, string clientUniqueId, bool notifyAdd, bool notifyUpdate, bool notifyRemove, QueryDataFilters datafilters) { lock (this) { if (clientRefs.ContainsKey(query.UniqueId)) { HashVector cRefs = (HashVector)clientRefs[query.UniqueId]; if (cRefs.ContainsKey(clientId)) { ClusteredList <string> refs = (ClusteredList <string>)cRefs[clientId]; if (!refs.Contains(clientUniqueId)) { refs.Add(clientUniqueId); } } else { ClusteredList <string> clientUniqueIds = new ClusteredList <string>(); clientUniqueIds.Add(clientUniqueId); cRefs[clientId] = clientUniqueIds; } UpdateNotifications(notifyAdd, clientId, query.UniqueId, clientUniqueId, addNotifications, datafilters.AddDataFilter, maxAddDFAgainstCID, addDFAgainstCUniqueID); UpdateNotifications(notifyUpdate, clientId, query.UniqueId, clientUniqueId, updateNotifications, datafilters.UpdateDataFilter, maxUpdateDFAgainstCID, updateDFAgainstCUniqueID); UpdateNotifications(notifyRemove, clientId, query.UniqueId, clientUniqueId, removeNotifications, datafilters.RemoveDataFilter, maxRemoveDFAgainstCID, removeDFAgainstCUniqueID); } } }
public void Populate(IDictionaryEnumerator e) { if (e != null) { if (e is RedBlackEnumerator) { while (e.MoveNext()) { HashVector tbl = e.Value as HashVector; this.Add(tbl, CollectionOperation.Union); this.Mark(CollectionOperation.Union); } } else { while (e.MoveNext()) { if (!_resultKeys.ContainsKey(e.Key)) { _resultKeys.Add(e.Key, null); } } } } }
/// <summary> /// Populates the trees' right list with objects contained in the enumerator. /// </summary> /// <param name="e"></param> public void Populate(IDictionaryEnumerator e) { if (e != null) { if (_rightList == null) { _rightList = new ArrayList(); } if (e is RedBlackEnumerator) { while (e.MoveNext()) { HashVector tbl = e.Value as HashVector; _rightList.AddRange(tbl.Keys); } } else { while (e.MoveNext()) { _rightList.Add(e.Key); } } } }
/// <summary> /// Gets the data groups of the items. /// </summary> /// <param name="keys">Keys of the items</param> /// <returns>Hashtable containing key of the item as 'key' and GroupInfo as 'value'</returns> public override Hashtable GetGroupInfoBulk(object[] keys, OperationContext operationContext) { Hashtable infoTahle = new Hashtable(); HashVector entries = (HashVector)Get(keys, operationContext); CacheEntry currentEntry; GroupInfo info; if (entries != null) { IDictionaryEnumerator ide = entries.GetEnumerator(); while (ide.MoveNext()) { info = null; currentEntry = (CacheEntry)ide.Value; if (currentEntry != null) { info = currentEntry.GroupInfo; if (info == null) { info = new GroupInfo(null, null); } } infoTahle.Add(ide.Key, info); } } return(infoTahle); }
private void DecrementBucketStats(string key, int bucketId, long dataSize) { if (_stats.LocalBuckets != null && _stats.LocalBuckets.Contains(bucketId)) { ((BucketStatistics)_stats.LocalBuckets[bucketId]).Decrement(dataSize); } if (_keyList != null) { if (_keyList.Contains(bucketId)) { HashVector keys = (HashVector)_keyList[bucketId]; long oldSize = keys.BucketCount * MemoryUtil.NetHashtableOverHead; keys.Remove(key); long newSize = 0; if (keys.Count == 0) { _keyList.Remove(bucketId); } else { newSize = keys.BucketCount * MemoryUtil.NetHashtableOverHead; } _keyListSize += newSize - oldSize; if (_keyListSize < 0) { _keyListSize = 0; } } } }