public ICollection <EventBean> GetCollectKeys(
            EventBean[] eventsPerStream,
            DataMap parent,
            ExprEvaluatorContext context,
            IList <object> keys,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            EventBean[] eventsToUse;
            if (_isNWOnTrigger)
            {
                eventsToUse = eventsPerStream;
            }
            else
            {
                Array.Copy(eventsPerStream, 0, _events, 1, eventsPerStream.Length);
                eventsToUse = _events;
            }

            var mk = EventBeanUtility.GetMultiKey(eventsToUse, _evaluators, context, _keyCoercionTypes);

            keys.AddAll(mk.Keys);
            var innerIndex = (DataMap)parent.Get(mk);

            if (innerIndex == null)
            {
                return(null);
            }
            return(_next.GetCollectKeys(eventsPerStream, innerIndex, context, keys, postProcessor));
        }
Exemple #2
0
        private void Normalize(
            ISet<EventBean> result,
            IDictionary<object, CompositeIndexEntry> submap,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            if (submap.Count == 0) {
                return;
            }

            if (_next == null) {
                if (postProcessor != null) {
                    foreach (KeyValuePair<object, CompositeIndexEntry> entry in submap) {
                        postProcessor.Add(entry.Value.AssertCollection(), result);
                    }
                }
                else {
                    foreach (KeyValuePair<object, CompositeIndexEntry> entry in submap) {
                        ICollection<EventBean> set = entry.Value.AssertCollection();
                        result.AddAll(set);
                    }
                }
            }
            else {
                foreach (KeyValuePair<object, CompositeIndexEntry> entry in submap) {
                    var index = entry.Value.AssertIndex();
                    _next.Lookup(index, result, postProcessor);
                }
            }
        }
Exemple #3
0
        public ICollection<EventBean> GetCollectKeys(
            EventBean[] eventsPerStream,
            IDictionary<object, CompositeIndexEntry> parent,
            ExprEvaluatorContext context,
            ICollection<object> keys,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            EventBean[] eventsToUse;
            if (_isNwOnTrigger) {
                eventsToUse = eventsPerStream;
            }
            else {
                Array.Copy(eventsPerStream, 0, _events, 1, eventsPerStream.Length);
                eventsToUse = _events;
            }

            var mk = _hashGetter.Evaluate(eventsToUse, true, context);
            if (mk is MultiKeyArrayOfKeys<object> mkArray) {
                keys.AddAll(mkArray.Array);
            }
            else {
                keys.Add(mk);
            }

            var innerEntry = parent.Get(mk);
            if (innerEntry == null) {
                return null;
            }

            var innerIndex = innerEntry.AssertIndex();
            return _next.GetCollectKeys(eventsPerStream, innerIndex, context, keys, postProcessor);
        }
Exemple #4
0
        public void LookupRange(
            ISet<EventBean> result,
            IOrderedDictionary<object, CompositeIndexEntry> propertyIndex,
            object keyStart,
            bool includeStart,
            object keyEnd,
            bool includeEnd,
            bool allowRangeReversal,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            if (keyStart == null || keyEnd == null) {
                return;
            }

            keyStart = Coerce(keyStart);
            keyEnd = Coerce(keyEnd);
         
            IDictionary<object, CompositeIndexEntry> submap;
            if (propertyIndex.KeyComparer.Compare(keyStart, keyEnd) <= 0) {
                submap = propertyIndex.Between(keyStart, includeStart, keyEnd, includeEnd);
            }
            else if (allowRangeReversal) {
                submap = propertyIndex.Between(keyEnd, includeStart, keyStart, includeEnd);
            }
            else {
                return;
            }

            Normalize(result, submap, postProcessor);
        }
Exemple #5
0
        public ICollection<EventBean> Lookup(
            EventBean[] eventsPerStream,
            IDictionary<object, CompositeIndexEntry> parent,
            ICollection<EventBean> result,
            CompositeIndexQuery next,
            ExprEvaluatorContext context,
            ICollection<object> optionalKeyCollector,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            var comparableStart = EvaluatePerStreamStart(eventsPerStream, context);
            optionalKeyCollector?.Add(comparableStart);

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

            var comparableEnd = EvaluatePerStreamEnd(eventsPerStream, context);
            optionalKeyCollector?.Add(comparableEnd);

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

            var index = (IOrderedDictionary<object, CompositeIndexEntry>) parent;
            var submapOne = index.Head(comparableStart, !includeStart);
            var submapTwo = index.Tail(comparableEnd, !includeEnd);
            return CompositeIndexQueryRange.Handle(eventsPerStream, submapOne, submapTwo, result, next, postProcessor);
        }
        public ICollection<EventBean> Lookup(
            EventBean[] eventPerStream,
            IDictionary<object, CompositeIndexEntry> parent,
            ICollection<EventBean> result,
            CompositeIndexQuery next,
            ExprEvaluatorContext context,
            ICollection<object> optionalKeyCollector,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            var index = (IOrderedDictionary<object, CompositeIndexEntry>) parent;
            var comparable = base.EvaluatePerStream(eventPerStream, context);
            optionalKeyCollector?.Add(comparable);

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

            return CompositeIndexQueryRange.Handle(
                eventPerStream,
                index.Tail(comparable),
                null,
                result,
                next,
                postProcessor);
        }
        public void LookupRange(
            ICollection <EventBean> result,
            OrderedDictionary <object, object> propertyIndex,
            object keyStart,
            bool includeStart,
            object keyEnd,
            bool includeEnd,
            bool allowRangeReversal,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            if (keyStart == null || keyEnd == null)
            {
                return;
            }
            keyStart = Coerce(keyStart);
            keyEnd   = Coerce(keyEnd);
            IEnumerable <KeyValuePair <object, object> > submap;

            try
            {
                submap = propertyIndex.Between(keyStart, includeStart, keyEnd, includeEnd);
            }
            catch (ArgumentException)
            {
                if (allowRangeReversal)
                {
                    submap = propertyIndex.Between(keyEnd, includeStart, keyStart, includeEnd);
                }
                else
                {
                    return;
                }
            }
            Normalize(result, submap, postProcessor);
        }
 public void Add(
     EventBean[] eventsPerStream,
     DataMap value,
     ICollection <EventBean> result,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     throw new UnsupportedOperationException();
 }
 public ICollection <EventBean> Get(
     EventBean[] eventsPerStream,
     IDictionary <object, object> parent,
     ExprEvaluatorContext context,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     return(_strategy.Lookup(eventsPerStream, parent, null, _next, context, null, postProcessor));
 }
 public void Add(
     EventBean theEvent,
     IDictionary <object, object> parent,
     ICollection <EventBean> result,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     _strategy.Lookup(theEvent, parent, result, _next, null, null, postProcessor);
 }
Exemple #11
0
 public void Add(
     EventBean theEvent,
     IDictionary<object, CompositeIndexEntry> value,
     ICollection<EventBean> result,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     throw new UnsupportedOperationException();
 }
Exemple #12
0
 public ICollection<EventBean> Get(
     EventBean theEvent,
     IDictionary<object, CompositeIndexEntry> parent,
     ExprEvaluatorContext context,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     return _strategy.Lookup(theEvent, parent, null, _next, context, null, postProcessor);
 }
Exemple #13
0
 public void Add(
     EventBean[] eventsPerStream,
     IDictionary<object, CompositeIndexEntry> parent,
     ICollection<EventBean> result,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     _strategy.Lookup(eventsPerStream, parent, result, _next, null, null, postProcessor);
 }
Exemple #14
0
 private void Normalize(
     ISet<EventBean> result,
     IDictionary<object, CompositeIndexEntry> submapOne,
     IDictionary<object, CompositeIndexEntry> submapTwo,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     Normalize(result, submapTwo, postProcessor);
     Normalize(result, submapOne, postProcessor);
 }
 public ICollection <EventBean> GetCollectKeys(
     EventBean theEvent,
     IDictionary <object, object> parent,
     ExprEvaluatorContext context,
     IList <object> keys,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     return(_strategy.Lookup(theEvent, parent, null, _next, context, keys, postProcessor));
 }
 private void Normalize(
     ICollection <EventBean> result,
     IEnumerable <KeyValuePair <object, object> > submapOne,
     IEnumerable <KeyValuePair <object, object> > submapTwo,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     Normalize(result, submapTwo, postProcessor);
     Normalize(result, submapOne, postProcessor);
 }
Exemple #17
0
 private static void AddResults(
     IDictionary<object, CompositeIndexEntry> sortedMapOne,
     IDictionary<object, CompositeIndexEntry> sortedMapTwo,
     ICollection<EventBean> result,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     AddResults(sortedMapOne, result, postProcessor);
     if (sortedMapTwo != null) {
         AddResults(sortedMapTwo, result, postProcessor);
     }
 }
 private static void AddResults(
     IEnumerable <KeyValuePair <object, ICollection <EventBean> > > sortedMapOne,
     IEnumerable <KeyValuePair <object, ICollection <EventBean> > > sortedMapTwo,
     ICollection <EventBean> result,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     AddResults(sortedMapOne, result, postProcessor);
     if (sortedMapTwo != null)
     {
         AddResults(sortedMapTwo, result, postProcessor);
     }
 }
Exemple #19
0
        public void LookupGreaterEqual(
            ISet<EventBean> result,
            IOrderedDictionary<object, CompositeIndexEntry> propertyIndex,
            object keyStart,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            if (keyStart == null) {
                return;
            }

            keyStart = Coerce(keyStart);
            Normalize(result, propertyIndex.Tail(keyStart), postProcessor);
        }
 public void LookupGreater(
     ICollection <EventBean> result,
     OrderedDictionary <object, object> propertyIndex,
     object keyStart,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     if (keyStart == null)
     {
         return;
     }
     keyStart = Coerce(keyStart);
     Normalize(result, propertyIndex.Tail(keyStart, false), postProcessor);
 }
Exemple #21
0
        public void Lookup(
            IDictionary<object, CompositeIndexEntry> parent,
            ISet<EventBean> result,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            var key = _multiKeyTransform.From(_keys);
            var innerEntry = parent.Get(key);
            if (innerEntry == null) {
                return;
            }

            var innerIndex = innerEntry.AssertIndex();
            _next.Lookup(innerIndex, result, postProcessor);
        }
Exemple #22
0
        public ICollection<EventBean> Get(
            EventBean theEvent,
            IDictionary<object, CompositeIndexEntry> parent,
            ExprEvaluatorContext context,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            _events[_lookupStream] = theEvent;
            var mk = _hashGetter.Evaluate(_events, true, context);
            var innerEntry = parent.Get(mk);
            if (innerEntry == null) {
                return null;
            }

            var innerIndex = innerEntry.AssertIndex();
            return _next.Get(theEvent, innerIndex, context, postProcessor);
        }
        public ICollection <EventBean> Get(
            EventBean theEvent,
            DataMap parent,
            ExprEvaluatorContext context,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            _events[_lookupStream] = theEvent;
            var mk         = EventBeanUtility.GetMultiKey(_events, _evaluators, context, _keyCoercionTypes);
            var innerIndex = (DataMap)parent.Get(mk);

            if (innerIndex == null)
            {
                return(null);
            }
            return(_next.Get(theEvent, innerIndex, context, postProcessor));
        }
        protected internal static ICollection <EventBean> Handle(
            EventBean[] eventsPerStream,
            IDictionary <object, object> sortedMapOne,
            IDictionary <object, object> sortedMapTwo,
            ICollection <EventBean> result,
            CompositeIndexQuery next,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            if (next == null)
            {
                if (result == null)
                {
                    result = new HashSet <EventBean>();
                }
                AddResults(
                    sortedMapOne != null ?
                    sortedMapOne.Select(entry => new KeyValuePair <object, ICollection <EventBean> >(entry.Key, entry.Value as ICollection <EventBean>)) :
                    null,
                    sortedMapTwo != null ?
                    sortedMapTwo.Select(entry => new KeyValuePair <object, ICollection <EventBean> >(entry.Key, entry.Value as ICollection <EventBean>)) :
                    null,
                    result,
                    postProcessor);

                return(result);
            }
            else
            {
                if (result == null)
                {
                    result = new HashSet <EventBean>();
                }
                foreach (var entry in sortedMapOne)
                {
                    next.Add(eventsPerStream, entry.Value as IDictionary <object, object>, result, postProcessor);
                }
                if (sortedMapTwo != null)
                {
                    foreach (var entry in sortedMapTwo)
                    {
                        next.Add(eventsPerStream, entry.Value as IDictionary <object, object>, result, postProcessor);
                    }
                }
                return(result);
            }
        }
Exemple #25
0
        private static void AddResults(
            IDictionary<object, CompositeIndexEntry> sortedMapOne,
            ICollection<EventBean> result,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            var map = sortedMapOne;

            if (postProcessor != null) {
                foreach (var entry in map) {
                    postProcessor.Add(entry.Value, result);
                }
            }
            else {
                foreach (var entry in map) {
                    result.AddAll(entry.Value.AssertCollection());
                }
            }
        }
Exemple #26
0
        public void LookupRangeInverted(
            ISet<EventBean> result,
            IOrderedDictionary<object, CompositeIndexEntry> propertyIndex,
            object keyStart,
            bool includeStart,
            object keyEnd,
            bool includeEnd,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            if (keyStart == null || keyEnd == null) {
                return;
            }

            keyStart = Coerce(keyStart);
            keyEnd = Coerce(keyEnd);
            var submapOne = propertyIndex.Head(keyStart, !includeStart);
            var submapTwo = propertyIndex.Tail(keyEnd, !includeEnd);
            Normalize(result, submapOne, submapTwo, postProcessor);
        }
 private static void AddResults(
     IEnumerable <KeyValuePair <object, ICollection <EventBean> > > sortedMapOne,
     ICollection <EventBean> result,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     if (postProcessor != null)
     {
         foreach (var entry in sortedMapOne)
         {
             postProcessor.Add(entry.Value, result);
         }
     }
     else
     {
         foreach (var entry in sortedMapOne)
         {
             result.AddAll(entry.Value);
         }
     }
 }
Exemple #28
0
        public ICollection<EventBean> Lookup(
            EventBean theEvent,
            IDictionary<object, CompositeIndexEntry> parent,
            ICollection<EventBean> result,
            CompositeIndexQuery next,
            ExprEvaluatorContext context,
            ICollection<object> optionalKeyCollector,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            object comparableStart = base.EvaluateLookupStart(theEvent, context);
            optionalKeyCollector?.Add(comparableStart);

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

            object comparableEnd = base.EvaluateLookupEnd(theEvent, context);
            optionalKeyCollector?.Add(comparableEnd);

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

            IOrderedDictionary<object, CompositeIndexEntry> index =
                (IOrderedDictionary<object, CompositeIndexEntry>) parent;

            
            IDictionary<object, CompositeIndexEntry> submap;
            if (index.KeyComparer.Compare(comparableStart, comparableEnd) <= 0) {
                submap = index.Between(comparableStart, includeStart, comparableEnd, includeEnd);
            }
            else if (_allowReverseRange) {
                submap = index.Between(comparableEnd, includeStart, comparableStart, includeEnd);
            }
            else {
                return null;
            }

            return CompositeIndexQueryRange.Handle(theEvent, submap, null, result, next, postProcessor);
        }
Exemple #29
0
        public ICollection <EventBean> Lookup(
            EventBean theEvent,
            DataMap parent,
            ICollection <EventBean> result,
            CompositeIndexQuery next,
            ExprEvaluatorContext context,
            IList <object> optionalKeyCollector,
            CompositeIndexQueryResultPostProcessor postProcessor)
        {
            var index      = (OrderedDictionary <object, object>)parent;
            var comparable = EvaluateLookup(theEvent, context);

            if (optionalKeyCollector != null)
            {
                optionalKeyCollector.Add(comparable);
            }
            if (comparable == null)
            {
                return(null);
            }
            comparable = EventBeanUtility.Coerce(comparable, CoercionType);
            return(CompositeIndexQueryRange.Handle(theEvent, index.Tail(comparable, false), null, result, next, postProcessor));
        }
 private void Normalize(
     ICollection <EventBean> result,
     IEnumerable <KeyValuePair <object, object> > submap,
     CompositeIndexQueryResultPostProcessor postProcessor)
 {
     if (!submap.Any())
     {
         return;
     }
     if (_next == null)
     {
         if (postProcessor != null)
         {
             foreach (var entry in submap)
             {
                 postProcessor.Add(entry.Value, result);
             }
         }
         else
         {
             foreach (var entry in submap)
             {
                 var set = (ISet <EventBean>)entry.Value;
                 result.AddAll(set);
             }
         }
     }
     else
     {
         foreach (var entry in submap)
         {
             var index = (OrderedDictionary <object, object>)entry.Value;
             _next.Lookup(index, result, postProcessor);
         }
     }
 }