// Converts expressions of the form:
        // x < 5 => -infinity <= x and x < 5
        // x <= 5 => -infinity <= x and x <= 5
        // x > 5 => 5 < x <= infinity
        // x >= 5 => 5 <= x <= infinity
        //
        // The variable is always to the left
        internal Interval(double literal, RelationOperator op)
        {
            this.lowerBound = double.MinValue;
            this.upperBound = double.MaxValue;
            this.lowerOp = IntervalOp.LessThanEquals;
            this.upperOp = IntervalOp.LessThanEquals;

            Fx.Assert(RelationOperator.Eq != op && RelationOperator.Ne != op, "");
            switch (op)
            {
                case RelationOperator.Lt:
                    this.upperBound = literal;
                    this.upperOp = IntervalOp.LessThan;
                    break;
                case RelationOperator.Le:
                    this.upperBound = literal;
                    break;
                case RelationOperator.Gt:
                    this.lowerBound = literal;
                    this.lowerOp = IntervalOp.LessThan;
                    break;
                case RelationOperator.Ge:
                    this.lowerBound = literal;
                    break;
            }
        }
Exemple #2
0
        // Converts expressions of the form:
        // x < 5 => -infinity <= x and x < 5
        // x <= 5 => -infinity <= x and x <= 5
        // x > 5 => 5 < x <= infinity
        // x >= 5 => 5 <= x <= infinity
        //
        // The variable is always to the left
        internal Interval(double literal, RelationOperator op)
        {
            this.lowerBound = double.MinValue;
            this.upperBound = double.MaxValue;
            this.lowerOp    = IntervalOp.LessThanEquals;
            this.upperOp    = IntervalOp.LessThanEquals;

            Fx.Assert(RelationOperator.Eq != op && RelationOperator.Ne != op, "");
            switch (op)
            {
            case RelationOperator.Lt:
                this.upperBound = literal;
                this.upperOp    = IntervalOp.LessThan;
                break;

            case RelationOperator.Le:
                this.upperBound = literal;
                break;

            case RelationOperator.Gt:
                this.lowerBound = literal;
                this.lowerOp    = IntervalOp.LessThan;
                break;

            case RelationOperator.Ge:
                this.lowerBound = literal;
                break;
            }
        }
Exemple #3
0
 public DTLocalDtoIntervalEval(
     IntervalOp intervalOp,
     TimeZoneInfo timeZone)
     : base(intervalOp)
 {
     this.timeZone = timeZone;
 }
Exemple #4
0
        public override object Evaluate(object startTimestamp, object endTimestamp, EvaluateParams evaluateParams)
        {
            var start = ((DateTimeEx)startTimestamp).TimeInMillis;
            var end   = ((DateTimeEx)endTimestamp).TimeInMillis;

            return(IntervalOp.Evaluate(start, end, evaluateParams));
        }
        public override object Evaluate(object startTimestamp, object endTimestamp, EvaluateParams evaluateParams)
        {
            var startTime = (long)startTimestamp;
            var endTime   = (long)endTimestamp;

            return(IntervalOp.Evaluate(startTime, endTime, evaluateParams));
        }
 internal DTLocalEvaluatorCalOpsIntervalBase(
     IList<CalendarOp> calendarOps,
     IntervalOp intervalOp)
 {
     this.calendarOps = calendarOps;
     this.intervalOp = intervalOp;
 }
Exemple #7
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);
                }
            }
        }
Exemple #8
0
 protected DTLocalEvaluatorCalOpsIntervalBase(
     IList <CalendarOp> calendarOps,
     IntervalOp intervalOp)
 {
     CalendarOps = calendarOps;
     IntervalOp  = intervalOp;
 }
 public DTLocalDtxOpsIntervalEval(
     IList<CalendarOp> calendarOps,
     IntervalOp intervalOp,
     TimeZoneInfo timeZone)
     : base(calendarOps, intervalOp)
 {
     this.timeZone = timeZone;
 }
Exemple #10
0
 internal DTLocalEvaluatorDateTimeOpsInterval(
     IList <CalendarOp> calendarOps,
     IntervalOp intervalOp,
     TimeZoneInfo timeZone)
     : base(calendarOps, intervalOp)
 {
     _timeZone = timeZone;
 }
Exemple #11
0
        public override object Evaluate(object target, EvaluateParams evaluateParams)
        {
            var dtx = ((DateTimeEx)target).Clone();

            EvaluateDtxOps(CalendarOps, dtx, evaluateParams);
            var time = dtx.TimeInMillis;

            return(IntervalOp.Evaluate(time, time, evaluateParams));
        }
Exemple #12
0
        internal bool Contains(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
        {
            if (null != this.intervals)
            {
                return(this.intervals.IndexOf(lowerBound, lowerOp, upperBound, upperOp) >= 0);
            }

            return(false);
        }
        internal Interval FindInterval(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
        {
            int num;

            if ((this.intervals != null) && (-1 != (num = this.intervals.IndexOf(lowerBound, lowerOp, upperBound, upperOp))))
            {
                return(this.intervals[num]);
            }
            return(null);
        }
Exemple #14
0
        public override object Evaluate(object target, EvaluateParams evaluateParams)
        {
            var dtx            = DateTimeEx.GetInstance(_timeZone);
            var startRemainder = _timeAbacus.CalendarSet((long)target, dtx);

            EvaluateDtxOps(CalendarOps, dtx, evaluateParams);
            var time = _timeAbacus.CalendarGet(dtx, startRemainder);

            return(IntervalOp.Evaluate(time, time, evaluateParams));
        }
Exemple #15
0
 internal DTLocalEvaluatorLongOpsInterval(
     IList <CalendarOp> calendarOps,
     IntervalOp intervalOp,
     TimeZoneInfo timeZone,
     TimeAbacus timeAbacus)
     : base(calendarOps, intervalOp)
 {
     _timeZone   = timeZone;
     _timeAbacus = timeAbacus;
 }
Exemple #16
0
 public DTLocalLongOpsIntervalEval(
     IList<CalendarOp> calendarOps,
     IntervalOp intervalOp,
     TimeZoneInfo timeZone,
     TimeAbacus timeAbacus)
     : base(calendarOps, intervalOp)
 {
     this.timeZone = timeZone;
     this.timeAbacus = timeAbacus;
 }
Exemple #17
0
        public override object Evaluate(object target, EvaluateParams evaluateParams)
        {
            var dto = (DateTimeOffset)target;
            var dtx = DateTimeEx.GetInstance(_timeZone, dto);

            EvaluateDtxOps(CalendarOps, dtx, evaluateParams);
            var time = dtx.TimeInMillis;

            return(IntervalOp.Evaluate(time, time, evaluateParams));
        }
Exemple #18
0
        Interval GetIntervalFromSlot(IntervalCollection slot, double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
        {
            int index;

            if (null != slot && -1 != (index = slot.IndexOf(lowerBound, lowerOp, upperBound, upperOp)))
            {
                return(slot[index]);
            }
            return(null);
        }
Exemple #19
0
            public override Object Evaluate(
                Object target,
                EventBean[] eventsPerStream,
                bool isNewData,
                ExprEvaluatorContext exprEvaluatorContext)
            {
                var time = target.AsLong();

                return(IntervalOp.Evaluate(time, time, eventsPerStream, isNewData, exprEvaluatorContext));
            }
Exemple #20
0
 internal Interval FindInterval(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
 {
     if (null != this.intervals)
     {
         int index;
         if (-1 != (index = this.intervals.IndexOf(lowerBound, lowerOp, upperBound, upperOp)))
         {
             return(this.intervals[index]);
         }
     }
     return(null);
 }
Exemple #21
0
            public override Object Evaluate(
                Object startTimestamp,
                Object endTimestamp,
                EventBean[] eventsPerStream,
                bool isNewData,
                ExprEvaluatorContext exprEvaluatorContext)
            {
                var start = startTimestamp.AsDateTimeOffset().TimeInMillis();
                var end   = endTimestamp.AsDateTimeOffset().TimeInMillis();

                return(IntervalOp.Evaluate(start, end, eventsPerStream, isNewData, exprEvaluatorContext));
            }
Exemple #22
0
            public override Object Evaluate(
                Object startTimestamp,
                Object endTimestamp,
                EventBean[] eventsPerStream,
                bool isNewData,
                ExprEvaluatorContext exprEvaluatorContext)
            {
                var startTime = startTimestamp.AsLong();
                var endTime   = endTimestamp.AsLong();

                return(IntervalOp.Evaluate(startTime, endTime, eventsPerStream, isNewData, exprEvaluatorContext));
            }
 internal int IndexOf(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
 {
     int count = this.Count;
     for (int i = 0; i < count; i++)
     {
         if (this[i].Equals(lowerBound, lowerOp, upperBound, upperOp))
         {
             return i;
         }
     }
     return -1;
 }
Exemple #24
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);
                var time = dateTime.TimeInMillis;

                return(IntervalOp.Evaluate(time, time, eventsPerStream, isNewData, exprEvaluatorContext));
            }
Exemple #25
0
        public override object Evaluate(object startTimestamp, object endTimestamp, EvaluateParams evaluateParams)
        {
            var startLong      = (long)startTimestamp;
            var endLong        = (long)endTimestamp;
            var dtx            = DateTimeEx.GetInstance(_timeZone);
            var startRemainder = _timeAbacus.CalendarSet(startLong, dtx);

            EvaluateDtxOps(CalendarOps, dtx, evaluateParams);
            var startTime = _timeAbacus.CalendarGet(dtx, startRemainder);
            var endTime   = startTime + (endLong - startLong);

            return(IntervalOp.Evaluate(startTime, endTime, evaluateParams));
        }
        internal int IndexOf(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
        {
            int count = this.Count;

            for (int i = 0; i < count; i++)
            {
                if (this[i].Equals(lowerBound, lowerOp, upperBound, upperOp))
                {
                    return(i);
                }
            }
            return(-1);
        }
Exemple #27
0
        internal Interval GetInterval(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
        {
            Interval interval;

            if (
                null != (interval = this.GetIntervalFromSlot(this.eqSlot, lowerBound, lowerOp, upperBound, upperOp)) ||
                null != (interval = this.GetIntervalFromSlot(this.ltSlot, lowerBound, lowerOp, upperBound, upperOp)) ||
                null != (interval = this.GetIntervalFromSlot(this.gtSlot, lowerBound, lowerOp, upperBound, upperOp))
                )
            {
                return(interval);
            }

            return(null);
        }
Exemple #28
0
        public override object Evaluate(
            object startTimestamp,
            object endTimestamp,
            EvaluateParams evaluateParams)
        {
            var startLong = ((DateTime)startTimestamp).UtcMillis();
            var endLong   = ((DateTime)endTimestamp).UtcMillis();
            var dtx       = DateTimeEx.GetInstance(_timeZone);

            dtx.SetUtcMillis(startLong);
            EvaluateDtxOps(CalendarOps, dtx, evaluateParams);
            var startTime = dtx.TimeInMillis;
            var endTime   = startTime + (endLong - startLong);

            return(IntervalOp.Evaluate(startTime, endTime, evaluateParams));
        }
Exemple #29
0
            public override Object Evaluate(
                Object startTimestamp,
                Object endTimestamp,
                EventBean[] eventsPerStream,
                bool isNewData,
                ExprEvaluatorContext exprEvaluatorContext)
            {
                var startLong = startTimestamp.AsLong();
                var endLong   = endTimestamp.AsLong();
                var dateTime  = new DateTimeEx(startLong.TimeFromMillis(_timeZone), _timeZone);

                EvaluateCalOps(CalendarOps, dateTime, eventsPerStream, isNewData, exprEvaluatorContext);
                var startTime = dateTime.TimeInMillis;
                var endTime   = startTime + (endLong - startLong);

                return(IntervalOp.Evaluate(startTime, endTime, eventsPerStream, isNewData, exprEvaluatorContext));
            }
Exemple #30
0
        internal Interval(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
        {
            Fx.Assert(lowerBound <= upperBound, "");

            this.lowerBound = lowerBound;
            this.upperBound = upperBound;
            if (this.lowerBound == this.upperBound)
            {
                this.lowerOp = IntervalOp.LessThanEquals;
                this.upperOp = IntervalOp.LessThanEquals;
            }
            else
            {
                this.lowerOp = lowerOp;
                this.upperOp = upperOp;
            }
        }
        internal Interval(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
        {
            Fx.Assert(lowerBound <= upperBound, "");

            this.lowerBound = lowerBound;
            this.upperBound = upperBound;
            if (this.lowerBound == this.upperBound)
            {
                this.lowerOp = IntervalOp.LessThanEquals;
                this.upperOp = IntervalOp.LessThanEquals;
            }
            else
            {
                this.lowerOp = lowerOp;
                this.upperOp = upperOp;
            }
        }
        internal Interval(double literal, RelationOperator op)
        {
            switch (op)
            {
                case RelationOperator.Gt:
                    this.lowerBound = literal;
                    this.lowerOp = IntervalOp.LessThan;
                    return;

                case RelationOperator.Ge:
                    this.lowerBound = literal;
                    return;

                case RelationOperator.Lt:
                    this.upperBound = literal;
                    this.upperOp = IntervalOp.LessThan;
                    return;

                case RelationOperator.Le:
                    this.upperBound = literal;
                    return;
            }
        }
        internal Interval(double literal, RelationOperator op)
        {
            switch (op)
            {
            case RelationOperator.Gt:
                this.lowerBound = literal;
                this.lowerOp    = IntervalOp.LessThan;
                return;

            case RelationOperator.Ge:
                this.lowerBound = literal;
                return;

            case RelationOperator.Lt:
                this.upperBound = literal;
                this.upperOp    = IntervalOp.LessThan;
                return;

            case RelationOperator.Le:
                this.upperBound = literal;
                return;
            }
        }
 Interval GetIntervalFromSlot(IntervalCollection slot, double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
 {
     int index;
     if (null != slot && -1 != (index = slot.IndexOf(lowerBound, lowerOp, upperBound, upperOp)))
     {
         return slot[index];
     }
     return null;
 }
        internal bool Contains(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
        {
            if (null != this.intervals)
            {
                return (this.intervals.IndexOf(lowerBound, lowerOp, upperBound, upperOp) >= 0);
            }

            return false;
        }
 internal Interval FindInterval(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
 {
     if (null != this.intervals)
     {
         int index;
         if (-1 != (index = this.intervals.IndexOf(lowerBound, lowerOp, upperBound, upperOp)))
         {
             return this.intervals[index];
         }
     }
     return null;
 }
 internal bool Equals(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
 {
     return (this.lowerBound == lowerBound && this.lowerOp == lowerOp && this.upperBound == upperBound && this.upperOp == upperOp);
 }
 internal Interval FindInterval(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
 {
     int num;
     if ((this.intervals != null) && (-1 != (num = this.intervals.IndexOf(lowerBound, lowerOp, upperBound, upperOp))))
     {
         return this.intervals[num];
     }
     return null;
 }
 public DTLocalLongIntervalEval(IntervalOp intervalOp)
     : base(intervalOp)
 {
 }
        internal Interval GetInterval(double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
        {
            Interval interval;
            if (
                null != (interval = this.GetIntervalFromSlot(this.eqSlot, lowerBound, lowerOp, upperBound, upperOp))
                || null != (interval = this.GetIntervalFromSlot(this.ltSlot, lowerBound, lowerOp, upperBound, upperOp))
                || null != (interval = this.GetIntervalFromSlot(this.gtSlot, lowerBound, lowerOp, upperBound, upperOp))
                )
            {
                return interval;
            }

            return null;
        }