public override void Remove( EventBean theEvent, ExprEvaluatorContext exprEvaluatorContext) { var key = GetIndexedValue(theEvent); if (key == null) { nullKeyedValues.Remove(theEvent); return; } key = Coerce(key); var events = propertyIndex.Get(key); if (events == null) { return; } if (!events.Remove(theEvent)) { // Not an error, its possible that an old-data event is artificial (such as for statistics) and // thus did not correspond to a new-data event raised earlier. return; } if (events.IsEmpty()) { propertyIndex.Remove(key); } }
public void Evaluate(ICollection<ScheduleHandle> handles) { lock (this) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QScheduleEval(_currentTime); } // Get the values on or before the current time - to get those that are exactly on the // current time we just add one to the current time for getting the head map var headMap = _timeHandleMap.Head(_currentTime + 1); if (headMap.IsEmpty()) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AScheduleEval(handles); } return; } // First determine all triggers to shoot IList<long> removeKeys = new List<long>(); foreach (var entry in headMap) { var key = entry.Key; var value = entry.Value; removeKeys.Add(key); foreach (var handle in value.Values) { handles.Add(handle); } } // Next remove all handles foreach (var entry in headMap) { foreach (var handle in entry.Value.Values) { _handleSetMap.Remove(handle); } } // Remove all triggered msec values foreach (var key in removeKeys) { _timeHandleMap.Remove(key); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AScheduleEval(handles); } } }
/// <summary> /// Binds a controls value to a property of an entity. /// </summary> /// <param name="control">The control to get the value from.</param> /// <param name="list">The <see cref="IOrderedDictionary"/> containing the values.</param> /// <param name="propertyName">The name of the property to bind the value to.</param> public static void BindControl(Control control, IOrderedDictionary list, String propertyName) { if (control != null) { if (list.Contains(propertyName)) { list.Remove(propertyName); } list.Add(propertyName, GetValue(control)); } }
public override void Remove(object filterConstant) { var range = (StringRange)filterConstant; if (range.Max == null || range.Min == null) { RangesNullEndpoints = null; } else { Ranges.Remove(range); } }
public void RemoveChild(string collectionKey) { if (_children == null) { return; } var child = GetChild(collectionKey); child.SetParent(null); child.onDestroy -= OnDestroy; _children.Remove(collectionKey); }
/// <summary> /// Resolves the aliases that could not be resolved when the node was created. /// </summary> /// <param name="state">The state of the document.</param> internal override void ResolveAliases(DocumentLoadingState state) { Dictionary <YamlNode, YamlNode>?keysToUpdate = null; Dictionary <YamlNode, YamlNode>?valuesToUpdate = null; foreach (var entry in children) { if (entry.Key is YamlAliasNode) { if (keysToUpdate == null) { keysToUpdate = new Dictionary <YamlNode, YamlNode>(); } // TODO: The representation model should be redesigned, because here the anchor could be null but that would be invalid YAML keysToUpdate.Add(entry.Key, state.GetNode(entry.Key.Anchor !, entry.Key.Start, entry.Key.End)); } if (entry.Value is YamlAliasNode) { if (valuesToUpdate == null) { valuesToUpdate = new Dictionary <YamlNode, YamlNode>(); } // TODO: The representation model should be redesigned, because here the anchor could be null but that would be invalid YAML valuesToUpdate.Add(entry.Key, state.GetNode(entry.Value.Anchor !, entry.Value.Start, entry.Value.End)); } } if (valuesToUpdate != null) { foreach (var entry in valuesToUpdate) { children[entry.Key] = entry.Value; } } if (keysToUpdate != null) { foreach (var entry in keysToUpdate) { YamlNode value = children[entry.Key]; children.Remove(entry.Key); children.Add(entry.Value, value); } } }
/// <summary> /// Resolves the aliases that could not be resolved when the node was created. /// </summary> /// <param name="state">The state of the document.</param> internal override void ResolveAliases(DocumentLoadingState state) { Dictionary <YamlNode, YamlNode> keysToUpdate = null; Dictionary <YamlNode, YamlNode> valuesToUpdate = null; foreach (var entry in children) { if (entry.Key is YamlAliasNode) { if (keysToUpdate == null) { keysToUpdate = new Dictionary <YamlNode, YamlNode>(); } keysToUpdate.Add(entry.Key, state.GetNode(entry.Key.Anchor, true, entry.Key.Start, entry.Key.End)); } if (entry.Value is YamlAliasNode) { if (valuesToUpdate == null) { valuesToUpdate = new Dictionary <YamlNode, YamlNode>(); } valuesToUpdate.Add(entry.Key, state.GetNode(entry.Value.Anchor, true, entry.Value.Start, entry.Value.End)); } } if (valuesToUpdate != null) { foreach (var entry in valuesToUpdate) { children[entry.Key] = entry.Value; } } if (keysToUpdate != null) { foreach (var entry in keysToUpdate) { YamlNode value = children[entry.Key]; children.Remove(entry.Key); children.Add(entry.Value, value); } } }
/// <summary> /// Remove call context which ended /// </summary> /// <remarks>This method does not decrement stack count, because it was decremented when a context was queued for removal</remarks> private void RemoveEndedCallContexts() { while (m_nodesToRemove.TryDequeue(out Guid guidToRemove)) { LinkedListNode <ConcurrentDictionary <string, object> > node; lock (m_nodesDictionary) { node = m_nodesDictionary[guidToRemove] as LinkedListNode <ConcurrentDictionary <string, object> >; m_nodesDictionary.Remove(guidToRemove); } if (node == m_dataStack.First) { m_data = node.Value; } if (node != null) { m_dataStack.Remove(node); } } }
/// <summary> /// Adds elements to the collection having the specified names and values. /// </summary> /// <param name="list">A collection of name/value pairs.</param> /// <param name="names">The property names.</param> /// <param name="values">The property values.</param> public static void SetValues(IOrderedDictionary list, String[] names, Object[] values) { for ( int i = 0; i < names.Length; i++ ) { if ( list.Contains(names[i]) ) { list.Remove(names[i]); } list.Add(names[i], values[i]); } }
protected virtual void ExtractRowValues (IOrderedDictionary fieldValues, GridViewRow row, bool includeReadOnlyFields, bool includePrimaryKey) { DataControlField field; foreach (TableCell cell in row.Cells) { DataControlFieldCell c = cell as DataControlFieldCell; if (c == null) continue; field = c.ContainingField; if (field != null && !field.Visible) continue; c.ContainingField.ExtractValuesFromCell (fieldValues, c, row.RowState, includeReadOnlyFields); } if (!includePrimaryKey && DataKeyNames != null) foreach (string key in DataKeyNames) fieldValues.Remove (key); }
protected virtual void ExtractRowValues (IOrderedDictionary fieldValues, bool includeReadOnlyFields, bool includePrimaryKey) { foreach (DetailsViewRow row in Rows) { if (row.Cells.Count < 1) continue; DataControlFieldCell c = row.Cells[row.Cells.Count-1] as DataControlFieldCell; if (c != null) c.ContainingField.ExtractValuesFromCell (fieldValues, c, row.RowState, includeReadOnlyFields); } if (!includePrimaryKey && DataKeyNames != null) foreach (string key in DataKeyNames) fieldValues.Remove (key); }
public override void Update( EventBean[] newData, EventBean[] oldData) { _agentInstanceContext.AuditProvider.View(newData, oldData, _agentInstanceContext, _rankWindowViewFactory); _agentInstanceContext.InstrumentationProvider.QViewProcessIRStream( _rankWindowViewFactory, newData, oldData); var removedEvents = new OneEventCollection(); // Remove old data if (oldData != null) { for (var i = 0; i < oldData.Length; i++) { var uniqueKey = GetUniqueKey(oldData[i]); var existingSortKey = _uniqueKeySortKeys.Get(uniqueKey); if (existingSortKey == null) { continue; } var @event = RemoveFromSortedEvents(existingSortKey, uniqueKey); if (@event != null) { _numberOfEvents--; _uniqueKeySortKeys.Remove(uniqueKey); removedEvents.Add(@event); InternalHandleRemovedKey(existingSortKey, oldData[i]); } } } // Add new data if (newData != null) { for (var i = 0; i < newData.Length; i++) { var uniqueKey = GetUniqueKey(newData[i]); var newSortKey = GetSortValues(newData[i]); var existingSortKey = _uniqueKeySortKeys.Get(uniqueKey); // not currently found: its a new entry if (existingSortKey == null) { CompareAndAddOrPassthru(newData[i], uniqueKey, newSortKey, removedEvents); } else { // same unique-key event found already, remove and add again // key did not change, perform in-place substitute of event if (existingSortKey.Equals(newSortKey)) { var replaced = InplaceReplaceSortedEvents(existingSortKey, uniqueKey, newData[i]); if (replaced != null) { removedEvents.Add(replaced); } InternalHandleReplacedKey(newSortKey, newData[i], replaced); } else { var removed = RemoveFromSortedEvents(existingSortKey, uniqueKey); if (removed != null) { _numberOfEvents--; removedEvents.Add(removed); InternalHandleRemovedKey(existingSortKey, removed); } CompareAndAddOrPassthru(newData[i], uniqueKey, newSortKey, removedEvents); } } } } // Remove data that sorts to the bottom of the window while (_numberOfEvents > _sortWindowSize) { var lastKey = _sortedEvents.Keys.Last(); var existing = _sortedEvents.Get(lastKey); if (existing is IList<EventBean> existingList) { while (_numberOfEvents > _sortWindowSize && !existingList.IsEmpty()) { var newestEvent = existingList.DeleteAt(0); var uniqueKey = GetUniqueKey(newestEvent); _uniqueKeySortKeys.Remove(uniqueKey); _numberOfEvents--; removedEvents.Add(newestEvent); InternalHandleRemovedKey(existing, newestEvent); } if (existingList.IsEmpty()) { _sortedEvents.Remove(lastKey); } } else { var lastSortedEvent = (EventBean) existing; var uniqueKey = GetUniqueKey(lastSortedEvent); _uniqueKeySortKeys.Remove(uniqueKey); _numberOfEvents--; removedEvents.Add(lastSortedEvent); _sortedEvents.Remove(lastKey); InternalHandleRemovedKey(lastKey, lastSortedEvent); } } // If there are child views, fireStatementStopped update method _optionalRankedRandomAccess?.Refresh(_sortedEvents, _numberOfEvents, _sortWindowSize); if (Child != null) { EventBean[] expiredArr = null; if (!removedEvents.IsEmpty()) { expiredArr = removedEvents.ToArray(); } _agentInstanceContext.InstrumentationProvider.QViewIndicate( _rankWindowViewFactory, newData, expiredArr); Child.Update(newData, expiredArr); _agentInstanceContext.InstrumentationProvider.AViewIndicate(); } _agentInstanceContext.InstrumentationProvider.AViewProcessIRStream(); }
public override void Remove(object filterConstant) { constantsMap.Remove(filterConstant); }
public override void Update( EventBean[] newData, EventBean[] oldData) { agentInstanceContext.AuditProvider.View(newData, oldData, agentInstanceContext, factory); agentInstanceContext.InstrumentationProvider.QViewProcessIRStream(factory, newData, oldData); OneEventCollection removedEvents = null; // Remove old data if (oldData != null) { for (var i = 0; i < oldData.Length; i++) { var oldDataItem = oldData[i]; var sortValues = GetSortValues(oldDataItem); var result = CollectionUtil.RemoveEventByKeyLazyListMap(sortValues, oldDataItem, sortedEvents); if (result) { eventCount--; if (removedEvents == null) { removedEvents = new OneEventCollection(); } removedEvents.Add(oldDataItem); InternalHandleRemoved(sortValues, oldDataItem); } } } // Add new data if (newData != null) { for (var i = 0; i < newData.Length; i++) { var newDataItem = newData[i]; var sortValues = GetSortValues(newDataItem); CollectionUtil.AddEventByKeyLazyListMapFront(sortValues, newDataItem, sortedEvents); eventCount++; InternalHandleAdd(sortValues, newDataItem); } } // Remove data that sorts to the bottom of the window if (eventCount > sortWindowSize) { var removeCount = eventCount - sortWindowSize; for (var i = 0; i < removeCount; i++) { // Remove the last element of the last key - sort order is key and then natural order of arrival var lastKey = sortedEvents.Keys.Last(); var lastEntry = sortedEvents.Get(lastKey); if (lastEntry is IList<EventBean>) { var events = (IList<EventBean>) lastEntry; var theEvent = events.DeleteAt(events.Count - 1); // remove oldest event, newest events are first in list eventCount--; if (events.IsEmpty()) { sortedEvents.Remove(lastKey); } if (removedEvents == null) { removedEvents = new OneEventCollection(); } removedEvents.Add(theEvent); InternalHandleRemoved(lastKey, theEvent); } else { var theEvent = (EventBean) lastEntry; eventCount--; sortedEvents.Remove(lastKey); if (removedEvents == null) { removedEvents = new OneEventCollection(); } removedEvents.Add(theEvent); InternalHandleRemoved(lastKey, theEvent); } } } // If there are child views, fireStatementStopped update method optionalSortedRandomAccess?.Refresh(sortedEvents, eventCount, sortWindowSize); if (child != null) { EventBean[] expiredArr = null; if (removedEvents != null) { expiredArr = removedEvents.ToArray(); } agentInstanceContext.InstrumentationProvider.QViewIndicate(factory, newData, expiredArr); child.Update(newData, expiredArr); agentInstanceContext.InstrumentationProvider.AViewIndicate(); } agentInstanceContext.InstrumentationProvider.AViewProcessIRStream(); }