CN114356302A - Gremlin language-based persistence layer optimization method - Google Patents

Gremlin language-based persistence layer optimization method Download PDF

Info

Publication number
CN114356302A
CN114356302A CN202210251927.7A CN202210251927A CN114356302A CN 114356302 A CN114356302 A CN 114356302A CN 202210251927 A CN202210251927 A CN 202210251927A CN 114356302 A CN114356302 A CN 114356302A
Authority
CN
China
Prior art keywords
graph database
graph
interface
database operation
script
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210251927.7A
Other languages
Chinese (zh)
Other versions
CN114356302B (en
Inventor
于广郢
温立旭
胡蕾蕾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangsu Shudui Technology Co ltd
Original Assignee
Jiangsu Shudui Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jiangsu Shudui Technology Co ltd filed Critical Jiangsu Shudui Technology Co ltd
Priority to CN202210251927.7A priority Critical patent/CN114356302B/en
Publication of CN114356302A publication Critical patent/CN114356302A/en
Application granted granted Critical
Publication of CN114356302B publication Critical patent/CN114356302B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a persistence layer optimization method based on Gremlin language, wherein a user initiates graph database operation: adding schema data in the graph by a user, requesting to call an interface for creating the schema, and transmitting corresponding parameters; the Java application program calls a resource analysis interface according to the request; reading graph database connection information in the configuration information; the resource analysis interface analysis system loads a database operation script, replaces parameter placeholders in the database operation script with actual parameters, transmits the analyzed script to an actuator interface, the actuator interface is connected with a database, sends the analyzed script to a database server to execute database operation, and returns a result; the graph database operation result returns to the Java program; the Java program packages the returned graph database operation result; and the Java program returns the packaged result to the user and returns to execute the graph database operation initiated by the user.

Description

Gremlin language-based persistence layer optimization method
Technical Field
The invention relates to a graph database persistence layer optimization technology, in particular to a persistence layer optimization method based on Gremlin language.
Background
MyBatis is a relational database-based persistence framework that supports custom SQL, stored procedures, and advanced mapping.
MyBatis eliminates almost all JDBC codes and manual setting parameters and search results. MyBatis can be configured using simple XML or annotations and maps primitives, Mapper interfaces, and Java POJO (Plain Old Java Objects) to database records.
The MyBatis persistence framework defines the self-defined SQL statement and the mapping of the database table and the Java object in the XML file, replaces the parameters in the analyzed SQL statement by analyzing the XML file and the Java reflection technology, and maps the SQL execution result with the JAVA object. Through the dynamic proxy technology, the method in the Mapper interface is executed to achieve the effect of executing the SQL statement.
The MyBatis persistence framework is integrated with the Spring framework, data sources, database connections and transactions are automatically managed through programs, and JDBC related codes are hardly embedded in the application.
The existing graph database-based persistence layer is manually connected with a graph database, graph database transactions are manually started and submitted, Gremlin traversal graph statements are hard-coded in codes, and graph operation is carried out.
The Atlas open source component manages the graph operation statements by enumerating classes, and is essentially hard-coded in the application.
The MyBatis persistence framework is a relational database-based component that cannot support graph databases.
The administration of the Atlas open source component for the graph database language is also hard coded in the code, and parameter replacement also requires manual replacement.
In the prior art, unified graph database persistent layer management, graph database statement management, parameter replacement and the like are not formed, manual hard coding is required, centralized management is not required, the management is scattered in application codes, and the code maintenance cost is high.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides a Gremlin language-based persistent layer optimization method which can form unified graph database persistent layer management, graph database statement management, parameter replacement and the like, does not need manual hard coding, applies code centralized management and has low code maintenance cost.
The purpose of the invention is realized by the following technical scheme.
A persistence layer optimization method based on Gremlin language comprises the following steps:
1) user initiates graph database operation: adding schema data in the graph by a user, requesting to call an interface for creating the schema, and transmitting corresponding parameters;
2) the Java application program calls a resource analysis interface according to the request;
3) reading graph database connection information in the configuration information;
4) the resource analysis interface analysis system loads a graph database operation script, replaces parameter placeholders in the returned graph database operation script with actual parameters, transmits the analyzed script to an actuator interface, the actuator interface is connected with a graph database, sends the analyzed script to a graph database server to execute graph database operation, and returns a result;
5) the graph database operation result returns to the Java program;
6) the Java program packages the returned graph database operation result;
7) and the Java program returns the packaged result to the user and returns to execute the step 1), and the method is ended.
The step 3) is specifically as follows: the resource analysis interface calls a resource loading interface to load the configured graph database operation script; the resource analysis interface calls a graph session factory interface to acquire graph database connection information.
And 4) uniformly managing the database operation scripts by the configuration class, and completing the loading of the scripts and the mapping between the scripts and the database operation interface when the Java program is started.
The step of sending the analyzed script to the graph database server to execute the graph database operation is to uniformly manage the link between the Java program and the graph database server through a session interface, wherein the session interface is responsible for opening the link between the Java program and the graph database server, sending the graph database operation script to the graph database server, then retrieving the execution result of the graph database operation script, and destroying the link.
The configuration class defines: the configuration class centrally manages XML configuration files, the XML configuration files comprise a graph database operation script, the graph database operation script comprises parameter placeholders needing to be replaced, the type of the output result and the mapping relation between entities in the configuration graph database and JAVA objects.
The graph session factory interface defines: the graph session factory interface uniformly manages all graph session information of the current service instance, and the all graph session information comprises generation and destruction of graph sessions.
The session interface defines methods for adding, deleting, changing, checking, list inquiring, transaction submitting and transaction rolling back of a graph database, and the operations of the graph database are uniformly operated through graph sessions which are isolated from each other.
And defining the actuator interface, namely adding, deleting, modifying and checking the database operated by the actuator interface, acquiring the database transaction, rolling back the transaction and submitting the transaction by finance.
The resource loading interface defines: and uniformly managing the loading of the configuration file.
The resource parsing interface defines parsing the configuration file and replacing parameters in the configuration file.
Compared with the prior art, the invention has the advantages that: the invention develops the database persistent layer component by technical means such as Java reflection, Java generalization, dynamic proxy, XML analysis and the like and design means such as Java design mode and the like, and is used for intensively managing real-time information such as configuration, affairs and the like of the database, eliminating manual setting of Gremlin statement parameters and manually retrieving a result set. By using the scheme of the invention, the database links and transactions can be uniformly managed through the database persistence component, resources can be managed in a centralized manner, upper-layer applications can be more concentrated in business logic, the development workload is greatly reduced, the development efficiency is improved, the development cost is reduced, and the learning cost of operation and maintenance personnel can be reduced.
Drawings
FIG. 1 is a schematic diagram of the persistence framework of the present invention.
FIG. 2 is a flow chart of the present invention.
Detailed Description
The invention is described in detail below with reference to the drawings and specific examples.
As shown in fig. 2, a persistence layer optimization method based on Gremlin language includes the steps of:
1) user initiates graph database operation: adding schema data in the graph by a user, requesting to call an interface for creating the schema, and transmitting corresponding parameters;
2) the Java application program calls a resource analysis interface according to the request;
3) reading graph database connection information in the configuration information;
4) the resource analysis interface analysis system loads a graph database operation script, replaces parameter placeholders in the returned graph database operation script with actual parameters, transmits the analyzed script to an actuator interface, the actuator interface is connected with a graph database, sends the analyzed script to a graph database server to execute graph database operation, and returns a result;
5) the graph database operation result returns to the Java program;
6) the Java program packages the returned graph database operation result;
7) and the Java program returns the packaged result to the user and returns to execute the step 1), and the method is ended.
The step 3) is specifically as follows: the resource analysis interface calls a resource loading interface to load the configured graph database operation script; the resource analysis interface calls a graph session factory interface to acquire graph database connection information.
And 4) uniformly managing the database operation scripts by the configuration class, and completing the loading of the scripts and the mapping between the scripts and the database operation interface when the Java program is started.
The step of sending the analyzed script to the graph database server to execute the graph database operation is to uniformly manage the link between the Java program and the graph database server through a session interface, wherein the session interface is responsible for opening the link between the Java program and the graph database server, sending the graph database operation script to the graph database server, then retrieving the execution result of the graph database operation script, and destroying the link.
As shown in fig. 1, a configuration (GraphConfiguration) class is defined, an XML configuration file is managed in a centralized manner, the XML configuration file contains a graph database operation sentence, the sentence contains a parameter placeholder to be replaced, a result type is output, and a mapping relationship between an entity in a graph database and a JAVA object is configured.
A graph session factory (grahppolicy) interface is defined to uniformly manage all graph session information of the current service instance. Including the generation and destruction of graph sessions.
Defining Graph conversation (Graph) interface, the interface defines the method of adding, deleting, changing, checking, list inquiry, transaction submission, transaction rollback and the like of Graph database, the operation of Graph database is operated by Graph conversation, and the Graph conversations are isolated from each other.
Defining an Executor (executing) interface, wherein a database session does not directly operate a database, but operates the database through an Executor, and realizing various executors including basic executors, batch executors, simple executors, cache executors and the like which are adapted to not be operated by the database of an application scene through a strategy mode. The executor includes true operations of adding, deleting, modifying, checking and the like of the graph database, and also includes operations of obtaining graph database transactions, rolling back transactions, submitting transactions and the like.
Defining a resource loading interface (resourceloader), and uniformly managing the loading of the configuration file, wherein the interface only comprises the resource loading interface.
A resource parsing interface (ResourceParser) is defined, the configuration file is parsed and parameters in the configuration file are replaced.
In order to facilitate the development of the personalized requirements of the user, the user can make customized development by realizing the form of a plug-in interface. The plug-in class (plug) is defined and used for managing plug-ins in a unified mode, developers can customize plug-ins to expand functions of the persistence layer, for example, the plug-ins can be defined, paging functions can be achieved, plug-ins for printing complete graph database operation statements are defined, and the plug-ins are convenient for the developers to locate problems. The customized plug-ins are all uniformly managed by the plug-in class.
The method is adopted for the graph data operation in the graph database in the knowledge service platform, the graph data operation scripts are managed in a unified mode and are configured in the operation script configuration file in a unified mode, and the linkage between the Java program and the graph database server side is maintained in a unified mode. By the method, the graph data operation script is prevented from scattering in each corner of the program, and the maintainability and the development efficiency of the program are greatly improved.

Claims (10)

1. A persistence layer optimization method based on Gremlin language is characterized by comprising the following steps:
1) user initiates graph database operation: adding schema data in the graph by a user, requesting to call an interface for creating the schema, and transmitting corresponding parameters;
2) the Java application program calls a resource analysis interface according to the request;
3) reading graph database connection information in the configuration information;
4) the resource analysis interface analysis system loads a graph database operation script, replaces parameter placeholders in the returned graph database operation script with actual parameters, transmits the analyzed script to an actuator interface, the actuator interface is connected with a graph database, sends the analyzed script to a graph database server to execute graph database operation, and returns a result;
5) the graph database operation result returns to the Java program;
6) the Java program packages the returned graph database operation result;
7) and the Java program returns the packaged result to the user and returns to execute the step 1), and the method is ended.
2. The method for optimizing a persistence layer based on the Gremlin language according to claim 1, wherein the step 3) is specifically: the resource analysis interface calls a resource loading interface to load the configured graph database operation script; the resource analysis interface calls a graph session factory interface to acquire graph database connection information.
3. The method for optimizing the persistence layer based on the Gremlin language according to claim 1 or 2, wherein the step 4) of the graph database operation script is uniformly managed by the configuration class, and the loading of the script and the mapping between the script and the graph database operation interface are completed when the Java program is started.
4. The Gremlin language-based persistence layer optimization method according to claim 1 or 2, wherein the step of sending the parsed script to the graph database server to execute the graph database operation is to uniformly manage the link between the Java program and the graph database server through a session interface, wherein the session interface is responsible for opening the link between the Java program and the graph database server, sending the graph database operation script to the graph database server, then retrieving the execution result of the graph database operation script, and destroying the link.
5. The method of claim 3, wherein the configuration class defines: the configuration class centrally manages XML configuration files, the XML configuration files comprise a graph database operation script, the graph database operation script comprises parameter placeholders needing to be replaced, the type of the output result and the mapping relation between entities in the configuration graph database and JAVA objects.
6. The Gremlin language-based persistence layer optimization method of claim 2, wherein the graph session factory interface defines: the graph session factory interface uniformly manages all graph session information of the current service instance, and the all graph session information comprises generation and destruction of graph sessions.
7. The method according to claim 4, wherein the session interface defines methods for adding, deleting, changing, searching, listing query, transaction submission and transaction rollback of graph databases, and the operations of the graph databases are uniformly operated by graph sessions which are isolated from each other.
8. The Gremlin language-based persistence layer optimization method of claim 1 or 2, wherein the executor interface defines that the executor interface operates on graph database addition, deletion, modification and check, and financially acquires graph database transactions, rolls back transactions and submits transactions.
9. The method of claim 2, wherein the resource loading interface defines: and uniformly managing the loading of the configuration file.
10. The Gremlin language-based persistence layer optimization method of claim 1 or 2, wherein the resource parsing interface defines parsing a configuration file and replacing parameters in the configuration file.
CN202210251927.7A 2022-03-15 2022-03-15 Gremlin language-based persistence layer optimization method Active CN114356302B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210251927.7A CN114356302B (en) 2022-03-15 2022-03-15 Gremlin language-based persistence layer optimization method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210251927.7A CN114356302B (en) 2022-03-15 2022-03-15 Gremlin language-based persistence layer optimization method

Publications (2)

Publication Number Publication Date
CN114356302A true CN114356302A (en) 2022-04-15
CN114356302B CN114356302B (en) 2022-06-21

Family

ID=81095034

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210251927.7A Active CN114356302B (en) 2022-03-15 2022-03-15 Gremlin language-based persistence layer optimization method

Country Status (1)

Country Link
CN (1) CN114356302B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101110030A (en) * 2007-08-23 2008-01-23 南京联创科技股份有限公司 Developing method for data base persistence layer based on JAVA
CN103049251A (en) * 2011-10-17 2013-04-17 中国移动通信集团公司 Database persistent layer device and database operation method
WO2020232569A1 (en) * 2019-05-17 2020-11-26 环球雅途集团有限公司 Database access layer representation method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101110030A (en) * 2007-08-23 2008-01-23 南京联创科技股份有限公司 Developing method for data base persistence layer based on JAVA
CN103049251A (en) * 2011-10-17 2013-04-17 中国移动通信集团公司 Database persistent layer device and database operation method
WO2020232569A1 (en) * 2019-05-17 2020-11-26 环球雅途集团有限公司 Database access layer representation method and device

Also Published As

Publication number Publication date
CN114356302B (en) 2022-06-21

Similar Documents

Publication Publication Date Title
US7895568B1 (en) Automatically generated objects within extensible object frameworks and links to enterprise resources
US7761406B2 (en) Regenerating data integration functions for transfer from a data integration platform
RU2441273C2 (en) Architecture of display with maintenance of increment representation
US7603658B2 (en) Application functionality for a test tool for application programming interfaces
US8321450B2 (en) Standardized database connectivity support for an event processing server in an embedded context
US8060863B2 (en) Conformance control module
US11726969B2 (en) Matching metastructure for data modeling
US20050243604A1 (en) Migrating integration processes among data integration platforms
US20050251533A1 (en) Migrating data integration processes through use of externalized metadata representations
US7865515B2 (en) Server side bucketization of parameterized queries
WO2001004726A9 (en) Automatically generated objects within extensible object frameworks and links to enterprise resources
US9563650B2 (en) Migrating federated data to multi-source universe database environment
US10402380B1 (en) Interactive user interface for schema transformation
CN117093599A (en) Unified SQL query method for heterogeneous data sources
US20190347341A1 (en) Method and system for schema transformation
CN112667598B (en) Data model rapid construction system based on business demand change
CN112487075B (en) Method for integrating relational database data conversion operators and non-relational database data conversion operators
CN112650526B (en) Method, device, electronic equipment and medium for detecting version consistency
CN116578585B (en) Data query method, device, electronic equipment and storage medium
CN114356302B (en) Gremlin language-based persistence layer optimization method
CN117033418A (en) Statement rewriting method, system and device
US11016830B2 (en) Entity-based service operation for object-based persistence
US7058651B2 (en) Method, computer program product, and system for automatic class generation with simultaneous customization and interchange capability
CN109857390B (en) Annotation transmission method of Git warehouse file annotation system
CN113868344A (en) Construction system, method and device for power application, server and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: A Persistence Layer Optimization Method Based on Gremlin Language

Granted publication date: 20220621

Pledgee: Bank of China Limited Nanjing Gulou Branch

Pledgor: Jiangsu shudui Technology Co.,Ltd.

Registration number: Y2024980004729

PE01 Entry into force of the registration of the contract for pledge of patent right