Database request processing method and device, electronic equipment, storage medium and program product

The database middleware determines the type of database request statement and obtains routing information, which solves the problem of high processing complexity in complex database request scenarios, and realizes efficient processing and deployment optimization of relational and non-relational databases.

CN119719076APending Publication Date: 2025-03-28INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411954745.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In complex database request scenarios, the complexity of database request processing is high, and the prior art is difficult to effectively distinguish the database type corresponding to the request statement, resulting in an increase in processing complexity.

Method used

The database middleware determines the database type corresponding to the request statement and determines the routing information of the target database based on the type, so as to distribute the request statement to the corresponding type of database queue for parsing, and finally obtains the request result from the target database.

Benefits of technology

This method reduces the complexity of database request processing in complex business scenarios, avoids the need to deploy relational and non-relational database systems respectively, and optimizes the database deployment architecture.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119719076A_ABST
    Figure CN119719076A_ABST
Patent Text Reader

Abstract

The invention provides a database request processing method and device, electronic equipment, a storage medium and a program product, and relates to the field of big data. The method comprises the following steps: a server receives a protocol message sent by a client, wherein the protocol message is obtained by packaging a request statement; routing information corresponding to the request statement is determined through database middleware, the routing information comprises a target database associated with the request statement and address information of the target database, the target database is a database matched with a database type corresponding to the request statement, and the database type is a relational database or a non-relational database; and obtaining a request result corresponding to the request statement from the target database according to the address information. According to the method, the complexity of database request processing is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of big data, and in particular to a database request processing method, device, electronic device, storage medium and program product. Background Art

[0002] With the rapid development of the Internet, the amount of data and access to databases has also increased, placing higher demands on the efficiency of complex and diverse database requests.

[0003] In the related art, database middleware is used to process and forward database requests. Specifically, the database middleware receives a database request statement sent by a client, processes the request statement, and sends the processed request statement to the database.

[0004] However, in the process of processing and forwarding database requests using the database middleware, in complex database request scenarios, the complexity of database request processing is high. Summary of the invention

[0005] The present application provides a database request processing method, device, electronic device, storage medium and program product to solve the technical problem of high complexity in database request processing.

[0006] In a first aspect, the present application provides a database request processing method, applied to a server, comprising:

[0007] Receive the protocol message sent by the client, which is obtained by encapsulating the request statement;

[0008] The protocol message is parsed and split by the database middleware to determine the request statement and the database type corresponding to the request statement;

[0009] Determine routing information corresponding to the request statement through the database middleware, the routing information includes the target database associated with the request statement and the address information of the target database, the target database is a database matching the database type corresponding to the request statement, and the database type is a relational database or a non-relational database;

[0010] According to the address information, the request result corresponding to the request statement is obtained from the target database.

[0011] In a second aspect, the present application provides a database request processing method, applied to a client, comprising:

[0012] Perform database type analysis on the request statement to determine the database type corresponding to the request statement, which is a relational database or a non-relational database;

[0013] Determine the target database protocol based on the database type corresponding to the request statement;

[0014] According to the target database protocol, the request statement is encapsulated and processed to obtain a protocol message;

[0015] Send protocol messages to the server.

[0016] In a third aspect, the present application provides a database request processing device, the device comprising:

[0017] A receiving unit, used for receiving a protocol message sent by a client, wherein the protocol message is obtained by encapsulating a request statement;

[0018] The first parsing unit is used to parse and split the protocol message through the database middleware to determine the request statement and the database type corresponding to the request statement;

[0019] A processing unit, configured to determine routing information corresponding to a request statement through a database middleware, wherein the routing information includes a target database associated with the request statement and address information of the target database, wherein the target database is a database matching a database type corresponding to the request statement, and the database type is a relational database or a non-relational database;

[0020] The acquisition unit is used to acquire the request result corresponding to the request statement from the target database according to the address information.

[0021] In a fourth aspect, the present application provides a database request processing device, the device comprising:

[0022] A second parsing unit is used to perform database type parsing on the request statement to determine the database type corresponding to the request statement, where the database type is a relational database or a non-relational database;

[0023] A determination unit, used to determine a target database protocol according to a database type corresponding to a request statement;

[0024] An encapsulation unit, used to encapsulate the request statement according to the target database protocol to obtain a protocol message;

[0025] The sending unit is used to send protocol messages to the server.

[0026] In a fifth aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;

[0027] Memory stores computer-executable instructions;

[0028] The processor executes the computer-executable instructions stored in the memory to implement the method described in the first aspect, or the processor executes the computer-executable instructions stored in the memory to implement the method described in the second aspect.

[0029] In a sixth aspect, the present application provides a computer-readable storage medium, in which computer-readable storage medium is stored computer execution instructions, which are used to implement the method described in the first aspect when the computer execution instructions are executed by a processor, or which are used to implement the method described in the second aspect when the computer execution instructions are executed by a processor.

[0030] In a seventh aspect, the present application provides a computer program product, comprising a computer program, which implements the method described in the first aspect when the computer program is executed by a processor, or implements the method described in the second aspect when the computer program is executed by a processor.

[0031] The database request processing method, device, electronic device, storage medium and program product provided by the present application, the server receives the protocol message sent by the client, the protocol message is obtained by encapsulating the request statement; then, the protocol message is parsed and split by the database middleware to determine the request statement and the database type corresponding to the request statement; thereby, the routing information corresponding to the request statement can be determined by the database middleware, the routing information includes the target database associated with the request statement, and the address information of the target database, the target database is a database matching the database type corresponding to the request statement, and the database type is a relational database or a non-relational database, and finally, according to the address information, the request result corresponding to the request statement is obtained from the target database, and for the protocol message encapsulated by the request statement of different database types, the database middleware can parse and split the protocol message, and then determine the corresponding routing information, so as to obtain the corresponding request result based on the routing information, so that in complex business scenarios, there is no need to deploy two types of database systems separately, the database deployment architecture is optimized, and the complexity of database request processing is reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0033] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application;

[0034] Figure 2 The process of the database request processing method provided in the embodiment of the present application Figure 1 ;

[0035] Figure 3The process of the database request processing method provided in the embodiment of the present application Figure 2 ;

[0036] Figure 4 A schematic diagram of the architecture of a database request processing method provided in an embodiment of the present application;

[0037] Figure 5 A signaling diagram of a database request processing method provided in an embodiment of the present application;

[0038] Figure 6 A schematic diagram of the structure of the database request processing device provided in the embodiment of the present application Figure 1 ;

[0039] Figure 7 A schematic diagram of the structure of the database request processing device provided in the embodiment of the present application Figure 2 ;

[0040] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0041] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0042] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0043] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0044] It should be noted that the database request processing method, device, electronic device, storage medium and program product provided in the present application can be used in the field of big data, and can also be used in any field other than big data. The application field of the database request processing method, device, electronic device, storage medium and program product in the present application is not limited.

[0045] With the rapid development of information technology, people's demands for the Internet have gradually diversified. In various business scenarios, not only high concurrent reading and writing are required, but also cumbersome and complex queries are required. In a distributed system environment, a single database is often difficult to meet the needs of large-scale data storage and high concurrent access. Therefore, database middleware technology is widely used in distributed database systems. Database middleware is located between the client and the database, acting as an intermediary layer responsible for coordinating and managing database access.

[0046] In the related art, for a distributed database system, the function of the database middleware is to process requests for a certain database protocol, such as request processing for a relational database protocol or a non-relational database protocol. Specifically, for a specific type of request, the client encapsulates the request statement into a protocol message through the Software Development Kit (SDK), sends the protocol message to the server, and the server receives the protocol message, parses the protocol message, obtains routing information, and forwards the request statement to the corresponding database node according to the routing information.

[0047] However, the above database middleware cannot effectively distinguish the database type corresponding to the request statement. In complex request scenarios, there is a problem of high complexity in database request processing.

[0048] Based on this, the embodiments of the present application provide a database request processing method, device, electronic device, storage medium and program product, which determine the database type corresponding to the request statement through the database middleware. The database types are divided into relational databases and non-relational databases. The request statements are sent to the corresponding types of database queues for parsing and processing, and finally the request results are obtained from the corresponding database, aiming to solve the above technical problems of the prior art.

[0049] First combine Figure 1 An applicable application scenario of the present application is introduced.

[0050] Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present application. Figure 1 As shown, it includes a client 11, a server 12, a relational database 13 and a non-relational database 14.

[0051] The client 11 and the server 12 can communicate through the network, and the server 12 and the database (including the relational database 13 and the non-relational database 14) can communicate through the network. The client 11 can be various electronic devices with a display screen, including but not limited to smart phones, tablet computers, desktop computers, portable computers, etc.; the server 12 is a server that provides request services for the client 11, and the database middleware is deployed on the server 12. The request service may include query requests, update requests, insert requests, and delete requests; the relational database 13 and the non-relational database 14 refer to two different types of databases, and the request statements of different types of databases are different.

[0052] The client 11 and the server 12 can communicate with each other through wireless communication or wired communication. The client 11 initiates a request, the server 12 responds to the request and performs semantic parsing on the request statement, and the server 12 sends the parsed request statement to the relational database 13 or the non-relational database 14, and obtains the request result from the corresponding database.

[0053] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0054] Figure 2 The process of the database request processing method provided in the embodiment of the present application Figure 1 , this method is applied to the client, such as Figure 2 As shown, the method includes:

[0055] S21, performing database type parsing processing on the request statement to determine the database type corresponding to the request statement, where the database type is a relational database or a non-relational database.

[0056] The request statement can be a database instruction entered by the user. The client receives the input request statement and parses the request statement into a database type through the SDK driver package. The SDK driver package is a set of drivers and related tools in the software development kit that support specific hardware devices or software platform functions. The SDK driver package provides the necessary components and interfaces required for the client to establish a connection with the database, and can recognize and process the syntax specific to different databases.

[0057] The request statement may contain instructions such as data query, data update, data insertion and data deletion. The client performs field detection on the request statement to obtain at least one command field and at least one object field; according to at least one command field or at least one object field, the database type corresponding to the request statement is obtained. Command fields may be, for example, SELECT (query), UPDATE (update), INSERT (insert), DELETE (delete), GET (query), INCR (increase), DECL (decrease), SET (set), DEL (delete), etc.; object fields may be, for example, noun fields containing table names, column names, key-value pairs, documents, graph structures, etc.

[0058] If the request statement includes fields such as SELECT, UPDATE, INSERT, DELETE, table name, column name, etc., the database type corresponding to the request statement is determined to be a relational database; if the request statement includes fields such as GET, INCR, DECL, SET, DEL, key-value pairs, documents, graph structures, etc., the database type corresponding to the request statement is determined to be a non-relational database.

[0059] According to the above analysis results, it can be determined whether the database type corresponding to the request statement is a relational database or a non-relational database.

[0060] S22, determining the target database protocol according to the database type corresponding to the request statement.

[0061] Request statements for different database types correspond to different database protocols. If the database type corresponding to the request statement is a relational database, the target database protocol is a relational database protocol; if the database type corresponding to the request statement is a non-relational database, the target database protocol is a non-relational database protocol. The database protocol of a non-relational database may be, for example, a key-value storage protocol, a document storage protocol, etc. Furthermore, in each database type, different types of databases use different database protocols. Based on the fields in the request statement, the corresponding database type can be determined, and then the target database protocol can be determined.

[0062] S23, encapsulating the request statement according to the target database protocol to obtain a protocol message.

[0063] The protocol message obtained by encapsulating the request statement includes header information, message body information and tail information. The header information of the protocol message includes a message length field, a message sequence and a command type field, etc., wherein the command type field may be, for example, SELECT, UPDATE, INSERT, DELETE, etc. (for the case where the database type corresponding to the request statement is a relational database), and the command type field may be, for example, GET, INCR, DECL, SET, DEL, etc. (for the case where the database type corresponding to the request statement is a non-relational database); the message body information includes the request statement, wherein the request statement is transmitted in an encoded form; the tail information of the protocol message includes verification information for verifying the integrity of the protocol message.

[0064] S24, sending a protocol message to the server.

[0065] After determining the target database protocol, the client encapsulates the request statement according to the target database protocol to obtain a protocol message, and sends the encapsulated protocol message to the server. Correspondingly, the server receives the protocol message.

[0066] Figure 3 The process of the database request processing method provided in the embodiment of the present application Figure 2 , this method is applied to the server, such as Figure 3 As shown, the method includes:

[0067] S31, receiving a protocol message sent by the client, where the protocol message is obtained by encapsulating the request statement.

[0068] A request statement refers to an instruction or command issued by a client to a database, which is used to perform database operations such as data query, data update, data insertion, and data deletion. Instructions for data query operations may include, for example, SELECT, GET, etc. Instructions for data update operations may include, for example, UPDATE, INCR, DECL, etc. Instructions for data insertion operations may include, for example, INSERT, SET, etc. Instructions for data deletion operations may include, for example, DELETE, DEL, etc.

[0069] The request statement may be a request statement corresponding to a relational database or a request statement corresponding to a non-relational database. A relational database refers to a database that uses a relational model (a two-dimensional table model) to organize data, organizes and stores data in the form of tables, and establishes relationships between data by defining relationships between tables. A non-relational database refers to a database that uses a more flexible data model to store data, such as key-value pairs, documents, graphics, and the like.

[0070] The client uses the SDK driver to encapsulate the request statement based on the target database protocol to obtain the protocol message. The encapsulation process is as follows: Figure 2 The client sends the protocol message to the server, and correspondingly, the server receives the protocol message sent by the client.

[0071] S32, parsing and splitting the protocol message through the database middleware to determine the request statement and the database type corresponding to the request statement.

[0072] After receiving the protocol message, the server parses and splits the protocol message through the database middleware, including: the database middleware obtains the header information and message body information of the protocol message, the header information includes the command type field of the protocol message; according to the command type field of the protocol message, determines the database type corresponding to the request statement; according to the database type corresponding to the request statement, decodes the message body information to obtain the request statement.

[0073] Specifically, the database middleware parses and splits the protocol message to obtain the message header, message body and message tail respectively, and determines the database type corresponding to the request statement through the command type field in the message header information. For example, if the command type field includes SELECT, UPDATE, INSERT, DELETE, etc., then the database type corresponding to the request statement is determined to be a relational database. If the command type field includes GET, INCR, DECL, SET, DEL, etc., then the database type corresponding to the request statement is determined to be a non-relational database. Further, the message body is decoded to obtain the request statement, wherein the encoding method in the message body corresponding to different database protocols is different. The database protocol used by the request statement can be determined according to the command type field, and the encoding method of the message body can be determined according to the database protocol. The message body is decoded in the corresponding manner to obtain the request statement.

[0074] Through the above method, the database type corresponding to the request statement can be determined, and the request statement can be parsed from the protocol message, so that the database middleware can further process and forward the request statement, thereby optimizing the database deployment architecture and reducing the complexity of database request processing.

[0075] S33, determine the routing information corresponding to the request statement through the database middleware, the routing information includes the target database associated with the request statement, and the address information of the target database, the target database is a database that matches the database type corresponding to the request statement, and the database type is a relational database or a non-relational database.

[0076] Database middleware is a software layer that sits between client applications and database servers. Database middleware is used to enhance, optimize, and manage database operations.

[0077] Routing information refers to a set of rules or data used to guide how a request statement is routed to the correct database or data shard. Routing information is used to indicate the database or data shard to which the request statement corresponds. Routing information includes the target database associated with the request statement and the address information of the target database.

[0078] The target database refers to a database that matches the database type corresponding to the request statement. When the request statement is a request statement corresponding to a relational database, the database type of the target database is a relational database; when the request statement is a request statement corresponding to a non-relational database, the database type of the target database is a non-relational database.

[0079] The address information of the target database is used to identify and locate the target database. The address information of the target database may include Internet Protocol (IP) address, port number, database name, etc. Among them, the IP address is used to locate the network location of the node device where the target database is located; the port number is used for the database middleware to establish a connection with the database server; the database name is the name of the target database.

[0080] Based on the above routing information, the database middleware determines to which database or database shard the request statement should be distributed.

[0081] In a possible implementation, the database type corresponding to the request statement is a relational database. After the database middleware parses the request statement, it determines that the type of the target database is a relational database, and determines the target database and the address information of the target database. The target database is a relational database.

[0082] In a possible implementation, the database type corresponding to the request statement is a non-relational database. After the database middleware parses the request statement, it determines that the type of the target database is a non-relational database, and determines the target database and the address information of the target database. The target database is a non-relational database.

[0083] S34, obtaining a request result corresponding to the request statement from the target database according to the address information.

[0084] The request result refers to the request result obtained by the target database responding to the request operation of the request statement and executing the request operation corresponding to the request statement. For example, when the request statement is a query instruction, the request result is the data query result corresponding to the data query instruction; when the request statement is a data update instruction, the request result is the data update result corresponding to the data update instruction; when the request statement is a data insert instruction, the request result is the data insert result corresponding to the data insert instruction; when the request statement is a data delete instruction, the request result is the data delete result corresponding to the data delete instruction, and so on.

[0085] The server sends the request statement to the node device where the target database is located based on the address information. The node device executes the request operation corresponding to the request statement based on the request statement and obtains the request result. The node device sends the request result to the database middleware and the server receives the request result.

[0086] The database request processing method provided by the embodiment of the present application is as follows: a server receives a protocol message sent by a client, where the protocol message is obtained by encapsulating a request statement; then, the protocol message is parsed and split by the database middleware to determine the request statement and the database type corresponding to the request statement, so that the routing information corresponding to the request statement can be determined by the database middleware, and the routing information includes a target database associated with the request statement and address information of the target database, where the target database is a database that matches the database type corresponding to the request statement, and the database type is a relational database or a non-relational database; finally, according to the address information, a request result corresponding to the request statement is obtained from the target database; for the protocol message encapsulated by the request statement of different database types, the database middleware can parse and split the protocol message to determine the corresponding routing information, so as to obtain the corresponding request result based on the routing information, so that in complex business scenarios, there is no need to deploy two types of database systems separately, thereby optimizing the database deployment architecture and reducing the complexity of database request processing.

[0087] Based on any of the above embodiments, the scheme of the embodiments of the present application is further introduced below in conjunction with the accompanying drawings.

[0088] Figure 4 A schematic diagram of the architecture of the database request processing method provided in the embodiment of the present application, such as Figure 4As shown, it includes three parts: client, server and database, among which the server is deployed with database middleware, and the database middleware includes client request processing module, relational protocol processing module and non-relational protocol processing module. The client is deployed with SDK driver, which is used to send protocol message to the server. After the server receives the protocol message, the client request processing module of the database middleware processes the protocol message, obtains the request statement and the database type corresponding to the request statement, and then sends the request statement to the relational protocol processing module or the non-relational protocol processing module according to the database type corresponding to the request statement. The corresponding protocol processing module parses the request statement and obtains the routing information. Finally, the server sends the request statement to the node device where the target database is located according to the routing information to obtain the request result.

[0089] exist Figure 4 Under the architecture of the database request processing method shown, the database request processing process is further introduced below in conjunction with the accompanying drawings.

[0090] Figure 5 A signaling diagram of a database request processing method provided in an embodiment of the present application, such as Figure 5 As shown, the method includes:

[0091] S51, the client performs database type parsing processing on the request statement to determine the database type corresponding to the request statement, and the database type is a relational database or a non-relational database.

[0092] The client performs database type parsing on the request statement to obtain the database type corresponding to the request statement. The database type corresponding to the request statement is a relational database or a non-relational database.

[0093] The client uses the SDK driver package to perform database type parsing on the request statement. The request statement may include instructions such as data query, data update, data insertion, and data deletion. Specifically, the client performs field detection on the request statement to obtain at least one command field and at least one object field. The command field may be, for example, SELECT, UPDATE, INSERT, DELETE, GET, INCR, DECL, SET, DEL, etc.; the object field may be, for example, a noun field including a table name, column name, key-value pair, document, graph structure, etc.

[0094] In a possible implementation, the client obtains the database type corresponding to the request statement according to at least one command field. For example, the client performs field detection processing on the request statement. If the obtained request statement includes fields such as SELECT, UPDATE, INSERT, and DELETE, it is determined that the database type corresponding to the request statement is a relational database; if the obtained request statement includes fields such as GET, INCR, DECL, SET, and DEL, it is determined that the database type corresponding to the request statement is a non-relational database.

[0095] In a possible implementation, the client obtains the database type corresponding to the request statement according to at least one object field. For example, the client performs field detection processing on the request statement. If the request statement includes fields such as table names and column names that can indicate a relational structure, the database type corresponding to the request statement is determined to be a relational database; if the request statement includes fields such as key-value pairs, documents, and graph structures, the database type corresponding to the request statement is determined to be a non-relational database.

[0096] S52: The client determines the target database protocol according to the database type corresponding to the request statement.

[0097] The client determines the target database protocol according to the database type corresponding to the request statement. Specifically, request statements of different database types correspond to different database protocols. If the database type corresponding to the request statement is a relational database, the target database protocol is a relational database protocol; if the database type corresponding to the request statement is a non-relational database, the target database protocol is a non-relational database protocol. The database protocol of the non-relational database may be, for example, a key-value storage protocol, a document storage protocol, etc. Furthermore, in each database type, different types of databases use different database protocols. According to the fields in the request statement, the corresponding database type can be determined, and then the target database protocol can be determined.

[0098] S53, the client encapsulates the request statement according to the target database protocol to obtain a protocol message.

[0099] The encapsulation process of the protocol message can be found in Figure 2 The relevant introduction of the embodiments will not be repeated here.

[0100] Through the above method, the client can determine the database type corresponding to the request statement and encapsulate the request statement according to the corresponding database type protocol, so that the database middleware can distribute the request statement to different protocol processing modules, reducing the complexity of database request processing.

[0101] S54, the client sends a protocol message to the server.

[0102] The client sends the protocol message obtained after decompression and encapsulation to the server, and correspondingly, the server receives the protocol message sent by the client.

[0103] S55, the server parses and splits the protocol message through the database middleware to determine the request statement and the database type corresponding to the request statement.

[0104] The database middleware includes a client request processing module and a protocol processing module. The client request processing module is used to parse and split the protocol message, determine the request statement and the database type corresponding to the request statement, and distribute the request statement to the target queue; the protocol processing module is used to perform semantic parsing on the request statement to obtain routing information. The protocol processing module includes a relational data protocol processing module and a non-relational protocol processing module. The relational protocol processing module is used to process the request statement corresponding to the relational database, and the non-relational protocol processing module is used to process the request statement corresponding to the non-relational database; the target queue is a queue that matches the database type corresponding to the request statement. There are multiple queues in the database middleware, and each queue is associated with a specific database type.

[0105] The client request processing module parses and splits the protocol message to obtain the header information, message body information and tail information respectively, and determines the database type corresponding to the request statement through the command type field in the header information. For example, if the command type field includes fields such as SELECT, UPDATE, INSERT, DELETE, etc., it is determined that the database type corresponding to the request statement is a relational database. If the command type field includes fields such as GET, INCR, DECL, SET, DEL, etc., it is determined that the database type corresponding to the request statement is a non-relational database. Further, the request statement is obtained by decoding the message body information, wherein the encoding methods in the message body information corresponding to different database protocols are different. The target database protocol used by the request statement can be determined according to the command type field, and the encoding method of the message body information can be determined according to the target database protocol. The message body information is decoded according to the corresponding encoding method to obtain the request statement.

[0106] S56, the server determines the routing information corresponding to the request statement through the database middleware.

[0107] The client request processing module distributes the request statement to the target queue according to the database type corresponding to the request statement. The target queue is the queue that matches the database type corresponding to the request statement. If the database type corresponding to the request statement is a relational database, the target queue is the queue that matches the relational database type; if the database type corresponding to the request statement is a non-relational database, the target queue is the queue that matches the non-relational database type.

[0108] The client request processing module distributes the request statement to the queue of the database type corresponding to the request statement, so that the protocol processing module can parse and process the request statement according to the corresponding database type.

[0109] The server obtains the request statement from the target queue through the protocol processing module of the database middleware, and the protocol processing module includes a relational data protocol processing module and a non-relational protocol processing module. When the target queue is a queue that matches the relational database type, the request statement is obtained from the target queue through the relational protocol processing module; when the target queue is a queue that matches the non-relational database type, the request statement is obtained from the target queue through the non-relational protocol processing module.

[0110] Through the above method, the relational protocol processing module can obtain the request statement corresponding to the relational database, and the non-relational data processing module can obtain the request statement corresponding to the non-relational database.

[0111] After the server obtains the request statement, the server performs semantic parsing on the request statement according to the database type matched by the target queue to obtain at least one field in the request statement; and obtains routing information according to the at least one field and a preset data shard routing table.

[0112] Semantic parsing refers to parsing the request statement using a specific parsing strategy, which may include keyword extraction, syntax analysis, semantic analysis, etc. At least one field in the request statement is determined by a candidate field. Specifically, the server obtains a candidate field library corresponding to a database type matching the target queue, and the candidate field library includes multiple candidate fields; then, the server performs semantic parsing on the request statement based on the multiple candidate fields to obtain at least one field.

[0113] The candidate field library refers to a collection of candidate fields obtained by performing keyword extraction on the request statement. The protocol processing module performs semantic parsing on the request statement through methods such as keyword extraction to obtain a candidate field library corresponding to the database type that matches the target queue. The candidate field library includes multiple candidate fields obtained through the keyword extraction method. Based on multiple candidate fields, the protocol processing module matches key information in the target database, such as column names, table names, etc., through methods such as semantic analysis and grammatical analysis, and determines at least one field from multiple candidate fields. For example, if the keywords in the request statement include SELECT, TABLE1 (Table 1), etc., then the candidate field library includes SELECT, TABLE1, etc. Through semantic analysis and grammatical analysis, it is matched that the request type of the request statement is a query request, and the query content is located in TABLE1, then the TABLE1 field is obtained.

[0114] After the protocol processing module obtains at least one field, it obtains routing information according to the at least one field and the preset data shard routing table. The preset data shard routing table records the mapping relationship between the data range or data block stored on each shard, and the preset data shard routing table can be, for example, a Sharding routing table. The preset data shard routing table includes the address information of the target database, which is used to uniquely identify which database or database shard the request statement should be distributed to. For example, the field obtained by the protocol processing module is TABLE1, and TABLE1 is the table name. According to the preset data shard routing table, the database containing the table name TABLE1 is determined as the target database, and its address information is obtained.

[0115] In a possible implementation, the request statement only involves one target database or a data slice corresponding to the target database, and the routing information includes the target database and address information of the target database.

[0116] In a possible implementation, the request statement involves multiple target databases or data shards corresponding to multiple target databases, and the routing information includes multiple target databases and respective address information of the multiple target databases. For example, the fields obtained by the protocol processing module are TABLE1 and TABLE2, TABLE1 and TABLE2 are table names, and according to the preset data shard routing table, a data table containing a table name of TABLE1 in database 1 and a data table containing a table name of TABLE2 in database 2 are obtained, then database 1 and database 2 are used as target databases, and according to the preset data shard routing table, the address information corresponding to database 1 and database 2 is obtained.

[0117] Through the above method, the request statement is parsed and processed according to the database type matching the target queue to obtain routing information, so that the database middleware can distribute the request statement to the corresponding database according to the routing information, thereby optimizing the database deployment architecture and reducing the complexity of database request processing.

[0118] S57, the server sends a request message to the node device where the target database is located.

[0119] The server sends a request message to the node device where the target database is located according to the address information, and the request message includes a request statement.

[0120] In a possible implementation, the request message is a unicast message, and the protocol processing module sends the unicast message to the node device where the single target database is located, and the unicast message includes the request statement. Specifically, the request statement only involves one target database or data shard, and the routing information includes the target database and the address information of the target database, and the protocol processing module sends the unicast message to the node device where the target database is located.

[0121] In a possible implementation, the request message is a broadcast message, and the protocol processing module sends the broadcast message to the node devices where the multiple target databases are located, and the broadcast message includes the request statement. Specifically, the request statement involves multiple target databases or multiple data shards, and the routing information includes multiple target databases and address information of the multiple target databases, and the protocol processing module sends the broadcast message to the node devices where the multiple target databases are located.

[0122] Through the above method, the protocol processing module sends the request statement to the node devices where the target databases are located in a unicast or broadcast manner, so that the target databases respond to the database request operation, thereby obtaining the request result.

[0123] S58, the node device where the target database is located sends a response message to the server.

[0124] The node device where the target database is located receives the request message sent by the server, executes the request operation indicated by the request statement, obtains response information, and sends the response information to the server.

[0125] The server receives the response information sent by the node devices where the target databases are located, and the request result includes the response information sent by the node devices where the target databases are located.

[0126] In a possible implementation, the target database is single, the server receives the response information sent by the node device where the single target database is located, and the request result includes the response information sent by the node device where the single target database is located.

[0127] In a possible implementation, there are multiple target databases, and the server receives response information sent by the node devices where the multiple target databases are located. The request result includes the response information sent by the node devices where the multiple target databases are located.

[0128] S59, the server sends the request result to the client.

[0129] After receiving the response information sent by the node device where the target database is located, the server sends the request result to the client, and the client receives the request result to complete the database request processing.

[0130] In summary, the client performs database type parsing on the request statement to obtain the database type corresponding to the request statement, determines the target database protocol according to the database type corresponding to the request statement, encapsulates the request statement according to the target database protocol, obtains the protocol message, and sends the protocol message to the server; the server receives the protocol message, parses and splits the protocol message through the client request processing module of the database middleware, determines the request statement and the database type corresponding to the request statement, and distributes the request statement to the target queue, and the protocol processing module of the database middleware parses and processes the request statement, obtains routing information according to at least one field parsed and the preset data shard routing table, and obtains the request result corresponding to the request statement according to the routing information. For the protocol message encapsulated by the request statements of different database types, the database middleware can parse and split the protocol message, and then determine the corresponding routing information, so as to obtain the corresponding request result based on the routing information, so that in complex business scenarios, there is no need to deploy two types of database systems separately, optimize the database deployment architecture, and reduce the complexity of database request processing.

[0131] Figure 6 A schematic diagram of the structure of the database request processing device provided in the embodiment of the present application Figure 1 ,like Figure 6 As shown, the database request processing device 60 includes:

[0132] The receiving unit 61 is used to receive a protocol message sent by the client, where the protocol message is obtained by encapsulating the request statement;

[0133] A first parsing unit 62 is used to parse and split the protocol message through the database middleware to determine the request statement and the database type corresponding to the request statement;

[0134] The processing unit 63 is used to determine the routing information corresponding to the request statement through the database middleware, where the routing information includes the target database associated with the request statement and the address information of the target database, where the target database is a database matching the database type corresponding to the request statement, and the database type is a relational database or a non-relational database;

[0135] The acquisition unit 64 is used to acquire the request result corresponding to the request statement from the target database according to the address information.

[0136] In a possible implementation, the first parsing unit 62 is specifically configured to:

[0137] Obtaining header information and message body information of the protocol message, where the header information includes a command type field of the protocol message;

[0138] Determine the database type corresponding to the request statement according to the command type field of the protocol message;

[0139] According to the database type corresponding to the request statement, the message body information is decoded to obtain the request statement.

[0140] In a possible implementation, the processing unit 63 is specifically configured to:

[0141] The client request processing module distributes the request statement to the target queue, which is a queue that matches the database type corresponding to the request statement;

[0142] Obtain the request statement from the target queue through the protocol processing module;

[0143] Parse the request statement to obtain routing information.

[0144] In a possible implementation, the processing unit 63 is specifically configured to:

[0145] In the case where the target queue is a queue that matches the relational database type, obtaining the request statement from the target queue through the relational protocol processing module;

[0146] In the case where the target queue is a queue that matches the non-relational database type, the request statement is obtained from the target queue through the non-relational protocol processing module.

[0147] In a possible implementation, the processing unit 63 is specifically configured to:

[0148] According to the database type matched by the target queue, the request statement is semantically parsed to obtain at least one field in the request statement;

[0149] Routing information is obtained according to at least one field and a preset data shard routing table.

[0150] In a possible implementation, the processing unit 63 is specifically configured to:

[0151] Obtain a candidate field library corresponding to a database type matching a target queue, wherein the candidate field library includes multiple candidate fields;

[0152] According to the multiple candidate fields, the request statement is semantically parsed to obtain at least one field.

[0153] In a possible implementation, the acquiring unit 64 is specifically configured to:

[0154] Sending a broadcast message to the node devices where the multiple target databases are located according to the address information, wherein the broadcast message includes a request statement;

[0155] Response information sent by the node devices where the multiple target databases are located is received, and the request result includes the response information sent by the node devices where the multiple target databases are located.

[0156] The database request processing device 60 provided in the embodiment of the present application can execute the technical solution in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0157] Figure 7 A schematic diagram of the structure of the database request processing device provided in the embodiment of the present application Figure 2 ,like Figure 7 As shown, the database request processing device 70 includes:

[0158] The second parsing unit 71 is used to perform database type parsing processing on the request statement to determine the database type corresponding to the request statement, where the database type is a relational database or a non-relational database;

[0159] A determination unit 72, configured to determine a target database protocol according to a database type corresponding to the request statement;

[0160] The encapsulation unit 73 is used to encapsulate the request statement according to the target database protocol to obtain a protocol message;

[0161] The sending unit 74 is used to send a protocol message to the server.

[0162] In a possible implementation, the second parsing unit 71 is specifically configured to:

[0163] Performing field detection processing on the request statement to obtain at least one command field and at least one object field;

[0164] The database type corresponding to the request statement is determined according to at least one command field or at least one object field.

[0165] The database request processing device 70 provided in the embodiment of the present application can execute the technical solution in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0166] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 8 As shown, it includes a memory 81 and a processor 82. Exemplarily, the memory 81 and the processor 82 are connected to each other via a bus 83. Wherein:

[0167] The memory 81 is used to store computer-executable instructions;

[0168] The processor 82 is configured to execute computer-executable instructions stored in the memory to implement the method in the above embodiment.

[0169] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0170] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0171] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0172] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.

[0173] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory (RRAM), a dynamic random access memory (DRAM), a static random access memory (SRAM), an enhanced dynamic random access memory (EDRAM), a high-bandwidth memory (HBM), a hybrid memory cube (HMC), etc.

[0174] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0175] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0176] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0177] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A database request processing method, characterized in that: Applied to a server, the method comprises: Receiving a protocol message sent by a client, wherein the protocol message is obtained by encapsulating a request statement; Parsing and splitting the protocol message through database middleware to determine the request statement and the database type corresponding to the request statement; Determining routing information corresponding to the request statement through the database middleware, the routing information including a target database associated with the request statement and address information of the target database, the target database being a database matching a database type corresponding to the request statement, the database type being a relational database or a non-relational database; According to the address information, a request result corresponding to the request statement is obtained from the target database.

2. The method according to claim 1, characterized in that The parsing and splitting of the protocol message by the database middleware to determine the request statement and the database type corresponding to the request statement includes: Acquire header information and message body information of the protocol message, wherein the header information includes a command type field of the protocol message; Determining the database type corresponding to the request statement according to the command type field of the protocol message; According to the database type corresponding to the request statement, the message body information is decoded to obtain the request statement.

3. The method according to claim 1, characterized in that The database middleware includes a client request processing module and a protocol processing module, and the determining of routing information corresponding to the request statement through the database middleware includes: Distributing the request statement to a target queue through the client request processing module, wherein the target queue is a queue that matches the database type corresponding to the request statement; Obtaining the request statement from the target queue through the protocol processing module; The request statement is parsed to obtain the routing information.

4. The method according to claim 3, characterized in that The protocol processing module includes a relational protocol processing module and a non-relational protocol processing module, and obtaining the request statement from the target queue through the protocol processing module includes: In the case where the target queue is a queue that matches the relational database type, obtaining the request statement from the target queue through the relational protocol processing module; In the case that the target queue is a queue that matches the non-relational database type, the request statement is obtained from the target queue by the non-relational protocol processing module.

5. The method according to claim 3 or 4, characterized in that: The parsing of the request statement to obtain the routing information includes: According to the database type matched by the target queue, semantically parse the request statement to obtain at least one field in the request statement; The routing information is obtained according to the at least one field and a preset data shard routing table.

6. The method according to claim 5, characterized in that The step of performing semantic parsing on the request statement according to the database type matched by the target queue to obtain at least one field in the request statement includes: Acquire a candidate field library corresponding to a database type matching the target queue, wherein the candidate field library includes a plurality of candidate fields; According to the multiple candidate fields, the request statement is semantically parsed to obtain the at least one field.

7. The method according to any one of claims 1 to 4, characterized in that: In the case that there are multiple target databases, obtaining the request result corresponding to the request statement from the target database according to the address information includes: Sending a broadcast message to node devices where each of the target databases is located according to the address information, wherein the broadcast message includes the request statement; Response information sent by the node devices where the multiple target databases are located is received, and the request result includes the response information sent by the node devices where the multiple target databases are located.

8. A database request processing method, characterized in that: Applied to a client, the method comprises: Performing database type parsing processing on the request statement to determine the database type corresponding to the request statement, the database type being a relational database or a non-relational database; Determine the target database protocol according to the database type corresponding to the request statement; According to the target database protocol, encapsulate the request statement to obtain a protocol message; Send the protocol message to the server.

9. The method according to claim 8, characterized in that The performing database type parsing processing on the request statement to determine the database type corresponding to the request statement includes: Performing field detection processing on the request statement to obtain at least one command field and at least one object field; A database type corresponding to the request statement is determined according to the at least one command field or the at least one object field.

10. A database request processing device, characterized in that: The device comprises: A receiving unit, configured to receive a protocol message sent by a client, wherein the protocol message is obtained by encapsulating a request statement; A first parsing unit, configured to parse and split the protocol message through a database middleware to determine the request statement and the database type corresponding to the request statement; a processing unit, configured to determine, through the database middleware, routing information corresponding to the request statement, the routing information including a target database associated with the request statement and address information of the target database, the target database being a database matching the corresponding database type, the database type being a relational database or a non-relational database; An acquiring unit is used to acquire a request result corresponding to the request statement from the target database according to the address information.

11. A database request processing device, characterized in that: The device comprises: A second parsing unit is used to perform database type parsing processing on the request statement to determine the database type corresponding to the request statement, where the database type is a relational database or a non-relational database; A determination unit, configured to determine a target database protocol according to a database type corresponding to the request statement; An encapsulation unit, configured to encapsulate the request statement according to the target database protocol to obtain a protocol message; A sending unit is used to send the protocol message to the server.

12. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7, or the processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 8 to 9.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor, or the computer-executable instructions are used to implement the method according to any one of claims 8 to 9 when executed by a processor.

14. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 7 when executed by a processor, or implements the method according to any one of claims 8 to 9 when executed by a processor.