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


            GraphTraversal2 graph        = new GraphTraversal2(connection);
            string          traversalStr = "graph.g().V().In().Out()";

            var result = graph.EvalGraphTraversal(traversalStr);
        }
Exemplo n.º 2
0
        private static void ClearGraphData(string CollectionName)
        {
            //string endpoint = ConfigurationManager.AppSettings["DocDBEndPoint"];
            string endpoint = ConfigurationManager.AppSettings["DocDBEndPointLocal"];
            //string authKey = ConfigurationManager.AppSettings["DocDBKey"];
            string authKey    = ConfigurationManager.AppSettings["DocDBKeyLocal"];
            string databaseId = ConfigurationManager.AppSettings["DocDBDatabaseGremlin"];

            GraphViewConnection.ResetGraphAPICollection(endpoint, authKey, databaseId, CollectionName,
                                                        AbstractGremlinTest.TEST_USE_REVERSE_EDGE, AbstractGremlinTest.TEST_SPILLED_EDGE_THRESHOLD_VIAGRAPHAPI,
                                                        AbstractGremlinTest.TEST_PARTITION_BY_KEY);
        }
Exemplo n.º 3
0
        private static void LoadModernGraphData()
        {
            //string endpoint = ConfigurationManager.AppSettings["DocDBEndPoint"];
            string endpoint = ConfigurationManager.AppSettings["DocDBEndPointLocal"];
            //string authKey = ConfigurationManager.AppSettings["DocDBKey"];
            string authKey      = ConfigurationManager.AppSettings["DocDBKeyLocal"];
            string databaseId   = ConfigurationManager.AppSettings["DocDBDatabaseGremlin"];
            string collectionId = ConfigurationManager.AppSettings["DocDBCollectionModern"];

            GraphViewConnection connection = GraphViewConnection.ResetGraphAPICollection(endpoint, authKey, databaseId,
                                                                                         collectionId, AbstractGremlinTest.TEST_USE_REVERSE_EDGE,
                                                                                         AbstractGremlinTest.TEST_SPILLED_EDGE_THRESHOLD_VIAGRAPHAPI, AbstractGremlinTest.TEST_PARTITION_BY_KEY);


            GraphViewCommand graphCommand = new GraphViewCommand(connection);

            //
            // NOTE: '#' charactor is now allowed in document id
            // NOTE: '\' charactor is now allowed in document id
            // NOTE: '?' charactor is now allowed in document id
            // NOTE: '/' charactor is now allowed in document id
            // NOTE: ' (single quote) charactor will cause an error now
            //
            //graphCommand.g().AddV("person").Property("id", "dummy!").Property("name", "marko").Property("age", 29).Next();
            //graphCommand.g().AddV("person").Property("id", "特殊符号:~!@$%^&*()_+").Property("name", "vadas").Property("age", 27).Next();
            //graphCommand.g().AddV("software").Property("id", "这是一个中文ID").Property("name", "lop").Property("lang", "java").Next();
            //graphCommand.g().AddV("person").Property("id", "引号\"`").Property("name", "josh").Property("age", 32).Next();
            //graphCommand.g().AddV("software").Property("id", "中文English(){}[]<>\"`~!@$%^^&*()_+-=|:;,.").Property("name", "ripple").Property("lang", "java").Next();
            //graphCommand.g().AddV("person").Property("name", "peter").Property("age", 35).Next();
            //graphCommand.g().V().Has("name", "marko").AddE("knows").Property("weight", 0.5d).To(graphCommand.g().V().Has("name", "vadas")).Next();
            //graphCommand.g().V().Has("name", "marko").AddE("knows").Property("weight", 1.0d).To(graphCommand.g().V().Has("name", "josh")).Next();
            //graphCommand.g().V().Has("name", "marko").AddE("created").Property("weight", 0.4d).To(graphCommand.g().V().Has("name", "lop")).Next();
            //graphCommand.g().V().Has("name", "josh").AddE("created").Property("weight", 1.0d).To(graphCommand.g().V().Has("name", "ripple")).Next();
            //graphCommand.g().V().Has("name", "josh").AddE("created").Property("weight", 0.4d).To(graphCommand.g().V().Has("name", "lop")).Next();
            //graphCommand.g().V().Has("name", "peter").AddE("created").Property("weight", 0.2d).To(graphCommand.g().V().Has("name", "lop")).Next();

            graphCommand.g().AddV("person").Property("id", "dummy").Property("name", "marko").Property("age", 29).Next();
            graphCommand.g().AddV("person").Property("id", "特殊符号").Property("name", "vadas").Property("age", 27).Next();
            graphCommand.g().AddV("software").Property("id", "这是一个中文ID").Property("name", "lop").Property("lang", "java").Next();
            graphCommand.g().AddV("person").Property("id", "引号").Property("name", "josh").Property("age", 32).Next();
            graphCommand.g().AddV("software").Property("id", "中文English").Property("name", "ripple").Property("lang", "java").Next();
            graphCommand.g().AddV("person").Property("name", "peter").Property("age", 35).Next();  // Auto generate document id
            graphCommand.g().V().Has("name", "marko").AddE("knows").Property("weight", 0.5d).To(graphCommand.g().V().Has("name", "vadas")).Next();
            graphCommand.g().V().Has("name", "marko").AddE("knows").Property("weight", 1.0d).To(graphCommand.g().V().Has("name", "josh")).Next();
            graphCommand.g().V().Has("name", "marko").AddE("created").Property("weight", 0.4d).To(graphCommand.g().V().Has("name", "lop")).Next();
            graphCommand.g().V().Has("name", "josh").AddE("created").Property("weight", 1.0d).To(graphCommand.g().V().Has("name", "ripple")).Next();
            graphCommand.g().V().Has("name", "josh").AddE("created").Property("weight", 0.4d).To(graphCommand.g().V().Has("name", "lop")).Next();
            graphCommand.g().V().Has("name", "peter").AddE("created").Property("weight", 0.2d).To(graphCommand.g().V().Has("name", "lop")).Next();

            graphCommand.Dispose();
            connection.Dispose();
        }
        public void SelectMarvelQuery4()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest");
            GraphViewCommand graph = new GraphViewCommand(connection);
            var results            = graph.g().V().Has("name", "AVF 4").In("appeared").Has("weapon", "shield").Values("name").Next();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 5
0
        private static void ClearGraphData(string CollectionName)
        {
            GraphViewConnection connection = new GraphViewConnection(
                //ConfigurationManager.AppSettings["DocDBEndPoint"],
                ConfigurationManager.AppSettings["DocDBEndPointLocal"],
                //ConfigurationManager.AppSettings["DocDBKey"],
                ConfigurationManager.AppSettings["DocDBKeyLocal"],
                ConfigurationManager.AppSettings["DocDBDatabaseGremlin"],
                CollectionName);

            connection.ResetCollection();
            connection.Dispose();
        }
Exemplo n.º 6
0
        public void TestAddAndDropEdges_DropSome_Small()
        {
            const int           EDGE_COUNT = 20;
            GraphViewConnection connection = CreateConnection($"AddAndDropEdges_DropSome_Small E={EDGE_COUNT}");
            GraphViewCommand    graph      = new GraphViewCommand(connection);

            graph.g().AddV("SourceV").Next();
            graph.g().AddV("SinkV").Next();
            for (int i = 0; i < EDGE_COUNT; i++)
            {
                graph.g().V().HasLabel("SourceV").AddE(edgeLabel: $"MOD_{i % 4}").To(graph.g().V().HasLabel("SinkV")).Next();
            }
            graph.g().V().OutE().HasLabel("MOD_0", "MOD_2").Drop().Next();
        }
Exemplo n.º 7
0
        public void SelectMarvelQuery4()
        {
            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);
            var results            = graph.g().V().Has("name", "AVF 4").In("appeared").Has("weapon", "shield").Values("name").Next();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 8
0
        private static GraphViewConnection CreateConnection(string tips = null)
        {
            StackFrame frame = new StackFrame(1);

            if (!string.IsNullOrEmpty(tips))
            {
                tips = $" {tips}";
            }
            string collectionName = $"[{frame.GetMethod().Name}]{tips}";

            GraphViewConnection connection = GraphViewConnection.ResetGraphAPICollection(DOCDB_URL, DOCDB_AUTHKEY, DOCDB_DATABASE, collectionName, AbstractGremlinTest.TEST_USE_REVERSE_EDGE, AbstractGremlinTest.TEST_SPILLED_EDGE_THRESHOLD_VIAGRAPHAPI);

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

            GraphViewCommand graph = new GraphViewCommand(connection);

            var results = graph.g().V();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }

            //var results = graph.g().V().Has("type", "University").Union(GraphTraversal.__().Properties("label", "type"), GraphTraversal.__().OutE().Properties("label")).next();

            //Insert character
            //string[] characterLines = File.ReadAllLines(@"C:\Users\v-jinjl\Desktop\GraphView-Development\GraphView\data\character.txt");
            //foreach (string line in characterLines)
            //{
            //    var arr = line.Split('\"');
            //    var id = arr[0].Substring(0, arr[0].Length - 1);
            //    var name = arr[1];
            //    graph.g().AddV("character").Property("id", id).Property("name", name).next();
            //}

            //Insert comicbook
            //string[] comicbookLines = File.ReadAllLines(@"C:\Users\v-jinjl\Desktop\GraphView-Development\GraphView\data\comicbook.txt");
            //foreach (string line in comicbookLines)
            //{
            //    var arr = line.Split('\"');
            //    var id = arr[0].Substring(0, arr[0].Length - 1);
            //    var name = arr[1];
            //    graph.g().AddV("comicbook").Property("id", id).Property("name", name).next();
            //}

            //Insert Edge
            //string[] edgeLines = File.ReadAllLines(@"C:\Users\v-jinjl\Desktop\GraphView-Development\GraphView\data\edge.txt");
            //foreach (string line in edgeLines)
            //{
            //    var arr = line.Split(' ');
            //    var sourceId = arr[0];
            //    for (var i = 1; i < arr.Length; i++)
            //    {
            //        var sinkId = arr[i];
            //        graph.g().V().Has("id", sourceId).AddE("appeared").To(graph.g().V().Has("id", sinkId)).next();
            //    }
            //}
        }
Exemplo n.º 10
0
        public void TestAddHeavyEdges_MidiumQuantity()
        {
            const int           EDGE_COUNT = 10;
            GraphViewConnection connection = CreateConnection($"E={EDGE_COUNT}");
            GraphViewCommand    graph      = new GraphViewCommand(connection);

            graph.g().AddV("SourceV").Next();
            graph.g().AddV("SinkV").Next();
            for (int i = 0; i < EDGE_COUNT; i++)
            {
                string longLabel = new string((char)('0' + i), 1024 * 900);  // Size = 900KB
                graph.g().V().HasLabel("SourceV").AddE(edgeLabel: longLabel).To(graph.g().V().HasLabel("SinkV")).Next();
            }
        }
Exemplo n.º 11
0
        public void TestAddAndDropEdges_Small()
        {
            const int           EDGE_COUNT = 10;
            GraphViewConnection connection = CreateConnection($"E={EDGE_COUNT}");
            GraphViewCommand    graph      = new GraphViewCommand(connection);

            graph.g().AddV("SourceV").Next();
            graph.g().AddV("SinkV").Next();
            for (int i = 0; i < EDGE_COUNT; i++)
            {
                graph.g().V().HasLabel("SourceV").AddE(edgeLabel: "Dummy").To(graph.g().V().HasLabel("SinkV")).Next();
            }
            graph.g().E().HasLabel("Dummy").Drop().Next();
        }
Exemplo n.º 12
0
        static void test()
        {
            GraphViewConnection connection =
                new GraphViewConnection(DOCDB_URL, DOCDB_AUTHKEY, DOCDB_DATABASE, DOCDB_COLLECTION);
            //connection.ResetCollection();
            GraphViewCommand graph = new GraphViewCommand(connection);

            try
            {
                /*graph.g().AddV(NODE_LABEL).Property(NODE_PROPERTY, "1").Next();
                 * graph.g().AddV(NODE_LABEL).Property(NODE_PROPERTY, "3").Next();
                 * graph.g().AddV(NODE_LABEL).Property(NODE_PROPERTY, "2").Next();
                 *
                 * graph.g().V().Has(NODE_PROPERTY, "1").
                 *             AddE(EDGE_LABEL).Property(EDGE_PROPERTY, 1).
                 *             To(graph.g().V().Has(NODE_PROPERTY, "2")).Next();
                 * graph.g().V().Has(NODE_PROPERTY, "1").
                 *            AddE(EDGE_LABEL).Property(EDGE_PROPERTY, -2).
                 *            To(graph.g().V().Has(NODE_PROPERTY, "3")).Next();
                 */              /*  graph.g().V().Has(NODE_PROPERTY, "6242519").
                 *            AddE(EDGE_LABEL).Property(EDGE_PROPERTY, 1.35183386).
                 *            To(graph.g().V().Has(NODE_PROPERTY, "343")).Next();
                 */
                //graph.CommandText = "g.E().Order().By("+EDGE_PROPERTY+", incr)";
                //var res= graph.Execute();

                //var res = graph.g().V().Has(NODE_PROPERTY, "12").BothV().Has(NODE_PROPERTY, "2").Values(NODE_PROPERTY).Next();

                //graph.g().V().Has(NODE_PROPERTY, "1").OutE(EDGE_LABEL).As("e").InV().Has(NODE_PROPERTY, "2").Select("e").Drop().Next();

                /*graph.g().V().Has(NODE_PROPERTY, "198036").OutE(EDGE_LABEL).As("e").
                 *          InV().Has(NODE_PROPERTY, "3888").Select("e").Drop().Next();
                 */
                var res = graph.g().V().Has(NODE_PROPERTY, "198036").OutE(EDGE_LABEL).As("e").
                          InV().Has(NODE_PROPERTY, "3888").Select("e").Next();



                foreach (var x in res)
                {
                    System.Console.WriteLine(x);
                }
                System.Console.WriteLine("");
            }
            finally
            {
                //connection.ResetCollection();
            }
        }
Exemplo n.º 13
0
        public void TestAddDropEdges_DropAll_Large()
        {
            const int           EDGE_COUNT = 10;
            GraphViewConnection connection = CreateConnection($"AddAndDropEdges_DropAll_Large E={EDGE_COUNT}");
            GraphViewCommand    graph      = new GraphViewCommand(connection);

            graph.g().AddV("SourceV").Next();
            graph.g().AddV("SinkV").Next();
            for (int i = 0; i < EDGE_COUNT; i++)
            {
                string label = $"{i}@{new string('_', 1024 * 900)}";
                graph.g().V().HasLabel("SourceV").AddE(edgeLabel: label).To(graph.g().V().HasLabel("SinkV")).Next();
            }
            graph.g().V().OutE().Drop().Next();
        }
Exemplo n.º 14
0
        public void TestSpillThreshold_Small()
        {
            const int           EDGE_COUNT = 20;
            const int           THRESHOLD  = 6;
            GraphViewConnection connection = CreateConnection($"Threshold={THRESHOLD},E={EDGE_COUNT}", THRESHOLD);
            GraphViewCommand    graph      = new GraphViewCommand(connection);

            Console.WriteLine($"EdgeSpillThreashold: {connection.EdgeSpillThreshold}");
            graph.g().AddV("SourceV").Next();
            graph.g().AddV("SinkV").Next();
            for (int i = 0; i < EDGE_COUNT; i++)
            {
                graph.g().V().HasLabel("SourceV").AddE($"...E{i}...").Property($"E{i} Property", $"E{i} PropValue").To(graph.g().V().HasLabel("SinkV")).Next();
            }
        }
        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);
            }
        }
Exemplo n.º 16
0
        public void TestAddDropEdges_DropSome_Large()
        {
            const int           EDGE_COUNT = 100;
            GraphViewConnection connection = CreateConnection($"AddAndDropEdges_DropSome_Large E={EDGE_COUNT}");
            GraphViewCommand    graph      = new GraphViewCommand(connection);
            string suffix = new string('_', 1024 * 900);

            graph.g().AddV("SourceV").Next();
            graph.g().AddV("SinkV").Next();
            for (int i = 0; i < EDGE_COUNT; i++)
            {
                graph.g().V().HasLabel("SourceV").AddE(edgeLabel: $"MOD_{i % 4}{suffix}").To(graph.g().V().HasLabel("SinkV")).Next();
            }
            graph.g().V().OutE().HasLabel($"MOD_0{suffix}", $"MOD_2{suffix}").Drop().Next();
        }
Exemplo n.º 17
0
        static private void validConnect()
        {
            System.Console.WriteLine("Validating");

            GraphViewConnection connection = new GraphViewConnection(DOCDB_URL, DOCDB_AUTHKEY, DOCDB_DATABASE, DOCDB_COLLECTION);
            GraphViewCommand    graph      = new GraphViewCommand(connection);

            var src_res = graph.g().V().Values(NODE_PROPERTY).Next();

            foreach (var src in src_res)
            {
                var dst_res = graph.g().V().Has(NODE_PROPERTY, src).Out().Values(NODE_PROPERTY).Dedup().Next();
                foreach (var dst in dst_res)
                {
                    double outAmount = -1;
                    double inAmount  = -1;

                    // TODO: bothE not implemented, have so explictly call twice
                    var edges_res = graph.g().V().Has(NODE_PROPERTY, src).OutE(EDGE_LABEL).As("e").
                                    InV().Has(NODE_PROPERTY, dst).Select("e").Values(EDGE_PROPERTY).Next();
                    foreach (var value in edges_res)
                    {
                        outAmount = double.Parse(value, CultureInfo.InvariantCulture);
                    }
                    edges_res = graph.g().V().Has(NODE_PROPERTY, dst).OutE(EDGE_LABEL).As("e").
                                InV().Has(NODE_PROPERTY, src).Select("e").Values(EDGE_PROPERTY).Next();
                    foreach (var value in edges_res)
                    {
                        inAmount = double.Parse(value, CultureInfo.InvariantCulture);
                    }

                    graph.g().V().Has(NODE_PROPERTY, src).OutE(EDGE_LABEL).As("e").
                    InV().Has(NODE_PROPERTY, dst).Select("e").Drop().Next();

                    graph.g().V().Has(NODE_PROPERTY, dst).OutE(EDGE_LABEL).As("e").
                    InV().Has(NODE_PROPERTY, src).Select("e").Drop().Next();


                    if (threshold_reached(inAmount, outAmount))
                    {
                        graph.g().V().Has(NODE_PROPERTY, src).
                        AddE(CONNECT_EDGE_LABEL).Property(CONNECT_EDGE_PROPERTY, inAmount + outAmount).
                        To(graph.g().V().Has(NODE_PROPERTY, dst)).Next();
                        debug.print("Add connected edge: " + src + " <-> " + dst + " : " + (inAmount + outAmount));
                    }
                }
            }
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            //  You should modify your database information in TestConfiguration
            TestConfiguration.localTest = true;

            var connection = new GraphViewConnection(TestConfiguration.getConnectionString());

            try
            {
                Console.WriteLine("Opening the DB...");
                connection.Open();

                connection.ClearData();

                Console.WriteLine("Creating table...");
                connection.CreateNodeTable(TestConfiguration.getCreateTableString());

                string Table        = TestConfiguration.TestCaseNodeTableName;
                string NodeId       = TestConfiguration.TestCaseNodeIdName;
                string EdgeName     = TestConfiguration.TestCaseEdgeName;
                string NodeDataFile = TestConfiguration.NodeDataFileLocation;
                string EdgeDataFile = TestConfiguration.EdgeDataFileLocation;

                Console.WriteLine("BulkLoading Nodes...");
                connection.BulkInsertNode(NodeDataFile, Table, "dbo", null, ",", "\n");

                Console.WriteLine("BulkLoading Edges...");
                connection.BulkInsertEdge(EdgeDataFile, "dbo", Table, NodeId, Table, NodeId, EdgeName, null, ",", "\n");

                Console.WriteLine("Updating Statistics...");
                connection.UpdateTableStatistics("dbo", Table);  //  updating staticestics allows GraphView do optimization on query precisely

                Console.WriteLine("Tests begin!");

                (new RectangleMatchTest()).run(connection);
                (new DoubleDiamondMatchTest()).run(connection);
                (new InfluxMatchTest()).run(connection);
                (new TripleTriangleMatchTest()).run(connection);
                (new PentagonMatchTest()).run(connection);
                (new TriangleMatchTest()).run(connection);
                (new LongChainsMatchTest()).run(connection);
            }
            finally
            {
                connection.ClearGraphDatabase();
                connection.Close();
            }
        }
Exemplo n.º 19
0
        public void GraphViewMarvelInsertDeleteTest()
        {
            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.g().AddV("character").Property("name", "VENUS II").Property("weapon", "shield").Next();
            graph.g().AddV("comicbook").Property("name", "AVF 4").Next();
            graph.g().V().Has("name", "VENUS II").AddE("appeared").To(graph.g().V().Has("name", "AVF 4")).Next();
            graph.g().AddV("character").Property("name", "HAWK").Property("weapon", "claws").Next();
            graph.g().V().As("v").Has("name", "HAWK").AddE("appeared").To(graph.g().V().Has("name", "AVF 4")).Next();
            graph.g().AddV("character").Property("name", "WOODGOD").Property("weapon", "lasso").Next();
            graph.g().V().As("v").Has("name", "WOODGOD").AddE("appeared").To(graph.g().V().Has("name", "AVF 4")).Next();
        }
Exemplo n.º 20
0
        private static GraphViewConnection CreateConnection(string tips = null, int?edgeSpillThreshold = null)
        {
            StackFrame frame = new StackFrame(1);

            if (!string.IsNullOrEmpty(tips))
            {
                tips = $" {tips}";
            }
            string collectionName = $"[{frame.GetMethod().Name}]{tips}";

            GraphViewConnection connection = new GraphViewConnection(DOCDB_URL, DOCDB_AUTHKEY, DOCDB_DATABASE, collectionName);

            connection.EnsureDatabaseExist();
            connection.ResetCollection(edgeSpillThreshold);
            return(connection);
        }
Exemplo n.º 21
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);
            }
        }
        public void SelectMarvelQuery1()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest");

            GraphViewCommand graph = new GraphViewCommand(connection);

            graph.OutputFormat = OutputFormat.GraphSON;
            var results = graph.g().V().Has("weapon", "shield").As("character").Out("appeared").As("comicbook").Select("character").Next();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
        }
Exemplo n.º 23
0
        public void TestAddHeavyEdges_LargeQuantity()
        {
            const int EDGE_COUNT = 100;

            GraphViewConnection connection = CreateConnection($"E={EDGE_COUNT}");
            GraphViewCommand    graph      = new GraphViewCommand(connection);

            graph.g().AddV("SourceV").Next();
            graph.g().AddV("SinkV").Next();
            for (int i = 0; i < EDGE_COUNT; i++)
            {
                Debug.WriteLine($"AddEdge: i = {i}");
                string longLabel = new string('-', 1024 * 10 * i);  // Size = 10-1000KB
                graph.g().V().HasLabel("SourceV").AddE(edgeLabel: longLabel).To(graph.g().V().HasLabel("SinkV")).Next();
            }
        }
Exemplo n.º 24
0
        public void WhereNeqTest()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest");
            //connection.ResetCollection();
            GraphViewCommand cmd = new GraphViewCommand(connection);
            var traversal        = cmd.g().V("11f09a6e-868c-44d5-86ba-7766d5b16d04").As("a").Out("appeared").In("appeared").Where(Predicate.neq("a"));
            var results          = traversal.Next();

            foreach (var result in results)
            {
                Console.WriteLine(result);
            }
            Console.WriteLine("Result Count: " + results.Count);
        }
        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.º 26
0
        public void query2()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "IOTTest", GraphType.GraphAPIOnly, AbstractGremlinTest.TEST_USE_REVERSE_EDGE, 1, AbstractGremlinTest.TEST_PARTITION_BY_KEY);
            GraphViewCommand graph = new GraphViewCommand(connection);

            var expTimes = 100;
            var sumTime  = 0.0;
            var result   = new List <Double>();

            for (int i = 0; i < expTimes; i++)
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                // Note: update as the random number
                string DeviceID = "25015";

                var q = graph.g().V()
                        .Has("label", "DeviceModel")
                        .Has("id", DeviceID)
                        .As("DeviceModel")
                        .Out("type_of")
                        .Has("label", "DeviceTwin")
                        .As("device")
                        .Select("device", "DeviceModel").Next();

                foreach (var x in q)
                {
                }

                sw.Stop();
                sumTime += sw.Elapsed.TotalMilliseconds;
                result.Add(sw.Elapsed.TotalMilliseconds);
                Console.WriteLine("query{0} time is:{1}", i, sw.Elapsed.TotalMilliseconds);
            }

            var avgTime = sumTime / expTimes;

            Console.WriteLine("max query time is: {0}", result.Max());
            Console.WriteLine("min query time is: {0}", result.Min());
            Console.WriteLine("avg query time is: {0}", result.Average());
            Console.WriteLine("stdDev query time is: {0}", stdDev(result));
            Console.WriteLine("avg,max,min,stdDev");
            Console.WriteLine("{0}, {1}, {2}, {3}", result.Average(), result.Max(), result.Min(), stdDev(result));
        }
        public void GraphViewMarvelInsertDeleteTest()
        {
            GraphViewConnection connection = new GraphViewConnection("https://graphview.documents.azure.com:443/",
                                                                     "MqQnw4xFu7zEiPSD+4lLKRBQEaQHZcKsjlHxXn2b96pE/XlJ8oePGhjnOofj1eLpUdsfYgEhzhejk2rjH/+EKA==",
                                                                     "GroupMatch", "MarvelTest");

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

            graph.g().AddV("character").Property("name", "VENUS II").Property("weapon", "shield").Next();
            graph.g().AddV("comicbook").Property("name", "AVF 4").Next();
            graph.g().V().Has("name", "VENUS II").AddE("appeared").To(graph.g().V().Has("name", "AVF 4")).Next();
            graph.g().AddV("character").Property("name", "HAWK").Property("weapon", "claws").Next();
            graph.g().V().As("v").Has("name", "HAWK").AddE("appeared").To(graph.g().V().Has("name", "AVF 4")).Next();
            graph.g().AddV("character").Property("name", "WOODGOD").Property("weapon", "lasso").Next();
            graph.g().V().As("v").Has("name", "WOODGOD").AddE("appeared").To(graph.g().V().Has("name", "AVF 4")).Next();
        }
Exemplo n.º 28
0
        static void createGraph()
        {
            GraphViewConnection connection = new GraphViewConnection(DOCDB_URL, DOCDB_AUTHKEY, DOCDB_DATABASE, DOCDB_COLLECTION);

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

            HashSet <string> nodes = new HashSet <string>();

            using (TextFieldParser parser = new TextFieldParser(INPUT_EDGE))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");
                while (!parser.EndOfData)
                {
                    string[] fields = parser.ReadFields();
                    string   start  = fields[1];
                    string   end    = fields[2];
                    double   amount = double.Parse(fields[4], CultureInfo.InvariantCulture);

                    // remove self circle
                    if (start.Equals(end))
                    {
                        continue;
                    }

                    if (!nodes.Contains(start))
                    {
                        graph.g().AddV(NODE_LABEL).Property(NODE_PROPERTY, start).Next();
                        debug.print("Node " + start + " added");
                    }
                    if (!nodes.Contains(end))
                    {
                        graph.g().AddV(NODE_LABEL).Property(NODE_PROPERTY, end).Next();
                        debug.print("Node " + end + " added");
                    }
                    nodes.Add(start);
                    nodes.Add(end);

                    graph.g().V().Has(NODE_PROPERTY, start).
                    AddE(EDGE_LABEL).Property(EDGE_PROPERTY, amount).
                    To(graph.g().V().Has(NODE_PROPERTY, end)).Next();
                    debug.print("Edge: " + start + "-> " + end + ": " + amount + " added");
                }
            }
        }
Exemplo n.º 29
0
        public void TestDropNodes_Small()
        {
            const int           EDGE_COUNT = 5;
            GraphViewConnection connection = CreateConnection($"TestDropNodes_Small(A->B->C, A->C) E={EDGE_COUNT}");
            GraphViewCommand    graph      = new GraphViewCommand(connection);
            string suffix = string.Empty;

            graph.g().AddV("A").Next();
            graph.g().AddV("B").Next();
            graph.g().AddV("C").Next();
            for (int i = 0; i < EDGE_COUNT; i++)
            {
                graph.g().V().HasLabel("A").AddE(edgeLabel: $"AB_{i}{suffix}").To(graph.g().V().HasLabel("B")).Next();
                graph.g().V().HasLabel("A").AddE(edgeLabel: $"AC_{i}{suffix}").To(graph.g().V().HasLabel("C")).Next();
                graph.g().V().HasLabel("B").AddE(edgeLabel: $"BC_{i}{suffix}").To(graph.g().V().HasLabel("C")).Next();
            }
            graph.g().V().HasLabel("B").Drop().Next();
        }
Exemplo n.º 30
0
        public void TestDropNodes_Large()
        {
            const int           EDGE_COUNT = 10;
            GraphViewConnection connection = CreateConnection($"{MethodBase.GetCurrentMethod().Name}(A->B->C, A->C) E={EDGE_COUNT}");
            GraphViewCommand    graph      = new GraphViewCommand(connection);
            string suffix = new string('_', 1024 * 900);

            graph.g().AddV("A").Next();
            graph.g().AddV("B").Next();
            graph.g().AddV("C").Next();
            for (int i = 0; i < EDGE_COUNT; i++)
            {
                graph.g().V().HasLabel("A").AddE(edgeLabel: $"AB_{i}{suffix}").To(graph.g().V().HasLabel("B")).Next();
                graph.g().V().HasLabel("A").AddE(edgeLabel: $"AC_{i}{suffix}").To(graph.g().V().HasLabel("C")).Next();
                graph.g().V().HasLabel("B").AddE(edgeLabel: $"BC_{i}{suffix}").To(graph.g().V().HasLabel("C")).Next();
            }
            graph.g().V().HasLabel("B").Drop().Next();
        }