Object-oriented graph database Gremlin interface access method and system

Through the Gremlin interface access method of the object-oriented graph database, the mapping mechanism of Java objects to Gremlin graph data is used to solve the problem that the interaction method of Gremlin query language in the prior art is not applicable, and the efficient graph data access is realized.

CN120216724APending Publication Date: 2025-06-27GLOBAL ENERGY INTERCONNECTION RES INST CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311820173.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-27
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

The existing Gremlin query language call interaction method is not suitable for graph database access, especially in object-oriented access mode, which makes it difficult to effectively access and operate graph data.

Method used

The Gremlin interface access method of the object-oriented graph database is introduced, and the object-oriented graph query interface is accessed based on the Java language, and the mapping mechanism of objects to Gremlin graph data is used to convert the operations of Java objects into Gremlin query statements.

Benefits of technology

The object-oriented graph data access technology is realized, providing a more intuitive and efficient graph database access method for clients using Java language as the development language, and solving the limitations of string splicing and general interface methods in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216724A_ABST
    Figure CN120216724A_ABST
Patent Text Reader

Abstract

The invention provides an object-oriented graph database Gremlin interface access method and system, and the method comprises the steps: carrying out the access through an introduced Java language-based object-oriented graph query interface based on a query demand when a query is carried out through a client; based on an introduced mapping mechanism from an object facing a Java programming language to Gremlin graph data, an operation based on a Java object is converted into a Gremlin query statement for query. According to the method, a mapping mechanism of'object 'to'graph database' server end data in a client programming language level is introduced into a graph database, a mapping method of the object to graph elements is introduced into the graph database based on a Gremlin graph query language, and an object-oriented graph data access technology is provided for a client taking a Java language as a development language.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of interface access, and particularly to an object-oriented graph database Gremlin interface access method and system. Background Art

[0002] With the explosive development of the Internet, mobile Internet, social networks, Internet of Things, and industrial field-related networks such as power networks, there is a great demand for the storage of relationship graphs and applications such as network topology analysis and functional analysis based on relationship graphs, which has also contributed to the research and development boom of graph databases.

[0003] A graph database is a data management system based on vertices and edges as basic storage units, with the design principle of efficiently storing and querying graph data.

[0004] There is no unified and standardized query language for existing graph query languages. The most widely used and typical mainstream languages include Gremlin and Cypher.

[0005] Gremlin is a graph traversal language under the TinkerPop framework. Gremlin is a functional data flow language that enables users to express traversals or queries of complex property graphs in a concise manner. Each Gremlin traversal consists of a series of steps (possibly nested), and each step performs an atomic operation on a data stream.

[0006] Gremlin is based on Groovy, but has many language variants that allow developers to write queries natively in programming languages such as Java and Python. It contains both imperative and declarative semantics, which can conveniently express the logic of graph traversal, so it is adopted by many graph database systems and widely used in the industry.

[0007] Many applications built on graph databases operate and query graph database data through the Gremlin query language. Generally speaking, these applications connect to the graph database service as clients for operations, and the operation process is as follows:

[0008] The client application system submits a Gremlin query language statement to the graph database;

[0009] The graph database executes this query language;

[0010] The graph database returns the execution result of the query language to the client application system.

[0011] When existing application systems interact with a graph database through the Gremlin query language and submit Gremlin statements, the following general methods are usually adopted:

[0012] Assemble and splice the Gremlin statement to be executed, including the execution string of the statement and its parameters, into a string, and finally submit the formed string as an execution operation statement to the graph database system;

[0013] Call the Java client interface supported by the Gremlin language, that is, submit the query operation in the way of Gremlin API call in the client application code. The content submitted in this way is not a "spliced" string, but an actual call at the Java code method level.

[0014] The problems existing in the above several different Gremlin query language call interaction methods are as follows:

[0015] For applications that interact in the way of "string" splicing, the graph database query statement needs to be submitted in the form of a string, and the content in the string is pure text with unclear syntax and semantics for the client Java code. Even if there are syntax problems in the Gremlin language in the spliced string, it is very difficult for application developers to know manually or detect through the development environment (such as a code editor).

[0016] The Gremlin API interface faced by applications that interact in the way of "Gremlin API interface" is a general "Gremlinized" interface method at the point and edge levels. This interface does not distinguish between this type of point or that type of edge, nor between this type of edge and that type of edge, nor between different attributes in the same type of point (or edge). And for graph data:

[0017] The information of different point (or edge) types in the graph data is still specified by a string in the Gremlin API interface. Its code is similar to: g.V().hasLabel(“point type name”), where the type is specified by the string “point type name”. The specific sample code is similar to: Vertex aPerson = g.V().hasLabel("person"). This Java statement queries the label named "person", which needs to be specially specified by a string parameter in the code. In addition, the obtained Vertex type is also a general type representing "point", and different point types cannot be known at the Java type level of "Vertex" itself.

[0018] For different attributes of the same vertex and edge types in graph data, they are also specified by strings. For example, g.V().property("attribute name", "attribute value"), and here the "attribute name" is also specified by a string. The specific sample code is: Vertex marko = g.V().has("name", "marko").next(). This Java statement queries for the attribute named "name", which needs to be specifically specified. Additionally, the obtained Vertex type is also a general type representing "vertices", and different vertex types cannot be known at the Java type level of "Vertex" itself.

[0019] This interface method is not a strictly object-oriented access method because, in an object-oriented access method, different vertex and edge types can be directly accessed through the "object" (or type) method at the language level. For example, in the Java language, different "classes" may be used to represent different vertex and edge types. Summary of the Invention

[0020] To solve the problem that the existing Gremlin query language call interaction method is not suitable for graph database access, the present invention proposes an object-oriented graph database Gremlin interface access method, including:

[0021] When querying through a client application, based on the query requirements, access through the introduced object-oriented graph query interface based on the Java language is performed;

[0022] Based on the introduced mapping mechanism from Java objects to Gremlin graph data, operations based on Java objects are converted into Gremlin query statements for querying.

[0023] Optionally, the access through the introduced object-oriented graph query interface based on the Java language according to the query requirements includes:

[0024] When the query requirement is a graph element query by ID, access through the object-oriented graph element query interface by ID;

[0025] When the query requirement is a query with query conditions, access through the object-oriented query interface with query conditions;

[0026] When the query requirement is a graph traversal query, access through the graph traversal query interface;

[0027] Among them, the object-oriented graph query interface based on the Java language includes: the object-oriented graph element query interface by ID, the object-oriented query interface with query conditions, and the graph traversal query interface.

[0028] Optionally, the introduced mapping mechanism for Java programming language objects to Gremlin graph data includes:

[0029] Mapping each vertex type in the graph database to a class in the Java language based on the mapping mechanism for Java programming language objects to Gremlin graph data;

[0030] Mapping each edge type in the graph database to a class in the Java language based on the mapping mechanism for Java programming language objects to Gremlin graph data;

[0031] Mapping each property of a vertex or edge in the graph database to a field of a class in the Java language based on the mapping mechanism for Java programming language objects to Gremlin graph data.

[0032] Optionally, based on the introduced mapping mechanism for Java programming language objects to Gremlin graph data, converting operations based on Java objects into Gremlin query statements for querying, including:

[0033] When the query requirement is a graph element query by ID, the client Driver performs Gremlin conversion for the graph element query by ID;

[0034] When the query requirement has query conditions, the client Driver performs Gremlin conversion for the query with query conditions;

[0035] When the query requirement is a graph traversal query, the client Driver performs Gremlin conversion for the graph traversal query.

[0036] Optionally, it further includes: introducing a Predicate in the object-oriented graph data query process, where Predicate is a predicate;

[0037] Among them, Predicate includes: not equal neq, equal eq, greater than gt, less than lt, less than or equal to lte, and greater than or equal to gte.

[0038] Optionally, before querying through the client application, it further includes:

[0039] Defining and representing the actual coding mapping for the client application.

[0040] Optionally, the defining and representing of the actual coding mapping for the client application includes:

[0041] Introducing a Java class definition corresponding to the Schema definition of the graph vertex element in the client application;

[0042] Introduce fields of a class with attributes of corresponding point elements in the client application;

[0043] Introduce a class definition with the Schema definition of corresponding graph edge elements in the client application;

[0044] Introduce fields of a class with attributes of corresponding edge elements in the client application.

[0045] On the other hand, the present application also provides an object-oriented graph database Gremlin interface access system, including:

[0046] A client, configured to access based on a query requirement through an introduced object-oriented graph query interface based on the Java language; and based on an introduced mapping mechanism from Java objects to Gremlin graph data, convert operations based on Java objects into Gremlin query statements for querying.

[0047] Optionally, the client includes:

[0048] An access module: configured to access based on a query requirement through an introduced object-oriented graph query interface based on the Java language;

[0049] A query module, configured to convert operations based on Java objects into Gremlin query statements for querying based on an introduced mapping mechanism from Java programming language objects to Gremlin graph data.

[0050] Optionally, the access module is specifically configured to:

[0051] When the query requirement is a graph element query by ID, access through an object-oriented graph element query interface by ID; when the query requirement is a query with query conditions, access through an object-oriented query interface with query conditions; when the query requirement is a graph traversal query, access through a graph traversal query interface;

[0052] Among them, the object-oriented graph query interface based on the Java language includes: an object-oriented graph element query interface by ID, an object-oriented query interface with query conditions, and a graph traversal query interface.

[0053] Optionally, the introduced mapping mechanism from Java programming language objects to Gremlin graph data in the query module specifically includes:

[0054] Map each point type in the graph database to a class in the Java language based on the mapping mechanism from Java programming language objects to Gremlin graph data;

[0055] Based on the mapping mechanism from objects in the Java programming language to Gremlin graph data, each edge type in the graph database is also mapped to a class in the Java language;

[0056] Based on the mapping mechanism from objects in the Java programming language to Gremlin graph data, each property of a vertex or an edge in the graph database is mapped to a field of a class in the Java language.

[0057] Optionally, in the query module, the operations based on Java objects are converted into Gremlin query statements for querying. The specific implementation steps include:

[0058] When the query requirement is to query graph elements by ID, the client Driver performs the Gremlin conversion for querying graph elements by ID;

[0059] When the query requirement has query conditions, the client Driver performs the Gremlin conversion for querying with query conditions;

[0060] When the query requirement is a graph traversal query, the client Driver performs the Gremlin conversion for graph traversal query.

[0061] Optionally, the query module is also used to introduce Predicate in the process of object-oriented graph data query, where Predicate is a predicate;

[0062] Among them, Predicate includes: not equal (neq), equal (eq), greater than (gt), less than (lt), less than or equal to (lte), and greater than or equal to (gte).

[0063] Optionally, it further includes a definition module for defining and representing the actual coding mapping for the client.

[0064] Optionally, the definition module is specifically used for:

[0065] Introducing the Java class definition corresponding to the Schema definition of the graph vertex elements in the client;

[0066] Introducing the fields of the class corresponding to the properties of the vertex elements in the client;

[0067] Introducing the class definition corresponding to the Schema definition of the graph edge elements in the client;

[0068] Introducing the fields of the class corresponding to the properties of the edge elements in the client.

[0069] On the other hand, the present application also provides a computing device, including: one or more processors;

[0070] The processor is used to execute one or more programs;

[0071] When the one or more programs are executed by the one or more processors, an object-oriented graph database Gremlin interface access method as described above is implemented.

[0072] On the other hand, the present application also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed, an object-oriented graph database Gremlin interface access method as described above is implemented.

[0073] Compared with the prior art, the beneficial effects of the present invention are:

[0074] The present invention provides an object-oriented graph database Gremlin interface access method, including: when querying through a client, based on the query requirements, accessing through an introduced graph query interface in an object-oriented manner based on the Java language; based on the introduced mapping mechanism from objects in the Java programming language to Gremlin graph data, converting operations based on Java objects into Gremlin query statements for querying. The present invention introduces a mapping mechanism from "objects" at the client programming language level to the data on the "graph database" server side for the graph database, introduces a mapping method from objects to graph elements for the graph database based on the Gremlin graph query language, and provides an object-oriented graph data access technology for clients developed in the Java language. BRIEF DESCRIPTION OF THE DRAWINGS

[0075] Figure 1 It is a flowchart of an object-oriented graph database Gremlin interface access method of the present invention;

[0076] Figure 2 It is a flowchart of the working process of an object-oriented graph database Gremlin interface access method of the present invention introducing a client Java language. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0077] The present invention proposes an object-oriented graph database Gremlin interface access method, innovatively introducing a "object-oriented" Gremlin graph object representation method based on the Java language, and a conversion technology from object-oriented Java object instance queries to Gremlin query statements.

[0078] Embodiment 1:

[0079] An object-oriented graph database Gremlin interface access method, as Figure 1 shown, includes:

[0080] Step S1: When querying through the client, based on the query requirements, access through the introduced graph query interface in an object-oriented manner based on the Java language.

[0081] Step S2: Based on the introduced mapping mechanism from Java programming language objects to Gremlin graph data, convert operations based on Java objects into Gremlin query statements for querying.

[0082] The present invention introduces a mapping mechanism (Object Graphic Mapping, OGM) from "objects" at the programming language level of a client application to server-side data (such as vertices, edges, etc.) in a graph database, and introduces a mapping method from objects to graph elements (such as vertices, edges, properties, etc.) for a graph database based on the Gremlin graph query language, providing an object-oriented graph data access technology for client applications developed in the Java language.

[0083] The present invention introduces a client-side object-oriented mapping and access method based on the Gremlin graph query language, and proposes a client-side access technology from Java language objects to data points and edge elements of the Gremlin graph query language:

[0084] Introduce a mapping mechanism from "objects" in the Java language to "graph data";

[0085] Introduce a conversion technology from Java object operations to Gremlin statements when querying through this mapping mechanism on the client side.

[0086] The following combines Figure 2 The technical solution of the present invention is described step by step as follows.

[0087] Before step S1, it also includes:

[0088] Step 1: Introduce a mapping mechanism from Java programming language objects to Gremlin graph data.

[0089] The mapping mechanism from Java language objects to graph data supports the mapping between Java types (i.e., classes / Class) and graph data (vertices, edges, properties). Specifically, this mapping mechanism includes the following:

[0090] Each type of vertex in the graph database is mapped to a class in the Java language. Here, each "type" of vertex can correspond to a Schema in some graph databases. For example, in a graph database instance, there are vertex Schemas such as "student" and "teacher". "Student" and "teacher" can be mapped as vertex types in the graph instance to classes in the Java language, that is, represented by classes in the Java language. For example, introduce classes Student and Teacher;

[0091] Each type of edge in the graph database is also mapped to a class in the Java language. For example, in a graph database instance, the directed edge "teacher" - "teach" -> "student", which represents the "teach" edge from the "teacher" vertex to the "student" vertex, can introduce a corresponding class (such as the TeacherTeachStudent class corresponding to "teach", the name is just for example) in the Java code on the client side;

[0092] Each attribute of a vertex (or edge) in the graph database is mapped to a field of a class in the Java language. For example, the attributes of the "student" vertex, such as the "student ID" and "name" of the "student", are mapped to the fields studentId and name of the corresponding class Student of the "student". The attributes of the edge can be processed according to the same rule

[0093] Through the above mapping method, the vertex and edge elements and their attributes in the graph database can be represented by classes and fields of classes defined in the application code in the Java language, which correspond to the specific types of vertices and edges in the graph database.

[0094] To achieve the engineering implementation of the above mapping, the client application actualizes the definition and representation of the mapping in the following ways:

[0095] The client application introduces the Java class definition corresponding to the Schema definition of the graph vertex element. This type of definition inherits from a common base class that is common to vertex types, and this base class provides basic operations for vertex types (such as accessing outgoing edges and incoming edges based on the vertex);

[0096] The client application introduces the fields of the class corresponding to the attributes of the vertex element;

[0097] The client application introduces the class definition corresponding to the Schema definition of the graph edge element. This type of definition inherits from a common base class that is common to edge types, and this base class provides basic operations for edge types (such as accessing the outgoing vertex and incoming vertex based on the edge);

[0098] The client application introduces the fields of the class corresponding to the attributes of the edge element.

[0099] According to such a mapping method, for a vertex like "Student" in the sample graph database, its attributes are "age" (INTEGER / integer type), "student ID" (STRING / string type), and "ID number" (STRING / string type), and the mapped Java types are:

[0100]

[0101] Similarly, for a vertex like "Teacher" in the sample graph database, its attributes are "subject" (STRING / string type) and "teacher qualification number" (STRING / string type), and the mapped Java types are:

[0102]

[0103] After the above Java type definitions, they can be used for the conversion from object - oriented instances to Gremlin general instances (general vertex and edge instances), and can also be used for the conversion from Gremlin general instances to Java object - oriented instances. Corresponding to the two Java types mentioned above:

[0104] The Student and Teacher in the above examples can be converted into corresponding Gremlin vertex object instances;

[0105] Gremlin vertex object instances can also be converted into Student or Teacher instances here when the vertex type matches.

[0106] Step 2: Introduce a graph query interface based on the object - oriented method in the Java language

[0107] Based on the mapping between the above graph elements and Java objects, introduce a query - level interface for the newly introduced Java types.

[0108] 1) Graph element query for ID

[0109] The graph element query for ID specifies the ID of a graph vertex (or edge), and queries the vertex (or edge) element according to this ID. In the object - oriented scenario introduced by the present invention, the introduced object - oriented query interface is:

[0110] <Vertex / Edge Java type> object = session.get(elementId, <Vertex / Edge Java type>.class);

[0111] Here, a session represents a legitimate user session on top of a connection from the client to the graph database server side. The session can be provided by the graph database client driver and is generated on the client after specifying the connection string from the client to the graph database server side and the authentication method for the legitimate user (such as username and password authentication method, OAuth authentication method, etc.) and successfully logging in.

[0112] In the above interface, elementId is the unique ID of a vertex (or edge) in the graph database. For example, when specifying the vertex id (studentId) of a certain "student", the sample query corresponding to the above interface for Student is:

[0113] Student student = session.get(studentId, Student.class);

[0114] From this, it can be seen that for ID-oriented queries, the interface method introduced by the present invention is in a way oriented to a specific Java type (i.e., the Student class exemplified here), neither in a string way nor in a general way accessing with specific application classes like the Vertex class in Java as exemplified above. Therefore, it is a truly object-oriented graph database access method.

[0115] 2) Queries with query conditions

[0116] Queries with query conditions refer to specifying query conditions in graph queries, such as specifying the label (i.e., the name of the Schema) in the graph instance for query, specifying the property value in the graph instance for query, etc.

[0117] For the object-oriented scenario introduced by the present invention, the introduced object-oriented query interface is:

[0118] Query query = session.createQuery();

[0119] Iterator iterator = query.get(<Java type of vertex or edge>, <variable-length parameter list for specifying label and property value conditions during query>);

[0120] In this interface, <Java type of point or edge> is the target Java type name for the actual query. The "variable-length parameter list" section is a "pair" of "condition type + condition value". The "condition type" can be a Label or an attribute name, and the "condition value" can be the name of a Label or the value of an attribute. The "variable-length parameter list" consists of pairs of "condition type" and "condition value". For example, when querying for students whose point type is "student" (i.e., the label name is student) and age is equal to 15, the actual code corresponding to the above query process is:

[0121] Query query = session.createQuery();

[0122] Iterator iterator = query.get(Student.class, Label, "student", "age", 15);

[0123] The obtained result exists in the form of an Iterator. For the students with the label of student and age equal to 15 in the above example, when the query result can get multiple student query results, through the following Java code, using the query method introduced here, the data information of each student can be directly obtained, and then managed in a List (a container in the Java language):

[0124]

[0125] It can be seen from this that for this query method with query conditions, the interface method introduced by the present invention is in a way oriented to a specific Java type (i.e., the Student class or Teacher class exemplified here), neither in the form of a string nor in a general way that accesses specific application classes like the Vertex class in Java, so it is a truly object-oriented graph database access method.

[0126] 3) Graph traversal query

[0127] For graph traversal operations, common ones include accessing its adjacent edges through a point (such as "only out edges", "only in edges", or "out edges + in edges"), and accessing its in-point or out-point (or in-point + out-point) through an edge.

[0128] As mentioned above, the Java "class" corresponding to the "point" type of the graph inherits from a common point base class, and thus has the corresponding operations of the "point" type. Specifically, for the point type, the following Java "class"-level operations are supported:

[0129] · Obtain the outgoing edges of a vertex through outE();

[0130] · Obtain the incoming edges of a vertex through inE();

[0131] · Obtain the outgoing and incoming edges of a vertex through bothE();

[0132] For the vertex "student" mentioned above, when it is necessary to access its incoming edges (specifying the specific incoming edge type as TeacherTeachStudent), it can be accessed through the following sample code (where the student object is an instance object of the Student class obtained in the above steps):

[0133] List <teacherteachstudent>outEdges =

[0134] student.outE(TeacherTeachStudent.class);

[0135] For a more complex multi-step graph traversal method, for example: starting from a specific "student" node, find all adjacent "teacher" nodes with "teach" as the incoming edge, and then find all "student" nodes that are outgoing edges of these adjacent "teacher" nodes with "teach". Such a query logic is actually: find the list of students taught by all teachers who teach a certain student. The object-oriented query method corresponding to such a query logic is (still starting from an instance object of the Student class obtained from the above query):

[0136] List <student>queriedStudents =

[0137] student.out(TeacherTeachStudent.class, Student.class)

[0138] .in(TeacherTeachStudent.class, Student.class);

[0139] Similar to the above interface, the type interface here does not use strings, but accesses through the Java language level and in a way oriented to type-specific information, which is a real page object access method.

[0140] It should be noted that in the above interface definition, "equivalent" queries are used during querying, that is, the label names are equal and the attribute values are equal as conditions. However, in the actual query environment, there are other judgment conditions besides "equivalent", such as not equal, greater than, less than, etc. In this regard, Predicate (predicate) is introduced in the process of object-oriented graph data query:

[0141] · Introduce not equal (neq), equal (eq), greater than (gt), less than (lt), not greater than (lte), not less than (gte);

[0142] · Among them, equal (eq) can be omitted, so directly writing the age query condition as 15 and writing

[0143] eq(15) have the same effect.

[0144] In the case of applying Predicate, the query conditions in different scenarios can be expressed as follows:

[0145] Iterator iterator = query.get(Student.class, Label, "student", "age", gt(15)); / / Older than 15 years old

[0146] Iterator iterator = query.get(Student.class, Label, "student", "age", lte(15)); / / Not older than 15 years old

[0147] Step S1: When querying through the client, based on the query requirements, access through the introduced graph query interface in an object-oriented manner based on the Java language, specifically including:

[0148] When the query requirement is to query graph elements of ID, access through the object-oriented graph element query interface of ID;

[0149] When the query requirement is a query with query conditions, it is accessed through an object-oriented query interface with query conditions.

[0150] When the query requirement is a graph traversal query, it is accessed through the graph traversal query interface.

[0151] Among them, the graph query interface in an object-oriented manner based on the Java language includes: a graph element query interface for object-oriented IDs, an object-oriented query interface with query conditions, and a graph traversal query interface.

[0152] Step S2: Based on the introduced mapping mechanism from objects in the Java programming language to Gremlin graph data, convert the operations based on Java objects into Gremlin query statements for querying, specifically including:

[0153] Among them, the introduced mapping mechanism from objects in the Java programming language to Gremlin graph data includes:

[0154] Based on the mapping mechanism from objects in the Java programming language to Gremlin graph data, map each vertex type in the graph database to a class in the Java language;

[0155] Based on the mapping mechanism from objects in the Java programming language to Gremlin graph data, map each edge type in the graph database to a class in the Java language;

[0156] Based on the mapping mechanism from objects in the Java programming language to Gremlin graph data, map each property of a vertex or an edge in the graph database to a field of a class in the Java language;

[0157] Converting the operations based on Java objects into Gremlin query statements for querying includes:

[0158] When the query requirement is a graph element query by ID, the client Driver performs Gremlin conversion for the graph element query by ID;

[0159] When the query requirement is with query conditions, the client Driver performs Gremlin conversion for the query with query conditions;

[0160] When the query requirement is a graph traversal query, the client Driver performs Gremlin conversion for the graph traversal query.

[0161] Step S2 is specifically as follows:

[0162] When the client queries through OGM, it converts operations based on Java objects into Gremlin query statements and submits them to the graph database for execution.

[0163] The client Driver provides the conversion from object-oriented queries to Gremlin language queries.

[0164] 1) Gremlin conversion for graph element queries by ID

[0165] For queries in the form: <Vertex / Edge Java type> object = session.get(elementId, <Vertex / Edge Java type>.class); the converted Gremlin language is:

[0166] Iterator iterator = g.V(elementId);

[0167] This statement performs a Gremlin query for the specified element ID and returns an Iterator of instances of the general Vertex / Edge type in Gremlin. After execution, for each call to the Iterator, through the method (<Vertex / Edge Java type>)iterator.next(), according to the aforementioned Java type definition of the present invention, it can be converted into an instance of the target Java type.

[0168] 2) Gremlin conversion for queries with query conditions

[0169] For queries in the form: Iterator iterator = query.get(<Vertex or Edge Java type>.class, <variable-length parameter list for specifying label and property value conditions during query>); the converted Gremlin language is:

[0170] Iterator iterator = g.V().hasLabel('label name').property('property name', 'property value');

[0171] This statement performs a Gremlin query for the specified element ID and returns an Iterator of instances of the general Vertex / Edge type in Gremlin. After execution, for each call to the Iterator, through the method (<Vertex / Edge Java type>)iterator.next(), according to the aforementioned Java type definition of the present invention, it can be converted into an instance of the target Java type.

[0172] For example, for the object-oriented query.get(Student.class, Label, "student",

[0173] "age", 15) call, the transformed Gremlin query is: Iterator iterator =

[0174] g.V().hasLabel('student').property('age', '15');

[0175] 3) Gremlin Transformation of Graph Traversal Queries

[0176] For a query such as outE() to obtain the outgoing edges of a vertex, the transformed Gremlin language is the outE() operation on the corresponding single vertex element.

[0177] For example: List <teacherteachstudent>outEdges =

[0178] student.outE(TeacherTeachStudent.class);

[0179] The transformed Gremlin is (where studentId is the studentId field of the student object in the Java object - oriented language):

[0180] Iterator iterator = g.V(studentId).outE();

[0181] This statement performs a Gremlin query for a specified element ID and returns an Iterator of an instance of the general vertex - edge type in Gremlin. After execution, for each call of the Iterator, through the method (<vertex - edge Java type>)iterator.next(), according to the aforementioned Java type definition of the present invention, it can be transformed into an instance of the target Java type. For the specific instance here, each edge traversed by the Iterator is an edge of the type that a teacher "teaches" a student, that is, Driver is correspondingly transformed into an instance of the TeacherTeachStudent.class type.

[0182] Embodiment 2:

[0183] The present invention based on the same inventive concept also provides an object - oriented graph database Gremlin interface access system, including:

[0184] A client, configured to access based on query requirements through the introduced object - oriented graph query interface based on the Java language; and based on the introduced mapping mechanism from Java objects to Gremlin graph data, transform operations based on Java objects into Gremlin query statements for querying.

[0185] Optionally, the client includes:

[0186] An access module: configured to access based on query requirements through the introduced object - oriented graph query interface based on the Java language;

[0187] A query module, configured to, based on the introduced mapping mechanism from Java programming language objects to Gremlin graph data, transform operations based on Java objects into Gremlin query statements for querying.

[0188] Optionally, the access module is specifically configured to:

[0189] When the query requirement is for querying graph elements with ID, it is accessed through the object-oriented graph element query interface for ID; when the query requirement is for a query with query conditions, it is accessed through the object-oriented query interface with query conditions; when the query requirement is for graph traversal query, it is accessed through the graph traversal query interface;

[0190] Among them, the graph query interface in the object-oriented manner based on the Java language includes: the object-oriented graph element query interface for ID, the object-oriented query interface with query conditions, and the graph traversal query interface.

[0191] Optionally, the mapping mechanism from objects in the Java programming language to Gremlin graph data introduced in the query module specifically includes:

[0192] Mapping each vertex type in the graph database to a class in the Java language based on the mapping mechanism from objects in the Java programming language to Gremlin graph data;

[0193] Mapping each edge type in the graph database to a class in the Java language based on the mapping mechanism from objects in the Java programming language to Gremlin graph data;

[0194] Mapping each property of a vertex or edge in the graph database to a field of a class in the Java language based on the mapping mechanism from objects in the Java programming language to Gremlin graph data.

[0195] Optionally, the query module converts operations based on Java objects into Gremlin query statements for querying, and the specific implementation steps include:

[0196] When the query requirement is for querying graph elements with ID, the client Driver performs Gremlin conversion for the graph element query for ID;

[0197] When the query requirement is for a query with query conditions, the client Driver performs Gremlin conversion for the query with query conditions;

[0198] When the query requirement is for graph traversal query, the client Driver performs Gremlin conversion for the graph traversal query.

[0199] Optionally, the query module is also used to introduce Predicate in the object-oriented graph data query process, where Predicate is a predicate;

[0200] Among them, Predicate includes: not equal neq, equal eq, greater than gt, less than lt, less than or equal to lte, and greater than or equal to gte.

[0201] Optionally, it further includes a definition module for defining and representing the actual coding mapping of the client.

[0202] Optionally, the definition module is specifically used for:

[0203] Introduce the Java class definition of the corresponding graph point element Schema definition in the client;

[0204] Introduce the fields of the class corresponding to the attributes of the point element in the client;

[0205] Introduce the class definition of the corresponding graph edge element Schema definition in the client;

[0206] Introduce the fields of the class corresponding to the attributes of the edge element in the client.

[0207] Embodiment 3:

[0208] Based on the same inventive concept, the present invention further provides a computer device, which includes a processor and a memory. The memory is used to store a computer program, and the computer program includes program instructions. The processor is used to execute the program instructions stored in the computer storage medium. The processor may be a Central Processing Unit (CPU), or may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, and is suitable for implementing one or more instructions. Specifically, it is suitable for loading and executing one or more instructions in the computer storage medium to implement the corresponding method flow or corresponding function, so as to implement the steps of an object-oriented graph database Gremlin interface access method in the above embodiment.

[0209] Embodiment 4:

[0210] Based on the same inventive concept, the present invention also provides a storage medium, specifically a computer-readable storage medium (Memory). The computer-readable storage medium is a memory device in a computer device, used to store programs and data. It can be understood that the computer-readable storage medium here can include both the built-in storage medium in the computer device and, of course, the extended storage medium supported by the computer device. The computer-readable storage medium provides a storage space, and this storage space stores the operating system of the terminal. Moreover, in this storage space, one or more instructions suitable for being loaded and executed by the processor are also stored. These instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. One or more instructions stored in the computer-readable storage medium can be loaded and executed by the processor to implement the steps of a method for accessing a Gremlin interface of an object-oriented graph database in the above-mentioned embodiments.

[0211] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program codes.

[0212] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of the flows and / or blocks in the flowchart and / or block diagram can also be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0213] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements the functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 The functions specified in one or more boxes.

[0214] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable device provide for implementing the steps of the functions specified in one Figure 1 process or more processes and / or boxes Figure 1 or more boxes.

[0215] The above are only embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention are included within the scope of the claims of the present invention pending approval.< / teacherteachstudent> < / student> < / teacherteachstudent>

Claims

1. An access method for the Gremlin interface of an object-oriented graph database, characterized in that, Including: When querying through the client, based on the query requirements, access is made through the introduced graph query interface in an object-oriented manner based on the Java language. Based on the introduced mapping mechanism from objects in the Java programming language to Gremlin graph data, operations based on Java objects are transformed into Gremlin query statements for querying.

2. The method according to claim 1, wherein The access through the introduced graph query interface in an object-oriented manner based on the Java language according to the query requirements includes: When the query requirement is a graph element query by ID, access is made through the object-oriented graph element query interface by ID. When the query requirement is a query with query conditions, access is made through the object-oriented query interface with query conditions. When the query requirement is a graph traversal query, access is made through the graph traversal query interface. Among them, the graph query interface in an object-oriented manner based on the Java language includes: the object-oriented graph element query interface by ID, the object-oriented query interface with query conditions, and the graph traversal query interface.

3. The method according to claim 1, wherein The introduced mapping mechanism from objects in the Java programming language to Gremlin graph data includes: Based on the mapping mechanism from objects in the Java programming language to Gremlin graph data, each vertex type in the graph database is mapped to a class in the Java language. Based on the mapping mechanism from objects in the Java programming language to Gremlin graph data, each edge type in the graph database is also mapped to a class in the Java language. Based on the mapping mechanism from objects in the Java programming language to Gremlin graph data, each property of a vertex or an edge in the graph database is mapped to a field of a class in the Java language.

4. The method according to claim 1, characterized in that, The transformation of operations based on Java objects into Gremlin query statements for querying includes: When the query requirement is a graph element query by ID, the client Driver performs Gremlin transformation for the graph element query by ID. When the query requirement is a query with query conditions, the client Driver performs Gremlin transformation for the query with query conditions. When the query requirement is a graph traversal query, the client Driver performs Gremlin transformation for the graph traversal query.

5. The method according to claim 1, wherein It also includes: introducing Predicate in the process of object-oriented graph data query, where Predicate is a predicate. Among them, Predicate includes: not equal neq, equal eq, greater than gt, less than lt, less than or equal to lte, and greater than or equal to gte.

6. The method according to claim 1, characterized in that, Before querying through the client, it also includes: Defining and representing the actual coding mapping of the client.

7. The method according to claim 6, wherein The defining and representing of the actual coding mapping of the client includes: Introducing the Java class definition corresponding to the Schema definition of the graph vertex element in the client. Introducing the fields of the class corresponding to the properties of the vertex element in the client. Introducing the class definition corresponding to the Schema definition of the graph edge element in the client. Introducing the fields of the class corresponding to the properties of the edge element in the client.

8. An object-oriented graph database Gremlin interface access system, characterized in that, Including: A client, which is used to access based on query requirements through the introduced graph query interface in an object-oriented manner based on the Java language; and Based on the introduced mapping mechanism from objects in the Java programming language to Gremlin graph data, operations based on Java objects are converted into Gremlin query statements for querying.

9. A computer device, characterized in that, It includes: One or more processors; The processor is used to store one or more programs; When the one or more programs are executed by the one or more processors, an object-oriented graph database Gremlin interface access method as described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and when the computer program is executed, an object-oriented graph database Gremlin interface access method as described in any one of claims 1 to 7 is implemented.