Distributed database data sharding method, device, equipment, medium and program
By obtaining and parsing the shard call clause in the shard processing module of the distributed database and generating the target database statement, the problem of too long content of the shard clause and difficulty in checking the consistency of shard rules in the existing technology is solved, and higher data shard statement readability and processing convenience are achieved.
Patent Information
- Application Number
- CN202411858822.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-04-08
AI Technical Summary
In existing distributed databases, in database statements that include shard rules, the content of the shard clause is too long, resulting in poor readability. In the scenario where multiple tables are kept unified, it is easy to make mistakes in manually checking the consistency of shard rules, and the workload is high when modifying shard rules.
By obtaining the shard call clause in the shard processing module, performing syntax analysis, and obtaining the target database statement, thereby performing data shard association processing operations in the target distributed database.
It improves the readability of data sharding statements in distributed databases, simplifies the process of maintaining unified sharding rules for multiple tables, reduces the workload of modifying sharding rules, and improves the convenience and maintainability of data sharding processing.
Smart Images

Figure CN119782423A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of data processing technology, and in particular to a distributed database data sharding method, device, electronic device, storage medium and program. Background Art
[0002] A distributed database is a physically decentralized but logically centralized database system that connects multiple geographically dispersed database units through a computer network to form a unified database system. These database units are usually called sites or nodes, which communicate with each other through the network and together form a complete database system.
[0003] Distributed databases extend the table structure definition, and the associated statements for table operations usually include clauses for sharding processing rules. For example, a table creation statement usually includes a clause like "DISTRIBUTEDBY...(...)". In this clause, the content within "...(...)" is the specific sharding rule.
[0004] In the process of implementing the present invention, the inventors found that the prior art has the following defects: At present, in the database statements including sharding rules in the distributed database, the content of the sharding clause used to describe the sharding rules is too long, and it is not convenient to read when written together with the table structure. At the same time, for the scenario where multiple tables need to maintain uniform sharding rules, it is easy to make mistakes when manually checking the consistency of the sharding rules of each table due to the excessive amount of detailed information of the sharding rules. When modifying the sharding rules of a table, it is necessary to present the table structure definition and the sharding rule details, which requires a large workload for editing and maintenance and is inconvenient for maintenance. Summary of the invention
[0005] The embodiments of the present invention provide a distributed database data sharding method, device, electronic device, storage medium and program, which can improve the readability of data sharding statements in the distributed database, thereby improving the convenience and maintainability of data sharding processing in the distributed database.
[0006] According to one aspect of the present invention, a distributed database data sharding method is provided, which is applied to a sharder processing module and includes:
[0007] Obtain a sharder call clause; wherein the sharder call clause is used by the database operation main clause to call the target sharder to perform sharding processing;
[0008] Parsing the sharder call clause according to the sharder syntax rule to obtain a target database statement;
[0009] The target database statement is used to be executed in the target distributed database to implement data shard association processing operations.
[0010] According to another aspect of the present invention, a distributed database data sharding device is provided, which is configured in a sharder processing module, and the device comprises:
[0011] A sharder call clause acquisition module is used to acquire a sharder call clause corresponding to a database operation main clause; wherein the sharder call clause is used by the database operation main clause to call a target sharder;
[0012] A target database statement parsing module, used for parsing the sharder call clause according to the sharder grammar rules to obtain a target database statement;
[0013] The target database statement is used to be executed in the target distributed database to implement data shard association processing operations.
[0014] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the distributed database data sharding method described in any embodiment of the present invention.
[0018] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the distributed database data sharding method described in any embodiment of the present invention when executed.
[0019] According to another aspect of the present invention, a computer program product is provided, including a computer program, which, when executed by a processor, implements the distributed database data sharding method described in any embodiment of the present invention.
[0020] The embodiment of the present invention obtains a sharder call clause through a sharder processing module, determines the target sharder called by the database operation main clause through the sharder call clause, and then performs grammatical analysis on the sharder call clause according to the sharder grammar rules to obtain a target database statement. After obtaining the target database statement, the target database statement can be used to operate the target distributed database to implement data sharding associated processing operations. The above technical solution can solve the problems of poor readability and maintainability of database statements in existing distributed database data sharding methods, and can improve the readability of data sharding statements in distributed databases, thereby improving the convenience and maintainability of data sharding processing in distributed databases.
[0021] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 This is a flow chart of a distributed database data sharding method provided in Embodiment 1 of the present invention;
[0024] Figure 2 It is a flow chart of a distributed database data sharding method provided by Embodiment 2 of the present invention;
[0025] Figure 3 It is a flow chart of data sharding processing based on a sharding processing module built into a target distributed database, provided by Embodiment 2 of the present invention;
[0026] Figure 4 It is a flow chart of a distributed database data sharding method provided by Embodiment 3 of the present invention;
[0027] Figure 5 It is a flowchart of data sharding processing based on a sharding processing module independent of a target distributed database provided by Embodiment 3 of the present invention;
[0028] Figure 6 It is a schematic diagram of a distributed database data sharding device provided by a fourth embodiment of the present invention;
[0029] Figure 7This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0032] Embodiment 1
[0033] Figure 1 This is a flow chart of a distributed database data sharding method provided by the first embodiment of the present invention. This embodiment is applicable to the case where the sharding rules are parsed by the sharding processing module to perform data sharding processing. The method can be executed by a distributed database data sharding device, which can be implemented by software and / or hardware, and can generally be integrated in the sharding processing module. The sharding processing module can be integrated in an electronic device, which can be a terminal device or a server device. The embodiment of the present invention does not limit the specific device type of the electronic device. Accordingly, Figure 1 As shown, the method includes the following operations:
[0034] S110, obtaining a sharder calling clause; wherein the sharder calling clause is used by the database operation main clause to call a target sharder to perform sharding processing.
[0035] Among them, the database operation main clause and the sharder call clause can together constitute the current database statement to be processed. The current database statement to be processed can be the database statement currently operating the target distributed database. The target distributed database can be any type of distributed database, and the embodiment of the present invention does not limit the database type of the target distributed database. The database operation main clause can be the main clause constituting the current database statement to be processed, for example, it can be a table creation statement or a statement for modifying the sharding rules in the table, etc., as long as it involves the application of sharding rules, and the embodiment of the present invention also does not limit the statement type of the database operation main clause. The sharder call clause can be the current database statement to be processed used to trigger the sharder processing module to parse the corresponding sharder to obtain the sharding rules. The target sharder can be the sharder called by the database operation main clause, and can also be the sharder specified for processing in the sharder call clause.
[0036] In the embodiment of the present invention, a sharder can be created for a specific sharding rule in a distributed data block. The sharder can be used to perform sharding processing according to the set sharding rules based on the input parameters. A sharder can be created for each sharding rule. Different sharders can be named with different names to distinguish them. That is, all sharding rules can be abstractly represented by a sharder.
[0037] When constructing the current database statement to be processed, the sharder call clause can be used to call the corresponding sharder to replace the clause that references the sharding rule in the original database statement. As a result, the database statement is no longer composed of a database operation main clause and a clause including specific sharding rules, but is composed of a database operation main clause and a sharder call clause. The sharder call clause can call the corresponding sharder with a short sentence, thereby avoiding the problem of poor readability and maintainability of the current database statement to be processed due to the introduction of cumbersome sharding rules.
[0038] It is understandable that when different database statements use the same sharder call clause, it indicates that the same sharder is called, that is, the same sharding rule is used.
[0039] Correspondingly, the sharder call clause part can be input into the sharder processing module, which parses the sharder call clause to determine the target sharder called by the database operation main clause and the specific sharding rule corresponding to the target sharder.
[0040] S120. Perform grammatical parsing on the sharder call clause according to the sharder grammar rules to obtain a target database statement; wherein the target database statement is used to be executed in the target distributed database to implement data sharding association processing operations.
[0041] Among them, the sharding grammar rules may be rules built into the sharding processing module for performing grammatical parsing on sharding call clauses. The target database statement may be a database statement obtained by parsing the sharding processing module, which may be used to operate the target distributed database. The data sharding associated processing operation may be an operation related to data sharding, for example, it may include but is not limited to data sharding when creating a table, or modifying the current sharding rules of the table, etc. As long as it is an operation related to sharding, the embodiment of the present invention does not limit the specific operation type of the data sharding associated processing operation.
[0042] Correspondingly, for the current pending database statement currently initiated by the target distributed database, the sharder processing module can parse the sharder call clause therein. Specifically, the sharder processing module can use the built-in sharder grammar rules to perform grammatical analysis on the sharder call clause to determine the specific sharding rule of the sharder called in the sharder call clause and obtain statement information related to the sharding rule.
[0043] Optionally, the sharder processing module can be integrated within the distributed database, or used as an independent offline model. Depending on the way the sharder processing module is used, the type of target database statement generated by the sharder processing module corresponding to the analysis will also be different. If the sharder processing module is integrated and used within the distributed database, the target database statement generated by the sharder processing module corresponding to the analysis can be a statement in the internal execution flow of the database. If the sharder processing module is used independently offline, the target database statement generated by the sharder processing module corresponding to the analysis can be a partial statement input into the distributed database for operation. Accordingly, when the sharder processing module is used independently offline, the database operation main sentence and the result of the grammatical parsing of the sharder call clause by the sharder processing module can be spliced to obtain a complete database operation statement.
[0044] Exemplarily, it is assumed that the database operation main clause in the current database statement to be processed is a main clause composed of the table creation keyword "CREATE TABLE", and the sharder call clause in the current database statement to be processed is a clause for calling sharder 1, in which the parameter passed in is the id field in the database operation main clause. After obtaining the current database statement to be processed, the sharder processing module can perform syntax analysis on the sharder call clause in the current database statement to be processed, obtain the specific sharding rules corresponding to sharder 1 to obtain the sharding clause. If the sharder processing module is an internal module of the distributed database, the sharding clause parsed by the sharder processing module can continue to be executed as an internal execution statement of the database. If the sharder processing module is an external independent module of the distributed database, the sharding clause parsed by the sharder processing module can be spliced with the database operation main clause to obtain a complete database operation statement, and the spliced complete database operation statement can be used to perform data sharding-related operations on the distributed database.
[0045] In the prior art, database statements constructed using sharding clauses have the problem of poor readability. In a specific example, refer to the following table creation statement:
[0046] CREATE TABLE titles(id int key,year_col INT,serail_no char(100),namevarchar(200),order int,.....) distributed by list(id)(g1 values in(1),g2values in(2),g3 values in(3),g4 values in(4),g5 values in(5),g6values in(6),g7 values in(7),g8 values in(8),g9 values in(9)g10 values in(0));
[0047] The above table creation statement includes the database operation main sentence of table structure definition, namely "CREATE TABLE titles(...)", and also includes the fragmentation clause part of fragmentation rule definition, namely "distributed by list(id)(...)". Since the script length of the latter fragmentation clause is much longer than the script length of the former database operation main sentence, the two are listed together, which increases the difficulty of reading and is inconvenient to check the database statement.
[0048] At the same time, multiple tables often need to maintain consistency in sharding rules. However, since the sharding clause includes too much detailed information about the sharding rules, the existing manual inspection of the consistency of sharding rules is prone to errors. For example, the following are the sharding rules of three tables, which need to be kept consistent. The following are the specific definition statements:
[0049] CREATE TABLE title(id int key,year_col INT,serail_no char(100),namevarchar(200),order int,.....) distributed by list(id)(g1 values in(1),g2values in(2),g3 values in(3),g4 values in(4),g5 values in(5),g6values in(6),g7 values in(7),g8 values in(8),g9 values in(9),g10 values in(0));
[0050] CREATE TABLE title_flow(flow_id int key,year_col INT,serail_no char(100),name varchar(200),order int,...) distributed by list(id)(g1 values in(1),g2 values in(2),g3 values in(3),g4 values in(4),g5 values in(5),g6 valuesin(6),g7 values in(7),g8 values in(8),g9values in(9),g10 values in(0));
[0051] CREATE TABLE title_history(hist_id int key,year_col INT,serail_nochar(100),name varchar(200),order int,...) distributed by list(id)(g1 values in(1),g2 values in(2),g3 values in(3),g4 values in(4),g5 values in(5),g6values in(6),g7 values in(7),g8 values in(8),g9values in(9),g10 values in(0));
[0052] The sharding rules of the sharding clauses in the above three table creation statements contain a lot of detailed information, so it is necessary to check whether each detail is consistent, which is very difficult to check manually.
[0053] At the same time, the existing database statements including sharding rules are inconvenient to maintain. When the sharding rules of a distributed database table need to be modified, the database statements in the prior art need to present the table structure definition and sharding rule details, and the workload of editing and maintenance is large. For example, continue to use the above example as an example, assuming that the sharding rules in the above three table creation statements need to be modified to other sharding rules, then each database statement that modifies the sharding rules must expand the details of the new sharding rules, as follows:
[0054] ALTER TABLE title(id int key,year_col INT,serail_no char(100),namevarchar(200),order int,.....) distributed by range(year_col)(g1 VALUES LESSTHAN(1991),g2 VALUES LESS THAN(1992),g3 VALUES LESS THAN(1993),g4VALUES LESSTHAN(1994),g5 VALUES LESS THAN(1995),g6 VALUES LESS THAN(1996),g7 VALUES LESSTHAN(1997),g8 VALUES LESS THAN(1998),...g34VALUES LESS THAN(2023),g35 VALUES LESS THAN MAXVALUE);
[0055] ALTER TABLE title_flow(flow_id int key,year_flow INT,serail_no char(100),name varchar(200),order int,.....)distributed by range(year_col)(g1VALUES LESS THAN(1991),g2 VALUES LESS THAN(1992),g3VALUES LESS THAN(1993),g4VALUES LESS THAN(1994),g5 VALUES LESS THAN(1995),g6 VALUES LESS THAN(1996),g7VALUES LESS THAN(1997),g8 VALUES LESS THAN(1998),...g34 VALUES LESS THAN(2023),g35 VALUES LESS THAN MAXVALUE);
[0056] ALTER TABLE title_history(hist_id int key,year_hist INT,serail_nochar(100),name varchar(200),order int,.....)distributed by range(year_col)(g1VALUES LESS THAN(1991),g2 VALUES LESS THAN(1992),g3VALUES LESS THAN(1993),g4VALUES LESS THAN(1994),g5 VALUES LESS THAN(1995),g6 VALUES LESS THAN(1996),g7VALUES LESS THAN(1997),g8 VALUES LESS THAN(1998),...g34 VALUES LESS THAN(2023),g35 VALUES LESS THAN MAXVALUE);
[0057] It can be seen that in the current distributed database, the database statements that include sharding rules have poor readability because the sharding clause used to describe the sharding rules is too long and written together with the table structure. At the same time, for scenarios where multiple tables need to maintain uniform sharding rules, it is easy to make mistakes when manually checking the consistency of the sharding rules of each table because there is too much detailed information in the sharding rules. When modifying the sharding rules of a table, it is necessary to present the table structure definition and the sharding rule details, which requires a lot of editing and maintenance work and is inconvenient to maintain.
[0058] In an optional embodiment of the present invention, the database operation main clause may include main clause keywords, main clause content and main clause conjunctions; the sharder call clause may include a target sharder name and a target sharder parameter; wherein the target sharder parameter is a field value of the database operation main clause; the sharder call clause may also include a sharder association processing clause, wherein: the sharder association processing clause may include a create sharder clause or a modify sharder clause; the sharder association processing clause may include a sharder association processing keyword, a target sharder name and sharding rule content.
[0059] Among them, the main clause keywords can be keywords in the database operation main clause, for example, can include but not limited to keyword types such as "CREATE TABLE" (create table) and "ALTER TABLE" (modify table), as long as they can be used for database table operations, the embodiment of the present invention does not limit the keyword type of the main clause keywords. The main clause conjunction can be a conjunction used to connect the database operation main clause and the fragmenter call clause, which is also a kind of keyword. The target fragmenter parameter can be a parameter that needs to be passed to the target fragmenter.
[0060] Among them, the fragmentor association processing clause may be a clause for processing the target fragmentor before calling the target fragmentor. Exemplarily, the fragmentor association processing clause may be a clause for creating a target fragmentor or modifying a target fragmentor, etc. The fragmentor association processing keyword may be a keyword in the fragmentor association processing clause, for example, it may include but not limited to keywords such as "CREATE DISTRIBUTOR" (create fragmentor), "ALTER DISTRIBUTOR" (modify fragmentor), and "DISTRIBUTED BY" for configuring specific fragmentation rules. The target fragmentor name may be the name of the fragmentor processed by the fragmentor association processing clause. The fragmentation rule content may be the specific fragmentation rule included in the target fragmentor.
[0061] To solve the above technical problems, an embodiment of the present invention improves the sharding clause in the database statement and proposes a new method for defining sharding rules, that is, independently maintaining the sharding rules as a new database object, which is called the database sharder (DISTRIBUTOR). An object syntax of the sharder is provided to manage various sharding rules through an abstract sharder.
[0062] In a specific example, refer to the following database statement:
[0063] CREATE DIRSTRIBUTOR each_id_one_shard(int byid)
[0064] distributed by list(byid)(g1 values in(1),g2 values in(2),g3 valuesin(3),g4 values in(4),g5 values in(5),g6 values in(6),g7 values in(7),g8values in(8),g9 values in(9),g10 values in(0));
[0065] CREATE TABLE titles(id int key,serail_no char(100),year_col INT,namevarchar(200),order int,...) distributed by each_id_one_shard(id);
[0066] In the above database statement, the first part is the sharder association processing clause of the sharder call clause, where "CREATE DIRSTRIBUTOR" is the sharder association processing keyword of the sharder association processing clause. The sharder association processing clause is specifically a create sharder clause, that is, the statement defines the rules of the target sharder, and names the target sharder as "each_id_one_shard()", and specifies the field type and field name (intbyid) of the target sharder parameter. "Distributed by list(...)" is the specific sharding rule content of the target sharder. The second part is the database operation main sentence, that is, the table creation statement. In this table creation statement, the main clause keywords are: "CREATE TABLE", the main clause content is: "titles(id int key,serail_no char(100),year_col INT,name varchar(200),order int,.....)", the main clause conjunction is the second "distributed by", and accordingly, the target shard name and target shard parameter in the shard call clause are: "each_id_one_shard(id)", where "id" is the target shard parameter.
[0067] It can be seen that since the shard is defined, the database statement in the embodiment of the present invention only needs to specify the name of the shard separately in the clause, and pass the id field in the database main clause as a parameter to the target shard: distributed by each_id_one_shard(id).
[0068] The database statement to be processed is composed of the database operation main clause and the sharder call clause, so the sharding rules of the table in the distributed database and the field type definition of the table are very clear.
[0069] If multiple tables use the same sharding rule, you only need to specify the same sharder name. Refer to the following three examples of table creation statements:
[0070] CREATE TABLE title(id int key,year_col INT,serail_no char(100),namevarchar(200),order int,...) distributed by each_id_one_shard(id);
[0071] CREATE TABLE title_flow(flow_id int key,year_col INT,serail_no char(100),name varchar(200),order int,...) distributed by each_id_one_shard(flow_id);
[0072] CREATE TABLE title_hist(hist_id int key,year_col INT,serail_no char(100),name varchar(200),order int,...) distributed by each_id_one_shard(hist_id);
[0073] As described in the above example, as long as you check whether the sharder names called in the above three table creation statements are the same, you can draw a conclusion whether the sharding rules of the three tables are the same. The process of checking the consistency of sharding rules is very intuitive and easy.
[0074] In addition, if you want to change the sharding rules of the above table to other sharding rules, you only need to define a new sharder and change the sharder name of the table. The script becomes very concise and easy to maintain.
[0075] The new script is as follows:
[0076] CREATE DIRSTRIBUTOR each_year_one_shard(int year)
[0077] DISTRIBUTED BY RANGE(year)(g1 VALUES LESS THAN(1991),g2 VALUES LESSTHAN(1992),g3 VALUES LESS THAN(1993),g4 VALUES LESS THAN(1994),g5VALUES LESSTHAN(1995),g6 VALUES LESS THAN(1996),g7 VALUES LESS THAN(1997),g8 VALUES LESSTHAN(1998),...g34 VALUES LESS THAN(2023),g35VALUES LESS THAN MAXVALUE);
[0078] ALTER TABLE titledistributed by each_year_one_shard(year_col);
[0079] ALTER TABLE title_flow distributed by each_year_one_shard(year_flow);
[0080] ALTER TABLE title_hist distributed by each_year_one_shard(year_hist);
[0081] In the above database statement, a new target shard "each_year_one_shard()" is created through the sharder association processing clause "CREATE DIRSTRIBUTOR each_year_one_shard(intyear)...". At the same time, the corresponding table is updated using the sharding rules defined by the new target shard "each_year_one_shard()" through the three database operation main clauses "ALTER TABLE..." and the corresponding sharder call clauses.
[0082] In summary, in a distributed database, a sharder can be created as a new database object. Optionally, a sharder can be created by using the sharder-associated processing keyword "CREATE DISTRIBUTOR". Creating a sharder includes the name of the sharder, the list of fields passed to the distributor, the type and name of each field, and the sharding rules.
[0083] Optionally, the sharder association processing clause may include clause types such as create sharder clause, modify sharder clause, delete sharder clause, and display sharder creation statement. When the sharder association processing clause is a clause type such as delete sharder clause or display sharder creation statement, it can be used as an independent database statement, that is, it does not form a database operation statement in conjunction with the database operation main clause, and independently performs data sharding association processing operations on the distributed database.
[0084] The types of fragmentor association processing clauses are different, and their grammatical structures may also be different. For example, taking the creation of fragmentor clause as an example, the structure of the creation of fragmentor clause may include the following contents:
[0085] CREATE DISTRIBUTOR distributor_name(type_column_list)
[0086] DISTRIBUTED BY distribute_rule_function(column_list)(distribute_rule_body);
[0087] type_column_list:=column_type column_name[,type_column_list];
[0088] column_list:=column_name[,column_list];
[0089] distribute_rule_function:=HASH|LIST|RANGE|DUPLICATE;
[0090] column_type:=int|char|varchar|float|numeric|blob|text|....;
[0091] Among them: CREATE DISTRIBUTOR and DISTRIBUTED BY are keywords for creating a sharding clause; distributor_name is the name of the sharding; type_column_list is a field list with parameter types, which can contain multiple fields; distribute_rule_function is the rule function of sharding, which can be HASH hash sharding, LIST list sharding, RANGE range sharding, DUPLICATE replication table, etc.; distribute_rule_body describes the mapping relationship between the field list and the sharding. column_type column_name represents the field name in the field list with parameter types, and [, type_column_list] represents that multiple different field types with parameter types can be set. column_list represents the content of the field list without type. column_name represents the field name in the field list without type. [, column_list] represents that multiple different field types without parameter types can be set. column_type represents what specific types the field type includes.
[0092] For the modify sharder clause, the clause's leading structure can be: ALTER DISTRIBUTORdistributor_name, which means it is used to modify a sharder. The subsequent structure of the modify sharder clause is the same as the corresponding part of the create sharder clause, that is:
[0093] ALTER DISTRIBUTOR distributor_name(type_column_list)
[0094] DISTRIBUTED BY distribute_rule_function(column_list)(distribute_rule_body);
[0095] type_column_list:=column_type column_name[,type_column_list];
[0096] column_list:=column_name[,column_list];
[0097] distribute_rule_function:=HASH|LIST|RANGE|DUPLICATE;
[0098] column_type:=int|char|varchar|float|numeric|blob|text|....;
[0099] For the delete fragmentor clause, the clause structure can be: DROP DISTIRBUTOR distributor_name, which means it is used to delete a fragmentor.
[0100] For a statement for creating a display shard, the clause structure may be: SHOW CREATE DISTRIBUTORdistributor_name, indicating a statement for creating a display shard.
[0101] In an optional embodiment of the present invention, the slicer call clause is also used to perform associated operations on the target slicer, and the method may further include: performing grammatical parsing on the slicer call clause according to the slicer grammar rule; and performing associated operations on the target slicer according to the parsing result of the slicer call clause.
[0102] It is understandable that when it comes to table sharding operations, the current database statement to be processed usually needs to include both the database operation main clause and the sharder call clause. However, in some cases, if only the sharding rules need to be processed, such as the creation statement of deleting a sharder or displaying a sharder, the current database statement to be processed may only include the sharder call clause for processing the sharder. In this scenario, the sharder call clause does not need to call the target sharder, and can directly perform the corresponding operation on the sharder.
[0103] Correspondingly, if the current database statement to be processed only includes a sharder call clause, such as a clause to delete a sharder or a clause to display a sharder creation statement, the sharder processing module can perform grammatical analysis on the sharder call clause according to the sharder grammar rules, and can directly perform associated operations such as deleting the sharder or displaying the sharder creation statement on the target sharder based on the parsed results of the sharder call clause.
[0104] The embodiment of the present invention obtains a sharder call clause through a sharder processing module, determines the target sharder called by the database operation main clause through the sharder call clause, and then performs grammatical analysis on the sharder call clause according to the sharder grammar rules to obtain a target database statement. After obtaining the target database statement, the target database statement can be used to operate the target distributed database to implement data sharding associated processing operations. The above technical solution can solve the problems of poor readability and maintainability of database statements in existing distributed database data sharding methods, and can improve the readability of data sharding statements in distributed databases, thereby improving the convenience and maintainability of data sharding processing in distributed databases.
[0105] Embodiment 2
[0106] Figure 2 is a flow chart of a distributed database data sharding method provided by the second embodiment of the present invention. This embodiment is specific based on the above embodiment. In this embodiment, a specific implementation method of the data sharding processing flow of the sharder processing module persisting in the internal scene of the target distributed database is given. Figure 2 As shown, the method of this embodiment may include:
[0107] S210, obtaining a sharder calling clause; wherein the sharder calling clause is used by the database operation main clause to call the target sharder to perform sharding processing.
[0108] In an optional embodiment of the present invention, if the sharder processing module is persisted inside the target distributed database, the current database statement to be processed is the original database statement.
[0109] The original database statement may be a database statement directly constructed through a database operation main clause and a sharder call clause.
[0110] S220, obtaining a slicer parser call request; wherein the slicer parser call request includes a name of a target slicer and a target slicer parameter.
[0111] S230: In response to the slicer parser call request, perform syntax parsing on the target slicer according to the slicer syntax rule, and generate a slice rule statement for the target slicer according to the syntax parsing result and the target slicer parameter.
[0112] S240. Generate execution plan data of the target sharder according to the sharding rule statement as a first target database statement.
[0113] The first target database statement may be a database statement obtained after a sharder processing module built into the target distributed database performs syntax parsing on a sharder call clause in a database statement currently to be processed.
[0114] Figure 3 1 is a flow chart of a data sharding process based on a sharding processing module built into a target distributed database provided by the second embodiment of the present invention. Figure 3 As shown, the sharding processing module can be integrated into the SQL (Structured Query Language) parser inside the target distributed database. Optionally, the sharding processing module integrated inside the target distributed database can include a parser module, a grammar rule module, a metadata persistence module, and an expansion module. Accordingly, when the sharding processing module built into the target distributed database is used for data sharding processing, the following process can be included:
[0115] A DDL (Data Definition Language) statement including a fragmenter call clause is sent to a target distributed database. The target distributed database calls an SQL parser to parse the DDL statement. For example, when it is determined that the DDL statement includes a fragmenter associated processing clause of "CREATE DISTRIBUTOR(...)", a fragmenter processing module may be called to parse the fragmenter associated processing clause.
[0116] Optional, such as Figure 3 As shown, the sharder processing module built into the target distributed database can be configured with grammatical rules for parsing the sharder in the sharder associated processing clause. The grammatical rules define the grammatical structures of different types of sharder associated processing clauses, for example, including but not limited to: CREATE DISTRIBUTOR (create sharder clause), DROP DISTRIBUTOR (delete sharder clause) or ALTER DISTRIBUTOR (modify sharder clause) and other grammatical structures related to sharders.
[0117] The shard processing module built into the target distributed database can also be configured with a parser. When the SQL parser of the target distributed database encounters statements such as CREATE DISTRIBUTOR, DROP DISTRIBUTOR, or ALTERDISTRIBUTOR, a shard parser call request can be initiated to the shard processing module to call the parser in the shard processing module, parse the shard call clause including the above shard associated processing clause according to the grammatical rules stored and configured in the shard processing module, verify the legality of the statement, generate a corresponding execution plan, and call the metadata persistence module for processing.
[0118] The metadata persistence module in the sharder processing module can persist the sharder object in the distributed database. When a new sharder is created, the module will persist the sharder object in the database, and other database users can use the sharder. Even if the device is restarted, the data of the sharder will not be lost. The metadata persistence module can save the execution plan inside the sharder, modify the execution plan inside the sharder, or delete the operation of the internal object of the sharder according to the instructions (CREATE, ALTER, or DROP, etc.) sent by the parser.
[0119] The sharding processing module built into the target distributed database can also be configured with an expansion module. When the SQL parser encounters data addition, deletion, modification, and query, by parsing the "DISTRIBUTED BY" part of the table creation statement in the table, the name of the target sharding called by the table can be determined, that is, (distributor_name). Then, based on the target sharding name and the target sharding parameter, a sharding parser call request is generated and sent to the sharding processing module. The sharding processing module responds to the sharding parser call request, calls the expansion module to determine the target sharding name and the target sharding, so as to expand the sharding rules of the target sharding, and generates the final sharding rule statement based on the target sharding parameter and the expanded sharding rule. Figure 3In the example shown, the sharder processing module parses the sharder call clause of "CREATE DISTRIBUTOR" and obtains the sharding rule statement of "distributed by list(id)(g1 values in(1),g2 values in(2),g3 values in(3),g4 values in(4),g5 values in(5),g6 values in(6),g7 valuesin(7),g8 values in(8),g9values in(9)g10 values in(0))". Furthermore, the sharder processing module returns the execution plan data corresponding to the sharding rule statement as the first target database statement to the SQL parser. The SQL parser merges the returned execution plan into the execution plan tree of addition, deletion, modification and query, and hands it over to the SQL executor for further execution.
[0120] The above technical solution can enrich the sharding processing function of the target distributed database by embedding the sharding processing module in the target distributed database, solves the problems of inconvenient reading, checking and maintenance of scripts caused by the excessive length of the sharding rule clauses in the related syntax of the distributed database, improves the readability of database statements, facilitates application developers based on distributed databases to quickly check whether multiple tables are sharded based on the same sharding rules, and facilitates the operation and maintenance personnel of the distributed database to modify the sharding rules of the table.
[0121] Embodiment 3
[0122] Figure 4 is a flow chart of a distributed database data sharding method provided by the third embodiment of the present invention. This embodiment is specific based on the above embodiment. In this embodiment, a specific implementation method of the data sharding processing flow of the sharder processing module persisting in the internal scene of the target distributed database is given. Figure 4 As shown, the method of this embodiment may include:
[0123] S310, obtaining a sharder call clause; wherein the sharder call clause is used by the database operation main clause to call the target sharder to perform sharding processing.
[0124] In an optional embodiment of the present invention, if the sharder processing module runs independently of the target distributed database, the current database statement to be processed is a macro-defined database statement.
[0125] The macro-defined database statement may be a database statement created in the form of a macro statement.
[0126] S320: Determine the name of the target sharder and the target sharder parameters according to the sharder call clause.
[0127] S330: Perform syntax analysis on the target slicer according to the slicer syntax rule, and generate a slice rule statement for the target slicer according to the syntax analysis result and the target slicer parameter.
[0128] S340. Update the sharder call clause according to the sharding rule statement to obtain a second target database statement.
[0129] The second target database statement is a database statement that is converted by the sharder processing module to the sharder call clause and can be directly recognized and executed by the target distributed database.
[0130] It is understandable that in the second embodiment, the sharding processing module is implemented inside the distributed database, so the service-side processing logic of the distributed database needs to be modified. As a simplified implementation method, the embodiment of the present invention does not need to modify the database, but provides an offline sharding processing module as an independent conversion tool to convert the sharding call clause into an offline form. Accordingly, the sharding call clause can be written in the form of a macro statement to obtain a statement that supports the sharding, and then the macro definition database statement is expanded through the offline sharding processing module to generate a SQL statement that can be supported by the expanded distributed database. The details are as follows:
[0131] Figure 5 1 is a flow chart of a data sharding process based on a sharding processing module independent of a target distributed database provided by the third embodiment of the present invention. Figure 5 As shown, the sharding processing module can also be independent of the target distributed database, as an offline model processing module to macro-define database statements separately. Among them, the macro-defined database statement is the database statement marked with "@". Optionally, the sharding processing module independent of the target distributed database may include a reading module, a grammar rule module, an object storage module and an output module. Accordingly, when the sharding processing module in offline mode is used for data sharding processing, the following process may be included:
[0132] The DDL statement including the database operation main clause and the fragmenter call clause is a macro-defined database statement, which is sent to the fragmenter processing module in the offline mode. The fragmenter processing module parses and processes the macro-defined database statement.
[0133] Optional, such as Figure 5As shown, the sharder processing module in the offline mode can also be configured with grammatical rules for parsing the sharders in the sharder associated processing clause. The grammatical rules define the grammatical structures of different types of sharder associated processing clauses, for example, may include but are not limited to: CREATE DISTRIBUTOR (create sharder clause), DROPDISTRIBUTOR (delete sharder clause) or ALTER DISTRIBUTOR (modify sharder clause) and other grammatical structures related to sharders. It should be noted that if the object storage module is a storage module that uses a cache method to store data, the sharder processing module in the offline mode is executed once, so there is no need to support the ALTER DISTRIBUTOR and DROPDISTRIBUTOR syntax. If the object storage module is a storage module that uses a persistent method to store data, the sharder processing module in the offline mode can also have a persistent storage function, and can support the ALTER DISTRIBUTOR and DROPDISTRIBUTOR syntax.
[0134] The offline mode sharding processing module can also be configured with a reading module for reading the macro definition database statements of the DDL script that supports the sharding. Exemplarily, when the offline mode sharding processing module determines that the sharding call clause is CREATE DISTRIBUTOR, it parses the grammar according to the grammar rules, verifies the legality of the statement, and stores the text of the sharding object or the parsed internal structure in the object storage module in a cache or persistent storage manner. Specifically, the reading module can determine the name of the target sharding and the target sharding parameters according to the sharding call clause, thereby performing grammatical parsing on the target sharding according to the sharding grammar rules, and generating the sharding rule statements of the target sharding according to the grammatical parsing results and the target sharding parameters.
[0135] The offline mode sharding processing module can also be configured with an object storage module, which can store data in a cache or persistent storage manner. Specifically, the object storage module can store the sharding call clauses parsed in the reading module, such as the text body of CREATE DISTRIBUTOR or the parsed internal structure in memory, or write them to a temporary file on disk.
[0136] The offline mode sharding processing module can also be configured with an output module, which is used to output the sharding rule statement of the target sharding obtained by parsing to a new script file, that is, to update the original sharding call clause according to the sharding rule statement of the target sharding to obtain the second target database statement. Exemplarily, when the output module encounters "DISTRIBUTED BYdistribute_name", it calls the object storage module to replace the name of the target sharding distribute_name with the expanded sharding rule statement, such as Figure 5 Replace "distributed by each_id_one_shard(id)" with "distributed by list(id)(...)" to obtain the second target database statement. After obtaining the second target database statement, the association operation of the data shard can be directly performed on the target distributed database according to the second target database statement. The target distributed database can adopt an internal statement parsing process, that is, the second target database statement is parsed into an execution tree through the SQL parser, and the execution tree is sent to the SQL executor for internal execution.
[0137] The above technical solution uses the sharder processing module as an independent module in offline mode, without modifying the functional logic of the target distributed database, making it easier to implement. It can also solve the problems of inconvenient reading, checking and maintenance of scripts caused by too long sharding rule clauses in the distributed database-related syntax. It improves the readability of database statements, facilitates application developers based on distributed databases to quickly check whether multiple tables are sharded based on the same sharding rules, and facilitates the operation and maintenance personnel of distributed databases to modify the sharding rules of tables.
[0138] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information are in compliance with the relevant laws and regulations and do not violate public order and good morals.
[0139] It should be noted that any arrangement and combination of the technical features in the above embodiments also falls within the protection scope of the present invention.
[0140] Embodiment 4
[0141] Figure 6 Schematic diagram of a distributed database data sharding device provided by Embodiment 4 of the present invention. Figure 6 As shown, the device includes: a sharder call clause acquisition module 410 and a target database statement parsing module 420, wherein:
[0142] A sharder calling clause acquisition module 410 is used to acquire a sharder calling clause corresponding to a database operation main clause; wherein the sharder calling clause is used by the database operation main clause to call a target sharder;
[0143] A target database statement parsing module 420 is used to perform syntax parsing on the sharder call clause according to the sharder syntax rules to obtain a target database statement;
[0144] The target database statement is used to be executed in the target distributed database to implement data shard association processing operations.
[0145] The embodiment of the present invention obtains a sharder call clause through a sharder processing module, determines the target sharder called by the database operation main clause through the sharder call clause, and then performs grammatical analysis on the sharder call clause according to the sharder grammar rules to obtain a target database statement. After obtaining the target database statement, the target database statement can be used to operate the target distributed database to implement data sharding associated processing operations. The above technical solution can solve the problems of poor readability and maintainability of database statements in existing distributed database data sharding methods, and can improve the readability of data sharding statements in distributed databases, thereby improving the convenience and maintainability of data sharding processing in distributed databases.
[0146] Optionally, the slicer call clause is also used to perform associated operations on a target slicer, and the above-mentioned device also includes a target slicer operation module, which is used to: perform grammatical parsing on the slicer call clause according to the slicer grammar rules; and perform associated operations on the target slicer according to the parsing result of the slicer call clause.
[0147] Optionally, the database operation main clause includes main clause keywords, main clause content and main clause conjunctions; the sharder call clause includes the target sharder name and target sharder parameters; wherein the target sharder parameters are field values of the database operation main clause; the sharder call clause also includes a sharder association processing clause, wherein: the sharder association processing clause includes a create sharder clause or a modify sharder clause; the sharder association processing clause includes a sharder association processing keyword, a target sharder name and sharding rule content.
[0148] Optionally, the sharder processing module is persisted inside the target distributed database, or the sharder processing module runs independently of the target distributed database; wherein, if the sharder processing module is persisted inside the target distributed database, the sharder call clause is an original database statement; if the sharder processing module runs independently of the target distributed database, the sharder call clause is a macro-defined database statement.
[0149] Optionally, if the sharder processing module is persisted inside the target distributed database, the target database statement parsing module 420 is also used to: obtain a sharder parser call request; wherein the sharder parser call request includes the name of the target sharder and the target sharder parameter; in response to the sharder parser call request, perform syntax parsing on the target sharder according to the sharder syntax rules, and generate a sharding rule statement for the target sharder according to the syntax parsing result and the target sharder parameter; and generate execution plan data for the target sharder according to the sharding rule statement as the first target database statement.
[0150] Optionally, if the sharder processing module runs independently of the target distributed database, the target database statement parsing module 420 is also used to: determine the name of the target sharder and the target sharder parameters according to the sharder call clause; perform syntax parsing on the target sharder according to the sharder syntax rules, and generate a sharding rule statement for the target sharder according to the syntax parsing result and the target sharder parameters; update the sharder call clause according to the sharding rule statement to obtain a second target database statement.
[0151] The above-mentioned distributed database data sharding device can execute the distributed database data sharding method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not fully described in this embodiment, please refer to the distributed database data sharding method provided by any embodiment of the present invention.
[0152] Since the distributed database data sharding device introduced above is a device that can execute the distributed database data sharding method in the embodiment of the present invention, based on the distributed database data sharding method introduced in the embodiment of the present invention, the technical personnel in this field can understand the specific implementation of the distributed database data sharding device in this embodiment and its various variations, so how the distributed database data sharding device implements the distributed database data sharding method in the embodiment of the present invention is not introduced in detail here. As long as the technical personnel in this field implement the device adopted by the distributed database data sharding method in the embodiment of the present invention, it belongs to the scope of protection of this application.
[0153] Embodiment 5
[0154] Figure 7A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0155] like Figure 7 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0156] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0157] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a distributed database data sharding method.
[0158] Optionally, the distributed database data sharding method is applied to a sharder processing module, comprising:
[0159] Obtain a sharder call clause; wherein the sharder call clause is used by the database operation main clause to call the target sharder to perform sharding processing;
[0160] Parsing the sharder call clause according to the sharder syntax rule to obtain a target database statement;
[0161] The target database statement is used to be executed in the target distributed database to implement data shard association processing operations.
[0162] In some embodiments, the distributed database data sharding method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the distributed database data sharding method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the distributed database data sharding method in any other appropriate manner (e.g., by means of firmware).
[0163] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0164] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0165] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0166] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0167] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0168] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0169] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0170] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A distributed database data sharding method, characterized in that: Applied to a slicer processing module, the method comprises: Obtain a sharder call clause; wherein the sharder call clause is used by the database operation main clause to call the target sharder to perform sharding processing; Parsing the sharder call clause according to the sharder syntax rule to obtain a target database statement; The target database statement is used to be executed in the target distributed database to implement data shard association processing operations.
2. The method according to claim 1, characterized in that: The sharder call clause is further used to perform an associated operation on the target sharder, and the method further includes: Performing grammatical analysis on the slicer call clause according to the slicer grammar rules; An association operation is performed on the target sharder according to the parsing result of the sharder call clause.
3. The method according to claim 1, characterized in that: The database operation main sentence includes main sentence keywords, main sentence content and main sentence conjunctions; The sharder call clause includes the target sharder name and the target sharder parameter; wherein the target sharder parameter is the field value of the database operation main clause; The sharder call clause also includes a sharder association processing clause, wherein: the sharder association processing clause includes a create sharder clause or a modify sharder clause; the sharder association processing clause includes a sharder association processing keyword, a target sharder name, and sharding rule content.
4. The method according to any one of claims 1 to 3, characterized in that: The sharding processing module is persisted inside the target distributed database, or The sharder processing module operates independently of the target distributed database; Wherein, if the sharder processing module is persisted inside the target distributed database, the sharder call clause is the original database statement; If the sharder processing module runs independently of the target distributed database, the sharder call clause is a macro-defined database statement.
5. The method according to claim 4, characterized in that If the sharder processing module is persisted inside the target distributed database, the sharder call clause is parsed according to the sharder grammar rules to obtain the target database statement, including: Obtaining a slicer parser call request; wherein the slicer parser call request includes the name of the target slicer and the target slicer parameter; In response to the slicer parser call request, grammar parse the target slicer according to the slicer grammar rule, and generate a slice rule statement of the target slicer according to the grammar parsing result and the target slicer parameter; Generate execution plan data of the target sharder according to the sharding rule statement as a first target database statement.
6. The method according to claim 4, characterized in that If the sharder processing module runs independently of the target distributed database, the sharder call clause is parsed according to the sharder grammar rules to obtain the target database statement, including: Determine the name of the target sharder and the target sharder parameters according to the sharder call clause; Parsing the target slicer according to the slicer grammar rule, and generating a slice rule statement for the target slicer according to the grammar parsing result and the target slicer parameter; The sharder call clause is updated according to the sharding rule statement to obtain a second target database statement.
7. A distributed database data sharding device, characterized in that: Configured in the slicer processing module, the device includes: A sharder call clause acquisition module is used to acquire a sharder call clause corresponding to a database operation main clause; wherein the sharder call clause is used by the database operation main clause to call a target sharder; A target database statement parsing module, used for parsing the sharder call clause according to the sharder grammar rules to obtain a target database statement; The target database statement is used to be executed in the target distributed database to implement data shard association processing operations.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the distributed database data sharding method described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the distributed database data sharding method described in any one of claims 1-6 when executed.
10. A computer program product comprising a computer program / instructions, wherein: When the computer program / instructions are executed by a processor, the distributed database data sharding method described in any one of claims 1-6 is implemented.