WO2017161989A1 - 分布式数据库预处理的方法及装置、计算机存储介质 - Google Patents

分布式数据库预处理的方法及装置、计算机存储介质 Download PDF

Info

Publication number
WO2017161989A1
WO2017161989A1 PCT/CN2017/074231 CN2017074231W WO2017161989A1 WO 2017161989 A1 WO2017161989 A1 WO 2017161989A1 CN 2017074231 W CN2017074231 W CN 2017074231W WO 2017161989 A1 WO2017161989 A1 WO 2017161989A1
Authority
WO
WIPO (PCT)
Prior art keywords
distributed database
operation statement
processing
template
server cluster
Prior art date
Application number
PCT/CN2017/074231
Other languages
English (en)
French (fr)
Inventor
丁岩
刘志文
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2017161989A1 publication Critical patent/WO2017161989A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries

Definitions

  • the present invention relates to the field of database preprocessing technology, and in particular, to a method and device for preprocessing a distributed database, and a computer storage medium.
  • the database preprocessing technology is usually used to operate the database server.
  • the client sends a database operation statement template including the query, insert, update, etc. to the database server, and then the database server pairs the database.
  • the operation statement template is parsed to generate a corresponding syntax tree, and the processed database operation statement template is saved.
  • the database preprocessing operation statement template uses a question mark (?) to represent the parameter value of the specific operation, and when the client executes the corresponding query.
  • the above process can be repeated multiple times.
  • the server where the database is located only needs to parse the database operation statement once, and the complete database operation statement will not be sent to the server. It only needs to send the parameter information of the specific service in the form of a binary protocol, which saves the overhead of processing specific services. Memory, bandwidth;
  • the server where the database is located caches some of the plans for processing database operation statements, so it only needs to perform the action of parsing the database operation statement once, which improves the efficiency of processing specific services;
  • the database server adopting the preprocessing technology can effectively avoid the injection attack of the database server and improve the security of the database server.
  • database preprocessing techniques can currently only be used on stand-alone database servers, not on distributed database servers.
  • an embodiment of the present invention provides a method and apparatus for preprocessing a distributed database, and a computer storage medium, which are to solve the technical problem that the database preprocessing technology cannot be used on a distributed database server.
  • the determining, by parsing the distributed database operation statement template, the distributed database server cluster corresponding to the distributed database operation statement template includes:
  • the operation statement parameter information includes an operation statement parameter value and identification information for matching the operation statement parameter value to the distributed database operation statement template.
  • the acquiring the distributed database server cluster according to The distributed database operation statement template and the processing result returned by the operation statement parameter information include:
  • result data returned by the distributed database server cluster wherein the result data is a plurality of distributed database servers located in the distributed database server cluster in conjunction with the distributed database operation statement template and the operation The result of the statement parameter information processing the data stored in the corresponding distributed database server;
  • the result data is aggregated and calculated, and the result set calculated by the summary is obtained.
  • the method further includes:
  • the template obtaining module is configured to obtain a distributed database operation statement template from the client, and obtain operation parameter parameter information;
  • a template processing module configured to determine a distributed database server cluster corresponding to the distributed database operation statement template by parsing the distributed database operation statement template, and send the distributed database operation statement template to the distributed database Server cluster
  • a parameter information forwarding module configured to send the operation statement parameter information to the distributed database server cluster
  • the result is returned to the module, configured to obtain a processing result returned by the distributed database server according to the request information of the performing the pre-processing operation.
  • the operation statement parameter information includes an operation statement parameter value. And identification information for matching the operation statement parameter value to the distributed database operation statement template.
  • the template processing module is further configured to:
  • the result returning module is further configured to:
  • result data returned by the distributed database server cluster wherein the result data is a plurality of distributed database servers located in the distributed database server cluster in conjunction with the distributed database operation statement template and the operation The result of the statement parameter information processing the data stored in the corresponding distributed database server;
  • the result data is aggregated and calculated, and the result set calculated by the summary is obtained.
  • the apparatus for pre-processing a distributed database further includes:
  • Closing the module configured to send the processing result to the client; obtaining, from the client, request information for closing the pre-processing operation, and transmitting the request information to the distributed database server cluster performing the pre-processing operation; Pre-processing services for multiple distributed database servers in a distributed database server cluster.
  • the computer storage medium provided by the embodiment of the present invention stores a computer program configured to perform the foregoing method of distributed database preprocessing.
  • Embodiments of the present invention provide a method and apparatus for preprocessing a distributed database, and a computer storage medium.
  • the distributed database operation statement is obtained by acquiring a distributed database operation statement template from a client and obtaining operation statement parameter information. Parsing the template, determining a distributed database server cluster corresponding to the distributed database operation statement template, and sending the score
  • the distributed database operation statement template is sent to the distributed database server cluster, and the operation statement parameter information is sent to the distributed database server cluster, and the distributed database server cluster is obtained according to the distributed database operation statement template and
  • the operation statement returns the processing result of the parameter information, thereby solving the technical problem that the database preprocessing technology cannot be used on the distributed database server.
  • FIG. 1 is a schematic flowchart of a method for pre-processing a distributed database according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of a second embodiment of a method for preprocessing a distributed database according to the present invention
  • FIG. 3 is a schematic diagram of functional modules of an apparatus for preprocessing a distributed database according to the present invention.
  • FIG. 4 is a schematic structural diagram of a distributed database system in an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of another functional module of an apparatus for preprocessing a distributed database operation statement according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of functional modules of a second embodiment of a device for pre-processing distributed databases according to the present invention.
  • Embodiments of the present invention provide a method for preprocessing a distributed database.
  • FIG. 1 is a schematic flowchart diagram of an embodiment of a method for preprocessing a distributed database operation statement according to the present invention.
  • the method for preprocessing the distributed database operation statement comprises:
  • Step S10 obtaining a distributed database operation statement template from the client, and obtaining an operation language Sentence parameter information
  • the technical solution in this embodiment relates to interaction between the client and the distributed database server, so that the client completes access to the distributed database by sending a distributed database operation statement request.
  • the embodiment introduces a middleware between the client and the distributed database server, and is also called a device for preprocessing the distributed database operation statement, and implements distributed database preprocessing through the middleware.
  • the structure of the distributed database system in this embodiment may be as shown in FIG. 4, wherein the apparatus for preprocessing the distributed database operation statement in this embodiment may include an execution module and an operation statement routing module (SQL routing module).
  • the apparatus for preprocessing the distributed database operation statement in this embodiment may include an execution module and an operation statement routing module (SQL routing module).
  • the execution module may include a thread pool unit, a thread scheduling unit, a data operation statement parsing unit (SQL parsing unit), and a data manipulation language unit (DML unit).
  • the data definition language unit (DDL unit), the mediation data cache unit, and the SQL routing interface, and the components of the specific execution module are not limited herein.
  • the thread pool unit is responsible for managing the use and recycling of all threads of the device preprocessed by the distributed database operation statement.
  • the thread scheduling unit schedules a thread from the thread pool unit for processing the distributed database operation Statement template.
  • the data definition language unit is responsible for converting the data definition statement into a data definition statement executable in the distributed database server, and storing the distribution policy information of the data definition statement in a data dictionary file, and then distributing the distribution policy Information is loaded into the cache for use by the data manipulation language unit.
  • the device preprocessed by the distributed database operation statement loads all the distribution policy information into the cache, and the number of the mediation
  • the cache unit is responsible for managing the distribution policy information and providing query services to the data manipulation language unit.
  • the distributed database operation statement is set by the client, wherein the distributed database operation statement includes a distributed database operation statement template and a distributed database operation statement parameter value.
  • the client splits the distributed database operation statement into separate distributed database operation statement templates and separate distributed database operation statement parameter values, where separate distributed database operation statement templates, such as INSERT INTO students (firstname, lastname, The VALUES (?, ?, ?) may include an operation statement syntax framework, a database header information, and an operation statement parameter variable.
  • the components of the distributed database operation statement template are not limited herein.
  • the distributed database operation statement template is sent by the client to the device preprocessed by the distributed database operation statement.
  • Step S20 Determine a distributed database server cluster corresponding to the distributed database operation statement template by parsing the distributed database operation statement template, and send the distributed database operation statement template to the distributed database server cluster;
  • the device pre-processed by the distributed database operation statement parses the distributed database operation statement template, and determines a distributed database server that stores the database table table with the database table header information as an identifier, and All eligible distributed database servers are packaged into a distributed database server cluster, and then distributed database operation statement templates including the database header information are sent to the distributed database server cluster.
  • Step S30 sending the operation statement parameter information to the distributed database server cluster
  • the apparatus for preprocessing the distributed database operation statement After the apparatus for preprocessing the distributed database operation statement acquires the operation statement parameter information that is sent by the client and matches the distributed database operation statement template, the device that is preprocessed by the distributed database operation statement sets the operation statement parameter Information sent to a determined distribution Database server cluster.
  • All distributed database servers located in the distributed database server cluster combine previously acquired distributed database operation statement templates with the operational statement parameter information to form a complete distributed executable that can be executed by the distributed database server a database operation statement, by performing the distributed database operation statement, completing specific operations on data stored in the distributed database server, such as querying data, inserting data, updating data, etc., specifically, the specific operation
  • the content of the operation is not limited herein.
  • Step S40 Acquire a processing result returned by the distributed database server cluster according to the distributed database operation statement template and the operation statement parameter information.
  • all distributed database servers send the operation results to the device preprocessed by the distributed database operation statement, and the operation results include operation success information, operation failure information, operation time information, etc., specifically, the The result of the operation is not limited herein.
  • the distributed database operation statement template is obtained from the client, and the operation statement parameter information is obtained, and the distributed database operation statement template is parsed to determine a distributed database corresponding to the distributed database operation statement template.
  • a server cluster sending the distributed database operation statement template to the distributed database server cluster, and sending the operation statement parameter information to the distributed database server cluster, acquiring the distributed database server cluster according to the distribution
  • the database operation statement template and the processing result returned by the operation statement parameter information Solved the technical problem that database preprocessing technology can not be used on distributed database servers.
  • step S20 may include:
  • the syntax tree of the distributed database operation statement template is generated by parsing the distributed database operation statement template obtained by the client, and the syntax tree is calculated by the data manipulation language unit to generate the distribution.
  • a plan execution tree of a database operation statement template according to the plan execution tree, the data manipulation language unit determines a distributed database server cluster corresponding to the distributed database operation statement template, and all located in the distributed database
  • the network address information of the distributed database server in the server cluster is stored in a node of the execution plan tree, and the device preprocessed by the distributed database operation statement sends the distributed database operation statement template to the distributed database server Cluster.
  • the data operation statement parsing unit is responsible for parsing the distributed database operation statement template acquired by the client, generating a syntax tree of the distributed database operation statement template, and then sending the syntax tree to the data manipulation
  • the language unit and the data definition language unit are configured to generate an execution plan tree corresponding to the distributed database operation statement template.
  • the client sends the distributed database operation statement template to the device pre-processed by the distributed database operation statement, when the device pre-processed by the distributed database operation statement acquires the distributed database operation statement template Parsing an operation statement syntax framework in the distributed database operation statement template to obtain a syntax tree, and the data manipulation language unit obtains a database header in the distributed database operation statement template by analyzing the syntax tree And acquiring, by the mediation data cache unit, network address information of all distributed database servers storing the database table header information as the identified database table, generating an execution plan tree according to the network address information, and generating the execution plan tree The address information is stored in the execution plan tree.
  • all the distributed database servers corresponding to the distributed database operation statement template are determined by the network address information stored in the execution plan tree. And establishing a logical link channel with all the distributed database server clusters, wherein the distributed database servers form a distributed database server cluster.
  • the distributed database operation statement template is sent to the distributed database server cluster through the logical link channel by an operation statement router, that is, an operation statement routing module. Solved the technical problem that database preprocessing technology can not be used on distributed database servers.
  • the operation statement parameter information includes an operation statement parameter value and identification information for matching the operation statement parameter value to the distributed database operation statement template.
  • the parameter information may include an intermediate variable.
  • All distributed database servers located in the distributed database server cluster combine the question mark (?) in the previously obtained distributed database operation statement template with the intermediate variable to obtain a distributed database operation including the intermediate variable Statement template, such as INSERT INTO students (firstname, lastname, email) VALUES (x, y, z), where the intermediate variable x, intermediate variable y and intermediate variable z can be set with the parameter x, parameter y set in the client And the parameter z forms a logical relationship.
  • the number of the intermediate variables is not limited herein.
  • the parameter value for performing the assignment operation may be for the intermediate variable x,
  • the intermediate variable y and the intermediate variable z are assigned, wherein the parameter value is a component of the parameter information.
  • the introduction of the intermediate variable solves the problem that the parameter value needs to be input at the client multiple times when the operation of transmitting the parameter information is required to be performed multiple times, thereby improving the user experience.
  • step S40 may include:
  • result data returned by the distributed database server cluster wherein the result data is a plurality of distributed database servers located in the distributed database server cluster in conjunction with the distributed database operation statement template and the operation Statement parameter information pairs are stored in pairs The result of processing the data in the distributed database server;
  • the result data is aggregated and calculated, and the result set calculated by the summary is obtained.
  • the distributed database server processes the data stored in the distributed database server by combining the distributed database operation statement template and the operation statement parameter information, and the processing manner may include adding data, deleting data, and changing data.
  • the processing content of the processing method is not limited herein.
  • the distributed database server obtains a processing result, and the processing result may include operation success information, operation failure information, operation time information, and the like.
  • the specific content of the operation success information such as the data obtained by the query operation, is not limited herein.
  • the operation statement router listens to the processing of the distributed database server, and when the processing ends, the distributed database server sends the result data to the node of the execution plan tree, and the distributed database operation statement
  • the pre-processed device performs a summary calculation on the result data stored in the node to obtain a result set that is aggregated and calculated. Solved the technical problem that database preprocessing technology can not be used on distributed database servers.
  • FIG. 2 is a schematic flowchart of a second embodiment of a method for pre-processing a distributed database according to the present invention.
  • the method further includes:
  • Step S50 Send the processing result to the client; acquire request information for closing the pre-processing operation from the client, and send the request information to the distributed database server cluster that performs the pre-processing operation; Pre-processing services for multiple distributed database servers in a database server cluster.
  • the processing result is sent to the client, and the request information for closing the pre-processing operation is obtained from the client, and when the device pre-processed by the distributed database operation statement acquires the request information for closing the pre-processing operation,
  • the apparatus for pre-processing the distributed database operation statement destroys the related data.
  • the data may include a syntax tree, an execution plan tree, and related cache information, which are not limited herein.
  • the distributed database server that performs the preprocessing operation Sending the request information to close the pre-processing service of the database server.
  • the technical problem that the database preprocessing technology cannot be used on the distributed database server is solved, and the memory and storage space of the hardware resources are saved on the basis of releasing the hardware resources.
  • Embodiments of the present invention further provide an apparatus for preprocessing a distributed database.
  • FIG. 3 is a schematic diagram of functional modules of an apparatus for pre-processing a distributed database according to the present invention.
  • the apparatus for preprocessing the distributed database operation statement may include: a template acquisition module 01, a template processing module 02, a parameter information forwarding module 03, and a result returning module 04, wherein:
  • the template obtaining module 01 is configured to obtain a distributed database operation statement template from the client, and obtain operation parameter parameter information;
  • the technical solution in this embodiment relates to the interaction between the client and the distributed database server, so that the client completes the operation on the distributed database by sending a distributed database operation statement request.
  • the middleware is introduced between the client and the distributed database server, that is, the device for preprocessing the distributed database operation statement proposed in the embodiment, and the distributed database preprocessing is implemented by using the middleware.
  • the distributed database operation statement is set by the client, wherein the distributed database operation statement includes a distributed database operation statement template and a distributed database operation statement parameter value.
  • the client splits the distributed database operation statement into separate distributed database operation statement templates and separate distributed database operation statement parameter values, where separate distributed database operation statement templates, such as INSERT INTO students (firstname, lastname, The VALUES (?, ?, ?) may include an operation statement syntax framework, a database header information, and an operation statement parameter variable. Specifically, the components of the distributed database operation statement template are not limited herein.
  • the distributed database operation statement template is sent by the client to the device preprocessed by the distributed database operation statement.
  • the template processing module 02 is configured to parse the distributed database operation statement template Defining a distributed database server cluster corresponding to the distributed database operation statement template, and sending the distributed database operation statement template to the distributed database server cluster;
  • the device pre-processed by the distributed database operation statement parses the distributed database operation statement template, and determines a distributed database server that stores the database table table with the database table header information as an identifier, and All eligible distributed database servers are packaged into a distributed database server cluster, and then distributed database operation statement templates including the database header information are sent to the distributed database server cluster.
  • the parameter information forwarding module 03 is configured to send the operation statement parameter information to the distributed database server cluster;
  • the apparatus for preprocessing the distributed database operation statement After the apparatus for preprocessing the distributed database operation statement acquires the operation statement parameter information that is sent by the client and matches the distributed database operation statement template, the device that is preprocessed by the distributed database operation statement sets the operation statement parameter Information is sent to the identified distributed database server cluster.
  • All distributed database servers located in the distributed database server cluster combine previously acquired distributed database operation statement templates with the operational statement parameter information to form a complete distributed executable that can be executed by the distributed database server a database operation statement, by performing the distributed database operation statement, completing specific operations on data stored in the distributed database server, such as querying data, inserting data, updating data, etc., specifically, the specific operation
  • the content of the operation is not limited herein.
  • the result is returned to the module 04, configured to obtain a processing result returned by the distributed database server according to the request information for performing the pre-processing operation.
  • all distributed database servers send the operation results to the device preprocessed by the distributed database operation statement, and the operation results include operation success information, operation failure information, operation time information, etc., specifically, the The result of the operation is not limited herein.
  • the distributed database operation statement template is obtained from the client, and the operation statement parameter information is obtained, and the distributed database operation statement template is parsed to determine a distributed database corresponding to the distributed database operation statement template.
  • a server cluster sending the distributed database operation statement template to the distributed database server cluster, and sending the operation statement parameter information to the distributed database server cluster, acquiring the distributed database server cluster according to the distribution
  • the database operation statement template and the processing result returned by the operation statement parameter information Solved the technical problem that database preprocessing technology can not be used on distributed database servers.
  • the structure of the distributed database system in this embodiment may be as shown in FIG. 4, wherein the apparatus for preprocessing the distributed database operation statement in this embodiment may include an execution module and an operation statement routing module (SQL).
  • the routing module wherein the execution module may include the functions of the template obtaining module 01 and the template processing module 02 in the above embodiment, and the operating statement routing module may include the parameter information forwarding module 03 and the result returning module 04 in the above embodiment.
  • the execution module may include a thread pool unit, a thread scheduling unit, a data operation statement parsing unit (SQL parsing unit), and a data manipulation language unit (DML unit).
  • the data definition language unit (DDL unit), the mediation data cache unit, and the SQL routing interface, and the components of the specific execution module are not limited herein.
  • the thread pool unit is responsible for managing the use and recycling of all threads of the device preprocessed by the distributed database operation statement.
  • the thread scheduling unit schedules a thread from the thread pool unit for processing the distributed database operation Statement template.
  • the data definition language unit is responsible for converting the data definition statement into a data definition statement executable in the distributed database server, and storing the distribution policy information of the data definition statement Stored in the data dictionary file, the distribution policy information is loaded into the cache for use by the data manipulation language unit.
  • the device preprocessed by the distributed database operation statement loads all the distribution policy information into the cache, and the mediation data cache unit is responsible for managing the distribution policy information. And providing a query service to the data manipulation language unit.
  • the template processing module 02 may be configured as:
  • Parsing a syntax tree for generating the distributed database operation statement template calculating an execution plan tree for generating the distributed database operation statement template according to the syntax tree; acquiring and operating the distributed database according to the execution plan tree
  • the distributed database server cluster corresponding to the statement template.
  • the syntax tree of the distributed database operation statement template is generated by parsing the distributed database operation statement template obtained by the client, and the data manipulation language unit is Calculating a syntax tree for generating a plan execution tree of the distributed database operation statement template, the data manipulation language unit determining a distributed database server cluster corresponding to the distributed database operation statement template according to the plan execution tree And storing network address information of all distributed database servers located in the distributed database server cluster in a node of the execution plan tree, and the device preprocessed by the distributed database operation statement operates the distributed database A statement template is sent to the distributed database server cluster.
  • the data operation statement parsing unit is responsible for parsing the distributed database operation statement template acquired by the client, generating a syntax tree of the distributed database operation statement template, and then sending the syntax tree to the data manipulation
  • the language unit and the data definition language unit are configured to generate an execution plan tree corresponding to the distributed database operation statement template.
  • the client sends a distributed database operation statement template to the distribution An apparatus for preprocessing a database operation statement, when the apparatus preprocessed by the distributed database operation statement acquires the distributed database operation statement template, parsing an operation statement syntax framework in the distributed database operation statement template, Obtaining a syntax tree, the data manipulation language unit obtaining the database header information in the distributed database operation statement template by analyzing the syntax tree, and acquiring, by using the mediation data cache unit, the database header information as the identifier
  • the network address information of all distributed database servers of the database table generates an execution plan tree according to the network address information, and stores the network address information in the execution plan tree.
  • the distributed database server constitutes a distributed database server cluster.
  • the distributed database operation statement template is sent to the distributed database server cluster through the logical link channel by an operation statement router, that is, an operation statement routing module. Solved the technical problem that database preprocessing technology can not be used on distributed database servers.
  • the operation statement parameter information includes an operation statement parameter value and identification information for matching the operation statement parameter value to the distributed database operation statement template.
  • the parameter information may include an intermediate variable.
  • All distributed database servers located in the distributed database server cluster combine the question mark (?) in the previously obtained distributed database operation statement template with the intermediate variable to obtain a distributed database operation including the intermediate variable Statement template, such as INSERT INTO students (firstname, lastname, email) VALUES (x, y, z), where the intermediate variable x, intermediate variable y and intermediate variable z can be set with the parameter x, parameter y set in the client And the parameter z forms a logical relationship.
  • the number of the intermediate variables is not limited herein.
  • the parameter value for performing the assignment operation may assign the intermediate variable x, the intermediate variable y, and the intermediate variable z, wherein The parameter value is an integral part of the parameter information.
  • the introduction of the intermediate variable solves the problem that the parameter value needs to be input at the client multiple times when the operation of transmitting the parameter information is required to be performed multiple times, thereby improving the user experience.
  • the above result returning module 04 can be configured as:
  • result data returned by the distributed database server cluster wherein the result data is a plurality of distributed database servers located in the distributed database server cluster in conjunction with the distributed database operation statement template and the operation
  • the statement parameter information is obtained by processing the data stored in the corresponding distributed database server; the result data is aggregated and calculated, and the result set obtained by the summary calculation is obtained.
  • the distributed database server processes the data stored in the distributed database server by combining the distributed database operation statement template and the operation statement parameter information, and the processing manner may include adding data, deleting data, and changing The data, the query data, and the like, in particular, the processing content of the processing method is not limited herein.
  • the distributed database server obtains a processing result, and the processing result may include operation success information, operation failure information, operation time information, and the like.
  • the specific content of the operation success information such as the data obtained by the query operation, is not limited herein.
  • the operation statement router listens to the processing of the distributed database server, and when the processing ends, the distributed database server sends the result data to the node of the execution plan tree, and the distributed database operation statement
  • the pre-processed device performs a summary calculation on the result data stored in the node to obtain a result set that is aggregated and calculated. Solved the technical problem that database preprocessing technology can not be used on distributed database servers.
  • FIG. 6 is a functional model of a second embodiment of a distributed database preprocessing apparatus according to the present invention.
  • Block diagram, on the basis of the foregoing embodiment, the apparatus for pre-processing the distributed database further includes:
  • Closing module 05 sending the processing result to the client; obtaining request information for closing the pre-processing operation from the client, and transmitting the request information to the distributed database server cluster performing the pre-processing operation; closing the distribution Preprocessing services for multiple distributed database servers in a database server cluster.
  • the processing result is sent to the client, and the request information for closing the pre-processing operation is obtained from the client, and when the device pre-processed by the distributed database operation statement acquires the request information for closing the pre-processing operation,
  • the apparatus for pre-processing the distributed database operation statement destroys the related data.
  • the data may include a syntax tree, an execution plan tree, and related cache information, which are not limited herein.
  • the request information is sent to the distributed database server performing the pre-processing operation, and the pre-processing service of the database server is closed. The technical problem that the database preprocessing technology cannot be used on the distributed database server is solved, and the memory and storage space of the hardware resources are saved on the basis of releasing the hardware resources.
  • each module in the distributed database pre-processing device may be implemented by a central processing unit (CPU) or a microprocessor located in a device preprocessed by the distributed database.
  • CPU central processing unit
  • MPU Micro Processor Unit
  • DSP Digital Signal Processor
  • FPGA Field Programmable Gate Array
  • the technical solution of the present invention which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk, In the CD), a number of instructions are included to make a terminal device (which may be a mobile phone, a computer, a server, Or a network device or the like) performs the methods described in various embodiments of the present invention.
  • a storage medium such as ROM/RAM, disk, In the CD
  • a number of instructions are included to make a terminal device (which may be a mobile phone, a computer, a server, Or a network device or the like) performs the methods described in various embodiments of the present invention.
  • an embodiment of the present invention further provides a computer storage medium, wherein a computer program is configured, the computer program configured to perform the method of distributed database preprocessing according to the embodiment of the present invention.
  • the distributed database operation statement template is obtained from the client, and the operation statement parameter information is obtained, and the distributed database operation statement template is parsed to determine the distributed database operation statement template.
  • Corresponding distributed database server cluster sending the distributed database operation statement template to the distributed database server cluster, and sending the operation statement parameter information to the distributed database server cluster to obtain the distributed database server.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Fuzzy Systems (AREA)
  • Probability & Statistics with Applications (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种分布式数据库预处理的方法、装置和计算机存储介质,该方法包括:从客户端处获取分布式数据库操作语句模板,并获取操作语句参数信息(S10);通过解析所述分布式数据库操作语句模板确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,并发送所述分布式数据库操作语句模板至所述分布式数据库服务器集群(S20);发送所述操作语句参数信息至所述分布式数据库服务器集群(S30);获取所述分布式数据库服务器集群根据所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果(S40)。

Description

分布式数据库预处理的方法及装置、计算机存储介质 技术领域
本发明涉及数据库预处理技术领域,尤其涉及一种分布式数据库预处理的方法及装置、计算机存储介质。
背景技术
目前,通常采用数据库预处理技术对数据库服务器进行操作,当创建数据库预处理操作语句时,客户端向数据库服务器发送一个包括查询、插入、更新等操作的数据库操作语句模板,然后,数据库服务器对数据库操作语句模板进行解析,生成对应的语法树,并将经过处理的数据库操作语句模板保存起来,数据库预处理操作语句模板用问号(?)代表执行具体操作的参数值,当客户端执行对应的查询、插入、更新等具体操作时,可以将问号所代表的参数值发送至数据库服务器,即可得到操作结果,上述过程可以重复多次,采用数据库预处理操作技术的优势在于:
1、数据库所在的服务器只需解析一次数据库操作语句,并且完整的数据库操作语句不会被发送至服务器,只需采用二进制协议的形式发送参与具体业务的参数信息,节约了处理具体业务的开销如内存、带宽;
2、数据库所在的服务器缓存了部分处理数据库操作语句的计划,所以只需执行一次解析数据库操作语句的动作,提高了处理具体业务的效率;
3、采用预处理技术的数据库服务器,可以有效避免所述数据库服务器遭遇注入式攻击,提高了数据库服务器的安全性。
但是,数据库预处理技术目前只能在独立式数据库服务器上使用,而不能在分布式数据库服务器上使用。
发明内容
为解决上述技术问题,本发明实施例提供了一种分布式数据库预处理的方法及装置、计算机存储介质,旨在解决数据库预处理技术不能在分布式数据库服务器上使用的技术问题。
本发明实施例提供的分布式数据库预处理的方法,包括:
从客户端处获取分布式数据库操作语句模板,并获取操作语句参数信息;
通过解析所述分布式数据库操作语句模板确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,并发送所述分布式数据库操作语句模板至所述分布式数据库服务器集群;
发送所述操作语句参数信息至所述分布式数据库服务器集群;
获取所述分布式数据库服务器集群根据所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果。
在本发明一实施方式中,所述通过解析所述分布式数据库操作语句模板确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,包括:
解析所述分布式数据库操作语句模板生成语法树;
根据所述语法树,计算生成所述分布式数据库操作语句模板的执行计划树;
根据所述执行计划树,获取与所述分布式数据库操作语句模板对应的分布式数据库服务器集群。
在本发明一实施方式中,所述操作语句参数信息包括操作语句参数值及用于将所述操作语句参数值匹配给所述分布式数据库操作语句模板的标识信息。
在本发明一实施方式中,所述获取所述分布式数据库服务器集群根据 所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果,包括:
获取由所述分布式数据库服务器集群返回的结果数据,其中,所述结果数据是位于所述分布式数据库服务器集群中的多个分布式数据库服务器结合所述分布式数据库操作语句模板及所述操作语句参数信息对存储于对应的分布式数据库服务器中的数据进行处理而得到的结果;
对所述结果数据进行汇总计算,获取经过汇总计算的结果集。
在本发明一实施方式中,所述获取所述分布式数据库服务器集群根据所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果之后,还包括:
将所述处理结果发送至客户端;从客户端处获取关闭预处理操作的请求信息,并发送所述请求信息至执行预处理操作的分布式数据库服务器集群;关闭位于所述分布式数据库服务器集群中的多个分布式数据库服务器的预处理服务。
本发明实施例提供的分布式数据库预处理的装置,包括:
模板获取模块,配置为从客户端处获取分布式数据库操作语句模板,并获取操作语句参数信息;
模板处理模块,配置为通过解析所述分布式数据库操作语句模板确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,并发送所述分布式数据库操作语句模板至所述分布式数据库服务器集群;
参数信息转发模块,配置为发送所述操作语句参数信息至所述分布式数据库服务器集群;
结果返回模块,配置为获取所述分布式数据库服务器根据所述执行预处理操作的请求信息返回的处理结果。
在本发明一实施方式中,所述操作语句参数信息包括操作语句参数值 及用于将所述操作语句参数值匹配给所述分布式数据库操作语句模板的标识信息。
在本发明一实施方式中,所述模板处理模块还配置为:
解析生成所述分布式数据库操作语句模板的语法树;
根据所述语法树,计算生成所述分布式数据库操作语句模板的执行计划树;
根据所述执行计划树,获取与所述分布式数据库操作语句模板对应的分布式数据库服务器集群。
在本发明一实施方式中,所述结果返回模块还配置为:
获取由所述分布式数据库服务器集群返回的结果数据,其中,所述结果数据是位于所述分布式数据库服务器集群中的多个分布式数据库服务器结合所述分布式数据库操作语句模板及所述操作语句参数信息对存储于对应的分布式数据库服务器中的数据进行处理而得到的结果;
对所述结果数据进行汇总计算,获取经过汇总计算的结果集。
在本发明一实施方式中,所述分布式数据库预处理的装置还包括:
关闭模块,配置为将所述处理结果发送至客户端;从客户端处获取关闭预处理操作的请求信息,并发送所述请求信息至执行预处理操作的分布式数据库服务器集群;关闭位于所述分布式数据库服务器集群中的多个分布式数据库服务器的预处理服务。
本发明实施例提供的计算机存储介质存储有计算机程序,该计算机程序配置为执行上述分布式数据库预处理的方法。
本发明实施例提供了一种分布式数据库预处理的方法及装置、计算机存储介质,通过从客户端处获取分布式数据库操作语句模板,并获取操作语句参数信息,对所述分布式数据库操作语句模板进行解析,确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,发送所述分 布式数据库操作语句模板至所述分布式数据库服务器集群,并发送所述操作语句参数信息至所述分布式数据库服务器集群,获取所述分布式数据库服务器集群根据所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果,从而解决了数据库预处理技术不能在分布式数据库服务器上使用的技术问题。
附图说明
图1为本发明分布式数据库预处理的方法一实施例的流程示意图;
图2为本发明分布式数据库预处理的方法二实施例的流程示意图;
图3为本发明分布式数据库预处理的装置一实施例的功能模块示意图;
图4是本发明实施例中分布式数据库系统的结构示意图;
图5是本发明实施例中分布式数据库操作语句预处理的装置的另一种功能模块示意图;
图6为本发明分布式数据库预处理的装置二实施例的功能模块示意图。
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。
本发明实施例提供一种分布式数据库预处理的方法。
参照图1,图1为本发明分布式数据库操作语句预处理的方法一实施例的流程示意图。
在一实施例中,该分布式数据库操作语句预处理的方法包括:
步骤S10,从客户端处获取分布式数据库操作语句模板,并获取操作语 句参数信息;
本实施例中的技术方案涉及客户端与分布式数据库服务器之间的交互,以实现客户端通过发送分布式数据库操作语句请求来完成对分布式数据库的访问。其中,本实施例在客户端与分布式数据库服务器之间引入中间件,也称分布式数据库操作语句预处理的装置,通过中间件实现分布式数据库预处理。
本实施例分布式数据库系统的结构可以如图4所示,其中,本实施例中的分布式数据库操作语句预处理的装置可以包括执行模块及操作语句路由模块(SQL路由模块)。
具体地,作为一种功能模块设置方式,可以参照图5所示,所述执行模块可以包括线程池单元、线程调度单元、数据操作语句解析单元(SQL解析单元)、数据操纵语言单元(DML单元)、数据定义语言单元(DDL单元)、中介数据缓存单元,以及与SQL路由接口,具体的执行模块的组成部分,在此不作限定。
具体地,所述线程池单元负责管理所述分布式数据库操作语句预处理的装置的所有线程的使用与回收。当所述分布式数据库操作语句预处理的装置获取由客户端处发送的分布式数据库操作语句模板时,所述线程调度单元从所述线程池单元调度一个线程用于处理所述分布式数据库操作语句模板。
所述数据定义语言单元负责将数据定义语句转化为可在分布式数据库服务器中执行的数据定义语句,并将所述数据定义语句的分发策略信息存储于数据字典文件中,再将所述分发策略信息加载至缓存中,以供所述数据操纵语言单元使用。
当所述分布式数据库操作语句预处理的装置启动时,所述分布式数据库操作语句预处理的装置将全部分发策略信息加载至缓存中,所述中介数 据缓存单元负责管理所述分发策略信息,并向所述数据操纵语言单元提供查询服务。
本实施例中,通过在客户端处设定分布式数据库操作语句,其中,所述分布式数据库操作语句包括分布式数据库操作语句模板与分布式数据库操作语句参数值。客户端将分布式数据库操作语句拆分为单独的分布式数据库操作语句模板与单独的分布式数据库操作语句参数值,其中,单独的分布式数据库操作语句模板,如INSERT INTO students(firstname,lastname,email)VALUES(?,?,?),可以包括操作语句语法框架、数据库表头信息、操作语句参数变量,具体地,所述分布式数据库操作语句模板的组成部分,在此不作限定。分布式数据库操作语句模板由客户端发送至分布式数据库操作语句预处理的装置。
步骤S20,通过解析所述分布式数据库操作语句模板确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,并发送所述分布式数据库操作语句模板至所述分布式数据库服务器集群;
在获取分布式数据库操作语句模板后,分布式数据库操作语句预处理的装置对所述分布式数据库操作语句模板进行解析,确定存储以数据库表头信息作为标识的数据库表的分布式数据库服务器,将全部符合条件的分布式数据库服务器打包成一个分布式数据库服务器集群,再向所述分布式数据库服务器集群发送包括所述数据库表头信息的分布式数据库操作语句模板。
步骤S30,发送所述操作语句参数信息至所述分布式数据库服务器集群;
在分布式数据库操作语句预处理的装置获取由客户端发送的与所述分布式数据库操作语句模板匹配的操作语句参数信息后,所述分布式数据库操作语句预处理的装置将所述操作语句参数信息发送至经过确定的分布式 数据库服务器集群。
位于所述分布式数据库服务器集群中的所有分布式数据库服务器将之前获取的分布式数据库操作语句模板与所述操作语句参数信息进行组合,形成可以被所述分布式数据库服务器执行的完整的分布式数据库操作语句,通过执行所述分布式数据库操作语句,完成对存储于所述分布式数据库服务器中的数据的具体操作,如查询数据、插入数据、更新数据等,具体的,所述具体操作的操作内容,在此不作限定。
步骤S40,获取所述分布式数据库服务器集群根据所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果。
在完成相关的操作后,所有分布式数据库服务器将操作结果发送至分布式数据库操作语句预处理的装置,所述操作结果包括操作成功信息、操作失败信息、操作用时信息等,具体地,所述操作结果,在此不作限定。
本实施例通过从客户端处获取分布式数据库操作语句模板,并获取操作语句参数信息,对所述分布式数据库操作语句模板进行解析,确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,发送所述分布式数据库操作语句模板至所述分布式数据库服务器集群,并发送所述操作语句参数信息至所述分布式数据库服务器集群,获取所述分布式数据库服务器集群根据所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果。解决了数据库预处理技术不能在分布式数据库服务器上使用的技术问题。
进一步地,在其他实施例中,上述步骤S20可以包括:
解析生成所述分布式数据库操作语句模板的语法树;
根据所述语法树,计算所述分布式数据库操作语句模板生成执行计划树;
根据所述执行计划树,获取与所述分布式数据库操作语句模板对应的分布式数据库服务器集群。
该实施例中,通过解析由客户端处获取的分布式数据库操作语句模板,生成所述分布式数据库操作语句模板的语法树,由数据操纵语言单元对所述语法树进行计算,生成所述分布式数据库操作语句模板的计划执行树,根据所述计划执行树,所述数据操纵语言单元确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,并将所有位于所述分布式数据库服务器集群中的分布式数据库服务器的网络地址信息存储于所述执行计划树的节点中,由分布式数据库操作语句预处理的装置将所述分布式数据库操作语句模板发送至所述分布式数据库服务器集群。
具体地,所述数据操作语句解析单元负责解析由客户端处获取的分布式数据库操作语句模板,生成所述分布式数据库操作语句模板的语法树,再将所述语法树发送至所述数据操纵语言单元与所述数据定义语言单元用于生成与所述分布式数据库操作语句模板对应的执行计划树。
在一种实施方式中,客户端将分布式数据库操作语句模板发送至分布式数据库操作语句预处理的装置,当所述分布式数据库操作语句预处理的装置获取所述分布式数据库操作语句模板时,对所述分布式数据库操作语句模板中的操作语句语法框架进行解析,得到语法树,所述数据操纵语言单元通过分析所述语法树,获取所述分布式数据库操作语句模板中的数据库表头信息,并通过中介数据缓存单元获取存储以所述数据库表头信息作为标识的数据库表的所有分布式数据库服务器的网络地址信息,根据所述网络地址信息,生成执行计划树,并将所述网络地址信息存储于所述执行计划树中。
上述实施例方案,通过存储于所述执行计划树中的所述网络地址信息,确定与所述分布式数据库操作语句模板对应的所有分布式数据库服务器, 并与所述所有分布式数据库服务器集群建立逻辑链路通道,其中,所述分布式数据库服务器组成一个分布式数据库服务器集群。通过操作语句路由器即操作语句路由模块通过所述逻辑链路通道向所述分布式数据库服务器集群发送所述分布式数据库操作语句模板。解决了数据库预处理技术不能在分布式数据库服务器上使用的技术问题。
进一步地,在其他实施例中,操作语句参数信息包括操作语句参数值及用于将所述操作语句参数值匹配给所述分布式数据库操作语句模板的标识信息。
该实施例中,参数信息可以包括中间变量。位于所述分布式数据库服务器集群中的所有分布式数据库服务器将之前获取的分布式数据库操作语句模板中的问号(?)与所述中间变量进行组合,获取包括所述中间变量的分布式数据库操作语句模板,如INSERT INTO students(firstname,lastname,email)VALUES(x,y,z),其中,中间变量x、中间变量y及中间变量z可以与在客户端中设定的参数x、参数y及参数z形成逻辑关系,具体地,所述中间变量的数量,在此不作限定。在所述客户端中,当对所述参数x、所述参数y及所述参数z执行赋值运算操作如循环赋值运算时,用于执行赋值操作的参数值可以对所述中间变量x、所述中间变量y及所述中间变量z进行赋值,其中,所述参数值是所述参数信息的组成部分。中间变量的引入,解决了当需多次要执行发送参数信息的操作时,需要在客户端处多次输入参数值的问题,提升了用户体验。
进一步地,在其他实施例中,上述步骤S40可以包括:
获取由所述分布式数据库服务器集群返回的结果数据,其中,所述结果数据是位于所述分布式数据库服务器集群中的多个分布式数据库服务器结合所述分布式数据库操作语句模板及所述操作语句参数信息对存储于对 应的分布式数据库服务器中的数据进行处理而得到的结果;
对所述结果数据进行汇总计算,获取经过汇总计算的结果集。
该实施例中,分布式数据库服务器通过结合分布式数据库操作语句模板与操作语句参数信息,对存储于所述分布式数据库服务器中的数据进行处理,处理方式可以包括增添数据、删除数据、更改数据、查询数据等,具体地,所述处理方式的处理内容,在此不作限定。在完成相关的操作后,所述分布式数据库服务器得到处理结果,所述处理结果可以包括操作成功信息、操作失败信息、操作用时信息等。具体地,所述操作成功信息的具体内容,如通过查询操作得到的数据,在此不作限定。
在一种实施方式中,操作语句路由器监听所述分布式数据库服务器的处理过程,当处理结束时,所述分布式数据库服务器将结果数据发送至执行计划树的节点中,由分布式数据库操作语句预处理的装置对存储于所述节点中的所述结果数据进行汇总计算,得到经过汇总计算的结果集。解决了数据库预处理技术不能在分布式数据库服务器上使用的技术问题。
参照图2,图2为本发明分布式数据库预处理的方法二实施例的流程示意图,在上述实施例的基础上,在上述步骤S40之后还包括:
步骤S50,将所述处理结果发送至客户端;从客户端处获取关闭预处理操作的请求信息,并发送所述请求信息至执行预处理操作的分布式数据库服务器集群;关闭位于所述分布式数据库服务器集群中的多个分布式数据库服务器的预处理服务。
本实施例中,将所述处理结果发送至客户端,并从客户端处获取关闭预处理操作的请求信息,当分布式数据库操作语句预处理的装置获取关闭预处理操作的请求信息时,所述分布式数据库操作语句预处理的装置销毁相关的数据,具体地,所述数据可以包括语法树、执行计划树及相关的缓存信息,在此不作限定。同时,向执行预处理操作的分布式数据库服务器 发送所述请求信息,关闭所述数据库服务器的预处理服务。解决了数据库预处理技术不能在分布式数据库服务器上使用的技术问题,并在释放硬件资源的基础上,节省了硬件资源的内存与存储空间。
本发明实施例进一步提供一种分布式数据库预处理的装置。
参照图3,图3为本发明分布式数据库预处理的装置一实施例的功能模块示意图。
在一实施例中,该分布式数据库操作语句预处理的装置可以包括:模板获取模块01、模板处理模块02、参数信息转发模块03、结果返回模块04,其中:
模板获取模块01,配置为从客户端处获取分布式数据库操作语句模板,并获取操作语句参数信息;
本实施例中的技术方案涉及客户端与分布式数据库服务器之间的交互,以实现客户端通过发送分布式数据库操作语句请求来完成对分布式数据库的操作。其中,本实施例在客户端与分布式数据库服务器之间引入中间件,也即本实施例提出的分布式数据库操作语句预处理的装置,通过中间件实现分布式数据库预处理。本实施例中,通过在客户端处设定分布式数据库操作语句,其中,所述分布式数据库操作语句包括分布式数据库操作语句模板与分布式数据库操作语句参数值。客户端将分布式数据库操作语句拆分为单独的分布式数据库操作语句模板与单独的分布式数据库操作语句参数值,其中,单独的分布式数据库操作语句模板,如INSERT INTO students(firstname,lastname,email)VALUES(?,?,?),可以包括操作语句语法框架、数据库表头信息、操作语句参数变量,具体地,所述分布式数据库操作语句模板的组成部分,在此不作限定。分布式数据库操作语句模板由客户端发送至分布式数据库操作语句预处理的装置。
模板处理模块02,配置为通过解析所述分布式数据库操作语句模板确 定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,并发送所述分布式数据库操作语句模板至所述分布式数据库服务器集群;
在获取分布式数据库操作语句模板后,分布式数据库操作语句预处理的装置对所述分布式数据库操作语句模板进行解析,确定存储以数据库表头信息作为标识的数据库表的分布式数据库服务器,将全部符合条件的分布式数据库服务器打包成一个分布式数据库服务器集群,再向所述分布式数据库服务器集群发送包括所述数据库表头信息的分布式数据库操作语句模板。
参数信息转发模块03,配置为发送所述操作语句参数信息至所述分布式数据库服务器集群;
在分布式数据库操作语句预处理的装置获取由客户端发送的与所述分布式数据库操作语句模板匹配的操作语句参数信息后,所述分布式数据库操作语句预处理的装置将所述操作语句参数信息发送至经过确定的分布式数据库服务器集群。
位于所述分布式数据库服务器集群中的所有分布式数据库服务器将之前获取的分布式数据库操作语句模板与所述操作语句参数信息进行组合,形成可以被所述分布式数据库服务器执行的完整的分布式数据库操作语句,通过执行所述分布式数据库操作语句,完成对存储于所述分布式数据库服务器中的数据的具体操作,如查询数据、插入数据、更新数据等,具体的,所述具体操作的操作内容,在此不作限定。
结果返回模块04,配置为获取所述分布式数据库服务器根据所述执行预处理操作的请求信息返回的处理结果。
在完成相关的操作后,所有分布式数据库服务器将操作结果发送至分布式数据库操作语句预处理的装置,所述操作结果包括操作成功信息、操作失败信息、操作用时信息等,具体地,所述操作结果,在此不作限定。
本实施例通过从客户端处获取分布式数据库操作语句模板,并获取操作语句参数信息,对所述分布式数据库操作语句模板进行解析,确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,发送所述分布式数据库操作语句模板至所述分布式数据库服务器集群,并发送所述操作语句参数信息至所述分布式数据库服务器集群,获取所述分布式数据库服务器集群根据所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果。解决了数据库预处理技术不能在分布式数据库服务器上使用的技术问题。
在一种实际应用中,本实施例分布式数据库系统的结构可以如图4所示,其中,本实施例中的分布式数据库操作语句预处理的装置可以包括执行模块及操作语句路由模块(SQL路由模块),其中,该执行模块可以包括上述实施例中的模板获取模块01和模板处理模块02的功能,操作语句路由模块可以包括上述实施例中的参数信息转发模块03和结果返回模块04。
具体地,作为一种功能模块设置方式,可以参照图5所示,所述执行模块可以包括线程池单元、线程调度单元、数据操作语句解析单元(SQL解析单元)、数据操纵语言单元(DML单元)、数据定义语言单元(DDL单元)、中介数据缓存单元,以及与SQL路由接口,具体的执行模块的组成部分,在此不作限定。
具体地,所述线程池单元负责管理所述分布式数据库操作语句预处理的装置的所有线程的使用与回收。当所述分布式数据库操作语句预处理的装置获取由客户端处发送的分布式数据库操作语句模板时,所述线程调度单元从所述线程池单元调度一个线程用于处理所述分布式数据库操作语句模板。
所述数据定义语言单元负责将数据定义语句转化为可在分布式数据库服务器中执行的数据定义语句,并将所述数据定义语句的分发策略信息存 储于数据字典文件中,再将所述分发策略信息加载至缓存中,以供所述数据操纵语言单元使用。
当所述分布式数据库操作语句预处理的装置启动时,所述分布式数据库操作语句预处理的装置将全部分发策略信息加载至缓存中,所述中介数据缓存单元负责管理所述分发策略信息,并向所述数据操纵语言单元提供查询服务。
进一步地,在其他实施例中,上述模板处理模块02可以配置为:
解析生成所述分布式数据库操作语句模板的语法树;根据所述语法树,计算生成所述分布式数据库操作语句模板的执行计划树;根据所述执行计划树,获取与所述分布式数据库操作语句模板对应的分布式数据库服务器集群。
基于图4所示的执行模块,在该实施例中,通过解析由客户端处获取的分布式数据库操作语句模板,生成所述分布式数据库操作语句模板的语法树,由数据操纵语言单元对所述语法树进行计算,生成所述分布式数据库操作语句模板的计划执行树,根据所述计划执行树,所述数据操纵语言单元确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,并将所有位于所述分布式数据库服务器集群中的分布式数据库服务器的网络地址信息存储于所述执行计划树的节点中,由分布式数据库操作语句预处理的装置将所述分布式数据库操作语句模板发送至所述分布式数据库服务器集群。
具体地,所述数据操作语句解析单元负责解析由客户端处获取的分布式数据库操作语句模板,生成所述分布式数据库操作语句模板的语法树,再将所述语法树发送至所述数据操纵语言单元与所述数据定义语言单元用于生成与所述分布式数据库操作语句模板对应的执行计划树。
在一种实施方式中,客户端将分布式数据库操作语句模板发送至分布 式数据库操作语句预处理的装置,当所述分布式数据库操作语句预处理的装置获取所述分布式数据库操作语句模板时,对所述分布式数据库操作语句模板中的操作语句语法框架进行解析,得到语法树,所述数据操纵语言单元通过分析所述语法树,获取所述分布式数据库操作语句模板中的数据库表头信息,并通过中介数据缓存单元获取存储以所述数据库表头信息作为标识的数据库表的所有分布式数据库服务器的网络地址信息,根据所述网络地址信息,生成执行计划树,并将所述网络地址信息存储于所述执行计划树中。
通过存储于所述执行计划树中的所述网络地址信息,确定与所述分布式数据库操作语句模板对应的所有分布式数据库服务器,并与所述所有分布式数据库服务器集群建立逻辑链路通道,其中,所述分布式数据库服务器组成一个分布式数据库服务器集群。通过操作语句路由器即操作语句路由模块通过所述逻辑链路通道向所述分布式数据库服务器集群发送所述分布式数据库操作语句模板。解决了数据库预处理技术不能在分布式数据库服务器上使用的技术问题。
进一步地,在其他实施例中,操作语句参数信息包括操作语句参数值及用于将所述操作语句参数值匹配给所述分布式数据库操作语句模板的标识信息。
该实施例中,参数信息可以包括中间变量。位于所述分布式数据库服务器集群中的所有分布式数据库服务器将之前获取的分布式数据库操作语句模板中的问号(?)与所述中间变量进行组合,获取包括所述中间变量的分布式数据库操作语句模板,如INSERT INTO students(firstname,lastname,email)VALUES(x,y,z),其中,中间变量x、中间变量y及中间变量z可以与在客户端中设定的参数x、参数y及参数z形成逻辑关系,具体地,所述中间变量的数量,在此不作限定。在所述客户端中,当对所述参数x、所 述参数y及所述参数z执行赋值运算操作如循环赋值运算时,用于执行赋值操作的参数值可以对所述中间变量x、所述中间变量y及所述中间变量z进行赋值,其中,所述参数值是所述参数信息的组成部分。中间变量的引入,解决了当需多次要执行发送参数信息的操作时,需要在客户端处多次输入参数值的问题,提升了用户体验。
进一步地,在其他实施例中,上述结果返回模块04可以配置为:
获取由所述分布式数据库服务器集群返回的结果数据,其中,所述结果数据是位于所述分布式数据库服务器集群中的多个分布式数据库服务器结合所述分布式数据库操作语句模板及所述操作语句参数信息对存储于对应的分布式数据库服务器中的数据进行处理而得到的结果;对所述结果数据进行汇总计算,获取经过汇总计算的结果集。
在该实施例中,分布式数据库服务器通过结合分布式数据库操作语句模板与操作语句参数信息,对存储于所述分布式数据库服务器中的数据进行处理,处理方式可以包括增添数据、删除数据、更改数据、查询数据等,具体地,所述处理方式的处理内容,在此不作限定。在完成相关的操作后,所述分布式数据库服务器得到处理结果,所述处理结果可以包括操作成功信息、操作失败信息、操作用时信息等。具体地,所述操作成功信息的具体内容,如通过查询操作得到的数据,在此不作限定。
在一种实施方式中,操作语句路由器监听所述分布式数据库服务器的处理过程,当处理结束时,所述分布式数据库服务器将结果数据发送至执行计划树的节点中,由分布式数据库操作语句预处理的装置对存储于所述节点中的所述结果数据进行汇总计算,得到经过汇总计算的结果集。解决了数据库预处理技术不能在分布式数据库服务器上使用的技术问题。
参照图6,图6为本发明分布式数据库预处理的装置二实施例的功能模 块示意图,在上述实施例的基础上,该分布式数据库预处理的装置还包括:
关闭模块05,将所述处理结果发送至客户端;从客户端处获取关闭预处理操作的请求信息,并发送所述请求信息至执行预处理操作的分布式数据库服务器集群;关闭位于所述分布式数据库服务器集群中的多个分布式数据库服务器的预处理服务。
本实施例中,将所述处理结果发送至客户端,并从客户端处获取关闭预处理操作的请求信息,当分布式数据库操作语句预处理的装置获取关闭预处理操作的请求信息时,所述分布式数据库操作语句预处理的装置销毁相关的数据,具体地,所述数据可以包括语法树、执行计划树及相关的缓存信息,在此不作限定。同时,向执行预处理操作的分布式数据库服务器发送所述请求信息,关闭所述数据库服务器的预处理服务。解决了数据库预处理技术不能在分布式数据库服务器上使用的技术问题,并在释放硬件资源的基础上,节省了硬件资源的内存与存储空间。
在实际应用中,所述分布式数据库预处理的装置中的各个模块所实现的功能,均可由位于分布式数据库预处理的装置中的中央处理器(Central Processing Unit,CPU)、或微处理器(Micro Processor Unit,MPU)、或数字信号处理器(Digital Signal Processor,DSP)、或现场可编程门阵列(Field Programmable Gate Array,FPGA)等实现。
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机。服务器, 或者网络设备等)执行本发明各个实施例所述的方法。
相应地,本发明实施例还提供一种计算机存储介质,其中存储有计算机程序,该计算机程序配置为执行本发明实施例的分布式数据库预处理的方法。
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。
工业实用性
本发明实施例的技术方案,通过从客户端处获取分布式数据库操作语句模板,并获取操作语句参数信息,对所述分布式数据库操作语句模板进行解析,确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,发送所述分布式数据库操作语句模板至所述分布式数据库服务器集群,并发送所述操作语句参数信息至所述分布式数据库服务器集群,获取所述分布式数据库服务器集群根据所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果,从而解决了数据库预处理技术不能在分布式数据库服务器上使用的技术问题。

Claims (11)

  1. 一种分布式数据库预处理的方法,所述分布式数据库预处理的方法包括:
    从客户端处获取分布式数据库操作语句模板,并获取操作语句参数信息;
    通过解析所述分布式数据库操作语句模板确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,并发送所述分布式数据库操作语句模板至所述分布式数据库服务器集群;
    发送所述操作语句参数信息至所述分布式数据库服务器集群;
    获取所述分布式数据库服务器集群根据所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果。
  2. 如权利要求1所述的分布式数据库预处理的方法,其中,所述通过解析所述分布式数据库操作语句模板确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,包括:
    解析所述分布式数据库操作语句模板生成语法树;
    根据所述语法树,计算生成所述分布式数据库操作语句模板的执行计划树;
    根据所述执行计划树,获取与所述分布式数据库操作语句模板对应的分布式数据库服务器集群。
  3. 如权利要求1所述的分布式数据库预处理的方法,其中,所述操作语句参数信息包括操作语句参数值及用于将所述操作语句参数值匹配给所述分布式数据库操作语句模板的标识信息。
  4. 如权利要求1所述的分布式数据库预处理的方法,其中,所述获取所述分布式数据库服务器集群根据所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果,包括:
    获取由所述分布式数据库服务器集群返回的结果数据,其中,所述结果数据是位于所述分布式数据库服务器集群中的多个分布式数据库服务器结合所述分布式数据库操作语句模板及所述操作语句参数信息对存储于对应的分布式数据库服务器中的数据进行处理而得到的结果;
    对所述结果数据进行汇总计算,获取经过汇总计算的结果集。
  5. 如权利要求1至4中任意一项所述的分布式数据库预处理的方法,其中,所述获取所述分布式数据库服务器集群根据所述分布式数据库操作语句模板及所述操作语句参数信息返回的处理结果之后还包括:
    将所述处理结果发送至客户端;
    从客户端处获取关闭预处理操作的请求信息,并发送所述请求信息至执行预处理操作的分布式数据库服务器集群;
    关闭位于所述分布式数据库服务器集群中的多个分布式数据库服务器的预处理服务。
  6. 一种分布式数据库预处理的装置,所述装置包括:
    模板获取模块,配置为从客户端处获取分布式数据库操作语句模板,并获取操作语句参数信息;
    模板处理模块,配置为通过解析所述分布式数据库操作语句模板确定与所述分布式数据库操作语句模板对应的分布式数据库服务器集群,并发送所述分布式数据库操作语句模板至所述分布式数据库服务器集群;
    参数信息转发模块,配置为发送所述操作语句参数信息至所述分布式数据库服务器集群;
    结果返回模块,配置为获取所述分布式数据库服务器根据所述执行预处理操作的请求信息返回的处理结果。
  7. 如权利要求6所述的分布式数据库预处理的装置,其中,所述模板处理模块还配置为:
    解析生成所述分布式数据库操作语句模板的语法树;根据所述语法树,计算生成所述分布式数据库操作语句模板的执行计划树;根据所述执行计划树,获取与所述分布式数据库操作语句模板对应的分布式数据库服务器集群。
  8. 如权利要求6所述的分布式数据库预处理的装置,其中,所述操作语句参数信息包括操作语句参数值及用于将所述操作语句参数值匹配给所述分布式数据库操作语句模板的标识信息。
  9. 如权利要求6所述的分布式数据库预处理的装置,其中,所述结果返回模块还配置为:
    获取由所述分布式数据库服务器集群返回的结果数据,其中,所述结果数据是位于所述分布式数据库服务器集群中的多个分布式数据库服务器结合所述分布式数据库操作语句模板及所述操作语句参数信息对存储于对应的分布式数据库服务器中的数据进行处理而得到的结果;对所述结果数据进行汇总计算,获取经过汇总计算的结果集。
  10. 如权利要求6至9中任意一项所述的分布式数据库预处理的装置,其中,还包括:
    关闭模块,配置为将所述处理结果发送至客户端;从客户端处获取关闭预处理操作的请求信息,并发送所述请求信息至执行预处理操作的分布式数据库服务器集群;关闭位于所述分布式数据库服务器集群中的多个分布式数据库服务器的预处理服务。
  11. 一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,该计算机可执行指令配置为执行权利要求1-5任一项所述的分布式数据库预处理的方法。
PCT/CN2017/074231 2016-03-23 2017-02-21 分布式数据库预处理的方法及装置、计算机存储介质 WO2017161989A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610171043.5 2016-03-23
CN201610171043.5A CN107229628B (zh) 2016-03-23 2016-03-23 分布式数据库预处理的方法及装置

Publications (1)

Publication Number Publication Date
WO2017161989A1 true WO2017161989A1 (zh) 2017-09-28

Family

ID=59899204

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/074231 WO2017161989A1 (zh) 2016-03-23 2017-02-21 分布式数据库预处理的方法及装置、计算机存储介质

Country Status (2)

Country Link
CN (1) CN107229628B (zh)
WO (1) WO2017161989A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112035514A (zh) * 2020-09-02 2020-12-04 北京金山云网络技术有限公司 一种数据库语句处理方法、装置、电子设备及存储介质

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109241154A (zh) * 2018-07-05 2019-01-18 武汉迎风聚智科技有限公司 一种分布式数据库监控分析方法及系统
CN112860740B (zh) * 2019-11-27 2022-12-20 金篆信科有限责任公司 一种触发器实现的方法和装置
CN111881216A (zh) * 2020-08-03 2020-11-03 北京罗克维尔斯科技有限公司 一种基于共享模板的数据获取方法和装置
CN112163000A (zh) * 2020-08-31 2021-01-01 阿里巴巴集团控股有限公司 一种数据查询方法和装置

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110029498A1 (en) * 2009-07-10 2011-02-03 Xkoto, Inc. System and Method for Subunit Operations in a Database
CN103336782A (zh) * 2013-05-30 2013-10-02 莱诺斯科技(北京)有限公司 一种关系型分布式数据库系统
CN103646051A (zh) * 2013-11-27 2014-03-19 武汉邮电科学研究院 一种基于列存储的大数据并行处理系统及方法
CN103729471A (zh) * 2014-01-21 2014-04-16 华为软件技术有限公司 数据库查询方法和装置
CN104333512A (zh) * 2014-10-30 2015-02-04 北京思特奇信息技术股份有限公司 一种分布式内存数据库访问系统及方法
CN104793988A (zh) * 2014-01-20 2015-07-22 阿里巴巴集团控股有限公司 跨数据库分布式事务的实现方法和装置

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1654648B1 (en) * 2003-08-14 2015-11-11 Oracle International Corporation Hierarchical management of the dynamic allocation of resources in a multi-node system
CN102193922B (zh) * 2010-03-04 2013-07-24 杭州华三通信技术有限公司 一种对数据库进行访问的方法和装置
CN102209118A (zh) * 2011-06-10 2011-10-05 成都勤智数码科技有限公司 一种分布式海量数据汇聚方法
CN102955801B (zh) * 2011-08-25 2017-06-16 中兴通讯股份有限公司 基于分布式数据库系统的数据控制方法及系统
CN104484392B (zh) * 2014-12-11 2018-02-02 北京国双科技有限公司 数据库查询语句生成方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110029498A1 (en) * 2009-07-10 2011-02-03 Xkoto, Inc. System and Method for Subunit Operations in a Database
CN103336782A (zh) * 2013-05-30 2013-10-02 莱诺斯科技(北京)有限公司 一种关系型分布式数据库系统
CN103646051A (zh) * 2013-11-27 2014-03-19 武汉邮电科学研究院 一种基于列存储的大数据并行处理系统及方法
CN104793988A (zh) * 2014-01-20 2015-07-22 阿里巴巴集团控股有限公司 跨数据库分布式事务的实现方法和装置
CN103729471A (zh) * 2014-01-21 2014-04-16 华为软件技术有限公司 数据库查询方法和装置
CN104333512A (zh) * 2014-10-30 2015-02-04 北京思特奇信息技术股份有限公司 一种分布式内存数据库访问系统及方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112035514A (zh) * 2020-09-02 2020-12-04 北京金山云网络技术有限公司 一种数据库语句处理方法、装置、电子设备及存储介质

Also Published As

Publication number Publication date
CN107229628A (zh) 2017-10-03
CN107229628B (zh) 2022-02-01

Similar Documents

Publication Publication Date Title
WO2017161989A1 (zh) 分布式数据库预处理的方法及装置、计算机存储介质
US11394805B1 (en) Automatic discovery of API information
US11487772B2 (en) Multi-party data joint query method, device, server and storage medium
US10467220B2 (en) System and method for generating an effective test data set for testing big data applications
CN111414381B (zh) 数据处理方法、装置、电子设备及存储介质
CN110188573B (zh) 分区授权方法、装置、设备及计算机可读存储介质
CN110765484B (zh) 一种征信数据处理方法及电子设备
US20210014274A1 (en) Group optimization for network communications
CN107766378A (zh) 请求信息的发送方法及装置、分布式数据库系统
CN106886535A (zh) 一种适配多种数据源的数据抽取方法和装置
US20190073600A1 (en) Skipping maintenance mode of applications
US10243798B2 (en) Variable SNMP data collection with embedded queries
CN114969441A (zh) 基于图数据库的知识挖掘引擎系统
Munonye et al. Performance analysis of the microsoft. Net-and java-based implementation of REST web services
CN107203594B (zh) 一种数据处理设备、方法和计算机可读存储介质
WO2023092981A1 (zh) 流式数据处理方法、规则插件、流式数据处理模块及系统
CN112883088A (zh) 一种数据处理方法、装置、设备及存储介质
CN107644103B (zh) 一种可追溯信息来源的信息存储的方法和系统
CN115510137A (zh) 基于jdbc规范的命令转换方法、系统、计算机设备及介质
CN113641557A (zh) 数据监控处理方法、装置、设备及存储介质
US20160085828A1 (en) Just-in-time computation in a federated system
CN117591565B (zh) 虚拟机器人的实例处理方法、实例处理装置及存储介质
CN114780216B (zh) 任务调度方法、装置、计算机设备和存储介质
CN109542896B (zh) 一种用于教育操作系统的数据处理方法及装置
CN117033748B (zh) 业务查询信息的获取方法、业务数据查询方法以及装置

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17769266

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 17769266

Country of ref document: EP

Kind code of ref document: A1