private static IContainer CreateContainer() { var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; var container = ContainerExtensions.CreateDefaultContainer(false); container.Register <IResourceManager>( xx => new DefaultResourceManager( true, Path.GetFullPath(Path.Combine(baseDirectory, "..", "..", "..", "etc")), Path.GetFullPath(Path.Combine(baseDirectory, "..", "..", "..", "..", "etc")), Path.GetFullPath(Path.Combine(baseDirectory, "..", "..", "..", "..", "..", "etc"))), Lifespan.Singleton); SupportEventTypeFactory.RegisterSingleton(container); SupportExprNodeFactory.RegisterSingleton(container); SupportDatabaseService.RegisterSingleton(container); SupportJoinResultNodeFactory.RegisterSingleton(container); container .InitializeDefaultServices() .InitializeDatabaseDrivers() .RegisterDatabaseDriver(typeof(DbDriverPgSQL)); return(container); }
public void TestFlow() { // Lookup from s0 Cursor[] cursors = Read(_repository.GetCursors(0)); Assert.AreEqual(1, cursors.Length); ICollection <EventBean> resultsS1 = SupportJoinResultNodeFactory.MakeEventSet(2); _repository.AddResult(cursors[0], resultsS1, 1); // Lookup from s1 cursors = Read(_repository.GetCursors(1)); Assert.AreEqual(2, cursors.Length); ICollection <EventBean>[] resultsS2 = SupportJoinResultNodeFactory.MakeEventSets(new[] { 2, 3 }); _repository.AddResult(cursors[0], resultsS2[0], 2); _repository.AddResult(cursors[1], resultsS2[1], 2); // Lookup from s2 cursors = Read(_repository.GetCursors(2)); Assert.AreEqual(5, cursors.Length); // 2 + 3 for s2 ICollection <EventBean>[] resultsS3 = SupportJoinResultNodeFactory.MakeEventSets(new[] { 2, 1, 3, 5, 1 }); _repository.AddResult(cursors[0], resultsS3[0], 3); _repository.AddResult(cursors[1], resultsS3[1], 3); _repository.AddResult(cursors[2], resultsS3[2], 3); _repository.AddResult(cursors[3], resultsS3[3], 3); _repository.AddResult(cursors[4], resultsS3[4], 3); // Lookup from s3 cursors = Read(_repository.GetCursors(3)); Assert.AreEqual(12, cursors.Length); }
public void TestProcess() { IList <Node>[] result = SupportJoinResultNodeFactory.MakeOneStreamResult(4, 1, 2, 2); _leafNode.Process(result, new List <EventBean[]>(), null); Assert.AreEqual(4, _parentNode.RowsList.Count); Assert.AreEqual(result[1][0].Events.First(), _parentNode.RowsList[0][1]); // compare event }
public void SetUp() { optAssemblyNode = new BranchOptionalAssemblyNode(1, 4); parentNode = new SupportJoinProcNode(-1, 4); parentNode.AddChild(optAssemblyNode); resultMultipleEvents = SupportJoinResultNodeFactory.MakeOneStreamResult(4, 1, 2, 1); // 2 nodes 1 event each for (1) resultSingleEvent = SupportJoinResultNodeFactory.MakeOneStreamResult(4, 1, 1, 1); // 1 nodes 1 event each for (1) }
public void TestFlowRequired() { _rootCartNodeOneReq.Init(null); EventBean[] stream2Events = SupportJoinResultNodeFactory.MakeEvents(2); // for identifying rows in cartesian product EventBean[] stream3Events = SupportJoinResultNodeFactory.MakeEvents(2); // for identifying rows in cartesian product EventBean[] stream4Events = SupportJoinResultNodeFactory.MakeEvents(2); // for identifying rows in cartesian product // Post result from 3, send 2 rows List <EventBean[]> resultFinalRows = new List <EventBean[]>(); EventBean[] childRow = new EventBean[5]; childRow[3] = stream3Events[0]; _rootCartNodeOneReq.Result(childRow, 3, null, null, resultFinalRows, null); childRow = new EventBean[5]; childRow[3] = stream3Events[1]; _rootCartNodeOneReq.Result(childRow, 3, null, null, resultFinalRows, null); // Post result from 2, send 2 rows childRow = new EventBean[5]; childRow[2] = stream2Events[0]; _rootCartNodeOneReq.Result(childRow, 2, null, null, resultFinalRows, null); childRow = new EventBean[5]; childRow[2] = stream2Events[1]; _rootCartNodeOneReq.Result(childRow, 2, null, null, resultFinalRows, null); // Post result from 4 childRow = new EventBean[5]; childRow[4] = stream4Events[0]; _rootCartNodeOneReq.Result(childRow, 4, null, null, resultFinalRows, null); childRow = new EventBean[5]; childRow[4] = stream4Events[1]; _rootCartNodeOneReq.Result(childRow, 4, null, null, resultFinalRows, null); // process posted rows (child rows were stored and are compared to find other rows to generate) _rootCartNodeOneReq.Process(null, resultFinalRows, null); // 5 generated rows: 2 (stream 2) + 2 (stream 3) + 1 (self, Node 2) Assert.AreEqual(8, _parentNode.RowsList.Count); EventBean[][] rowArr = SupportJoinResultNodeFactory.ConvertTo2DimArr(_parentNode.RowsList); EPAssertionUtil.AssertEqualsAnyOrder( new[] { new[] { null, null, stream2Events[0], stream3Events[0], stream4Events[0] }, new[] { null, null, stream2Events[0], stream3Events[1], stream4Events[0] }, new[] { null, null, stream2Events[1], stream3Events[0], stream4Events[0] }, new[] { null, null, stream2Events[1], stream3Events[1], stream4Events[0] }, new[] { null, null, stream2Events[0], stream3Events[0], stream4Events[1] }, new[] { null, null, stream2Events[0], stream3Events[1], stream4Events[1] }, new[] { null, null, stream2Events[1], stream3Events[0], stream4Events[1] }, new[] { null, null, stream2Events[1], stream3Events[1], stream4Events[1] }, }, rowArr); }
public virtual void SetUpCommon() { container = SupportContainer.Reset(); supportEventTypeFactorySupplier = Suppliers.Memoize(() => SupportEventTypeFactory.GetInstance(container)); supportExprNodeFactorySupplier = Suppliers.Memoize(() => SupportExprNodeFactory.GetInstance(container)); supportDatabaseServiceSupplier = Suppliers.Memoize(() => SupportDatabaseService.GetInstance(container)); supportJoinResultNodeFactorySupplier = Suppliers.Memoize(() => SupportJoinResultNodeFactory.GetInstance(container)); }
public void SetUp() { _optCartNode = new CartesianProdAssemblyNode(1, 4, true, new int[] { 0, 0, 0, 1 }); _parentNode = new SupportJoinProcNode(-1, 4); _parentNode.AddChild(_optCartNode); // add child nodes to indicate what sub-streams to build the cartesian product from _optCartNode.AddChild(new SupportJoinProcNode(2, 4)); _optCartNode.AddChild(new SupportJoinProcNode(3, 4)); _resultMultipleEvents = SupportJoinResultNodeFactory.MakeOneStreamResult(4, 1, 2, 1); // 2 nodes 1 event each for (1) _resultSingleEvent = SupportJoinResultNodeFactory.MakeOneStreamResult(4, 1, 1, 1); // 1 nodes 1 event each for (1) }
private static IList <EventBean[]> MakeRows(int numRows, int[] substreamsPopulated) { IList <EventBean[]> result = new List <EventBean[]>(); for (int i = 0; i < numRows; i++) { var row = new EventBean[NUM_COL]; for (int j = 0; j < substreamsPopulated.Length; j++) { int index = substreamsPopulated[j]; row[index] = SupportJoinResultNodeFactory.MakeEvent(); } result.Add(row); } return(result); }
public void TestFlow() { _optCartNode.Init(_resultMultipleEvents); EventBean[] stream2Events = SupportJoinResultNodeFactory.MakeEvents(2); // for identifying rows in cartesian product EventBean[] stream3Events = SupportJoinResultNodeFactory.MakeEvents(2); // for identifying rows in cartesian product Node nodeOne = _resultMultipleEvents[1][0]; EventBean eventOneStreamOne = nodeOne.Events.First(); Node nodeTwo = _resultMultipleEvents[1][1]; EventBean eventTwoStreamOne = nodeTwo.Events.First(); // generate an event row originating from child 1 List <EventBean[]> resultFinalRows = new List <EventBean[]>(); EventBean[] childRow = new EventBean[4]; // new rows for each result childRow[2] = stream2Events[0]; _optCartNode.Result(childRow, 2, eventOneStreamOne, nodeOne, resultFinalRows, null); // child is stream 2 childRow = new EventBean[4]; childRow[2] = stream2Events[1]; _optCartNode.Result(childRow, 2, eventOneStreamOne, nodeOne, resultFinalRows, null); // child is stream 2 // generate an event row originating from child 2 childRow = new EventBean[4]; childRow[3] = stream3Events[0]; _optCartNode.Result(childRow, 3, eventOneStreamOne, nodeOne, resultFinalRows, null); // child is stream 3 childRow = new EventBean[4]; childRow[3] = stream3Events[1]; _optCartNode.Result(childRow, 3, eventOneStreamOne, nodeOne, resultFinalRows, null); // child is stream 3 // process posted rows (child rows were stored and are compared to find other rows to generate) _optCartNode.Process(_resultMultipleEvents, resultFinalRows, null); // 5 generated rows: 2 (stream 2) + 2 (stream 3) + 1 (self, Node 2) Assert.AreEqual(5, _parentNode.RowsList.Count); EventBean[][] rowArr = SupportJoinResultNodeFactory.ConvertTo2DimArr(_parentNode.RowsList); EPAssertionUtil.AssertEqualsAnyOrder( new[] { new[] { null, eventOneStreamOne, stream2Events[0], stream3Events[0] }, new[] { null, eventOneStreamOne, stream2Events[0], stream3Events[1] }, new[] { null, eventOneStreamOne, stream2Events[1], stream3Events[0] }, new[] { null, eventOneStreamOne, stream2Events[1], stream3Events[1] }, new[] { null, eventTwoStreamOne, null, null }, }, rowArr); }
public static void TestChildResult(BaseAssemblyNode nodeUnderTest, SupportJoinProcNode mockParentNode) { EventBean[] childRow = new EventBean[4]; childRow[3] = SupportJoinResultNodeFactory.MakeEvent(); EventBean myEvent = SupportJoinResultNodeFactory.MakeEvent(); Node myNode = SupportJoinResultNodeFactory.MakeNode(3, 1); // indicate child result List <EventBean[]> resultFinalRows = new List <EventBean[]>(); nodeUnderTest.Result(childRow, 3, myEvent, myNode, resultFinalRows, null); // assert parent node got the row Assert.AreEqual(1, mockParentNode.RowsList.Count); EventBean[] resultRow = mockParentNode.RowsList[0]; // assert the node has added his event to the row Assert.AreEqual(myEvent, resultRow[1]); }
public void TestFlowOptional() { RootCartProdAssemblyNode rootCartNodeAllOpt = (RootCartProdAssemblyNode) new RootCartProdAssemblyNodeFactory(1, 5, true).MakeAssemblerUnassociated(); rootCartNodeAllOpt.AddChild(new SupportJoinProcNode(2, 5)); rootCartNodeAllOpt.AddChild(new SupportJoinProcNode(3, 5)); rootCartNodeAllOpt.AddChild(new SupportJoinProcNode(4, 5)); _parentNode.AddChild(rootCartNodeAllOpt); rootCartNodeAllOpt.Init(null); List <EventBean[]> resultFinalRows = new List <EventBean[]>(); rootCartNodeAllOpt.Process(null, resultFinalRows, null); // 5 generated rows: 2 (stream 2) + 2 (stream 3) + 1 (self, Node 2) Assert.AreEqual(1, _parentNode.RowsList.Count); EventBean[][] rowArr = SupportJoinResultNodeFactory.ConvertTo2DimArr(_parentNode.RowsList); EPAssertionUtil.AssertEqualsAnyOrder( new[] { new EventBean[] { null, null, null, null, null } }, rowArr); }
public void TestAddResult() { ICollection <EventBean> results = SupportJoinResultNodeFactory.MakeEventSet(2); _repository.AddResult(_repository.GetCursors(0).Advance(), results, 1); Assert.AreEqual(1, _repository.NodesPerStream[1].Count); try { _repository.AddResult(_repository.GetCursors(0).Advance(), new HashSet <EventBean>(), 1); Assert.Fail(); } catch (ArgumentException) { // expected } try { _repository.AddResult(_repository.GetCursors(0).Advance(), null, 1); Assert.Fail(); } catch (NullReferenceException) { // expected } }
public void TestCompute() { // test null IList <EventBean[]> rowsA = null; IList <EventBean[]> rowsB = null; TryCompute(rowsA, rowsB); Assert.IsTrue(_results.IsEmpty()); // test no rows A rowsA = new List <EventBean[]>(); TryCompute(rowsA, rowsB); Assert.IsTrue(_results.IsEmpty()); // test no rows B rowsA = null; rowsB = new List <EventBean[]>(); TryCompute(rowsA, rowsB); Assert.IsTrue(_results.IsEmpty()); // test side A one row, B empty rowsA = MakeRowsA(1); rowsB = null; TryCompute(rowsA, rowsB); Assert.AreEqual(1, _results.Count); EPAssertionUtil.AssertEqualsExactOrder(rowsA[0], _results[0]); // test side B one row, A empty rowsA = null; rowsB = MakeRowsB(1); TryCompute(rowsA, rowsB); Assert.AreEqual(1, _results.Count); EPAssertionUtil.AssertEqualsExactOrder(rowsB[0], _results[0]); // test A and B one row rowsA = MakeRowsA(1); rowsB = MakeRowsB(1); TryCompute(rowsA, rowsB); Assert.AreEqual(1, _results.Count); EPAssertionUtil.AssertEqualsExactOrder( new[] { rowsA[0][0], rowsB[0][1], null, rowsA[0][3] }, _results[0]); // test A=2 rows and B=1 row rowsA = MakeRowsA(2); rowsB = MakeRowsB(1); TryCompute(rowsA, rowsB); Assert.AreEqual(2, _results.Count); EPAssertionUtil.AssertEqualsAnyOrder( new[] { new[] { rowsA[0][0], rowsB[0][1], null, rowsA[0][3] }, new[] { rowsA[1][0], rowsB[0][1], null, rowsA[1][3] } }, SupportJoinResultNodeFactory.ConvertTo2DimArr(_results)); // test A=1 rows and B=2 row rowsA = MakeRowsA(1); rowsB = MakeRowsB(2); TryCompute(rowsA, rowsB); Assert.AreEqual(2, _results.Count); EPAssertionUtil.AssertEqualsAnyOrder( new[] { new[] { rowsA[0][0], rowsB[0][1], null, rowsA[0][3] }, new[] { rowsA[0][0], rowsB[1][1], null, rowsA[0][3] } }, SupportJoinResultNodeFactory.ConvertTo2DimArr(_results)); // test A=2 rows and B=2 row rowsA = MakeRowsA(2); rowsB = MakeRowsB(2); TryCompute(rowsA, rowsB); Assert.AreEqual(4, _results.Count); EPAssertionUtil.AssertEqualsAnyOrder( new[] { new[] { rowsA[0][0], rowsB[0][1], null, rowsA[0][3] }, new[] { rowsA[0][0], rowsB[1][1], null, rowsA[0][3] }, new[] { rowsA[1][0], rowsB[0][1], null, rowsA[1][3] }, new[] { rowsA[1][0], rowsB[1][1], null, rowsA[1][3] } }, SupportJoinResultNodeFactory.ConvertTo2DimArr(_results)); // test A=2 rows and B=3 row rowsA = MakeRowsA(2); rowsB = MakeRowsB(3); TryCompute(rowsA, rowsB); Assert.AreEqual(6, _results.Count); EPAssertionUtil.AssertEqualsAnyOrder( new[] { new[] { rowsA[0][0], rowsB[0][1], null, rowsA[0][3] }, new[] { rowsA[0][0], rowsB[1][1], null, rowsA[0][3] }, new[] { rowsA[0][0], rowsB[2][1], null, rowsA[0][3] }, new[] { rowsA[1][0], rowsB[0][1], null, rowsA[1][3] }, new[] { rowsA[1][0], rowsB[1][1], null, rowsA[1][3] }, new[] { rowsA[1][0], rowsB[2][1], null, rowsA[1][3] } }, SupportJoinResultNodeFactory.ConvertTo2DimArr(_results)); }