Exemplo n.º 1
0
 private void AssignThreadLocalCache(
     Viewable[] streamViews,
     HistoricalDataCacheClearableMap[] caches)
 {
     for (var stream = 0; stream < streamViews.Length; stream++) {
         if (streamViews[stream] is HistoricalEventViewable) {
             var historicalViewable = (HistoricalEventViewable) streamViews[stream];
             caches[stream] = new HistoricalDataCacheClearableMap();
             historicalViewable.DataCacheThreadLocal.Value = caches[stream];
         }
     }
 }
Exemplo n.º 2
0
        public ISet<MultiKeyArrayOfKeys<EventBean>> StaticJoin()
        {
            ISet<MultiKeyArrayOfKeys<EventBean>> result = new LinkedHashSet<MultiKeyArrayOfKeys<EventBean>>();
            var lookupEvents = new EventBean[1];

            // Assign a local cache for the thread's evaluation of the join
            // This ensures that if a SQL/method generates a row for a result set based on an input parameter, the event instance is the same
            // in the join, and thus the same row does not appear twice.
            var caches = new HistoricalDataCacheClearableMap[QueryStrategies.Length];
            AssignThreadLocalCache(streamViews, caches);

            // perform join
            try {
                // for each stream, perform query strategy
                for (var stream = 0; stream < QueryStrategies.Length; stream++) {
                    if (streamViews[stream] is HistoricalEventViewable) {
                        var historicalViewable = (HistoricalEventViewable) streamViews[stream];
                        if (historicalViewable.HasRequiredStreams) {
                            continue;
                        }

                        // there may not be a query strategy since only a full outer join may need to consider all rows
                        if (QueryStrategies[stream] != null) {
                            IEnumerator<EventBean> streamEvents = historicalViewable.GetEnumerator();
                            for (; streamEvents.MoveNext();) {
                                lookupEvents[0] = streamEvents.Current;
                                QueryStrategies[stream].Lookup(lookupEvents, result, staticEvalExprEvaluatorContext);
                            }
                        }
                    }
                    else {
                        IEnumerator<EventBean> streamEvents = streamViews[stream].GetEnumerator();
                        for (; streamEvents.MoveNext();) {
                            lookupEvents[0] = streamEvents.Current;
                            QueryStrategies[stream].Lookup(lookupEvents, result, staticEvalExprEvaluatorContext);
                        }
                    }
                }
            }
            finally {
                DeassignThreadLocalCache(streamViews, caches);
            }

            return result;
        }