Exemplo n.º 1
0
        public void testAndPipeBasic2()
        {
            var _Names 			= new List<String>() { "marko", "povel", "peter", "povel", "marko" };
            var _Pipe1 			= new ObjectFilterPipe<String>("marko", ComparisonFilter.NOT_EQUAL);
            var _Pipe2 			= new ObjectFilterPipe<String>("marko", ComparisonFilter.NOT_EQUAL);
            var _AndFilterPipe 	= new AndFilterPipe<String>(new HasNextPipe<String>(_Pipe1), new HasNextPipe<String>(_Pipe2));
            _AndFilterPipe.SetSourceCollection(_Names);

            var _Counter = 0;
            while (_AndFilterPipe.MoveNext())
                _Counter++;

            Assert.AreEqual(2, _Counter);
        }
Exemplo n.º 2
0
        public void testAndOrPipeGraph()
        {
            // ./outE[@label='created' or (@label='knows' and @weight > 0.5)]

            var _Graph 		= TinkerGraphFactory.CreateTinkerGraph();
            var _Marko 		= _Graph.VertexById(1);

            var _Pipe1 		= new OutEdgesPipe   <UInt64, Int64, String, String, Object,
                                                  UInt64, Int64, String, String, Object,
                                                  UInt64, Int64, String, String, Object,
                                                  UInt64, Int64, String, String, Object>();

            var _PipeA 		= new EdgeLabelFilterPipe<UInt64, Int64, String, String, Object,
                                                      UInt64, Int64, String, String, Object,
                                                      UInt64, Int64, String, String, Object,
                                                      UInt64, Int64, String, String, Object>(v => v != "created");

            var _PipeB 		= new EdgeLabelFilterPipe<UInt64, Int64, String, String, Object,
                                                      UInt64, Int64, String, String, Object,
                                                      UInt64, Int64, String, String, Object,
                                                      UInt64, Int64, String, String, Object>(v => v != "knows");

            var _PipeC 		= new EdgePropertyFilterPipe<UInt64, Int64, String, String, Object,
                                                         UInt64, Int64, String, String, Object,
                                                         UInt64, Int64, String, String, Object,
                                                         UInt64, Int64, String, String, Object>("weight", v => (0.5).Equals(v));

            var _PipeD 		= new AndFilterPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                                     UInt64, Int64, String, String, Object,
                                                                     UInt64, Int64, String, String, Object,
                                                                     UInt64, Int64, String, String, Object>>(

                                  new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object>>(_PipeB),
                                  new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object>>(_PipeC));

            var _Pipe2 = new OrFilterPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                               UInt64, Int64, String, String, Object,
                                                               UInt64, Int64, String, String, Object,
                                                               UInt64, Int64, String, String, Object>>(

                                  new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object>>(_PipeA),
                                  new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object>>(_PipeD));

            var _Pipeline 	= new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                  UInt64, Int64, String, String, Object,
                                                                  UInt64, Int64, String, String, Object,
                                                                  UInt64, Int64, String, String, Object>,

                                           IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                                UInt64, Int64, String, String, Object,
                                                                UInt64, Int64, String, String, Object,
                                                                UInt64, Int64, String, String, Object>>(_Pipe1, _Pipe2);

            _Pipeline.SetSourceCollection(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object>>() { _Marko });

            int _Counter = 0;
            while (_Pipeline.MoveNext())
            {
                var _Edge = _Pipeline.Current;
                Assert.IsTrue(_Edge.Id.Equals(8) || _Edge.Id.Equals(9));
                Assert.IsTrue(_Edge.Label.Equals("created") || (((Double)_Edge.GetProperty("weight")) > 0.5 && _Edge.Label.Equals("knows")));
                _Counter++;
            }

            Assert.AreEqual(2, _Counter);
        }
Exemplo n.º 3
0
        public void testFutureFilterGraph()
        {
            // ./outE[@label='created']/inV[@name='lop']/../../@name

            var _Graph      = TinkerGraphFactory.CreateTinkerGraph();
            var _Marko      = _Graph.VertexById(1);

            var _PipeA      = new OutEdgesPipe   <UInt64, Int64, String, String, Object,
                                                  UInt64, Int64, String, String, Object,
                                                  UInt64, Int64, String, String, Object,
                                                  UInt64, Int64, String, String, Object>();

            var _PipeB      = new EdgeLabelFilterPipe<UInt64, Int64, String, String, Object,
                                                      UInt64, Int64, String, String, Object,
                                                      UInt64, Int64, String, String, Object,
                                                      UInt64, Int64, String, String, Object>(v => v != "created");

            var _PipeC      = new InVertexPipe   <UInt64, Int64, String, String, Object,
                                                  UInt64, Int64, String, String, Object,
                                                  UInt64, Int64, String, String, Object,
                                                  UInt64, Int64, String, String, Object>();

            var _PipeD      = new VertexPropertyFilterPipe<UInt64, Int64, String, String, Object,
                                                           UInt64, Int64, String, String, Object,
                                                           UInt64, Int64, String, String, Object,
                                                           UInt64, Int64, String, String, Object>("name", v => v == "lop");

            var _Pipe1      = new AndFilterPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object>>(

                                  new HasNextPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                         UInt64, Int64, String, String, Object,
                                                                         UInt64, Int64, String, String, Object,
                                                                         UInt64, Int64, String, String, Object>>(

                                  new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                      UInt64, Int64, String, String, Object,
                                                                      UInt64, Int64, String, String, Object,
                                                                      UInt64, Int64, String, String, Object>,

                                               IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                      UInt64, Int64, String, String, Object,
                                                                      UInt64, Int64, String, String, Object,
                                                                      UInt64, Int64, String, String, Object>>(_PipeA, _PipeB, _PipeC, _PipeD)));

            var _Pipe2      = new PropertyPipe<String, Object>(Keys: "name");

            var _Pipeline   = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                  UInt64, Int64, String, String, Object,
                                                                  UInt64, Int64, String, String, Object,
                                                                  UInt64, Int64, String, String, Object>, String>(_Pipe1, _Pipe2);

            _Pipeline.SetSourceCollection(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object>>() { _Marko });

            var _Counter = 0;
            while (_Pipeline.MoveNext())
            {
                var name = _Pipeline.Current;
                Assert.AreEqual("marko", name);
                _Counter++;
            }

            Assert.AreEqual(1, _Counter);
        }
Exemplo n.º 4
0
        public void testComplexFutureFilterGraph()
        {
            // ./outE[@weight > 0.5]/inV/../../outE/inV/@name

            var _Graph      = TinkerGraphFactory.CreateTinkerGraph();
            var _Marko      = _Graph.VertexById(1);

            var _PipeA      = new OutEdgesPipe<UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object>();

            var _PipeB      = new EdgePropertyFilterPipe<UInt64, Int64, String, String, Object,
                                                         UInt64, Int64, String, String, Object,
                                                         UInt64, Int64, String, String, Object,
                                                         UInt64, Int64, String, String, Object>("weight", v => (0.5).Equals(v));

            var _PipeC      = new InVertexPipe<UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object>();

            var _Pipe1      = new AndFilterPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object,
                                                                       UInt64, Int64, String, String, Object>>(

                                  new HasNextPipe<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                         UInt64, Int64, String, String, Object,
                                                                         UInt64, Int64, String, String, Object,
                                                                         UInt64, Int64, String, String, Object>>(

                                      new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object>,

                                                   IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object>>(_PipeA, _PipeB, _PipeC)));

            var _Pipe2      = new OutEdgesPipe<UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object>();

            var _Pipe3      = new InVertexPipe<UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object,
                                               UInt64, Int64, String, String, Object>();

            var _Pipe4      = new PropertyPipe<String, Object>(Keys: "name");

            var _Pipeline   = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                  UInt64, Int64, String, String, Object,
                                                                  UInt64, Int64, String, String, Object,
                                                                  UInt64, Int64, String, String, Object>, String>(_Pipe1, _Pipe2, _Pipe3, _Pipe4);

            _Pipeline.SetSourceCollection(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object>>() { _Marko });

            var _Counter = 0;
            while (_Pipeline.MoveNext())
            {
                var _Name = _Pipeline.Current;
                Assert.IsTrue(_Name.Equals("vadas") || _Name.Equals("lop") || _Name.Equals("josh"));
                _Counter++;
            }

            Assert.AreEqual(3, _Counter);
        }
Exemplo n.º 5
0
        public void testAndPipeGraph()
        {
            var _Graph 			= TinkerGraphFactory.CreateTinkerGraph();
            var _Marko 			= _Graph.VertexById(1);
            var _Peter 			= _Graph.VertexById(6);

            var _Pipe0 			= new OutEdgesPipe<UInt64, Int64, String, String, Object,
                                                   UInt64, Int64, String, String, Object,
                                                   UInt64, Int64, String, String, Object,
                                                   UInt64, Int64, String, String, Object>();

            var _Pipe1 			= new EdgeLabelFilterPipe<UInt64, Int64, String, String, Object,
                                                          UInt64, Int64, String, String, Object,
                                                          UInt64, Int64, String, String, Object,
                                                          UInt64, Int64, String, String, Object>(v => v != "knows");

            var _Pipe2 			= new EdgePropertyFilterPipe<UInt64, Int64, String, String, Object,
                                                             UInt64, Int64, String, String, Object,
                                                             UInt64, Int64, String, String, Object,
                                                             UInt64, Int64, String, String, Object>("weight", v => (0.5).Equals(v));

            var _AndFilterPipe	= new AndFilterPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                                         UInt64, Int64, String, String, Object,
                                                                         UInt64, Int64, String, String, Object,
                                                                         UInt64, Int64, String, String, Object>>(

                                      new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                                           UInt64, Int64, String, String, Object,
                                                                           UInt64, Int64, String, String, Object,
                                                                           UInt64, Int64, String, String, Object>>(_Pipe1),

                                      new HasNextPipe<IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                                           UInt64, Int64, String, String, Object,
                                                                           UInt64, Int64, String, String, Object,
                                                                           UInt64, Int64, String, String, Object>>(_Pipe2));

            var _Pipeline = new Pipeline<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                UInt64, Int64, String, String, Object,
                                                                UInt64, Int64, String, String, Object,
                                                                UInt64, Int64, String, String, Object>,

                                               IGenericPropertyEdge<UInt64, Int64, String, String, Object,
                                                                    UInt64, Int64, String, String, Object,
                                                                    UInt64, Int64, String, String, Object,
                                                                    UInt64, Int64, String, String, Object>>(_Pipe0, _AndFilterPipe);

            _Pipeline.SetSourceCollection(new List<IGenericPropertyVertex<UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object,
                                                                          UInt64, Int64, String, String, Object>>() { _Marko, _Peter, _Marko });

            var _Counter = 0;
            while (_Pipeline.MoveNext())
            {
                var _Edge = _Pipeline.Current;
                Assert.IsTrue(_Edge.Id.Equals(8));
                Assert.IsTrue(((Double)_Edge.GetProperty("weight")) > 0.5f && _Edge.Label.Equals("knows"));
                _Counter++;
            }

            Assert.AreEqual(2, _Counter);
        }