private EventBean GetSubstitute(EventBean[] eventsPerStream,
                                        ExprEvaluatorContext exprEvaluatorContext)
        {
            // Use constant if supplied
            int?index;

            if (_isConstantIndex)
            {
                index = _constantIndexNumber;
            }
            else
            {
                // evaluate first child, which returns the index
                Object indexResult = _indexNode.Evaluate(new EvaluateParams(eventsPerStream, true, exprEvaluatorContext));
                if (indexResult == null)
                {
                    return(null);
                }
                index = indexResult.AsInt();
            }

            // access based on index returned
            EventBean substituteEvent;

            if (_randomAccessGetter != null)
            {
                RandomAccessByIndex randomAccess = _randomAccessGetter.Accessor;
                if (!_isTail)
                {
                    substituteEvent = randomAccess.GetNewData(index.Value);
                }
                else
                {
                    substituteEvent = randomAccess.GetNewDataTail(index.Value);
                }
            }
            else
            {
                var evalEvent      = eventsPerStream[_streamNumber];
                var relativeAccess = _relativeAccessGetter.GetAccessor(evalEvent);
                if (relativeAccess == null)
                {
                    return(null);
                }
                if (!_isTail)
                {
                    substituteEvent = relativeAccess.GetRelativeToEvent(evalEvent, index.Value);
                }
                else
                {
                    substituteEvent = relativeAccess.GetRelativeToEnd(evalEvent, index.Value);
                }
            }
            return(substituteEvent);
        }
Ejemplo n.º 2
0
        private EventBean GetSubstitute(
            EventBean[] eventsPerStream,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            // Use constant if supplied
            int? index;
            if (isConstantIndex) {
                index = constantIndexNumber;
            }
            else {
                // evaluate first child, which returns the index
                object indexResult = indexNode.Evaluate(eventsPerStream, true, exprEvaluatorContext);
                if (indexResult == null) {
                    return null;
                }

                index = (indexResult).AsInt32();
            }

            // access based on index returned
            EventBean substituteEvent;
            if (randomAccessGetter != null) {
                RandomAccessByIndex randomAccess = randomAccessGetter.Accessor;
                if (!isTail) {
                    substituteEvent = randomAccess.GetNewData(index.Value);
                }
                else {
                    substituteEvent = randomAccess.GetNewDataTail(index.Value);
                }
            }
            else {
                EventBean evalEvent = eventsPerStream[streamNumber];
                RelativeAccessByEventNIndex relativeAccess = relativeAccessGetter.GetAccessor(evalEvent);
                if (relativeAccess == null) {
                    return null;
                }

                if (!isTail) {
                    substituteEvent = relativeAccess.GetRelativeToEvent(evalEvent, index.Value);
                }
                else {
                    substituteEvent = relativeAccess.GetRelativeToEnd(index.Value);
                }
            }

            return substituteEvent;
        }