public void ApplyLeave(EventBean[] eventsPerStream, object optionalGroupKeyPerRow, ExprEvaluatorContext exprEvaluatorContext) { // acquire table-level write lock ExprTableEvalLockUtil.ObtainLockUnless(_tableStateInstance.TableLevelRWLock.WriteLock, exprEvaluatorContext); var @event = _tableStateInstance.GetCreateRowIntoTable(null, exprEvaluatorContext); var row = ExprTableEvalStrategyUtil.GetRow(@event); var evaluateParams = new EvaluateParams(eventsPerStream, false, exprEvaluatorContext); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QAggregationUngroupedApplyEnterLeave(false, row.Methods.Length, row.States.Length); } for (var i = 0; i < _methodPairs.Length; i++) { var methodPair = _methodPairs[i]; var method = row.Methods[methodPair.TargetIndex]; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QAggNoAccessEnterLeave(false, i, method, methodPair.AggregationNode); } var columnResult = methodPair.Evaluator.Evaluate(evaluateParams); method.Leave(columnResult); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AAggNoAccessEnterLeave(false, i, method); } } for (var i = 0; i < _targetStates.Length; i++) { var state = row.States[_targetStates[i]]; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QAggAccessEnterLeave(false, i, state, _accessStateExpr[i]); } _agents[i].ApplyLeave(eventsPerStream, exprEvaluatorContext, state); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AAggAccessEnterLeave(false, i, state); } } _tableStateInstance.HandleRowUpdated(@event); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AAggregationUngroupedApplyEnterLeave(false); } }
public override EventBean[] ProcessInsert(EPPreparedExecuteIUDSingleStreamExecInsert insert) { ExprTableEvalLockUtil.ObtainLockUnless(_instance.TableLevelRWLock.WriteLock, insert.Services.TableService.TableExprEvaluatorContext); var theEvent = insert.InsertHelper.Process(new EventBean[0], true, true, insert.ExprEvaluatorContext); var aggs = _instance.TableMetadata.RowFactory.MakeAggs(insert.ExprEvaluatorContext.AgentInstanceId, null, null); ((object[])theEvent.Underlying)[0] = aggs; _instance.AddEvent(theEvent); return(CollectionUtil.EVENTBEANARRAY_EMPTY); }
public override ICollection <EventBean> SnapshotBestEffort(EPPreparedExecuteMethodQuery query, FilterSpecCompiled filter, Attribute[] annotations) { ExprTableEvalLockUtil.ObtainLockUnless(_instance.TableLevelRWLock.ReadLock, query.AgentInstanceContext); var events = SnapshotNullWhenNoIndex(filter, annotations, null, null); if (events != null) { return(events); } return(_instance.EventCollection); }
public ICollection <EventBean> Lookup(EventBean[] events, ExprEvaluatorContext context) { ExprTableEvalLockUtil.ObtainLockUnless(_lock, context); var result = _inner.Lookup(events, context); if (result == null) { return(Collections.GetEmptyList <EventBean>()); } return(result); }
public override EventBean[] ProcessDelete(EPPreparedExecuteIUDSingleStreamExecDelete delete) { ExprTableEvalLockUtil.ObtainLockUnless(_instance.TableLevelRWLock.WriteLock, delete.Services.TableService.TableExprEvaluatorContext); if (delete.OptionalWhereClause == null) { _instance.ClearEvents(); } var found = SnapshotAndApplyFilter(delete.Filter, delete.Annotations, delete.OptionalWhereClause, _instance.AgentInstanceContext); foreach (var @event in found) { _instance.DeleteEvent(@event); } return(CollectionUtil.EVENTBEANARRAY_EMPTY); }
private ICollection <EventBean> LookupInternal(ExprEvaluatorContext context) { ExprTableEvalLockUtil.ObtainLockUnless(_tableLevelLock, context); var it = _contents.GetEnumerator(); if (!it.MoveNext()) { return(null); } var result = new ArrayDeque <EventBean>(2); do { result.Add(it.Current); } while (it.MoveNext()); return(result); }
public override EventBean[] ProcessUpdate(EPPreparedExecuteIUDSingleStreamExecUpdate update) { ExprTableEvalLockUtil.ObtainLockUnless(_instance.TableLevelRWLock.WriteLock, update.Services.TableService.TableExprEvaluatorContext); var events = SnapshotAndApplyFilter(update.Filter, update.Annotations, update.OptionalWhereClause, _instance.AgentInstanceContext); if (events != null && events.IsEmpty()) { return(CollectionUtil.EVENTBEANARRAY_EMPTY); } var eventsPerStream = new EventBean[3]; if (events == null) { update.TableUpdateStrategy.UpdateTable(_instance.EventCollection, _instance, eventsPerStream, _instance.AgentInstanceContext); } else { update.TableUpdateStrategy.UpdateTable(events, _instance, eventsPerStream, _instance.AgentInstanceContext); } return(CollectionUtil.EVENTBEANARRAY_EMPTY); }
public object GetValue(int column, int agentInstanceId, EvaluateParams evaluateParams) { // acquire table-level write lock ExprTableEvalLockUtil.ObtainLockUnless(_tableStateInstance.TableLevelRWLock.WriteLock, evaluateParams.ExprEvaluatorContext); var @event = _tableStateInstance.EventUngrouped; if (@event == null) { return null; } var row = ExprTableEvalStrategyUtil.GetRow(@event); var aggregators = row.Methods; if (column < aggregators.Length) { return aggregators[column].Value; } else { var pair = _accessors[column - aggregators.Length]; return pair.Accessor.GetValue(row.States[pair.Slot], evaluateParams); } }
public void ClearResults(ExprEvaluatorContext exprEvaluatorContext) { // acquire table-level write lock ExprTableEvalLockUtil.ObtainLockUnless(_tableStateInstance.TableLevelRWLock.WriteLock, exprEvaluatorContext); var @event = _tableStateInstance.EventUngrouped; if (@event == null) { return; } var row = ExprTableEvalStrategyUtil.GetRow(@event); var aggregators = row.Methods; foreach (var state in row.States) { state.Clear(); } foreach (var aggregator in aggregators) { aggregator.Clear(); } }
private void Route(EventBean[] events, ExprEvaluatorContext exprEvaluatorContext) { foreach (var routed in events) { if (routed is NaturalEventBean) { var natural = (NaturalEventBean)routed; if (_audit) { AuditPath.AuditInsertInto(_agentInstanceContext.EngineURI, _agentInstanceContext.StatementName, natural.OptionalSynthetic); } if (_tableStateInstance != null) { _tableStateInstance.AddEventUnadorned(natural.OptionalSynthetic); } else { _parent.InternalEventRouter.Route(natural.OptionalSynthetic, _parent.EpStatementHandle, _agentInstanceContext.StatementContext.InternalEventEngineRouteDest, exprEvaluatorContext, _parent.IsAddToFront); } } else { if (_audit) { AuditPath.AuditInsertInto(_agentInstanceContext.EngineURI, _agentInstanceContext.StatementName, routed); } if (_tableStateInstance != null) { ExprTableEvalLockUtil.ObtainLockUnless(_tableStateInstance.TableLevelRWLock.WriteLock, exprEvaluatorContext); _tableStateInstance.AddEventUnadorned(routed); } else { _parent.InternalEventRouter.Route(routed, _parent.EpStatementHandle, _agentInstanceContext.StatementContext.InternalEventEngineRouteDest, exprEvaluatorContext, _parent.IsAddToFront); } } } }
public EventBean GetEventBean(int column, EventBean[] eventsPerStream, bool isNewData, ExprEvaluatorContext context) { // acquire table-level write lock ExprTableEvalLockUtil.ObtainLockUnless(_tableStateInstance.TableLevelRWLock.WriteLock, context); var @event = _tableStateInstance.EventReference.Get(); if (@event == null) { return(null); } var row = ExprTableEvalStrategyUtil.GetRow(@event); var aggregators = row.Methods; if (column < aggregators.Length) { return(null); } else { var pair = _accessors[column - aggregators.Length]; return(pair.Accessor.GetEnumerableEvent(row.States[pair.Slot], eventsPerStream, isNewData, context)); } }
public void ApplyLeave(EventBean[] eventsPerStream, object groupByKey, ExprEvaluatorContext exprEvaluatorContext) { // acquire table-level write lock ExprTableEvalLockUtil.ObtainLockUnless(TableStateInstance.TableLevelRWLock.WriteLock, exprEvaluatorContext); ApplyLeaveInternal(eventsPerStream, groupByKey, exprEvaluatorContext); }