示例#1
0
        // Filter and Select
        public Object[] TypableEvaluate(
            EventBean[] eventsPerStream,
            bool isNewData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            var events          = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            var subSelectResult = ExprSubselectRowNodeUtility.EvaluateFilterExpectSingleMatch(
                events, isNewData, matchingEvents, exprEvaluatorContext, parent);

            if (subSelectResult == null)
            {
                return(null);
            }

            events[0] = subSelectResult;
            var selectClauseEvaluator = parent.SelectClauseEvaluator;
            var results        = new Object[selectClauseEvaluator.Length];
            var evaluateParams = new EvaluateParams(events, isNewData, exprEvaluatorContext);

            for (var i = 0; i < results.Length; i++)
            {
                results[i] = selectClauseEvaluator[i].Evaluate(evaluateParams);
            }
            return(results);
        }
        public override ICollection<EventBean> EvaluateGetCollEvents(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection<EventBean> matchingEvents,
            ExprEvaluatorContext context,
            ExprSubselectRowNode parent)
        {
            AggregationService aggregationService =
                parent.SubselectAggregationService.GetContextPartitionAggregationService(context.AgentInstanceId);
            ICollection<object> groupKeys = aggregationService.GetGroupKeys(context);
            if (groupKeys.IsEmpty())
            {
                return null;
            }
            var events = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            var evaluateParams = new EvaluateParams(events, newData, context);
            var result = new ArrayDeque<EventBean>(groupKeys.Count);
            foreach (object groupKey in groupKeys)
            {
                aggregationService.SetCurrentAccess(groupKey, context.AgentInstanceId, null);

                var pass = _havingClause.Evaluate(evaluateParams);
                if (true.Equals(pass))
                {
                    IDictionary<string, object> row = parent.EvaluateRow(events, true, context);
                    EventBean @event = parent.SubselectMultirowType.EventAdapterService.AdapterForTypedMap(
                        row, parent.SubselectMultirowType.EventType);
                    result.Add(@event);
                }
            }
            return result;
        }
示例#3
0
        // No filter and with select clause
        public virtual object Evaluate(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            if (matchingEvents.Count > 1)
            {
                Log.Warn(parent.MultirowMessage);
                return(null);
            }

            EventBean[] events = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            events[0] = EventBeanUtility.GetNonemptyFirstEvent(matchingEvents);

            object result;

            if (parent.SelectClauseEvaluator.Length == 1)
            {
                result = parent.SelectClauseEvaluator[0].Evaluate(new EvaluateParams(events, true, exprEvaluatorContext));
            }
            else
            {
                // we are returning a Map here, not object-array, preferring the self-describing structure
                result = parent.EvaluateRow(events, true, exprEvaluatorContext);
            }
            return(result);
        }
        public static EventBean EvaluateFilterExpectSingleMatch(
            EventBean[] eventsZeroSubselect,
            bool newData,
            ICollection<EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            EventBean subSelectResult = null;
            foreach (EventBean subselectEvent in matchingEvents)
            {
                // Prepare filter expression event list
                eventsZeroSubselect[0] = subselectEvent;

                var pass = parent.FilterExpr.Evaluate(new EvaluateParams(eventsZeroSubselect, newData, exprEvaluatorContext));
                if ((pass != null) && (true.Equals(pass)))
                {
                    if (subSelectResult != null)
                    {
                        Log.Warn(parent.MultirowMessage);
                        return null;
                    }
                    subSelectResult = subselectEvent;
                }
            }

            return subSelectResult;
        }
示例#5
0
        // Filter and Select
        public ICollection <object> EvaluateGetCollScalar(
            EventBean[] eventsPerStream,
            bool isNewData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext context,
            ExprSubselectRowNode parent)
        {
            var result = new List <Object>();
            var selectClauseEvaluator = parent.SelectClauseEvaluator;
            var filterExpr            = parent.FilterExpr;
            var events          = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            var evaluateParamsA = new EvaluateParams(events, true, context);
            var evaluateParamsB = new EvaluateParams(events, isNewData, context);

            foreach (var subselectEvent in matchingEvents)
            {
                events[0] = subselectEvent;
                var pass = filterExpr.Evaluate(evaluateParamsA);
                if ((pass != null) && true.Equals(pass))
                {
                    result.Add(selectClauseEvaluator[0].Evaluate(evaluateParamsB));
                }
            }
            return(result);
        }
        // Filter and no-select
        public ICollection <EventBean> EvaluateGetCollEvents(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext context,
            ExprSubselectRowNode parent)
        {
            var events         = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            var evaluateParams = new EvaluateParams(events, true, context);

            ArrayDeque <EventBean> filtered = null;

            foreach (var subselectEvent in matchingEvents)
            {
                events[0] = subselectEvent;
                var pass = parent.FilterExpr.Evaluate(evaluateParams);
                if ((pass != null) && true.Equals(pass))
                {
                    if (filtered == null)
                    {
                        filtered = new ArrayDeque <EventBean>();
                    }
                    filtered.Add(subselectEvent);
                }
            }
            return(filtered);
        }
示例#7
0
        // No filter and with select clause
        public virtual object[][] TypableEvaluateMultirow(
            EventBean[] eventsPerStream,
            bool isNewData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            var rows           = new object[matchingEvents.Count][];
            var index          = -1;
            var events         = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            var evaluateParams = new EvaluateParams(events, isNewData, exprEvaluatorContext);

            foreach (EventBean matchingEvent in matchingEvents)
            {
                index++;
                events[0] = matchingEvent;
                var results = new object[parent.SelectClauseEvaluator.Length];
                for (int i = 0; i < results.Length; i++)
                {
                    results[i] = parent.SelectClauseEvaluator[i].Evaluate(evaluateParams);
                }
                rows[index] = results;
            }
            return(rows);
        }
示例#8
0
        public Object Evaluate(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            EventBean[] eventsZeroBased = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            var         pass            = parent.HavingExpr.Evaluate(new EvaluateParams(eventsZeroBased, newData, exprEvaluatorContext));

            if ((pass == null) || (false.Equals(pass)))
            {
                return(null);
            }

            Object result;

            if (parent.SelectClauseEvaluator.Length == 1)
            {
                result = parent.SelectClauseEvaluator[0].Evaluate(new EvaluateParams(eventsZeroBased, true, exprEvaluatorContext));
            }
            else
            {
                // we are returning a Map here, not object-array, preferring the self-describing structure
                result = parent.EvaluateRow(eventsZeroBased, true, exprEvaluatorContext);
            }

            return(result);
        }
        public override ICollection <EventBean> EvaluateGetCollEvents(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext context,
            ExprSubselectRowNode parent)
        {
            ICollection <object> groupKeys = parent.SubselectAggregationService.GetGroupKeys(context);

            if (groupKeys.IsEmpty())
            {
                return(null);
            }
            ICollection <EventBean> events = new ArrayDeque <EventBean>(groupKeys.Count);

            foreach (object groupKey in groupKeys)
            {
                parent.SubselectAggregationService.SetCurrentAccess(groupKey, context.AgentInstanceId, null);
                IDictionary <string, object> row = parent.EvaluateRow(null, true, context);
                EventBean @event = parent.subselectMultirowType.EventAdapterService.AdapterForTypedMap(
                    row, parent.subselectMultirowType.EventType);
                events.Add(@event);
            }
            return(events);
        }
示例#10
0
        // Filter and Select
        public Object Evaluate(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            var eventsZeroBased = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            var subSelectResult = ExprSubselectRowNodeUtility.EvaluateFilterExpectSingleMatch(
                eventsZeroBased, newData, matchingEvents, exprEvaluatorContext, parent);

            if (subSelectResult == null)
            {
                return(null);
            }

            eventsZeroBased[0] = subSelectResult;
            Object result;

            if (parent.SelectClauseEvaluator.Length == 1)
            {
                result = parent.SelectClauseEvaluator[0].Evaluate(new EvaluateParams(eventsZeroBased, true, exprEvaluatorContext));
            }
            else
            {
                // we are returning a Map here, not object-array, preferring the self-describing structure
                result = parent.EvaluateRow(eventsZeroBased, true, exprEvaluatorContext);
            }

            return(result);
        }
 // Filter and no-select
 public EventBean EvaluateGetEventBean(
     EventBean[] eventsPerStream,
     bool newData,
     ICollection <EventBean> matchingEvents,
     ExprEvaluatorContext context,
     ExprSubselectRowNode parent)
 {
     return(null);
 }
 public virtual EventBean EvaluateGetEventBean(
     EventBean[] eventsPerStream,
     bool newData,
     ICollection <EventBean> matchingEvents,
     ExprEvaluatorContext exprEvaluatorContext,
     ExprSubselectRowNode parent)
 {
     return(null); // this actually only applies to when there is a select-clause
 }
 // No filter and no select-clause: return matching events
 public virtual ICollection <EventBean> EvaluateGetCollEvents(
     EventBean[] eventsPerStream,
     bool newData,
     ICollection <EventBean> matchingEvents,
     ExprEvaluatorContext context,
     ExprSubselectRowNode parent)
 {
     return(matchingEvents);
 }
 // Filter and no-select
 public ICollection <object> EvaluateGetCollScalar(
     EventBean[] eventsPerStream,
     bool isNewData,
     ICollection <EventBean> matchingEvents,
     ExprEvaluatorContext context,
     ExprSubselectRowNode parent)
 {
     return(null);
 }
 // Filer and no-select
 public Object[][] TypableEvaluateMultirow(
     EventBean[] eventsPerStream,
     bool newData,
     ICollection <EventBean> matchingEvents,
     ExprEvaluatorContext exprEvaluatorContext,
     ExprSubselectRowNode parent)
 {
     return(null);
 }
示例#16
0
 // Filter and no-select
 public virtual object[] TypableEvaluate(
     EventBean[] eventsPerStream,
     bool isNewData,
     ICollection <EventBean> matchingEvents,
     ExprEvaluatorContext exprEvaluatorContext,
     ExprSubselectRowNode parent)
 {
     return(null);
 }
示例#17
0
        // No filter and with select clause
        public virtual EventBean EvaluateGetEventBean(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext context,
            ExprSubselectRowNode parent)
        {
            EventBean[] events = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            events[0] = EventBeanUtility.GetNonemptyFirstEvent(matchingEvents);
            var row = parent.EvaluateRow(events, true, context);

            return(parent.subselectMultirowType.EventAdapterService.AdapterForTypedMap(
                       row, parent.subselectMultirowType.EventType));
        }
示例#18
0
 // No filter and no select-clause: return underlying event
 public virtual Object Evaluate(
     EventBean[] eventsPerStream,
     bool newData,
     ICollection <EventBean> matchingEvents,
     ExprEvaluatorContext exprEvaluatorContext,
     ExprSubselectRowNode parent)
 {
     if (matchingEvents.Count > 1)
     {
         Log.Warn(parent.GetMultirowMessage());
         return(null);
     }
     return(EventBeanUtility.GetNonemptyFirstEventUnderlying(matchingEvents));
 }
示例#19
0
        // Filter and no-select
        public virtual object Evaluate(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            EventBean[] eventsZeroBased = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            EventBean   subSelectResult = ExprSubselectRowNodeUtility.EvaluateFilterExpectSingleMatch(eventsZeroBased, newData, matchingEvents, exprEvaluatorContext, parent);

            if (subSelectResult == null)
            {
                return(null);
            }
            return(subSelectResult.Underlying);
        }
示例#20
0
        public override object Evaluate(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            if (matchingEvents.Count > 1)
            {
                Log.Warn(parent.MultirowMessage);
                return(null);
            }
            EventBean @event = EventBeanUtility.GetNonemptyFirstEvent(matchingEvents);

            return(_tableMetadata.EventToPublic.ConvertToUnd(@event, eventsPerStream, newData, exprEvaluatorContext));
        }
        public override Object Evaluate(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection<EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            ICollection<Object> groupKeys = parent.SubselectAggregationService.GetGroupKeys(exprEvaluatorContext);
            if (groupKeys.IsEmpty() || groupKeys.Count > 1)
            {
                return null;
            }
            parent.SubselectAggregationService.SetCurrentAccess(
                groupKeys.First(), exprEvaluatorContext.AgentInstanceId, null);

            return base.Evaluate(eventsPerStream, newData, matchingEvents, exprEvaluatorContext, parent);
        }
        public override Object Evaluate(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            EventBean[] eventsZeroBased = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            EventBean   subSelectResult = ExprSubselectRowNodeUtility.EvaluateFilterExpectSingleMatch(
                eventsZeroBased, newData, matchingEvents, exprEvaluatorContext, parent);

            if (subSelectResult == null)
            {
                return(null);
            }
            return(_tableMetadata.EventToPublic.ConvertToUnd(
                       subSelectResult, new EvaluateParams(eventsPerStream, newData, exprEvaluatorContext)));
        }
示例#23
0
        public virtual ICollection <object> EvaluateGetCollScalar(
            EventBean[] eventsPerStream,
            bool isNewData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext context,
            ExprSubselectRowNode parent)
        {
            var result         = new List <object>();
            var events         = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            var evaluateParams = new EvaluateParams(events, isNewData, context);

            foreach (EventBean subselectEvent in matchingEvents)
            {
                events[0] = subselectEvent;
                result.Add(parent.SelectClauseEvaluator[0].Evaluate(evaluateParams));
            }
            return(result);
        }
示例#24
0
        // No filter and with select clause
        public virtual ICollection <EventBean> EvaluateGetCollEvents(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext context,
            ExprSubselectRowNode parent)
        {
            if (matchingEvents.Count == 0)
            {
                return(Collections.GetEmptyList <EventBean>());
            }

            // when selecting a single property in the select clause that provides a fragment
            if (parent.subselectMultirowType == null)
            {
                ICollection <EventBean> eventsX = new ArrayDeque <EventBean>(matchingEvents.Count);
                var eval = (ExprIdentNodeEvaluator)parent.SelectClauseEvaluator[0];
                EventPropertyGetter getter = eval.Getter;
                foreach (EventBean subselectEvent in matchingEvents)
                {
                    object fragment = getter.GetFragment(subselectEvent);
                    if (fragment == null)
                    {
                        continue;
                    }
                    eventsX.Add((EventBean)fragment);
                }
                return(eventsX);
            }

            // when selecting a combined output row that contains multiple fields
            ICollection <EventBean> events = new ArrayDeque <EventBean>(matchingEvents.Count);

            EventBean[] eventsPerStreamEval = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            foreach (EventBean subselectEvent in matchingEvents)
            {
                eventsPerStreamEval[0] = subselectEvent;
                var       row    = parent.EvaluateRow(eventsPerStreamEval, true, context);
                EventBean @event = parent.subselectMultirowType.EventAdapterService.AdapterForTypedMap(
                    row, parent.subselectMultirowType.EventType);
                events.Add(@event);
            }
            return(events);
        }
示例#25
0
        // No filter and with select clause

        // No filter and with select clause
        public virtual object[] TypableEvaluate(
            EventBean[] eventsPerStream,
            bool isNewData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            // take the first match only
            EventBean[] events = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            events[0] = EventBeanUtility.GetNonemptyFirstEvent(matchingEvents);
            var results        = new object[parent.SelectClauseEvaluator.Length];
            var evaluateParams = new EvaluateParams(events, isNewData, exprEvaluatorContext);

            for (int i = 0; i < results.Length; i++)
            {
                results[i] = parent.SelectClauseEvaluator[i].Evaluate(evaluateParams);
            }
            return(results);
        }
示例#26
0
        public Object[][] TypableEvaluateMultirow(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            var rows           = new Object[matchingEvents.Count][];
            var index          = -1;
            var events         = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            var evaluateParams = new EvaluateParams(events, newData, exprEvaluatorContext);

            foreach (var matchingEvent in matchingEvents)
            {
                events[0] = matchingEvent;

                var pass = parent.FilterExpr.Evaluate(evaluateParams);
                if ((pass != null) && true.Equals(pass))
                {
                    index++;
                    var selectClauseEvaluator = parent.SelectClauseEvaluator;
                    var results = new Object[selectClauseEvaluator.Length];
                    for (var i = 0; i < results.Length; i++)
                    {
                        results[i] = selectClauseEvaluator[i].Evaluate(evaluateParams);
                    }
                    rows[index] = results;
                }
            }
            if (index == rows.Length - 1)
            {
                return(rows);
            }
            if (index == -1)
            {
                return(new Object[0][]);
            }
            var access   = index + 1;
            var rowArray = new Object[access][];

            Array.Copy(rows, 0, rowArray, 0, rowArray.Length);
            return(rowArray);
        }
示例#27
0
        // Filter and Select
        public EventBean EvaluateGetEventBean(
            EventBean[] eventsPerStream,
            bool isNewData,
            ICollection <EventBean> matchingEvents,
            ExprEvaluatorContext context,
            ExprSubselectRowNode parent)
        {
            var events          = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            var subSelectResult = ExprSubselectRowNodeUtility.EvaluateFilterExpectSingleMatch(
                events, isNewData, matchingEvents, context, parent);

            if (subSelectResult == null)
            {
                return(null);
            }
            var row = parent.EvaluateRow(events, true, context);

            return(parent.SubselectMultirowType.EventAdapterService.AdapterForTypedMap(
                       row, parent.SubselectMultirowType.EventType));
        }
        public override Object Evaluate(
            EventBean[] eventsPerStream,
            bool newData,
            ICollection<EventBean> matchingEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            ExprSubselectRowNode parent)
        {
            var aggregationService = parent.SubselectAggregationService.GetContextPartitionAggregationService(
                    exprEvaluatorContext.AgentInstanceId);
            var groupKeys = aggregationService.GetGroupKeys(exprEvaluatorContext);
            if (groupKeys.IsEmpty())
            {
                return null;
            }

            var events = EventBeanUtility.AllocatePerStreamShift(eventsPerStream);
            bool haveResult = false;
            Object result = null;

            var evaluateParams = new EvaluateParams(events, newData, exprEvaluatorContext);
            foreach (object groupKey in groupKeys)
            {
                aggregationService.SetCurrentAccess(groupKey, exprEvaluatorContext.AgentInstanceId,null);

                var pass = _havingClause.Evaluate(evaluateParams);
                if (true.Equals(pass))
                {
                    if (haveResult)
                    {
                        return null;
                    }

                    result = base.Evaluate(eventsPerStream, newData, matchingEvents, exprEvaluatorContext, parent);
                    haveResult = true;
                }
            }

            return haveResult ? result : null;
        }