public ISet <MultiKey <EventBean> > StaticJoin() { var result = new LinkedHashSet <MultiKey <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 DataCacheClearableMap[_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) { var streamEvents = historicalViewable.GetEnumerator(); for (; streamEvents.MoveNext();) { lookupEvents[0] = streamEvents.Current; _queryStrategies[stream].Lookup(lookupEvents, result, _staticEvalExprEvaluatorContext); } } } else { var streamEvents = _streamViews[stream].GetEnumerator(); for (; streamEvents.MoveNext();) { lookupEvents[0] = streamEvents.Current; _queryStrategies[stream].Lookup(lookupEvents, result, _staticEvalExprEvaluatorContext); } } } } finally { DeassignThreadLocalCache(_streamViews, caches); } return(result); }
private void AssignThreadLocalCache(Viewable[] streamViews, DataCacheClearableMap[] caches) { for (var stream = 0; stream < streamViews.Length; stream++) { if (streamViews[stream] is HistoricalEventViewable) { var historicalViewable = (HistoricalEventViewable)streamViews[stream]; caches[stream] = new DataCacheClearableMap(); historicalViewable.DataCacheThreadLocal.Value = caches[stream]; } } }