public void TestAddMergeViews() { IList <ViewSpec> specOne = SupportViewSpecFactory.MakeSpecListOne(); ViewServiceHelper.AddMergeViews(specOne); Assert.AreEqual(3, specOne.Count); IList <ViewSpec> specFour = SupportViewSpecFactory.MakeSpecListTwo(); ViewServiceHelper.AddMergeViews(specFour); Assert.AreEqual(3, specFour.Count); Assert.AreEqual("merge", specFour[2].ObjectName); Assert.AreEqual(specFour[0].ObjectParameters.Count, specFour[1].ObjectParameters.Count); }
public ViewFactoryChain CreateFactories(int streamNum, EventType parentEventType, ViewSpec[] viewSpecDefinitions, StreamSpecOptions options, StatementContext context, bool isSubquery, int subqueryNumber) { // Clone the view spec list to prevent parameter modification IList <ViewSpec> viewSpecList = new List <ViewSpec>(viewSpecDefinitions); // Inspect views and add merge views if required ViewServiceHelper.AddMergeViews(viewSpecList); // Instantiate factories, not making them aware of each other yet var viewFactories = ViewServiceHelper.InstantiateFactories(streamNum, viewSpecList, context, isSubquery, subqueryNumber); ViewFactory parentViewFactory = null; IList <ViewFactory> attachedViewFactories = new List <ViewFactory>(); for (var i = 0; i < viewFactories.Count; i++) { var factoryToAttach = viewFactories[i]; try { factoryToAttach.Attach(parentEventType, context, parentViewFactory, attachedViewFactories); attachedViewFactories.Add(viewFactories[i]); parentEventType = factoryToAttach.EventType; } catch (ViewParameterException ex) { var text = "Error attaching view to parent view"; if (i == 0) { text = "Error attaching view to event stream"; } throw new ViewProcessingException(text + ": " + ex.Message, ex); } } // obtain count of data windows var dataWindowCount = 0; var firstNonDataWindowIndex = -1; for (var i = 0; i < viewFactories.Count; i++) { var factory = viewFactories[i]; if (factory is DataWindowViewFactory) { dataWindowCount++; continue; } if ((factory is GroupByViewFactoryMarker) || (factory is MergeViewFactory)) { continue; } if (firstNonDataWindowIndex == -1) { firstNonDataWindowIndex = i; } } var isAllowMultipleExpiry = context.ConfigSnapshot.EngineDefaults.ViewResources.IsAllowMultipleExpiryPolicies; var isRetainIntersection = options.IsRetainIntersection; var isRetainUnion = options.IsRetainUnion; // Set the default to retain-intersection unless allow-multiple-expiry is turned on if ((!isAllowMultipleExpiry) && (!isRetainUnion)) { isRetainIntersection = true; } // handle multiple data windows with retain union. // wrap view factories into the union view factory and handle a group-by, if present if ((isRetainUnion || isRetainIntersection) && dataWindowCount > 1) { viewFactories = GetRetainViewFactories(parentEventType, viewFactories, isRetainUnion, context); } return(new ViewFactoryChain(parentEventType, viewFactories)); }