Exemplo n.º 1
0
        public void TestExecuteCommandText()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "Modern", GraphType.GraphAPIOnly, AbstractGremlinTest.TEST_USE_REVERSE_EDGE, 1, AbstractGremlinTest.TEST_PARTITION_BY_KEY);
            GraphViewCommand graph = new GraphViewCommand(connection);


            //Regex arrayRegex = new Regex("[\\[](\\s*?[\\\"|']\\w+[\\\"|']\\s*?[,]*?\\s*?)+[\\]]", RegexOptions.Multiline);
            //string testText = "constant(['_name','_properties']),__.select('#v1').as('#a').constant(['_name','_properties']),__.select('#v2').as('#a').constant(['_name','_properties']),__.select('#v3').as('#a').constant(['_name','_properties'])).as('#p'),__.select('#e').union(__.select('#e0'),__.select('#e1'),__.select('#e2'),__.select('#e3'),__.select('#e4'),__.select('#e5')).as('#f').union(__.inV().as('#a').select('#f').outV(),__.outV().as('#a').select('#f').";
            //if (arrayRegex.IsMatch(testText))
            //{
            //    var match = arrayRegex.Match(testText);
            //    //sCSCode = sCSCode.Replace(match.Groups[1].Value);
            //}

            graph.CommandText =
                "g.V().has('_app','test-app').has('_id','test-app').hasLabel('application').coalesce(__.union(__.not(__.V().has('_app','test-app').has('_id','test-app').hasLabel('application')).constant('~0'),__.V().has('_app','test-app').has('_id','test-app').hasLabel('application').has('_provisioningState',0).constant('~1'),__.V().has('_app','test-app').has('_id','test-app').hasLabel('application').has('_provisioningState',2).constant('~2'),__.V().has('_app','test-app').has('_id','test-app').hasLabel('application').has('_deleted',true).constant('~3')),__.flatMap(__.V().has('_app','test-app').has('_id','uber-product:soda-machine:shop-3').hasLabel('product').range(0,100).union(__.identity().sideEffect(__.id().store('^ids')),__.as('@v').flatMap(__.optional(__.out('mdl')).outE('ref')).repeat(__.as('@e').flatMap(__.inV().as('mdl').select(last,'@v').both().dedup().and(__.optional(__.out('mdl')).where(eq('mdl')))).as('@v').optional(__.flatMap(__.select(last,'@e').values('_ref').as('key').select(last,'@v').optional(__.out('mdl')).outE('ref').and(__.values('_key').where(eq('key')))))).until(__.flatMap(__.as('res').select(last,'@v').where(eq('res')))).sideEffect(__.project('data','info').by(__.select('@e').unfold().project('key','ref').by(__.values('_key')).by(__.values('_ref')).fold()).by(__.select('@v').unfold().project('id','type','etag').by(__.values('_id')).by(__.label()).by(__.values('_etag')).fold()).store('^refs'))).dedup().union(__.identity().sideEffect(__.group('^mdls').by(__.id()).by(__.coalesce(__.out('mdl').values('_id'),__.constant('')))),__.out('mdl')).dedup()).union(__.emit().repeat(__.outE('_val').as('_').inV()).tree(),__.cap('^ids'),__.cap('^mdls'),__.cap('^refs')).fold())";

            var results = graph.Execute();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 2
0
        public void ProjectTest()
        {
            //          GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
            //"MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
            //"GroupMatch", "MarvelTest");
            //          GraphViewCommand cmd = new GraphViewCommand(connection);
            //          //cmd.CommandText = "g.V().project('c', 'u').by('|provisioning').by('|provisioning').where('c', gt('u'))";
            //          //cmd.CommandText = "g.V().project('c').by('|provisioning')";
            //          cmd.CommandText = "g.V().has('weapon', 'lasso').as('character').out('appeared').as('comicbook').select('comicbook').next()";
            //          cmd.OutputFormat = OutputFormat.GraphSON;
            //          var results = cmd.Execute();
            //          foreach (var result in results)
            //          {
            //              Console.WriteLine(result);
            //          }

            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest");
            GraphViewCommand graph = new GraphViewCommand(connection);

            //graph.CommandText = "g.V().has('weapon', 'lasso').as('character').out('appeared').as('comicbook').select('comicbook').next()";
            //graph.CommandText = "g.V().project('c', 'u').by('|provisioning').by('|provisioning').where('c', gt('u'))";
            //graph.CommandText = "g.V().Where(GraphTraversal2.__().As('a').Values('name').Is('josh'))";
            graph.CommandText  = "g.V().where('c')";
            graph.OutputFormat = OutputFormat.GraphSON;
            var results = graph.Execute();

            foreach (string result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 3
0
        public void runQuery(int queryNum)
        {
            string line;

            // Read the file and display it line by line.
            System.IO.StreamReader file =
                new System.IO.StreamReader("D:\\project\\GraphView_11_29\\DocDB-merge2\\query_processed\\" + queryNum + ".txt");
            line = file.ReadLine();
            file.Close();

            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest");

            GraphViewCommand cmd = new GraphViewCommand(connection);

            cmd.CommandText  = line;
            cmd.OutputFormat = OutputFormat.GraphSON;
            var results = cmd.Execute();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 4
0
        public void queryTest44()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest", GraphType.GraphAPIOnly, AbstractGremlinTest.TEST_USE_REVERSE_EDGE, 1, AbstractGremlinTest.TEST_PARTITION_BY_KEY);
            //connection.ResetCollection();
            GraphViewCommand cmd = new GraphViewCommand(connection);

            cmd.OutputFormat = OutputFormat.GraphSON;
            //cmd.CommandText = "g.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3')),__.flatMap(__.project('vertices','edges').by(__.constant()).by(__.union(g.E().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','product-to-device-1').has('|v0',1).has('|v1',0).hasLabel('instance')).fold()).sideEffect(__.select('edges').unfold().union(__.identity(),__.hasLabel('model').as('eM').inV().as('end').select('eM').outV().BothE('ref').and(__.otherV().where(eq('end')))).project('edge','source','target').by().by(__.outV().id()).by(__.inV().id()).store('^edges')).union(__.select('vertices').unfold().sideEffect(__.id().store('^ids')),__.select('edges').unfold().union(__.inV(),__.outV())).dedup().union(__.identity(),__.as('@v').flatMap(__.optional(__.out('mdl')).outE('ref')).repeat(__.as('@e').flatMap(__.inV().as('mdl').select(last,'@v').both().dedup().and(__.optional(__.out('mdl')).where(eq('mdl')))).as('@v').optional(__.flatMap(__.select(last,'@e').values('|ref:propertyId').as('key').select(last,'@v').optional(__.out('mdl')).outE('ref').and(__.values('/_id').where(eq('key')))))).until(__.flatMap(__.as('res').select(last,'@v').where(eq('res')))).sideEffect(__.project('segments','targets').by(__.select('@e').unfold().fold()).by(__.select('@v').unfold().project('label','/_id','|v0','|v1').by(__.label()).by(__.values('/_id')).by(__.values('|v0')).by(__.values('|v1')).fold()).store('^refs'))).dedup().union(__.identity().sideEffect(__.group('^mdls').by(__.id()).by(__.coalesce(__.out('mdl').id(),__.constant('')))),__.out('mdl')).dedup()).union(__.emit().repeat(__.outE('_val').as('_').inV()).tree(),__.cap('^ids'),__.cap('^mdls'),__.cap('^refs')).fold().union(__.identity(),__.cap('^edges')))";
            // (1) extract the top error sub query
            //cmd.CommandText = "g.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3')),__.flatMap(__.project('vertices','edges').by(__.constant()).by(__.union(g.E().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','product-to-device-1').has('|v0',1).has('|v1',0).hasLabel('instance')).fold()).sideEffect(__.select('edges').unfold().union(__.identity(),__.hasLabel('model').as('eM').inV().as('end').select('eM').outV().BothE('ref').and(__.otherV().where(eq('end')))).project('edge','source','target').by().by(__.outV().id()).by(__.inV().id()).store('^edges')).union(__.select('vertices').unfold().sideEffect(__.id().store('^ids')),__.select('edges').unfold().union(__.inV(),__.outV()))))";
            // (2) Remove the union out of it
            //cmd.CommandText = "g.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3')),__.flatMap(__.project('vertices','edges').by(__.constant()).by(__.union(g.E().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','product-to-device-1').has('|v0',1).has('|v1',0).hasLabel('instance')).fold()).sideEffect(__.select('edges').unfold().union(__.identity(),__.hasLabel('model').as('eM').inV().as('end').select('eM').outV().BothE('ref').and(__.otherV().where(eq('end')))).project('edge','source','target').by().by(__.outV().id()).by(__.inV().id()).store('^edges')).select('vertices').unfold().sideEffect(__.id().store('^ids'))))";
            // (3) Remove the first id op
            // remove unfold, also throw, when debug into unfold the pivot variable is also the scalar variable
            cmd.CommandText = "g.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3')),__.flatMap(__.project('vertices','edges').by(__.constant()).by(__.union(g.E().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','product-to-device-1').has('|v0',1).has('|v1',0).hasLabel('instance')).fold()).sideEffect(__.select('edges').unfold().union(__.identity(),__.hasLabel('model').as('eM').inV().as('end').select('eM').outV().BothE('ref').and(__.otherV().where(eq('end'))))).id()))";
            //cmd.CommandText = "g.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3')),__.flatMap(__.project('vertices','edges').by(__.constant()).by(__.union(g.E().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','product-to-device-1').has('|v0',1).has('|v1',0).hasLabel('instance')).fold()).sideEffect(__.select('edges').unfold().union(__.identity(),__.hasLabel('model').as('eM').inV().as('end').select('eM').outV().BothE('ref').and(__.otherV().where(eq('end')))).project('edge','source','target').by().by(__.outV().id()).by(__.inV().id()).store('^edges')).id()))";
            //cmd.CommandText = "g.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3')),__.flatMap(__.project('vertices','edges').by(__.constant()).by(__.union(g.E().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','product-to-device-1').has('|v0',1).has('|v1',0).hasLabel('instance')).fold()).sideEffect(__.select('edges').unfold().union(__.identity(),__.hasLabel('model').as('eM').inV().as('end').select('eM').outV().BothE('ref').and(__.otherV().where(eq('end')))).project('edge','source','target').by().by(__.outV().id()).by(__.inV().id()).store('^edges'))))";
            // The reason is that the unfold operator make the data to the Scalar type
            //cmd.CommandText = "g.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3')),__.flatMap(__.project('vertices','edges').by(__.constant()).by(__.union(g.E().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','product-to-device-1').has('|v0',1).has('|v1',0).hasLabel('instance')).fold()).sideEffect(__.select('edges').unfold().union(__.identity(),__.hasLabel('model').as('eM').inV().as('end').select('eM').outV().BothE('ref').and(__.otherV().where(eq('end')))).project('edge','source','target').by().by(__.outV().id()).by(__.inV().id()).store('^edges')).select('vertices').sideEffect(__.id().store('^ids'))))";
            // (4) Remove the store op
            //cmd.CommandText = "g.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3')),__.flatMap(__.project('vertices','edges').by(__.constant()).by(__.union(g.E().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','product-to-device-1').has('|v0',1).has('|v1',0).hasLabel('instance')).fold()).sideEffect(__.select('edges').unfold().union(__.identity(),__.hasLabel('model').as('eM').inV().as('end').select('eM').outV().BothE('ref').and(__.otherV().where(eq('end')))).project('edge','source','target').by().by(__.outV().id()).by(__.inV().id()))))";
            // (5) Make it to single column project
            //cmd.CommandText = "g.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3')),__.flatMap(__.project('vertices','edges').by(__.constant()).by(__.union(g.E().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','product-to-device-1').has('|v0',1).has('|v1',0).hasLabel('instance')).fold()).sideEffect(__.select('edges').unfold().union(__.identity(),__.hasLabel('model').as('eM').inV().as('end').select('eM').outV().BothE('ref').and(__.otherV().where(eq('end')))).project('edge').by(__.outV().id()))))";
            // (6)
            //cmd.CommandText = "g.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3')),__.flatMap(__.project('vertices','edges').by(__.constant()).by(__.union(g.E().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','product-to-device-1').has('|v0',1).has('|v1',0).hasLabel('instance')).fold()).sideEffect(__.select('edges').unfold().union(__.identity(),__.hasLabel('model').as('eM').inV().as('end').select('eM').outV().BothE('ref').and(__.otherV().where(eq('end')))))))";
            var results = cmd.Execute();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 5
0
        public async Task AddVertexTest()
        {
            GraphViewCommand cmd = new GraphViewCommand(graphConnection);

            cmd.OutputFormat = OutputFormat.GraphSON;
            cmd.CommandText  = "g.AddV('character').Property('name', 'VENUS II').Property('weapon', 'shield')";
            cmd.OutputFormat = OutputFormat.GraphSON;
            var results = cmd.Execute();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
        public void SelectMarvelQuery4b()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest");
            GraphViewCommand graph = new GraphViewCommand(connection);

            graph.CommandText = "g.V().has('name', 'AVF 4').in('appeared').has('weapon', 'shield').values('name').next()";
            var results = graph.Execute();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
        public void SelectMarvelQuery2b()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest");
            GraphViewCommand graph = new GraphViewCommand(connection);

            graph.CommandText  = "g.V().has('weapon', 'lasso').as('character').out('appeared').as('comicbook').select('comicbook').next()";
            graph.OutputFormat = OutputFormat.GraphSON;
            var results = graph.Execute();

            foreach (string result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 8
0
        public void SelectMarvelQuery4b()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest", GraphType.GraphAPIOnly, AbstractGremlinTest.TEST_USE_REVERSE_EDGE,
                                                                     AbstractGremlinTest.TEST_SPILLED_EDGE_THRESHOLD_VIAGRAPHAPI, null);
            GraphViewCommand graph = new GraphViewCommand(connection);

            graph.CommandText = "g.V().has('name', 'AVF 4').in('appeared').has('weapon', 'shield').values('name').next()";
            var results = graph.Execute();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 9
0
        public void queryTest63()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest", GraphType.GraphAPIOnly, AbstractGremlinTest.TEST_USE_REVERSE_EDGE, 1, AbstractGremlinTest.TEST_PARTITION_BY_KEY);
            //connection.ResetCollection();
            GraphViewCommand cmd = new GraphViewCommand(connection);

            cmd.OutputFormat = OutputFormat.GraphSON;
            // (1) the sub query
            cmd.CommandText = "g.inject(0).flatMap(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').drop())";
            var results = cmd.Execute();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 10
0
        public void queryTest2_41()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest", GraphType.GraphAPIOnly, AbstractGremlinTest.TEST_USE_REVERSE_EDGE, 1, AbstractGremlinTest.TEST_PARTITION_BY_KEY);
            //connection.ResetCollection();
            GraphViewCommand cmd = new GraphViewCommand(connection);

            cmd.OutputFormat = OutputFormat.GraphSON;
            // (1) the sub query, preprocess constant(["", ""]) should keep []
            cmd.CommandText = "g.inject(0).coalesce(__.union(__.not(__.V().has('|app','96289b06-c417-4757-beb0-7ba28412c203').hasLabel('application')).constant('~0'),__.V().has('|app','96289b06-c417-4757-beb0-7ba28412c203').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','96289b06-c417-4757-beb0-7ba28412c203').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','96289b06-c417-4757-beb0-7ba28412c203').hasLabel('application').has('|deleted',true).constant('~3'),__.not(__.V(303136).has('/etag','0001489626889687')).constant('~4'),__.not(__.V(352280).has('/etag','0001489626889687')).constant('~5'),__.not(__.V(327840).has('/etag','0001489626901249')).constant('~6'),__.not(__.V(327856).has('/etag','0001489626896965')).constant('~7')),__.project('#v0','#v1').by(__.V(303136).sideEffect(__.union(__.sideEffect(__.outE('_val').has('_key','device-property').inV().sideEffect(__.union(__.properties().drop(),__.repeat(__.out('_val')).emit().barrier().drop())).drop()).property('device-property','device-property-value-updated')))).by(__.V(327840).sideEffect(__.union(__.sideEffect(__.outE('_val').has('_key','product-property').inV().sideEffect(__.union(__.properties().drop(),__.repeat(__.out('_val')).emit().barrier().drop())).drop()).property('product-property','product-property-value-updated')))).as('#v').union(__.select('#v').union(__.V(303136).as('#a').constant('device-property'),__.V(327840).as('#a').constant('product-property','reference-property')).as('#p')).select('#a').union(__.identity(),__.as('@v').flatMap(__.optional(__.out('mdl')).inE('ref').and(__.values('|ref:propertyId').where(within('#p')))).repeat(__.as('@e').flatMap(__.outV().as('mdl').select(last,'@v').both().dedup().and(__.optional(__.out('mdl')).where(eq('mdl')))).as('@v').optional(__.flatMap(__.select(last,'@e').values('/_id').as('key').select(last,'@v').optional(__.out('mdl')).inE('ref').and(__.values('|ref:propertyId').where(eq('key')))))).until(__.flatMap(__.as('res').select(last,'@v').where(eq('res')))).select('@v').unfold()).dedup().property('/etag','0001489626902274').project('label','/_id','|v0','|v1').by(__.label()).by(__.values('/_id')).by(__.values('|v0')).by(__.values('|v1')))";
            var results = cmd.Execute();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 11
0
        public void SelectMarvelQuery1b()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest", GraphType.GraphAPIOnly, AbstractGremlinTest.TEST_USE_REVERSE_EDGE,
                                                                     AbstractGremlinTest.TEST_SPILLED_EDGE_THRESHOLD_VIAGRAPHAPI, null);

            GraphViewCommand cmd = new GraphViewCommand(connection);

            cmd.CommandText =
                "g.V().has('weapon','shield').as('character').out('appeared').as('comicbook').select('character').next()";
            cmd.OutputFormat = OutputFormat.GraphSON;
            var results = cmd.Execute();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 12
0
        public void ProjectTest()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest", GraphType.GraphAPIOnly, AbstractGremlinTest.TEST_USE_REVERSE_EDGE, 1, AbstractGremlinTest.TEST_PARTITION_BY_KEY);
            GraphViewCommand graph = new GraphViewCommand(connection);

            //graph.CommandText = "g.V().has('weapon', 'lasso').as('character').out('appeared').as('comicbook').select('comicbook').next()";
            //graph.CommandText = "g.V().project('c', 'u').by('|provisioning').by('|provisioning').where('c', gt('u'))";
            //graph.CommandText = "g.V().Where(GraphTraversal.__().As('a').Values('name').Is('josh'))";
            graph.CommandText  = "g.V().where('c')";
            graph.OutputFormat = OutputFormat.GraphSON;
            var results = graph.Execute();

            foreach (string result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 13
0
        public void queryTest48()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest", GraphType.GraphAPIOnly, AbstractGremlinTest.TEST_USE_REVERSE_EDGE, 1, AbstractGremlinTest.TEST_PARTITION_BY_KEY);
            //connection.ResetCollection();
            GraphViewCommand cmd = new GraphViewCommand(connection);

            cmd.OutputFormat = OutputFormat.GraphSON;
            // (1) the sub query
            //cmd.CommandText = "g.inject(0).coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3'),__.not(__.V(307424).outE().hasId('ayak-6l7k-f11-5pfk').has('/etag','nEszMsmsS8CindxZLzW09g==')).constant('~4'),__.not(__.V(307424).has('/etag','I9cr2GEAQraOsG8wFRBsww==')).constant('~5'),__.not(__.V(217320).has('/etag','vFSAV9c/Qn6b4IegSI4NMQ==')).constant('~6')),__.map(__.union(__.coalesce(__.V(307424).outE().hasId('ayak-6l7k-f11-5pfk'),__.constant(''))).fold()).as('#-e').map(__.union(__.V(307424).addE('instance').to(__.V(217320)).property('|app','ed011feb-0db1-40de-b633-9ec16b758259').property('/_id','parent-to-product').property('|v0',1).property('|v1',0).property('/_schemaVersion','1.0.0')).property('/etag','j5FJhuu8RMWqyfx42G0IUA==').fold()).as('#e').map(__.union(__.union(__.select('#-e'),__.select('#e')).unfold())))";
            // (2) sub query
            cmd.CommandText = "g.inject(0).coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3'),__.not(__.V(307424).outE().hasId('ayak-6l7k-f11-5pfk').has('/etag','nEszMsmsS8CindxZLzW09g==')).constant('~4'),__.not(__.V(307424).has('/etag','I9cr2GEAQraOsG8wFRBsww==')).constant('~5'),__.not(__.V(217320).has('/etag','vFSAV9c/Qn6b4IegSI4NMQ==')).constant('~6')),__.map(__.union(__.coalesce(__.V(307424).outE().hasId('ayak-6l7k-f11-5pfk'),__.constant(''))).fold()).as('#-e').map(__.union(__.V(307424).addE('instance').to(__.V(217320)).property('|app','ed011feb-0db1-40de-b633-9ec16b758259').property('/_id','parent-to-product').property('|v0',1).property('|v1',0).property('/_schemaVersion','1.0.0')).property('/etag','j5FJhuu8RMWqyfx42G0IUA==').fold()).as('#e').map(__.union(__.union(__.select('#-e'),__.select('#e')).unfold())))";

            var results = cmd.Execute();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 14
0
        public void queryTest51()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest", GraphType.GraphAPIOnly, AbstractGremlinTest.TEST_USE_REVERSE_EDGE, 1, AbstractGremlinTest.TEST_PARTITION_BY_KEY);
            //connection.ResetCollection();
            GraphViewCommand cmd = new GraphViewCommand(connection);

            cmd.OutputFormat = OutputFormat.GraphSON;
            // (1) the sub query
            cmd.CommandText = "g.inject(0).coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3'),__.V(221416).in('mdl').constant('~4')),__.map(__.union(__.coalesce(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','parent-model').has('|v0',1).has('|v1',0).hasLabel('model').sideEffect(__.union(__.properties().drop(),__.repeat(__.out('_val')).emit().barrier().drop())),__.constant(''))).fold()).as('#-v').map(__.union(__.select('#-v').unfold().as('#a').constant('').as('#p')).select('#a')))";
            // (2) sub query select('#p')
            //cmd.CommandText = "g.inject(0).coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3'),__.V(221416).in('mdl').constant('~4')),__.map(__.union(__.coalesce(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','parent-model').has('|v0',1).has('|v1',0).hasLabel('model').sideEffect(__.union(__.properties().drop(),__.repeat(__.out('_val')).emit().barrier().drop())),__.constant(''))).fold()).as('#-v').map(__.union(__.select('#-v').unfold().as('#a').constant('').as('#p')).select('#p')))";
            // (3) without constant operator, the reason is the #p override the previous #a mark
            //cmd.CommandText = "g.inject(0).coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3'),__.V(221416).in('mdl').constant('~4')),__.map(__.union(__.coalesce(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','parent-model').has('|v0',1).has('|v1',0).hasLabel('model').sideEffect(__.union(__.properties().drop(),__.repeat(__.out('_val')).emit().barrier().drop())),__.constant(''))).fold()).as('#-v').map(__.union(__.select('#-v').unfold().as('#a').as('#p')).select('#p')))";
            // (4) without constant the #P also can't find
            //cmd.CommandText = "g.inject(0).coalesce(__.union(__.not(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application')).constant('~0'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',0).constant('~1'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|provisioning',2).constant('~2'),__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').hasLabel('application').has('|deleted',true).constant('~3'),__.V(221416).in('mdl').constant('~4')),__.map(__.union(__.coalesce(__.V().has('|app','ed011feb-0db1-40de-b633-9ec16b758259').has('/_id','parent-model').has('|v0',1).has('|v1',0).hasLabel('model').sideEffect(__.union(__.properties().drop(),__.repeat(__.out('_val')).emit().barrier().drop())),__.constant(''))).fold()).as('#-v').map(__.union(__.select('#-v').unfold().as('#a').as('#p')).select('#p')))";
            var results = cmd.Execute();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 15
0
        public void GraphViewMarvelInsertTest()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest", GraphType.GraphAPIOnly, AbstractGremlinTest.TEST_USE_REVERSE_EDGE,
                                                                     AbstractGremlinTest.TEST_SPILLED_EDGE_THRESHOLD_VIAGRAPHAPI, null);
            GraphViewCommand cmd = new GraphViewCommand(connection);

            cmd.CommandText = "g.addV('character').property('name', 'VENUS II').property('weapon', 'shield').next()";
            cmd.Execute();
            cmd.CommandText = "g.addV('comicbook').property('name', 'AVF 4').next()";
            cmd.Execute();
            cmd.CommandText = "g.V().has('name', 'VENUS II').addE('appeared').to(g.V().has('name', 'AVF 4')).next()";
            cmd.Execute();
            cmd.CommandText = "g.addV('character').property('name', 'HAWK').property('weapon', 'claws').next()";
            cmd.Execute();
            cmd.CommandText = "g.V().as('v').has('name', 'HAWK').addE('appeared').to(g.V().has('name', 'AVF 4')).next()";
            cmd.Execute();
            cmd.CommandText = "g.addV('character').property('name', 'WOODGOD').property('weapon', 'lasso').next()";
            cmd.Execute();
            cmd.CommandText = "g.V().as('v').has('name', 'WOODGOD').addE('appeared').to(g.V().has('name', 'AVF 4')).next()";
            cmd.Execute();
        }
        public void GraphViewMarvelInsertTest()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest");

            connection.ResetCollection();
            GraphViewCommand cmd = new GraphViewCommand(connection);

            cmd.CommandText = "g.addV('character').property('name', 'VENUS II').property('weapon', 'shield').next()";
            cmd.Execute();
            cmd.CommandText = "g.addV('comicbook').property('name', 'AVF 4').next()";
            cmd.Execute();
            cmd.CommandText = "g.V().has('name', 'VENUS II').addE('appeared').to(g.V().has('name', 'AVF 4')).next()";
            cmd.Execute();
            cmd.CommandText = "g.addV('character').property('name', 'HAWK').property('weapon', 'claws').next()";
            cmd.Execute();
            cmd.CommandText = "g.V().as('v').has('name', 'HAWK').addE('appeared').to(g.V().has('name', 'AVF 4')).next()";
            cmd.Execute();
            cmd.CommandText = "g.addV('character').property('name', 'WOODGOD').property('weapon', 'lasso').next()";
            cmd.Execute();
            cmd.CommandText = "g.V().as('v').has('name', 'WOODGOD').addE('appeared').to(g.V().has('name', 'AVF 4')).next()";
            cmd.Execute();
        }