示例#1
0
        public ExprDotEvalDT(
            IList <CalendarOp> calendarOps,
            TimeZoneInfo timeZone,
            ReformatOp reformatOp,
            IntervalOp intervalOp,
            Type inputType,
            EventType inputEventType)
        {
            _evaluator = GetEvaluator(calendarOps, timeZone, inputType, inputEventType, reformatOp, intervalOp);

            if (intervalOp != null)
            {
                _returnType = EPTypeHelper.SingleValue(typeof(bool?));
            }
            else if (reformatOp != null)
            {
                _returnType = EPTypeHelper.SingleValue(reformatOp.ReturnType);
            }
            else
            {
                // only calendar ops
                if (inputEventType != null)
                {
                    _returnType = EPTypeHelper.SingleValue(
                        inputEventType.GetPropertyType(inputEventType.StartTimestampPropertyName));
                }
                else
                {
                    _returnType = EPTypeHelper.SingleValue(inputType);
                }
            }
        }
示例#2
0
        public override object Evaluate(object target, EvaluateParams evaluateParams)
        {
            var dtx = ((DateTimeEx)target).Clone();

            DTLocalEvaluatorBase.EvaluateDtxOps(CalendarOps, dtx, evaluateParams);
            return(ReformatOp.Evaluate(dtx, evaluateParams.EventsPerStream, evaluateParams.IsNewData, evaluateParams.ExprEvaluatorContext));
        }
示例#3
0
 protected DTLocalEvaluatorCalopReformatBase(
     IList <CalendarOp> calendarOps,
     ReformatOp reformatOp)
 {
     CalendarOps = calendarOps;
     ReformatOp  = reformatOp;
 }
        public override object Evaluate(object target, EvaluateParams evaluateParams)
        {
            var dt  = (DateTimeOffset)target;
            var dtx = DateTimeEx.GetInstance(_timeZone, dt);

            DTLocalEvaluatorBase.EvaluateDtxOps(CalendarOps, dtx, evaluateParams);
            return(ReformatOp.Evaluate(dtx, evaluateParams.EventsPerStream, evaluateParams.IsNewData, evaluateParams.ExprEvaluatorContext));
        }
示例#5
0
 public override Object Evaluate(
     Object target,
     EventBean[] eventsPerStream,
     bool isNewData,
     ExprEvaluatorContext exprEvaluatorContext)
 {
     return(ReformatOp.Evaluate(target.AsLong(), eventsPerStream, isNewData, exprEvaluatorContext));
 }
示例#6
0
 public DTLocalDtoOpsReformatEval(
     IList<CalendarOp> calendarOps,
     ReformatOp reformatOp)
     : base(
         calendarOps,
         reformatOp)
 {
 }
示例#7
0
 internal DTLocalEvaluatorLongOpsReformat(
     IList <CalendarOp> calendarOps,
     ReformatOp reformatOp,
     TimeZoneInfo timeZone)
     : base(calendarOps, reformatOp)
 {
     _timeZone = timeZone;
 }
 public DTLocalLongOpsReformatEval(
     IList<CalendarOp> calendarOps,
     ReformatOp reformatOp,
     TimeZoneInfo timeZone,
     TimeAbacus timeAbacus)
     : base(calendarOps, reformatOp)
 {
     this.timeZone = timeZone;
     this.timeAbacus = timeAbacus;
 }
示例#9
0
            public override Object Evaluate(
                Object target,
                EventBean[] eventsPerStream,
                bool isNewData,
                ExprEvaluatorContext exprEvaluatorContext)
            {
                var dateTime = new DateTimeEx(target.AsLong().TimeFromMillis(_timeZone), _timeZone);

                EvaluateCalOps(CalendarOps, dateTime, eventsPerStream, isNewData, exprEvaluatorContext);
                return(ReformatOp.Evaluate(dateTime.DateTime, eventsPerStream, isNewData, exprEvaluatorContext));
            }
示例#10
0
 internal DTLocalEvaluatorDateTimeReformat(ReformatOp reformatOp)
     : base(reformatOp)
 {
 }
示例#11
0
 internal DTLocalDtxReformatEval(ReformatOp reformatOp)
     : base(reformatOp)
 {
 }
示例#12
0
 public override object Evaluate(object target, EvaluateParams evaluateParams)
 {
     return(ReformatOp.Evaluate((DateTimeEx)target, evaluateParams.EventsPerStream, evaluateParams.IsNewData, evaluateParams.ExprEvaluatorContext));
 }
 public DTLocalDateTimeReformatEval(ReformatOp reformatOp)
     : base(reformatOp)
 {
 }
示例#14
0
        public DTLocalEvaluator GetEvaluator(
            IList <CalendarOp> calendarOps,
            TimeZoneInfo timeZone,
            Type inputType,
            EventType inputEventType,
            ReformatOp reformatOp,
            IntervalOp intervalOp)
        {
            if (inputEventType == null)
            {
                if (reformatOp != null)
                {
                    if (inputType.GetBoxedType() == typeof(DateTime?))
                    {
                        if (calendarOps.IsEmpty())
                        {
                            return(new DTLocalEvaluatorDateTimeReformat(reformatOp));
                        }
                        return(new DTLocalEvaluatorDateTimeOpsReformat(calendarOps, reformatOp, timeZone));
                    }
                    if (inputType.GetBoxedType() == typeof(DateTimeOffset?))
                    {
                        if (calendarOps.IsEmpty())
                        {
                            return(new DTLocalEvaluatorDateTimeReformat(reformatOp));
                        }
                        return(new DTLocalEvaluatorDateTimeOpsReformat(calendarOps, reformatOp, timeZone));
                    }
                    if (inputType.GetBoxedType() == typeof(long?))
                    {
                        if (calendarOps.IsEmpty())
                        {
                            return(new DTLocalEvaluatorLongReformat(reformatOp));
                        }
                        return(new DTLocalEvaluatorLongOpsReformat(calendarOps, reformatOp, timeZone));
                    }
                }
                else if (intervalOp != null)
                {
                    if (inputType.GetBoxedType() == typeof(DateTime?))
                    {
                        if (calendarOps.IsEmpty())
                        {
                            return(new DTLocalEvaluatorDateTimeInterval(intervalOp));
                        }
                        return(new DTLocalEvaluatorDateTimeOpsInterval(calendarOps, intervalOp, timeZone));
                    }
                    if (inputType.GetBoxedType() == typeof(DateTimeOffset?))
                    {
                        if (calendarOps.IsEmpty())
                        {
                            return(new DTLocalEvaluatorDateTimeInterval(intervalOp));
                        }
                        return(new DTLocalEvaluatorDateTimeOpsInterval(calendarOps, intervalOp, timeZone));
                    }
                    if (inputType.GetBoxedType() == typeof(long?))
                    {
                        if (calendarOps.IsEmpty())
                        {
                            return(new DTLocalEvaluatorLongInterval(intervalOp));
                        }
                        return(new DTLocalEvaluatorLongOpsInterval(calendarOps, intervalOp, timeZone));
                    }
                }
                else
                {
                    // only calendar ops, nothing else
                    if (inputType.GetBoxedType() == typeof(DateTime?))
                    {
                        return(new DTLocalEvaluatorCalOpsDateTime(calendarOps, timeZone));
                    }
                    if (inputType.GetBoxedType() == typeof(DateTimeOffset?))
                    {
                        return(new DTLocalEvaluatorCalOpsDateTime(calendarOps, timeZone));
                    }
                    if (inputType.GetBoxedType() == typeof(long?))
                    {
                        return(new DTLocalEvaluatorCalOpsLong(calendarOps, timeZone));
                    }
                }
                throw new ArgumentException("Invalid input type '" + inputType + "'");
            }

            var getter           = inputEventType.GetGetter(inputEventType.StartTimestampPropertyName);
            var getterResultType = inputEventType.GetPropertyType(inputEventType.StartTimestampPropertyName);

            if (reformatOp != null)
            {
                var inner = GetEvaluator(calendarOps, timeZone, getterResultType, null, reformatOp, null);
                return(new DTLocalEvaluatorBeanReformat(getter, inner));
            }
            if (intervalOp == null)
            {
                // only calendar ops
                var inner = GetEvaluator(calendarOps, timeZone, getterResultType, null, null, null);
                return(new DTLocalEvaluatorBeanCalOps(getter, inner));
            }

            // have interval ops but no end timestamp
            if (inputEventType.EndTimestampPropertyName == null)
            {
                var inner = GetEvaluator(calendarOps, timeZone, getterResultType, null, null, intervalOp);
                return(new DTLocalEvaluatorBeanIntervalNoEndTS(getter, inner));
            }

            // interval ops and have end timestamp
            var getterEndTimestamp = inputEventType.GetGetter(inputEventType.EndTimestampPropertyName);
            var intervalComp       =
                (DTLocalEvaluatorIntervalComp)GetEvaluator(calendarOps, timeZone, getterResultType, null, null, intervalOp);

            return(new DTLocalEvaluatorBeanIntervalWithEnd(getter, getterEndTimestamp, intervalComp));
        }
示例#15
0
 internal DTLocalEvaluatorLongReformat(ReformatOp reformatOp)
     : base(reformatOp)
 {
 }
示例#16
0
 protected DTLocalReformatEvalBase(ReformatOp reformatOp)
 {
     this.reformatOp = reformatOp;
 }
示例#17
0
 public DTLocalDtoReformatEval(ReformatOp reformatOp)
     : base(reformatOp)
 {
 }
示例#18
0
        public static ExprDotEvalDTMethodDesc ValidateMake(
            StreamTypeService streamTypeService,
            Deque <ExprChainedSpec> chainSpecStack,
            DatetimeMethodEnum dtMethod,
            String dtMethodName,
            EPType inputType,
            IList <ExprNode> parameters,
            ExprDotNodeFilterAnalyzerInput inputDesc,
            TimeZoneInfo timeZone)
        {
            // verify input
            String message = "Date-time enumeration method '" + dtMethodName +
                             "' requires either a DateTime or long value as input or events of an event type that declares a timestamp property";

            if (inputType is EventEPType)
            {
                if (((EventEPType)inputType).EventType.StartTimestampPropertyName == null)
                {
                    throw new ExprValidationException(message);
                }
            }
            else
            {
                if (!(inputType is ClassEPType || inputType is NullEPType))
                {
                    throw new ExprValidationException(message + " but received " + EPTypeHelper.ToTypeDescriptive(inputType));
                }
                if (inputType is ClassEPType)
                {
                    ClassEPType classEPType = (ClassEPType)inputType;
                    if (!TypeHelper.IsDateTime(classEPType.Clazz))
                    {
                        throw new ExprValidationException(
                                  message + " but received " + classEPType.Clazz.GetTypeNameFullyQualPretty());
                    }
                }
            }

            IList <CalendarOp> calendarOps       = new List <CalendarOp>();
            ReformatOp         reformatOp        = null;
            IntervalOp         intervalOp        = null;
            DatetimeMethodEnum currentMethod     = dtMethod;
            IList <ExprNode>   currentParameters = parameters;
            String             currentMethodName = dtMethodName;

            // drain all calendar ops
            ExprDotNodeFilterAnalyzerDesc filterAnalyzerDesc = null;

            while (true)
            {
                // handle the first one only if its a calendar op
                var evaluators = GetEvaluators(currentParameters);
                var opFactory  = currentMethod.MetaData().OpFactory;

                // compile parameter abstract for validation against available footprints
                var footprintProvided = DotMethodUtil.GetProvidedFootprint(currentParameters);

                // validate parameters
                DotMethodUtil.ValidateParametersDetermineFootprint(
                    currentMethod.Footprints(),
                    DotMethodTypeEnum.DATETIME,
                    currentMethodName, footprintProvided,
                    DotMethodInputTypeMatcherImpl.DEFAULT_ALL);

                if (opFactory is CalendarOpFactory)
                {
                    CalendarOp calendarOp = ((CalendarOpFactory)opFactory).GetOp(currentMethod, currentMethodName, currentParameters, evaluators);
                    calendarOps.Add(calendarOp);
                }
                else if (opFactory is ReformatOpFactory)
                {
                    reformatOp = ((ReformatOpFactory)opFactory).GetOp(timeZone, currentMethod, currentMethodName, currentParameters);

                    // compile filter analyzer information if there are no calendar ops in the chain
                    if (calendarOps.IsEmpty())
                    {
                        filterAnalyzerDesc = reformatOp.GetFilterDesc(streamTypeService.EventTypes, currentMethod, currentParameters, inputDesc);
                    }
                    else
                    {
                        filterAnalyzerDesc = null;
                    }
                }
                else if (opFactory is IntervalOpFactory)
                {
                    intervalOp = ((IntervalOpFactory)opFactory).GetOp(streamTypeService, currentMethod, currentMethodName, currentParameters, evaluators);

                    // compile filter analyzer information if there are no calendar ops in the chain
                    if (calendarOps.IsEmpty())
                    {
                        filterAnalyzerDesc = intervalOp.GetFilterDesc(streamTypeService.EventTypes, currentMethod, currentParameters, inputDesc);
                    }
                    else
                    {
                        filterAnalyzerDesc = null;
                    }
                }
                else
                {
                    throw new IllegalStateException("Invalid op factory class " + opFactory);
                }

                // see if there is more
                if (chainSpecStack.IsEmpty() || !DatetimeMethodEnumExtensions.IsDateTimeMethod(chainSpecStack.First.Name))
                {
                    break;
                }

                // pull next
                var next = chainSpecStack.RemoveFirst();
                currentMethod     = DatetimeMethodEnumExtensions.FromName(next.Name);
                currentParameters = next.Parameters;
                currentMethodName = next.Name;

                if ((reformatOp != null || intervalOp != null))
                {
                    throw new ExprValidationException("Invalid input for date-time method '" + next.Name + "'");
                }
            }

            ExprDotEval dotEval;
            EPType      returnType;

            dotEval    = new ExprDotEvalDT(calendarOps, timeZone, reformatOp, intervalOp, EPTypeHelper.GetClassSingleValued(inputType), EPTypeHelper.GetEventTypeSingleValued(inputType));
            returnType = dotEval.TypeInfo;
            return(new ExprDotEvalDTMethodDesc(dotEval, returnType, filterAnalyzerDesc));
        }
示例#19
0
 internal DTLocalEvaluatorDtxOpsReformat(IList <CalendarOp> calendarOps, ReformatOp reformatOp)
     : base(calendarOps, reformatOp)
 {
 }
 protected DTLocalEvaluatorReformatBase(ReformatOp reformatOp)
 {
     ReformatOp = reformatOp;
 }
示例#21
0
 public DTLocalLongReformatEval(ReformatOp reformatOp)
     : base(reformatOp)
 {
 }