Esempio n. 1
0
        internal ServiceEdgeTypePredefinition(EdgeTypePredefinition myEdgeTypePredefinition)
        {
            this.EdgeTypeName      = myEdgeTypePredefinition.TypeName;
            this.SuperEdgeTypeName = myEdgeTypePredefinition.SuperTypeName;
            this.IsSealed          = myEdgeTypePredefinition.IsSealed;
            this.Comment           = myEdgeTypePredefinition.Comment;

            this.Properties = (myEdgeTypePredefinition.Properties == null)
                ? null : myEdgeTypePredefinition.Properties.Select(x => new ServicePropertyPredefinition(x)).ToList();
        }
Esempio n. 2
0
        internal ServiceEdgeTypePredefinition(EdgeTypePredefinition myEdgeTypePredefinition)
        {
            this.EdgeTypeName = myEdgeTypePredefinition.TypeName;
            this.SuperEdgeTypeName = myEdgeTypePredefinition.SuperTypeName;
            this.IsSealed = myEdgeTypePredefinition.IsSealed;
            this.Comment = myEdgeTypePredefinition.Comment;

            this.Properties = (myEdgeTypePredefinition.Properties == null)
                ? null : myEdgeTypePredefinition.Properties.Select(x => new ServicePropertyPredefinition(x)).ToArray();
        }
Esempio n. 3
0
        public void Init(ParsingContext context,
                         ParseTreeNode myParseTreeNode)
        {
            //createTypesStmt.Rule =    S_CREATE + S_EDGE + S_TYPE + bulkEdgeType
            //                        | S_CREATE + S_EDGE + S_TYPES + bulkEdgeTypeList;

            if (myParseTreeNode.ChildNodes[2].Token.KeyTerm ==
                ((SonesGQLGrammar)context.Language.Grammar).S_TYPES)
            {
                #region multiple VertexTypes

                foreach (var _ParseTreeNode in myParseTreeNode.ChildNodes[3].ChildNodes)
                {
                    if (_ParseTreeNode.AstNode != null)
                    {
                        BulkEdgeTypeListMemberNode aTempNode = (BulkEdgeTypeListMemberNode)_ParseTreeNode.AstNode;

                        var predef = new EdgeTypePredefinition(aTempNode.TypeName)
                                     .SetSuperTypeName(aTempNode.Extends)
                                     .SetComment(aTempNode.Comment);

                        foreach (var attr in aTempNode.Attributes)
                        {
                            predef.AddProperty(GenerateProperty(attr));
                        }

                        _TypePredefinitions.Add(predef);
                    }
                }

                #endregion
            }
            else
            {
                #region single vertex type

                BulkEdgeTypeNode aTempNode = (BulkEdgeTypeNode)myParseTreeNode.ChildNodes[3].AstNode;

                var predef =
                    new EdgeTypePredefinition(aTempNode.TypeName)
                    .SetSuperTypeName(aTempNode.Extends)
                    .SetComment(aTempNode.Comment);

                foreach (var attr in aTempNode.Attributes)
                {
                    predef.AddProperty(GenerateProperty(attr));
                }

                _TypePredefinitions.Add(predef);

                #endregion
            }
        }
Esempio n. 4
0
        public void Init(ParsingContext context,
                            ParseTreeNode myParseTreeNode)
        {
            //createTypesStmt.Rule =    S_CREATE + S_EDGE + S_TYPE + bulkEdgeType
            //                        | S_CREATE + S_EDGE + S_TYPES + bulkEdgeTypeList;

            if (myParseTreeNode.ChildNodes[2].Token.KeyTerm ==
                    ((SonesGQLGrammar)context.Language.Grammar).S_TYPES)
            {
                #region multiple VertexTypes

                foreach (var _ParseTreeNode in myParseTreeNode.ChildNodes[3].ChildNodes)
                {
                    if (_ParseTreeNode.AstNode != null)
                    {
                        BulkEdgeTypeListMemberNode aTempNode = (BulkEdgeTypeListMemberNode)_ParseTreeNode.AstNode;

                        var predef = new EdgeTypePredefinition(aTempNode.TypeName)
                                            .SetSuperTypeName(aTempNode.Extends)
                                            .SetComment(aTempNode.Comment);

                        foreach (var attr in aTempNode.Attributes)
                            predef.AddProperty(GenerateProperty(attr));

                        _TypePredefinitions.Add(predef);
                    }
                }

                #endregion
            }
            else
            {
                #region single vertex type

                BulkEdgeTypeNode aTempNode = (BulkEdgeTypeNode)myParseTreeNode.ChildNodes[3].AstNode;

                var predef =
                    new EdgeTypePredefinition(aTempNode.TypeName)
                        .SetSuperTypeName(aTempNode.Extends)
                        .SetComment(aTempNode.Comment);

                foreach (var attr in aTempNode.Attributes)
                    predef.AddProperty(GenerateProperty(attr));

                _TypePredefinitions.Add(predef);

                #endregion
            }
        }
        public EdgeTypePredefinition ToEdgeTypePredefinition()
        {
            EdgeTypePredefinition EdgeTypePreDef = new EdgeTypePredefinition(this.EdgeTypeName);

            if (this.IsSealed)
                EdgeTypePreDef.MarkAsSealed();

            EdgeTypePreDef.SetComment(this.Comment);
            EdgeTypePreDef.SetSuperTypeName(this.SuperEdgeTypeName);

            if (this.Properties != null)
            {
                foreach (var Property in this.Properties)
                {
                    EdgeTypePreDef.AddProperty(Property.ToPropertyPredefinition());
                }
            }

            return EdgeTypePreDef;
        }
        public EdgeTypePredefinition ToEdgeTypePredefinition()
        {
            EdgeTypePredefinition EdgeTypePreDef = new EdgeTypePredefinition(this.EdgeTypeName);

            if (this.IsSealed)
            {
                EdgeTypePreDef.MarkAsSealed();
            }

            EdgeTypePreDef.SetComment(this.Comment);
            EdgeTypePreDef.SetSuperTypeName(this.SuperEdgeTypeName);

            if (this.Properties != null)
            {
                foreach (var Property in this.Properties)
                {
                    EdgeTypePreDef.AddProperty(Property.ToPropertyPredefinition());
                }
            }

            return(EdgeTypePreDef);
        }
Esempio n. 7
0
        private void Run()
        {
            /*var UserVertexPredifinition = new VertexTypePredefinition("User")
                     .AddProperty(new PropertyPredefinition("Name", "String"))
                     .AddOutgoingEdge(new OutgoingEdgePredefinition("friends", "User").SetMultiplicityAsMultiEdge());*/

            EdgeTypePredefinition EdgeDate_TypePredefinition = new EdgeTypePredefinition("EdgeDate").
                AddProperty(new PropertyPredefinition("Time", "Int32"));
            var UserVertexPredifinition = new VertexTypePredefinition("User")
                     .AddProperty(new PropertyPredefinition("Name", "String"))
                     .AddOutgoingEdge(new OutgoingEdgePredefinition("friends", "User").SetMultiplicityAsMultiEdge("EdgeDate"));


            var UserEdge = GraphDSServer.CreateEdgeType<IEdgeType>(
               SecToken,
               TransactionID,
               new RequestCreateEdgeType(EdgeDate_TypePredefinition),
               (Statistics, EdgeType) => EdgeType);

            var UserVertex = GraphDSServer.CreateVertexType<IVertexType>(
               SecToken,
               TransactionID,
               new RequestCreateVertexType(UserVertexPredifinition),
               (Statistics, VertexTypes) => VertexTypes);

            DateTime dt = DateTime.Now;
            DateTime full_time = DateTime.Now;

            ReadFile();

            Console.WriteLine("Time of reading: {0}", DateTime.Now - dt);
            dt = DateTime.Now;

            for (int i = 0; i < vertices; ++i)
            {
                EdgePredefinition temp_edge = new EdgePredefinition("friends");
                for (int j = 0; j < edge_list[i].Count; ++j)
                    temp_edge.AddEdge(new EdgePredefinition()
                                        .AddStructuredProperty("Time", edge_list[i][j].Value)
                                        .AddVertexID("User", edge_list[i][j].Key));

                var ins = GraphDSServer.Insert<IVertex>(
                         SecToken,
                         TransactionID,
                         new RequestInsertVertex("User")
                             .AddStructuredProperty("Name", "User" + i.ToString())
                             .AddUnknownProperty("VertexID", i)
                             .AddEdge(temp_edge),
                         (Statistics, Result) => Result);
            }

            Console.WriteLine("Time of inserting: {0}", DateTime.Now - dt);
            dt = DateTime.Now;

            edge_list.Clear();
            
            //PrintAllVerticesInBase(UserVertex);

            //Console.WriteLine("Time of selecting: {0}", DateTime.Now - dt);
            //Console.WriteLine("Full time: {0}", DateTime.Now - full_time);

            //var qres_dij = GraphDSServer.Query(SecToken, TransactionID,
            //                    "FROM User U SELECT U.Name, U.friends.Dijkstra(U.Name = 'User4', 5, 'EdgeDate') AS 'path' WHERE U.Name = 'User0'",
            //                    SonesGQLConstants.GQL);

            //var qres = GraphDSServer.Query(SecToken, TransactionID,
            //                                "FROM User U SELECT U.Name, U.friends.PATH(U.Name = 'User4', 5, 5, true, false) AS 'path' WHERE U.Name = 'User0' OR U.Name = 'User1'",
            //                                SonesGQLConstants.GQL);

            //Console.WriteLine("Time of BFS: {0}", DateTime.Now - dt);
            //dt = DateTime.Now;

            //CheckResult(qres);

            //var first_vert = qres.Vertices.FirstOrDefault();

            //foreach (var vert in qres.Vertices)
            //    PrintWays(vert);

            //Console.WriteLine("Time of printing: {0}", DateTime.Now - dt);
            //Console.WriteLine("Full time: {0}", DateTime.Now - full_time);
        }
Esempio n. 8
0
 /// <summary>
 /// Creates a new request that creates a new edge type inside the Graphdb
 /// </summary>
 /// <param name="myVertexTypeDefinition">Describes the edge that is going to be created</param>
 public RequestCreateEdgeType(EdgeTypePredefinition myEdgeTypePredefinition)
 {
     EdgeTypePredefinition = myEdgeTypePredefinition;
 }
Esempio n. 9
0
 /// <summary>
 /// Creates a new request that creates a new edge type inside the Graphdb
 /// </summary>
 /// <param name="myVertexTypeDefinition">Describes the edge that is going to be created</param>
 public RequestCreateEdgeType(EdgeTypePredefinition myEdgeTypePredefinition)
 {
     EdgeTypePredefinition = myEdgeTypePredefinition;
 }