CN117743422A - Data processing method and device, storage medium and electronic equipment - Google Patents

Data processing method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN117743422A
CN117743422A CN202211114691.9A CN202211114691A CN117743422A CN 117743422 A CN117743422 A CN 117743422A CN 202211114691 A CN202211114691 A CN 202211114691A CN 117743422 A CN117743422 A CN 117743422A
Authority
CN
China
Prior art keywords
sub
parameter
information
database access
access layer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211114691.9A
Other languages
Chinese (zh)
Inventor
贺立强
齐俊
刘惠敏
景雷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202211114691.9A priority Critical patent/CN117743422A/en
Publication of CN117743422A publication Critical patent/CN117743422A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a data processing method and device, a storage medium and electronic equipment, which intercept a called database access layer method, and acquire a sub-table parameter, a sub-table attribute value and a sub-table additional information value from calling information of the database access layer method based on metadata analyzed from parameter annotation information of the database access layer method; in the sub-table strategy, index calculation is carried out on the sub-table attribute value based on the sub-table attribute value, the sub-table additional information value and the database access layer method information; reconstructing the sub-table parameters by using the calculated sub-table index, and storing the sub-table index into a sub-table context; based on the sub-table index in the sub-table context, replacing the logical table name of the original SQL statement with the actual table name to generate a final SQL statement, and aggregating the library access results of the final SQL statement to obtain the final calling result of the database access layer method. The invention can realize the sub-table transformation without changing the system, and improves the sub-table efficiency of the data.

Description

Data processing method and device, storage medium and electronic equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data processing method and apparatus, a storage medium, and an electronic device.
Background
In the running process of the system, the service data volume is greatly increased along with the development of the service, and the data volume can reach tens of millions or even hundreds of millions. If the system adopts single-table storage, tens of millions of data storage often affect the query performance of data, and then affect the usability and user experience of system services, in this case, the system generally adopts a database and table splitting mode to split data, and in particular, performs horizontal table splitting on the data.
When the data is horizontally sorted, specific names or types of sorted parameters are needed, and the interface specification of the system is required to be changed, otherwise, the sorted modification of the existing system cannot be supported, so that the sorted efficiency of the data is low.
Disclosure of Invention
In view of the above, embodiments of the present invention provide a data processing method and apparatus, a storage medium, and an electronic device, by which the present invention can perform sub-metering without performing sub-metering modification on a system, thereby improving sub-metering efficiency.
In order to achieve the above object, the embodiment of the present invention provides the following technical solutions:
a data processing method, comprising:
intercepting a currently called database access layer method through a preset first interceptor;
Analyzing the parameter annotation information of the database access layer method to obtain metadata of the database access layer method, wherein the metadata comprises a method entity mapping table, a method parameter name analyzer mapping table, a sub-table information mapping table and an additional information mapping table;
based on the metadata of the database access layer method, obtaining sub-table parameters, sub-table attribute values and sub-table additional information values from the calling information of the database access layer method;
acquiring a sub-table strategy based on a sub-table strategy name of the database access layer method, and in the sub-table strategy, carrying out index calculation on the sub-table attribute value based on the sub-table attribute value, the sub-table additional information value and the database access layer method information to obtain a sub-table index result of the sub-table attribute value;
reconstructing the sub-table parameters based on the sub-table index result to obtain each reconstructed sub-table parameter and a sub-table index of each reconstructed sub-table parameter, and storing the sub-table index of each reconstructed sub-table parameter to a preset sub-table context;
replacing a logical table name of the SQL sentence corresponding to each reconstruction sub-table parameter with an actual table name through a preset second interceptor based on each sub-table index in the sub-table context, so that each reconstruction sub-table parameter performs library access based on the actual table name of the SQL sentence, and a library access result of each reconstruction sub-table parameter is obtained;
And aggregating the database access results of each reconstructed sub-table parameter to obtain a final calling result of the database access layer method.
A data processing apparatus comprising:
the interception unit is used for intercepting a currently called database access layer method through a preset first interceptor;
the analyzing unit is used for analyzing the parameter annotation information of the database access layer method and obtaining metadata of the database access layer method, wherein the metadata comprises a method entity mapping table, a method parameter name analyzer mapping table, a sub-table information mapping table and an additional information mapping table;
the acquisition unit is used for acquiring sub-table parameters, sub-table attribute values and sub-table additional information values from the calling information of the database access layer method based on the metadata of the database access layer method;
the calculation unit is used for acquiring a sub-table strategy based on the sub-table strategy name of the database access layer method, and in the sub-table strategy, index calculation is carried out on the sub-table attribute value based on the sub-table attribute value, the sub-table additional information value and the database access layer method information to obtain a sub-table index result of the sub-table attribute value;
The reconstruction unit is used for reconstructing the sub-table parameters based on the sub-table index result to obtain each reconstructed sub-table parameter and the sub-table index of each reconstructed sub-table parameter, and storing the sub-table index of each reconstructed sub-table parameter to a preset sub-table context;
the replacing unit is used for replacing the logical table name of the SQL statement corresponding to each reconstruction sub-table parameter with an actual table name based on each sub-table index in the sub-table context through a preset second interceptor so that each reconstruction sub-table parameter accesses a library based on the actual table name of the SQL statement to obtain a library access result of each reconstruction sub-table parameter;
and the aggregation unit is used for aggregating the database access results of each reconstruction sub-table parameter to obtain the final calling result of the database access layer method.
A storage medium comprising stored instructions, wherein the instructions, when executed, control a device on which the storage medium resides to perform a data processing method as described above.
An electronic device comprising a memory, and one or more instructions, wherein the one or more instructions are stored in the memory and configured to perform a data processing method as described above by one or more processors.
Compared with the prior art, the invention has the following advantages:
in the data processing method, the device, the storage medium and the electronic equipment provided by the invention, a currently called database access layer method is intercepted by a first interceptor, parameter annotation information of the database access layer method is analyzed, metadata of the database access layer method is obtained, and sub-table parameters, sub-table attribute values and sub-table additional information values are obtained from calling information of the database access layer method based on the metadata of the database access layer method; obtaining a sub-table strategy based on a sub-table strategy name of a database access layer method, wherein in the sub-table strategy, index calculation is carried out on the sub-table attribute value based on the sub-table attribute value, the sub-table additional information value and the database access layer method information, so as to obtain a sub-table index result of the sub-table attribute value; reconstructing sub-table parameters based on sub-table index results and sub-table attribute values to obtain each reconstructed sub-table parameter and sub-table index of each reconstructed sub-table parameter, and storing the sub-table index of each reconstructed sub-table parameter into a sub-table context so that a second interceptor replaces a logical table name of an SQL sentence of each reconstructed sub-table parameter with an actual table name based on the sub-table context so that each reconstructed sub-table parameter accesses a library based on the actual table name of the SQL sentence to obtain an access library result of each reconstructed sub-table parameter; and aggregating all the database access results to obtain the final calling result of the database access layer method. The invention can realize the modification of the sub-table without changing the system, thereby improving the sub-table efficiency of the data.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for data processing according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for analyzing annotation information of a database access layer method to obtain metadata of the database access layer method according to an embodiment of the present invention;
FIG. 3 is a flowchart of a method for obtaining sub-table parameters, sub-table attribute values and sub-table additional information values according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of an implementation principle of a data processing method according to the present invention;
FIG. 5 is a block diagram of a data processing method according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a data processing apparatus according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In this application, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In the running process of the system, the service data volume is greatly increased along with the development of the service, and the data volume can reach tens of millions or even hundreds of millions. If the system adopts single-table storage, tens of millions of data storage often affect the query performance of data, and then affect the usability and user experience of system services, in this case, the system generally adopts a database and table splitting mode to split data, and in particular, performs horizontal table splitting on the data.
There are two current horizontal sub-metering modes, scheme one: calculating the sub-table index of the related data in the service layer by adopting a sub-table index placeholder scheme, and then performing sub-table index replacement by transmitting the sub-table index to the Mapper layer and the Mybatis at the bottom layer; scheme II: the method adopts a Mybatis-StatementHandler interceptor mode, carries out sub-table index calculation in the interceptor according to specific service data or non-service data (such as current month or year), and then carries out logical table name replacement.
When the system adopts the sub-table index placeholder scheme, the sub-table index is needed to be calculated in the business logic, the sub-table index parameter transmission is added in each layering method of the system, and the sub-table index placeholder is needed to be added in the mapper. For new services needing to be built or existing services needing to be expanded, related logic of sub-tables needs to be added into service logic, so that the code logic is unclear, expansibility is general, and research and development staff cannot concentrate on service logic development to influence development efficiency and code quality.
When the Mybatis-StatementHandler interceptor scheme is adopted, the scheme mainly intercepts the preparation method of the StatementHandler, calculates the sub-table index by analyzing the specific name or the specific type of sub-table parameter, and then replaces the logical table name of the SQL sentence, so that the sub-table reconstruction workload is larger for the existing system with non-uniform sub-table parameter, and the sub-table parameter needs to be unified; moreover, the target object of the scheme operation is SQL statement, for the operations of IN query, batch modification, batch insertion and the like, not only the logical table name of the SQL statement needs to be modified, but also the parameter placeholder of the SQL statement needs to be modified, especially the transformation of the parameter placeholder is performed, and the workload and the risk are not controllable, so that the scheme only supports single operation, does not support batch operation at present, and the efficiency of splitting the table is low.
The invention is operational with numerous general purpose or special purpose computing device environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet devices, multiprocessor devices, distributed computing environments that include any of the above devices or devices, and the like. The invention can be applied to a level sub-meter device constructed based on Mybatis. By using the method provided by the invention, the system can be divided into tables without modification, and the table dividing efficiency is improved.
Referring to fig. 1, a method flowchart of a data processing method according to an embodiment of the present invention is specifically described below:
s101, intercepting a currently called database access layer method through a preset first interceptor.
The first interceptor in the invention is an interceptor, the interceptor receives a data processing request sent by a data persistence layer, and a database access layer method can be determined through the data processing request.
S102, analyzing parameter annotation information of the database access layer method to obtain metadata of the database access layer method, wherein the metadata comprises a method entity mapping table, a method parameter name analyzer mapping table, a sub-table information mapping table and an additional information mapping table.
The annotation information of the database access layer method may be understood as sub-table related information of the database access layer method, including but not limited to sub-table parameter annotations and additional information annotations.
In the process of analyzing annotation information of the database access layer method, analysis is mainly performed in 4 aspects, namely: resolution about method entities, resolution about method parameter name resolvers, resolution about sub-table information, and resolution about additional information.
It should be noted that, the method entity mapping table in the metadata may also be referred to as a method name- > method entity mapping table; the method parameter name resolver mapping table may be referred to as a method name- > method parameter name resolver mapping table; the sub-table information mapping table may be referred to as a method name- > sub-table information mapping table; the additional information mapping table may be referred to as a method name- > additional information mapping table.
Referring to fig. 2, a flowchart of a method for analyzing parameter annotation information of a database access layer method to obtain metadata of the database access layer method according to an embodiment of the present invention is described below:
s201, a first interceptor acquires a first parameter in the parameter array attribute of the calling information, and acquires the bottom layer encapsulation object based on the first parameter.
It should be noted that the underlying encapsulation object is a mappdstatement object, that is, the mappdstatement object is acquired based on the first parameter.
S202, analyzing the identity attribute of the bottom packaging object to obtain the fully-defined class name and the method name.
Preferably, the identity attribute may be represented as an id attribute, and the id attribute of the mappdstatement object is parsed to obtain a fully defined class name and a method name.
S203, acquiring a byte code object corresponding to the full-limit class name, determining a method entity corresponding to the method name in the byte code object, and caching the determined method entity to obtain a method entity mapping table.
It should be noted that the bytecode object is a class object, that is, a class object corresponding to a fully defined class name is acquired.
S204, acquiring a method parameter name analyzer based on the bottom layer packaging object, and caching the method parameter name analyzer to obtain a mapping table of the method parameter name analyzer.
S205, sub-table parameter annotation information of the database access layer method is obtained from the parameter annotation information, sub-table parameters and sub-table attributes of the sub-table parameters of the database access layer method are analyzed based on the sub-table parameter annotation information, sub-table information is obtained, and the sub-table information is cached, so that a sub-table information mapping table is obtained.
S206, analyzing the sub-table additional parameters of the database access layer method from the parameter annotation information based on the sub-table additional parameter annotation information to obtain sub-table additional information, and caching the sub-table additional information to obtain an additional information mapping table.
According to the method and the device, the parameter annotation information of the called database access layer method is analyzed, metadata of the database access layer method can be obtained, and the metadata contains sub-table related information of the database access layer method, such as mapping relation of method names and method entity objects, mapping relation of method names and method parameter name resolvers and the like, so that multiple analyses can be avoided.
S103, based on metadata of the database access layer method, obtaining the sub-table parameters, the sub-table attribute values and the sub-table additional information values from calling information of the database access layer method.
Referring to fig. 3, a flowchart of a method for obtaining a sub-table parameter, a sub-table attribute value and a sub-table additional information value according to an embodiment of the present invention is specifically described below:
s301, a first interceptor acquires a second parameter in the parameter array attribute of the calling information, determines a parameter value of the database access layer method from the second parameter, and processes the parameter value by applying a method parameter name parser mapping table in metadata of the database access layer method to obtain a parameter array.
It should be noted that the call information is call information of a database access layer method.
S302, obtaining sub-table parameter subscripts of the database access layer method of sub-table information by using sub-table information mapping tables in metadata of the database access layer method.
S303, obtaining sub-table parameters based on the sub-table parameter subscript and the parameter array of the database access layer method.
S304, determining a sub-table scene of the sub-table parameters, and acquiring sub-table information corresponding to the sub-table scene, wherein the sub-table scene is one of an array, a list, a set and a single object.
It should be noted that, the List in the sub-table scenario in the present invention may be represented by List, and the Set may be represented by Set.
S305, executing a sub-table flow corresponding to the sub-table scene based on the sub-table information to obtain a sub-table attribute value.
S306, based on the parameter array and the additional information mapping table in the metadata of the database access layer method, obtaining the sub-table additional information value.
It should be noted that, the contents of the sub-table information corresponding to different sub-table scenes are different, and the sub-table flows of different sub-table scenes are also different, and when the sub-table scenes are an array, the sub-table information includes the information of sub-table parameter types, sub-table attribute types, whether the sub-table attribute exists, sub-table attribute names, etc.; when the sub-table scene is a List, the sub-table information comprises sub-table parameter general type, sub-table attribute type, whether the sub-table attribute exists, sub-table attribute name and the like; when the sub-table scene is a Set, the sub-table information comprises sub-table parameter generalized type, sub-table attribute type, whether the sub-table attribute exists, sub-table attribute name and the like; when the sub-table scene is a single object, the sub-table information comprises the sub-table parameter type, whether the sub-table attribute is an array, whether the sub-table attribute is a set, the sub-table attribute type, the sub-table attribute general type, whether the sub-table attribute exists and the like.
S104, obtaining a sub-table strategy based on the sub-table strategy name of the database access layer method, and in the sub-table strategy, carrying out index calculation on the sub-table attribute value based on the sub-table attribute value, the sub-table additional information value and the database access layer method information to obtain a sub-table index result of the sub-table attribute value.
It should be noted that, the process of obtaining the sub-table policy based on the sub-table policy name of the database access layer method includes: obtaining sub-table information of a database access layer method from a sub-table information mapping table; based on the sub-table policy name in the sub-table information, the sub-table policy is acquired from the sub-table policy manager.
Preferably, the sub-table attribute value has a plurality of values, and the sub-table index result includes List < single sub-table attribute value > and sub-table index.
Preferably, the sub-table index result satisfying the preset structure may specifically be: map < sub-table index, list < single sub-table attribute value > >, further, list < single sub-table attribute value > is a heap result.
S105, reconstructing the sub-table parameters based on the sub-table index result and the sub-table attribute value to obtain each reconstructed sub-table parameter and the sub-table index of each reconstructed sub-table parameter, and storing the sub-table index of each reconstructed sub-table parameter to a preset sub-table context.
It should be noted that, based on the sub-table index result and the sub-table attribute value, the sub-table parameters are reconstructed, and the specific process of obtaining each reconstructed sub-table parameter is as follows: determining whether the sub-table parameters support sub-tables based on the sub-table information; when the fact that the sub-table parameters support sub-tables is determined, splitting sub-table parameters by using a pile-up result in the sub-table index result to obtain each reconstruction sub-table parameter, and determining the sub-table index of each reconstruction sub-table parameter based on sub-table index information in the pile-up result.
Preferably, the sub-table parameters comprise a plurality of sub-table values, each reconstructed sub-table parameter obtained after reconstruction comprises at least one sub-table value, one reconstructed sub-table parameter corresponds to one sub-table index, and each sub-table value in the reconstructed sub-table parameter corresponds to the same sub-table index.
After the sub-table index of each reconstruction sub-table parameter is obtained, each sub-table index is saved into the sub-table context.
Further, when it is determined that the sub-table parameter does not support the sub-table, the exception information is thrown to indicate that the sub-table parameter does not support the sub-table.
S106, replacing the logical table name of the structured query language SQL sentence corresponding to each reconstruction sub-table parameter with an actual table name based on each sub-table index in the sub-table context through a preset second interceptor, so that each reconstruction sub-table parameter performs library access based on the actual table name of the SQL sentence, and a library access result of each reconstruction sub-table parameter is obtained.
The second interceptor in the invention is a StatementHandler interceptor; it should be noted that, each sub-table attribute value in the reconstructed sub-table parameter corresponds to the same structured query language SQL statement, and the SQL statement herein may also be referred to as a sub-table SQL statement; the StatementHandler interceptor replaces the logical table name of the SQL statement with the actual table name based on each sub-table index in the sub-table context, so that each reconstructed sub-table parameter uses the corresponding actual table name of the SQL statement to access the library, and a library access result is obtained.
S107, aggregating the database access results of each reconstructed sub-table parameter to obtain a final calling result of the database access layer method.
According to the method provided by the invention, a currently called database access layer method is intercepted by a first interceptor, parameter annotation information of the database access layer method is analyzed, metadata of the database access layer method is obtained, and sub-table parameters, sub-table attribute values and sub-table additional information values are obtained from calling information of the database access layer method based on the metadata of the database access layer method; obtaining a sub-table strategy based on a sub-table strategy name of a database access layer method, wherein in the sub-table strategy, index calculation is carried out on the sub-table attribute value based on the sub-table attribute value, the sub-table additional information value and the database access layer method information, so as to obtain a sub-table index result of the sub-table attribute value; reconstructing sub-table parameters based on sub-table index results and sub-table attribute values to obtain each reconstructed sub-table parameter and sub-table index of each reconstructed sub-table parameter, and storing the sub-table index of each reconstructed sub-table parameter into a sub-table context so that a second interceptor replaces a logical table name of an SQL sentence of each reconstructed sub-table parameter with an actual table name based on the sub-table context so that each reconstructed sub-table parameter accesses a library based on the actual table name of the SQL sentence to obtain an access library result of each reconstructed sub-table parameter; and aggregating all the database access results to obtain the final calling result of the database access layer method. The invention can realize the modification of the sub-table without changing the system, thereby improving the sub-table efficiency of the data.
Referring to fig. 4, an architecture diagram of an implementation principle of the method provided by the invention is based on Mybatis, and performs sub-table processing by adopting a mode of parameter dimension annotation + Executor interceptor + StatementHandler interceptor. The scheme not only decouples the sub-table logic and the business logic, the research personnel only need to pay attention to the business logic, but also can support the sub-table reconstruction rapidly for the existing system with non-uniform sub-table parameters, and can also support the batch operation of the array and the list, such as the operations of IN inquiry, batch insertion, batch update and the like.
The scheme provided by the invention is realized through the parameter dimension sub-table annotation, the Executor interceptor and the StatementHandler interceptor in fig. 4. The parameter dimension sub-table annotation acts on sub-table parameters of the Mapper method, and the sub-table index calculation is performed by the method based on which parameter or parameter attribute; the method comprises the steps that an Executor interceptor intercepts query and update methods of the Executor, and mainly comprises four core functions of sub-table parameter analysis, sub-table index calculation, sub-table parameter reconstruction, sub-table result aggregation and the like, wherein the sub-table parameter analysis mainly comprises the steps of analyzing sub-table parameters (namely parameters containing sub-table parameter annotation) of a Mapper method, obtaining sub-table attribute values participating in the sub-table index calculation, and simultaneously storing sub-table information to a metadata registry in the analysis process; the sub-table index calculation is mainly used for calculating the sub-table index corresponding to the sub-table attribute value based on the specific implementation of the externally provided sub-table strategy SPI; the sub-table parameter reconstruction is mainly based on sub-table index and sub-table attribute values to reconstruct sub-table parameters, particularly when the sub-table parameters are the group and set type parameters, the group and the set are required to be split and piled; the sub-table result aggregation is mainly to aggregate the visit library results after the sub-table parameter reconstruction; the StatementHandler interceptor intercepts the preparation method of the StatementHandler, and mainly comprises a table name replacement function, namely changing a logical table name into an actual table name according to a sub-table index calculated by the Executor interceptor.
According to the scheme, a mode of parameter dimension annotation, an Executor interceptor and a StatementHandler interceptor is adopted, based on the parameter dimension annotation, only sub-table parameter annotation is needed to be carried out on a Mapper layer, and sub-table indexes are uniformly calculated in the interceptor without calculation in service logic, so that the intrusion of the whole scheme to the service logic is low, and the decoupling of the service logic is realized.
The scheme adopts parameter dimension annotation, can flexibly mark the sub-table parameters on the Mapper method, so that the name or type of the sub-table parameters is not required to be unified for the existing system needing sub-table reconstruction, the interface specification is not required to be changed, and the sub-table reconstruction of the existing system can be rapidly supported; according to the scheme, by intercepting the query and update methods of the Executor, splitting and reconstructing the sub-table parameters of the method before BoundSql is generated, then converting dynamic SQL into static or original SQL by means of the existing BoundSql generating function of Mybatis, and manually analyzing and reconstructing SQL is not needed, and processing of the sub-table is increased from a reconstructed SQL statement to reconstruct the method parameters, so that a sub-table scene supporting batch operation can be quickly and stably supported.
The core of the scheme is as follows: 1) Defining parameter dimension annotation, and marking sub-table parameters on a Mapper method; 2) Realizing an exechamter interceptor, in which first, the sub-table parameters are analyzed to obtain sub-table attribute values participating in sub-table index calculation and sub-table information metadata of each Mapper method; secondly, carrying out sub-table index calculation on the sub-table attribute values based on a sub-table strategy; then splitting and reconstructing sub-table parameters based on the sub-table index and the sub-table attribute value; finally, aggregating the visit library results of each sub-table; 3) A StatementHandler interceptor is implemented in which the table names of the individual sub-tables are replaced, i.e. the logical table names are replaced with the actual table names.
In the scheme, a universal horizontal sub-table device is mainly realized through three components of a sub-table annotation, an Executor interceptor and a statementHandler interceptor.
Referring to fig. 5, an organization structure diagram of a data processing method according to an embodiment of the present invention includes three contents of a sub-table annotation definition, an Executor interceptor and a StatementHandler interceptor.
The sub-table annotation definition mainly defines sub-table parameter annotation and additional information annotation, wherein the sub-table parameter annotation mainly marks parameters of a sub-table in a Mapper method, the additional information annotation is mainly used for marking parameters which need to participate in sub-table index calculation in the Mapper method, the additional information is not core sub-table parameters and is used for scenes such as test or cut-out, and the sub-table index calculation is carried out in a sub-table strategy according to sub-table attribute values and sub-table additional information values obtained through analysis of the sub-table parameters.
The Executor interceptor is used for ascending the processing of the sub-table from the reconstructed SQL statement to reconstruct the method parameters, and mainly comprises 6 components such as metadata management, sub-table policy management, sub-table parameter analysis, sub-table index calculation, sub-table parameter reconstruction, sub-table result aggregation and the like. The metadata management is mainly used for analyzing and caching sub-table related information of the Mapper method, such as a mapping relation between a method name and a method entity object, a mapping relation between a method name and a method parameter name analyzer, and the like, so that multiple analyses are avoided; the sub-table strategy management is mainly used for loading and caching sub-table strategies of each service table and is used for sub-table index calculation; the sub-table parameter analysis is mainly used for analyzing sub-table parameters of the Mapper method and obtaining sub-table attribute values; the sub-table index calculation is mainly based on a sub-table strategy, and sub-table index calculation and heap returning processing are carried out on sub-table attribute values; the sub-table parameter reconstruction is mainly based on sub-table indexes and sub-table attribute values, and is characterized in that sub-table parameter splitting and reconstruction are carried out, and the parameters of the same sub-table index are piled, in particular to the processing of aggregation and grouping type sub-table parameters; the sub-table result aggregation is mainly to aggregate the library access results after sub-table parameter reconstruction.
The StatementHandler interceptor is mainly used for defining a logical table name converter and is used for replacing the logical table name of the sub-table SQL with an actual table name.
The definition of the sub-table annotation mainly defines the sub-table parameter annotation and the additional information annotation, the sub-table parameter annotation mainly marks the parameter of the sub-table in the Mapper method, and the additional information annotation mainly marks the parameter of the sub-table in the Mapper method, which needs to participate in the sub-table index calculation.
The sub-table parameter annotation is further described:
the sub-table parameter annotation can be named as @ Sharringfield in the program and is mainly used for annotating parameters of sub-tables on the Mapper method, wherein the annotation information comprises sub-table attribute, basic table name, sub-table format, sub-table strategy and the like.
To avoid configuration of the underlying table names, sub-table formats, and sub-table policies on each Mapper method, annotations of the Mapper interface dimensions are defined, named @ SbardingTable.
The data priority of the two fields is @ SharringField in preference to @ SharringTable, i.e. if the two fields are configured with information such as base table name, sub-table format, sub-table policy, etc., the configuration information of @ SharringField is preferably used.
Illustratively, the definition of @ ShardingField is as follows:
Defining/sub-table parameter annotation, and acting on parameter dimension of Mapper interface method
I.e. PARAMETER dimension
@ShardingField{
Meter attribute/min
String value()default“”;
The name of the base table
String base()default“”;
Meter format
String format()default“”;
Meter policy//
String strategy()default“”;
}
Annotation definition of the dimension of the/Mapper interface, which acts on the dimension of the Mapper interface
The// TYPE dimension
@ShardingTable{
The name of the base table
String base()default“”;
Meter format
String format()default“”;
Meter policy//
String strategy()default“”;
}
value set value: if the sub-table parameter of the Mapper interface method is a simple data type, an array or set of simple data types, the value of the @ ShardingField is not assigned; if the sub-table parameter is a reference data type, an array or collection of reference data types, then the value of @ SbardingField is assigned as the sub-table attribute in the reference data type and a multi-level sub-table attribute set value, i.e., an OGNL-like expression, is supported.
base setting: base is the logical table name;
format setting value: the format is the prefix of the actual table name;
strategy setting: the strategy setting value is the name of the sub-table strategic device, namely, what sub-table strategy is adopted for sub-table index calculation.
The sub-table parameter notes are illustrated and the following other functional examples are presented as examples.
The// OrderMapper is an order DAO class, database operations for orders
@ShardingTable(base=”tbl_order”,format=”tbl_order_”,strategy=”orderShardingStrategy”)
OrderMapper{
Order insertion
int insert(@ShardingField(“id”)
@ShardingAddition(value=“pin”,mapkey=“pin”)
@Param(“order”)OrderPO order);
}
Class of order entities for mapping with database order tables
OrderPO{
/(order id)
Long id;
/(lower order pin)
String pin;
Per order amount
Long amount;
Time of ordering
Date submitTime;
……
}
Illustrating: the tbl_order is stored by adopting a sub-table, the corresponding persistence entity class is OrderPO, the order table is sub-table based on order id, the cutting stage adopts an order id number segment to cut, in order to facilitate testing, the test materials in the test environment can fall into the sub-table, the sub-table index calculation is carried out by combining the test pin in the test environment, namely, when the order pin is the test pin, the order can fall into the order sub-table.
Based on the above scenario, the OrderMapper class is marked with @ SharringTable (base= "tbl_order", format= "tbl_order_", structy= "orderSharringStrategy"), where "tbl_order" is a logical table name, and "tbl_order_" is the prefix of the order sub-table, if the calculated sub-table index is 1, the actual table name is tbl_order_1, the sub-table strategicer is ordarSharringStrategy, and the above information may be configured into @ SharringIng notes, which will cover the value in @ SharringTable.
In the insert method, the sub-table parameters are marked with @ SharringField ("id"), and since the order table is sub-table based on order id, the @ SharringField ("id") is used for marking, where id is the order attribute id in OrderPO;
In the insert method, the sub-table additional information is marked by adopting a value= "pin" and a mapkey= "pin", and since the cut is carried out by adopting an order id number segment in the cut stage, in order to ensure that test materials in a test environment can fall into the sub-table, the sub-table index calculation is required to be carried out by combining the test pin in the test environment, and therefore, the order attribute ordering pin of OrderPO is required to be transmitted to the sub-table strategicer orderlingStrategy.
Further explanation is made for additional information notes:
the additional information annotation can be named as @ SharringAdtion in the program and is mainly used for annotating parameters which need to participate in sub-table index calculation on the Mapper method, and the additional information is not a core sub-table parameter and is used for scenes such as testing or cutting, wherein the annotation information comprises additional information attributes, additional information keys and the like.
Preferably, the definition of @ SbardingAdsition is as follows:
annotation definition of/additional information, acting on parameter dimension of Mapper interface method
I.e. PARAMETER dimension
@ShardingAddition{
Attribute of// additional information
String value()default“”;
/(additional information key)
String mapkey()default“”;
}
value set value: if the additional information parameter of the Mapper interface method is a simple data type, an array or a set of simple data types, the value of the @ sharingaddition is not set; if the additional information parameter is a reference data type, an array or collection of reference data types, the value of the @ SharringAddition is assigned as the additional information attribute in the reference data type and supports multi-level additional information attribute settings, i.e., like OGNL expressions, using values similar to the value of @ SharringField values.
The mapkey set value: the attachment information is transmitted to the sub-table strategicer through the map structure, and the mapkey is set as a key of the map structure.
The Executor interceptor comprises a reconstruction method parameter for ascending the processing of the sub-table from the reconstruction SQL statement, and mainly comprises 6 components such as metadata management, sub-table policy management, sub-table parameter analysis, sub-table index calculation, sub-table parameter reconstruction, sub-table result aggregation and the like.
Metadata management, sub-table policy management, sub-table parameter analysis, sub-table index calculation, sub-table parameter reconstruction and sub-table result aggregation are explained one by one.
Metadata management:
the metadata management is mainly used for analyzing and caching sub-table related information of the Mapper method, avoiding multiple analysis, and mainly comprises 4 mapping table information such as a method name-method entity mapping table, a method name-method parameter name analyzer mapping table, a method name-sub-table information mapping table, a method name-additional information mapping table and the like, wherein the mapping information is used for processing sub-table logic in the interceptor.
The following details the 4 mapping tables from the storage structure and parsing procedure of each mapping table, respectively.
1) Method name- > method entity mapping table
a. Storage structure
The method name is the name of the Mapper interface method, namely the fully defined class name+the method name, the method entity is a method entity object of the Mapper interface, and the mapping table information of the insert method in the example is:
map < OrderMapper. Insert, insert method instance ]
b. Resolution process
The method entity analysis is mainly based on statementId, processing is carried out in a reflection mode, and after analysis, the method entity is cached, so that multiple analyses are avoided.
The method comprises the following specific processes of entity analysis:
step 1, an interceptor intercepts calls of the query and update methods, and acquires call information in interceptor interaction method parameter solicitation.
It should be noted that, the method of the parser includes: statementId; the method for intercepting the query/update of the Executor by the interceptor of the Executor comprises the following steps: object interface (Invocation Invocation), wherein the information of the animation is as follows:
object target: the objects are execu or objects, including objects such as simpleexecu or reuseexecu;
method: the query/update method is called currently;
object [ ] args: parameters of the currently called query/update method;
the parameters of the query and update methods of Executor are as follows:
MappedStatement ms: the method entity analysis is mainly carried out based on the id corresponding to the MappedStatement of the current Mapper method, wherein the id corresponds to the fully defined class name+method name of the current calling method;
object parameter: the parameter values of the current Mapper method (here, the parameter structure of Mybatis package, the structure is Map or single object).
It should be noted that, parameters of the query and update methods of the Executor only list parameters that need to be used in the interceptor in the present invention.
Step 2, acquiring an args attribute of the solicitation, and acquiring a 0 th bit parameter of an args array, namely MappedStatement.
And 3, analyzing a Mapper method according to the id attribute of the Mapper state to obtain the last offset of the id, wherein the last offset is used as segmentation, the first half is a full-defined class name, and the second half is a method name.
It should be noted that, this part is preferably acquired from the method entity registry according to id, if so, the method is directly returned, otherwise, the method is analyzed.
And 4, acquiring corresponding Class objects according to the full-defined names, then acquiring all method entities in the Class, filtering out the corresponding method entities according to the method names, and storing into a method entity mapping table.
2) Method name- > method parameter name parser mapping table
a. Storage structure
The method name is the name of the Mapper interface method, namely the fully defined class name+the method name, and the method parameter name analyzer is mainly used for storing the corresponding relation between the index of the Mapper interface method parameter and the parameter name, namely Map < paramIndex, paramName >, and the mapping table information of the insert method in the example is:
Map<OrderMapper.insert,Map<0:”order”>>;
b. resolution process
The method parameter name resolver obtains MappedStatement- > Configuration- > MapperRegistrict- > MapperProxyFactoy- > MapperMethod- > method Signature- > ParamNameResolver,
processing is carried out through a reflection mechanism, and after analysis, a method parameter name analyzer is cached, so that multiple analyses are avoided.
The process of parsing by the method parameter name parser is as follows:
step 1, an interceptor intercepts calls of the query and update methods, and acquires call information in interceptor interaction method parameter solicitation.
It should be noted that, the method of the parser includes: a mappdstatement object and a Method object; the method parameter name resolver ParamNameResover acquisition path is as follows:
MappedStatement->Configuration->MapperRegistry->MapperProxyFactory->MapperMethod->MethodSignature->ParamNameResolver。
step 2, acquiring an args attribute of the solicitation, and acquiring a 0 th bit parameter of an args array, namely MappedStatement.
And step 3, acquiring an attribute Configuration of the MappedStatement, wherein the type is the Configuration.
And 4, acquiring the attribute mappers registry of the Configuration, wherein the type is mappers registry.
And 5, obtaining attribute knownmaps of Map registry, wherein the type is Map < class, map Proxyfactor >.
And 6, obtaining the MapperProxyFactory according to the current type of the Mapper.
And 7, acquiring a Method dCAche attribute of MapperProxyFactoy, wherein the type of the Method is Map < Method >, mapperMethod >.
And 8, acquiring a MapperMethod according to the current Method entity.
Step 9, obtaining a method attribute of the MapperMethod, wherein the type of the method attribute is method Signature.
And step 10, acquiring a paramname resolution attribute of the method Signature, wherein the type of the paramname resolution attribute is ParamNameResolver, and the object is a method parameter name resolver and the resolver is placed in a method parameter name resolver mapping table.
It should be noted that, the method parameter name resolver needs to be stored in the metadata registry, so as to avoid repeated resolution and loss of performance.
3) Method name- > sub-table information mapping table
a. Storage structure
The method name is the name of the Mapper interface method, namely the fully defined class name and the method name, the sub-table information is the method sub-table information analyzed according to the @ SharringField and @ SharringTable notes, and the method sub-table information is mainly encapsulated by SharringFieldInfo and has the following structure:
ShardingFieldInfo extends ShardingTableInfo{
I/O sub-table
Boolean isShardingTable;
Meter parameter subscript of the/(map method)
Integer shardingArgIndex;
Attribute name of the sub-table of the/(map method)
String shardingFieldName;
The// mapper method is whether the sub-table parameters are array
Boolean isShardingArgArray;
Whether the/map method sub-table parameters are aggregated
Boolean isShardingArgCollection;
Meter parameter type for/(map method)
Class shardingArgType;
Class of parameter type of the sub-table of the method of the/(map)
Type[]shardingArgParameterizedTypes;
Whether the sub-table parameters of the/(map method are resolved
Boolean isShardingArgParsed;
Whether the attribute of the sub-table of the/(map method is array or not
Boolean isShardingFieldArray;
Whether the attribute of the sub-table of the/(map method is aggregated or not
Boolean isShardingFieldCollection;
Meter attribute type for the/(map method
Class shardingFieldType;
Class of attribute type of the sub-table of the method of the/(map)
Type[]shardingFieldParameterizedTypes;
Whether the attribute of the sub-table of the/(map method is resolved
Boolean isShardingFieldParsed;
}
ShardingTableInfo{
The name of the base table
String baseName;
Meter prefix
String splitTablePrefix;
Meter policy//
String strategy;
}
Description: the mapper method sub-table parameter is a parameter marked by the mapper method with @ SharringField, such as the order parameter in the above example, and the mapper method sub-table attribute is an attribute marked by the value of @ SharringField in the sub-table parameter, such as the id attribute in the order parameter in the above example.
For example, the table information mapping table information after being parsed by the insert method is:
Map<OrderMapper.insert,{ShardingFieldInfo{
I/O sub-tables, yes
isShardingTable:true,
Index of sub-table parameter of/(map method: 0)
shardingArgIndex:0,
Attribute name of sub-table of/(map method: id)
shardingFieldName:”id”,
Whether the sub-table parameters of the/(map method are arrayed or not, if not
isShardingArgArray:false,
Whether the sub-table parameters of the/(map method are aggregated or not, no
isShardingArgCollection:false,
OrderPO type of the sub-table parameters of the/(mapper) method
shardingArgType:OrderPO,
The method of the/(map method) is divided into parameter type generalization and non-generalization
shardingArgParameterizedTypes:null,
The// mapper method sub-table parameter is analyzed or not
isShardingArgParsed:true,
The attribute of the sub-table of the/(map method is whether the array is false
isShardingFieldArray:false,
Whether the attribute of the sub-table of the/(map method is set or not
isShardingFieldCollection:false,
The attribute type of the sub-table of the/(map method: long)
shardingFieldType:Long,
The attribute type of the sub-table of the method of the/(map: non-generic type)
shardingFieldParameterizedTypes:null,
Whether the attribute of the sub-table of the/(map method is resolved or not is
isShardingFieldParsed:true,
The name of the base table tbl_order
baseName:”tbl_order”,
Meter prefix
splitTablePrefix:”tbl_order_”,
Meter policy//
strategy:”orderShardingStrategy”;
}}>
b. Resolution process
The sub-table information shadingfeldinfo resolution is resolved in two stages:
analyzing the sub-table parameters of the mapper method;
analyzing sub-table attributes of sub-table parameters of a mapper method;
and processing through parameter annotation and a reflection mechanism, and caching sub-table information after analysis to avoid multiple analyses.
The detailed flow of the sub-table parameter analysis is as follows:
step 1, obtaining Method parameters according to the getGenericParameterTypes () Method of the Method.
It should be noted that, the method of the parser includes: a Method object; the ShardingFieldInfo analysis of the sub-table information is analyzed in two stages, wherein one stage is the analysis of the sub-table parameters of the Mapper method, and the other stage is the analysis of the sub-table attributes of the sub-table parameters of the Mapper method.
Step 2, judging whether the method parameters are empty or not; if not, executing the step 3; if the signal is empty, the step 8 is executed.
And step 3, acquiring parameter annotation information according to a getParameterAnactions () Method of the Method, wherein the result is a two-dimensional array.
Note that the format of the annotation two-dimensional array is as follows: [ annotation array for parameter 0, annotation array for parameter 1, annotation array for parameter x ].
And 4, traversing the parameter annotation two-dimensional array to obtain parameters marked with @ ShardingField, namely sub-table parameters.
And 5, judging whether the sub-table parameters are empty, if not, executing the step 6, and if so, executing the step 8.
Step 6, setting isShardingTable, shardingArgIndex, shardingFieldName of the ShardingFieldInfo; setting base, splitTablePrefix of the sharingfieldinfo and strategy attribute based on the @ sharingfield annotation, and if empty, performing acquisition setting based on the @ sharingtable annotation, and executing step 7.
And 7, setting shardingArgType, shardingArgParameterizedTypes, isShardingArgArray, isShardingArgCollection and isShardingArgParsed attributes according to the type of the sub-table parameters.
It should be noted that if the type of the sub-table parameter is Class, the following settings are performed:
shrdingArgType: dividing the parameter types into table;
isshardingergarray: returning a result by using isArray () of the sub-table parameter type;
isshardingergcollection: the collection.class.issignadblef rom () returns the result.
If the sub-table parameter type is parameterizer dtype, the following settings are made:
shrdingArgType: the getRawType () of the sub-table parameter type returns the result;
sharingargparameterizer dttypes: the getActualTypeArgments () of the sub-table parameter type returns the result;
isshardingergarray: returning a result by using isArray () of the sub-table parameter type RawType;
isshardingergcollection: the collection.class.issignadblef rom () returns the result.
If the sub-table parameter type is GenericArrayType, the following settings are made:
shrdingArgType: getGenericComponentType (). GetRawType () of the sub-table parameter type returns the result;
sharingargparameterizer dttypes: getGenericComponentType (). Getactualpypearsegments () of the sub-table parameter type returns a result;
isShardingArgArray:true;
isShardingArgCollection:false;
other types do not support sub-tables.
Step 8, setting issharingtable of sharingfieldinfo to false, and returning.
The detailed flow of sub-table attribute parsing is as follows.
Step 1, acquiring a value of a SharingFieldName attribute of SharingFieldInfo, such as a.b.c or a.
It should be noted that, the reference numbers are ShardingFieldInfo and the sub-table parameter ShardingArg; the sub-table information SbardingFieldInfo analysis is analyzed in two stages, one is the analysis of the sub-table parameters of the Mapper method, and the other is the analysis of the sub-table attributes of the sub-table parameters of the Mapper method.
And 2, acquiring the last offset of the "in the sharingFieldName, wherein the offset is divided into the first half of the name of the object of the class where the sub-table attribute is located, and the second half of the name of the sub-table attribute in the object, which is named tmpShardingFieldName.
Taking a.b.c as an example, the shrdingObjectName= a.b, tmpShardingFieldName=c.
Taking a as an example, the sharingobjectname=null, tmpshardingfieldname=a.
Step 3, obtaining an object in which the sub-table attribute tmpShardingFieldName is located according to the MetaObject and the shardingObjectName of the sub-table parameter shardingArg, and marking the object as a sub-table object shardingObject.
Note that, taking a.b.c as an example, the sharingobjectname= a.b, tmpshardingfieldname=c. The b object may be obtained according to MetaObject and a.b of the sub-table parameter shadingarg, where the object b is the object in which the sub-table attribute c is located, i.e. shadingobject.
Taking a as an example, objectname=null, tmpshardingfieldname=a, and since objectName is empty, shrringarg is the object in which sub-table attribute a is located, i.e., shrringobject.
And 4, acquiring the sub-table attribute Field object according to the class of the sub-table object shardingObject and the sub-table attribute tmpShardingfield name.
It should be noted that this step is implemented based on a reflection mechanism.
And 5, obtaining the sub-table attribute Type through a TypeParameterResolveFieldType.
And 6, setting shardingFieldType, shardingFieldParameterizedTypes, isShardingFieldArray, isShardingFieldCollection and isshardingedbase attributes according to the type of the sub-table attributes.
It should be noted that if the type of the sub-table attribute is Class, the following settings are performed:
the shrringFieldType: a sub-table attribute type;
isshardingefield array: returning a result by using isArray () of the sub-table attribute type;
isshardingefield collection: the collection.class.issignadblef rom () returns the result.
If the sub-table attribute type is parameterizer dtype, the following settings are made:
the shrringFieldType: the getRawType () of the sub-table attribute type returns the result;
the shardingmeldparameterizer dttypes: the getActualTypeArgments () of the sub-table attribute type returns a result;
isshardingefield array: returning a result by using the isArray () of the RawType of the sub-table attribute type;
isshardingefield collection: the collection.class.issignadblef rom () returns the result.
If the sub-table attribute type is GenericArrayType, the following settings are made:
the shrringFieldType: getGenericComponentType (). GetRawType () of the sub-table attribute type returns the result;
the shardingmeldparameterizer dttypes: getGenericComponentType (). Getactualpypearsegments () of the sub-table attribute type returns a result;
isShardingFieldArray:true;
isShardingFieldCollection:false;
other types do not support sub-tables.
4) Method name- > additional information mapping table
a. Storage structure
The method name is the name of the Mapper interface method, namely the fully defined class name and the method name, the additional information is method sub-table additional information analyzed according to the @ SharringAddition annotation, and the method sub-table additional information is mainly packaged by SharringAdditionInfo and has the following structure:
ShardingAdditionInfo{
index of additional information parameter
private Integer paramIndex;
+/-additional attribute name
private String fieldName;
The/(additional attribute mapKey)
private String keyName;
}
For example, mapping table information after being parsed by an insert method is:
Map<OrderMapper.insert:[{ShardingFieldInfo{
subscript of/(additional information parameter: 0)
paramIndex:0,
"pin" is the name of the additional attribute "
fieldName:”pin”,
"pin" as an additional attribute "
keyName:”pin”;
]}}>
b. Resolution process
Processing is carried out through annotation, after analysis, additional information is cached, multiple analysis is avoided, and the detailed flow of the additional information analysis is as follows:
Step 1, obtaining Method parameters according to the getGenericParameterTypes () Method of the Method.
It should be noted that, the method of the parser in this step is as follows: method object.
Step 2, judging whether the method parameters are empty or not; if not, executing the step 3; if the air is empty, the step 6 is executed.
And step 3, acquiring parameter annotation information according to a getParameterAnactions () Method of the Method, wherein the result is a two-dimensional array.
Note that, the format of the annotation two-dimensional array is as follows: [ annotation array for parameter 0, annotation array for parameter 1, annotation array for parameter x ].
And 4, traversing the parameter annotation two-dimensional array to obtain the parameter marked with @ Sharringaddition, namely the additional information parameter.
Step 5, setting a paramIndex of the ShardingAdationInfo; the fieldName and keyName of the shadingdationinfo are set based on the @ shadingdtion annotation.
And 6, ending.
(II) sub-table policy management
The sub-table policy management is mainly used for loading and caching sub-table policies of each service table and is used for sub-table index calculation of sub-table attribute values. The system mainly comprises a sub-table policy interface definition and a sub-table policy manager, and the sub-table policy interface and the sub-table policy manager are respectively described in detail below.
1) Sub-table policy interface definition
The sub-table strategy interface is used for defining the specification of sub-table index calculation and supporting the custom sub-table logic of each service table.
When the sub-table strategy is called, the sub-table attribute value, the sub-table additional information value and the Mapper method information of the currently called Mapper method are transmitted into the sub-table strategy, sub-table index calculation is carried out, the return result is a Map structure, wherein the key is a sub-table attribute value element, and the value is the sub-table index corresponding to the key.
The sub-table policy interface pseudocode is as follows:
ShardingTableStrategy{
/**
* Sub-table processing
*
* @ param shardingIds sub-table attribute values
* Additional information value @ param shardingAdditionMap sub-table
* Method information of current call of @ param endpoint
*@return
*/
Map<String,String>sharding(List<String>shardingIds,Map<String,Object>shardingAdditionMap,Endpoint endpoint);
}
Endpoint is defined as follows:
Endpoint{
type of/(map)
private Class mapperType;
Method entity of/(mapper)
private Method method;
Values of the parameter of the/(map method)
Object[]params;
}
The sharingids is a sub-table attribute value, which is mainly obtained by sub-table information analysis in metadata management, and details are found in sub-table parameter analysis;
the sharingAdditionMap is a sub-table additional information value Map, which is mainly obtained through sub-table additional information in metadata management, and details are found in sub-table parameter analysis;
the endpoint is the current invoked Mapper method information, and comprises the type of the current invoked Mapper class, the current invoked Mapper method entity and the method parameters.
2) Sub-table policy manager
The sub-table policy manager is used for loading and caching sub-table policies, and the sub-table policy manager can scan the implementation class of the interface for realizing the sub-table policies and automatically register; when the sub-table index calculation is carried out in the interceptor, the sub-table strategy is obtained according to the sub-table strategy name configured by the Mapper method, so that the sub-table index calculation of the sub-table attribute value is realized.
(III) analysis of sub-table parameters
And analyzing the sub-table parameters, wherein the sub-table parameters, the sub-table attribute values and the sub-table additional information values used for sub-table index calculation are analyzed from the current Mapper method. The part mainly comprises sub-table parameter analysis, sub-table attribute value analysis and sub-table additional information value analysis.
1) Sub-table parameter resolution
Sub-table parameter resolution for entry method from Executor interceptor
The parameter array of the Mapper method is parsed from the input parameter solicitation of Object interface (Invocation Invocation), and then the sub-table parameter, the sub-table attribute value and the sub-table additional information value are parsed respectively based on the parameter array.
The solicitation is defined as follows:
Invocaton{
the// is an Executor object, comprising objects such as SimpleExecutor and ReuseExecutor
Object target;
Query/update method for currently called Exactor object
Method method;
Parameters of query/update method for the currently invoked Exactor object
Object[]args;
}
Wherein, the array, i.e. the query and update method parameters of the Executor object are as follows:
MappedStatement ms, which is MappedStatement corresponding to the current Mapper method;
the Object parameter is a parameter value (here, a parameter structure of Mybatis package, and the structure is Map or a single Object) of the current Map method, and a sub-table parameter, a sub-table attribute value and a sub-table additional information value of the Map method are analyzed based on the parameter.
It should be noted that only parameters needed to be used in the interceptor are listed in the present invention.
The table parameter analysis flow is as follows:
step 1, an exechamter interceptor intercepts calls of a query method and an update method; acquiring call information in interceptor interrupt method parameter solicitation; obtaining a parameter value parameter of a Mapper method (here, a parameter structure of Mybatis package, the structure is Map or a single object) from the call information, analyzing the structure into an actual parameter array of the Mapper method, and analyzing the parameter to obtain a sub-table parameter; wherein the parameter structure is Map < paramName, paramObject > or single object.
It should be noted that, the interceptor intercepts the query/update method of the interceptor, and the interceptor entry method is Object interrupt (Invocation Invocation), wherein, information of the solicitation is as follows:
Object target: the objects are execu or objects, including objects such as simpleexecu or reuseexecu;
method: the query/update method is called currently;
object [ ] args: is a parameter of the currently called query/update method.
The query and update method parameters of the Executor are as follows:
MappedStatement ms: mappedStatement corresponding to the current Mapper method;
object parameter: the parameter values of the current Mapper method (here, the parameter structure of Mybatis package, the structure is Map or single object).
Wherein, the query and update method parameters of the Executor only list the parameters needed to be used in the interceptor.
And 2, acquiring a method parameter name analyzer of the Mapper method from a mapping table of the method name and the method parameter name analyzer, wherein a name array (stored according to a parameter sequence) of actual parameters of the Mapper method is stored and is marked as names, and the actual parameters of the Mapper method can be acquired from the parameter through the name array.
Step 3, judging whether the parameter structure is Map, if so, executing step 4; if not, step 5 is performed.
Step 4, if the parameter contains an element with a key being collection and the parameter has only one element, packaging the element with an Object array for returning; if the parameter contains an element whose key is list and the parameter has only one element, then the element is packed with an Object array for return; if the parameter contains an element whose key is array and the parameter has only one element, then the element is packed with an Object array for return; if the elements are not contained, circularly traversing the names, and acquiring an actual parameter array of the Mapper method from the parameter.
It should be noted that if the parameter contains an element whose key is collection and there is only one element in the parameter, the actual parameter describing the Mapper method is a set; if the parameter contains an element with a key being List and the parameter has only one element, the actual parameter describing the Mapper method is a List; if the parameter contains an element with a key being an array and the parameter has only one element, the actual parameter for describing the map method is an array; if the above elements are not included, the Mapper method is described as including a plurality of parameters.
After step 4, step 6 is performed.
And step 5, packaging the parameter by using the Object array for returning.
After execution 5, step 6 is executed.
And 6, acquiring the sharingArgIndex of the sub-table information from the method name- > sub-table information mapping table, and combining the parameter array returned in the last step to acquire the sub-table parameters.
2) Sub-table attribute value resolution
Based on the sub-table parameters, the sub-table attribute value analysis is carried out according to the value of the attribute sharingFieldName of the sub-table information sharingFieldInfo, and the sub-table attribute value analysis is used for subsequent sub-table index calculation.
The sub-table scene mainly comprises the following four cases by combining the sub-table parameter type and the value of the sharingFieldName (whether the sub-table parameter type is empty or not):
a. The sub-table parameters are array
i. The sub-table parameters are arrays, if the sharingFieldName is empty, the array type is Long, intger, int, short, byte and String, and the sub-table can be supported;
if the shardingFieldName is not empty, the sub-table attribute type is Long, long, integer, int, short, short, byte, byte and String, and the sub-table can be supported.
The table attribute value analysis process using the table scene as an array is as follows:
and step 1, obtaining the sub-table information SbardingFieldInfo of the Mapper method, and judging whether the sub-table is supported.
The main contents of the acquired sub-table information shadingfeldinfo are as follows:
shardingArgClazz: dividing the parameter types into table;
shardingmeldclazz: a sub-table attribute type;
hasshardingefield: whether the sub-table attribute exists;
the sharingfieldname: the sub-table attribute name.
It should be noted that, the sub-table parameter is the parameter annotated by the Mapper method @ Sharringfield, and the flow mainly describes the analysis process of the sub-table attribute value when the sub-table parameter is an array.
When the sub-table parameters are arrays, the sub-table is supported only by the following two cases:
If the sharingFieldName is empty, then the array type needs to be Long [ ], integer [ ], int [ ], short [ ], byte [ ] and String [ ], and the square can support sub-tables; if the sharingFieldName is not empty then the sub-table attribute type needs to be Long, long, integer, int, short, short, byte, byte and String, and the party can support the sub-table.
Step 2, judging whether the sub-table attribute name does not exist and the sub-table parameter type is a basic data type array (including String); if not, executing the step 3; if yes, go to step 5.
Step 3, judging whether the sub-table attribute names exist or not and judging whether the sub-table attribute types are basic data types (including String); if yes, executing the step 4; if not, executing step 6.
Step 4, circularly traversing the MetaObject object of the sub-table parameters to obtain each array element; pseudo code such as: metashardingengag argetvalue ("[" +i+ "]); the meta object of each array element is used to obtain its sub-table attribute value, and the pseudo code is as follows: metaitem, getvalue (sharingfieldname); and adding the acquired sub-table attribute value to the List < String > for returning, and ending.
It should be noted that, the process of obtaining the attribute value of the sub-table is mainly completed by means of the meta object function of Mybatis.
And 5, converting the sub-table parameters of the array type into a character string set, and ending.
And step 6, throwing exception, namely, not supporting sub-table and ending.
b. The sub-table parameter is List
i. The List parameter is List, if the sharingFieldName is empty, the List needs Long, integer, short, byte and String, and the List can be supported;
if the table division parameter is List, and if the sharingfield name is not empty, the division attribute type needs to be Long, long, integer, int, short, short, byte, byte and String, and the party can support division.
When the List is the sub-table scene, the corresponding sub-table attribute value analysis flow is as follows:
and step 1, obtaining the sub-table information SbardingFieldInfo of the Mapper method, and judging whether the sub-table is supported.
The main contents of the acquired sub-table information shadingfeldinfo are as follows:
sharingargparameterizer dttypes: the parameters of the sub-table are general;
shardingmeldclazz: a sub-table attribute type;
hasshardingefield: whether the sub-table attribute exists;
the sharingfieldname: the sub-table attribute name.
It should be noted that, the sub-table parameter is the parameter annotated by the Mapper method @ SbardingField, and the flow mainly describes the analysis process of the sub-table attribute value when the sub-table parameter is the List.
When the sub-table parameter is List, the sub-table is supported only by the following two cases:
if the sharingFieldName is empty, the List is Long, integer, short, byte and String, and the List can support sub-tables; if the sharingFieldName is not empty, then the sub-table attribute type needs to be Long, long, integer, int, short, short, byte, byte and String, and the party can support the sub-table.
Step 2, judging whether the sub-table attribute names do not exist and the sub-table parameter generic type is a basic data type (including String); if not, executing the step 3; if yes, go to step 5.
Step 3, judging whether the sub-table attribute names exist or not and judging whether the sub-table attribute types are basic data types (including String); if yes, executing the step 4; if not, go to step 6.
Step 4, circularly traversing the List to obtain each set element, and obtaining the sub-table attribute value of the MetaObject object of each set element through the MetaObject object of each set element, wherein the pseudo code is as follows: metaitem, getvalue (sharingfieldname); and adding the acquired sub-table attribute value to the List < String > for returning, and ending.
It should be noted that, the process of obtaining the attribute value of the sub-table is mainly completed by means of the meta object function of Mybatis.
And 5, converting List type sub-table parameters into character string sets, returning and ending.
And step 6, throwing exception, namely, not supporting sub-table and ending.
c. The sub-table parameter is Set
i. The sub-table parameter is Set, if the sharingFieldName is empty, the generalized type of the Set needs to be Long, integer, short, byte and String, and the sub-table can be supported;
if the shardingFieldName is not empty, the type of the sub-table attribute needs to be Long, long, integer, int, short, short, byte, byte and String, and the sub-table can be supported.
The flow of analyzing the sub-table attribute value when the sub-table scene is Set is as follows:
and step 1, obtaining the sub-table information SbardingFieldInfo of the Mapper method, and judging whether the sub-table is supported.
The main contents of the acquired sub-table information shadingfeldinfo are as follows:
sharingargparameterizer dttypes: the parameters of the sub-table are general;
shardingmeldclazz: a sub-table attribute type;
hasshardingefield: whether the sub-table attribute exists;
the sharingfieldname: the sub-table attribute name.
It should be noted that, the sub-table parameter is the parameter annotated by the Mapper method @ SbardingField, and the flow mainly describes the analysis process of the sub-table attribute value when the sub-table parameter is Set.
When the sub-table parameter is Set, the sub-table is supported only by the following two cases:
If the sharingFieldName is empty, the Set's generalized type needs to be Long, integer, short, byte and String, and the party can support sub-tables; if the sharingFieldName is not empty, then the sub-table attribute type needs to be Long, long, integer, int, short, short, byte, byte and String, and the party can support the sub-table.
Step 2, judging whether the sub-table attribute names do not exist and the sub-table parameter generic type is a basic data type (including String); if not, executing the step 3; if yes, go to step 5.
Step 3, judging whether the sub-table attribute names exist or not and judging whether the sub-table attribute types are basic data types (including String); if yes, executing the step 4; if not, go to step 6.
Step 4, circularly traversing the Set to acquire each Set element, and acquiring the sub-table attribute value of the MetaObject object of each Set element through the MetaObject object of each Set element, wherein the pseudo code is as follows: metaitem, getvalue (sharingfieldname); and adding the acquired sub-table attribute value to List < String >, and ending.
The acquisition of the sub-table attribute values is mainly accomplished by means of the MetaObject function of Mybatis.
And 5, converting the sub-table parameters of the Set type into character string sets, returning and ending.
And step 6, throwing exception, namely, not supporting sub-table and ending.
d. The sub-table parameters are single objects
i. The sub-table parameter is a single object, if the sharingFieldName is empty, the type of the single object needs to be Long, long, integer, int, short, short, byte, byte and String, and the sub-table can be supported;
the sub-table parameters are single objects, if the sharingFieldName is not empty, the sub-table attributes are arrays of basic types (including String), list, set, and single objects, which can support the sub-table.
The flow of analyzing the sub-table attribute value when the sub-table scene is a single object is as follows:
and step 1, obtaining the sub-table information SbardingFieldInfo of the Mapper method, and judging whether the sub-table is supported.
The main contents of the acquired sub-table information shadingfeldinfo are as follows:
shardingArgClazz: dividing the parameter types into table;
isshardingefield array: whether the sub-table attribute is an array;
isshardingefield collection: whether the sub-table attributes are aggregated;
shardingmeldclazz: a sub-table attribute type;
the shardingmeldparameterizer dttypes: the sub-table attribute is of a generic type;
hasshardingefield: whether a sub-table attribute exists.
It should be noted that, the sub-table parameter is the parameter annotated by the Mapper method @ SbardingField, and the flow mainly describes the analysis process of the sub-table attribute value when the sub-table parameter is a single object.
When the sub-table parameter is a single object, the sub-table is supported only by the following two cases:
if the sharingFieldName is empty, the type of the single object needs to be Long, long, integer, int, short, short, byte, byte and String, and the party can support sub-tables; if the sharingFieldName is not empty, then the sub-table attributes are an array of base types (including String), list, set, and a single object, which may support the sub-table.
Step 2, judging whether the sub-table attribute names do not exist and the sub-table parameter generic type is a basic data type (comprising String); if not, executing the step 3; if yes, go to step 5.
Step 3, judging whether the sub-table attribute names exist, if yes, executing step 4; if not, go to step 6.
Step 4, the attribute type of the sub-table is an array, the array type is a basic type array (comprising String [ ]), and the array is converted into a character String set to return; the attribute type of the sub-table is List, the generalization is basic data type (including String), and the List is converted into a character String set to return; the attribute type of the sub-table is Set, the generalized type is basic data type (including String), and the Set is converted into a character String Set to return; the sub-table attribute type is a single object, and the type is a basic data type (including String), and the sub-table attribute is converted into a character String set to return and end.
And 5, converting the sub-table parameters into character string sets, and ending.
And step 6, throwing exception, namely, not supporting sub-table and ending.
3) Sub-table additional information value resolution
And (3) carrying out analysis on the value of the sub-table additional information according to the sub-table additional information ShardingAdditionInfo based on the parameter array of the Mapper method (see sub-table parameter analysis for details), and using the parameter array for subsequent sub-table index calculation. The flow of analysis of the sub-table additional information value is as follows:
and step 1, analyzing the actual parameter array and the sub-table additional information by combining the Mapper method.
It should be noted that, the actual parameter array analysis process of the Mapper method is referred to as sub-table parameter analysis process; the sub-table additional information is maintained by a method name- > additional information mapping table.
Step 2, circularly traversing the additional information list, and acquiring additional information parameters from the parameter array according to the paramIndex; additional information values are obtained by the MetaObject object of the additional information parameter and the fieldName of the additional information, pseudo codes such as: metaObject. GetValue (fieldName); and acquiring the keyName of the additional information, storing the keyName and the additional information value into the Map, and returning.
It should be noted that the additional information acquisition process is mainly completed by means of the meta object function of Mybatis.
(IV) sub-table index calculation
And carrying out sub-table index calculation and heap returning processing on the sub-table attribute values mainly based on a sub-table strategy.
1) Sub-table index calculation
The sub-table index calculation is mainly based on a sub-table strategy, and calculates the sub-table index corresponding to each sub-table attribute value according to the sub-table attribute value, the sub-table additional information value and the currently called Mapper method information, wherein the return result is Map < single sub-table attribute value, sub-table index >. The definition of the sub-table policy interface is shown in sub-table policy management.
The implementation of the sub-table strategy of each service table is realized by each system, and can be realized by MurmurHash or a disturbance function and the like, and the details are not repeated here.
2) Piling treatment
And (3) performing heap returning processing, namely performing heap returning processing on the Map < single sub-table attribute value and the sub-table index > returned by the sub-table index calculation, and performing heap returning on the sub-table attribute value according to the dimension of the sub-table index, wherein the processing result is Map < sub-table index and List < single sub-table attribute value >.
The specific flow of the sub-table index calculation is as follows:
step 1, obtaining the sub-table strategy from a sub-table strategy manager according to the sub-table strategy name in the sub-table information.
It should be noted that, the sub-table information is obtained from the method name- > sub-table information mapping table; the sub-table policy is obtained from a sub-table policy manager.
And step 2, calling a sub-table strategy (sub-table attribute value, sub-table additional information value and currently called Mapper method information) to obtain a sub-table index, wherein the structure is Map < single sub-table attribute value, sub-table index >.
And 3, traversing Map < single sub-table attribute value, sub-table index >, and performing heap grouping processing on sub-table attribute values with the same sub-table index, wherein the structure is Map < sub-table index, list < single sub-table attribute value >.
(V) sub-table parameter reconstruction
The sub-table parameter reconstruction is mainly based on a pile-up result obtained by sub-table index calculation, namely Map < sub-table index, list < single sub-table attribute value > >, and sub-table parameter splitting and reconstruction are carried out, and particularly, sub-table parameters of a set type and an array type are processed.
And compared with the analysis of the sub-table attribute values from the sub-table parameters, the sub-table parameter reconstruction can be understood as reverse engineering of the sub-table attribute value analysis, and the sub-table parameters are reconstructed based on the sub-table attribute values.
The sub-table parameter reconstruction mainly comprises the following four cases by combining the sub-table parameter type and the value of the sharingFieldName (whether the sub-table parameter type is empty or not):
1) The sub-table parameters are array
i. If the sharingFieldName is empty and the array type is Long [ ], integer [ ], int [ ], short [ ], byte [ ] and String [ ], directly splitting the split table parameters;
if the sharingFieldName is not empty and the sub-table attribute types are Long, long, integer, int, short, short, byte, byte and String, then the sub-table parameters are split according to the sub-table attribute values.
The flow of sub-table parameter reconstruction when the scene sub-table parameters are the array is as follows:
step 1, obtaining the sub-table information SbardingFieldInfo of the Mapper method, and splitting the sub-table parameters.
The main contents of the acquired sub-table information shadingfeldinfo are as follows:
shardingArgClazz: dividing the parameter types into table;
shardingmeldclazz: a sub-table attribute type;
hasshardingefield: whether the sub-table attribute exists;
the sharingfieldname: the sub-table attribute name.
It should be noted that, according to the sub-table attribute value stacking result obtained by the sub-table index calculation, that is, map < sub-table index, list < single sub-table attribute value > >, sub-table parameter splitting is circularly performed.
The sub-table parameters are annotated by the Mapper method @ ShardingField, and the process mainly describes the splitting process of the sub-table parameters when the sub-table parameters are arrays.
When the sub-table parameters are arrays, splitting the sub-table parameters under two conditions, specifically, as follows: if the sharingFieldName is empty and the array type is Long [ ], integer [ ], int [ ], short [ ], byte [ ] and String [ ], directly splitting the split table parameters; if the sharingFieldName is not empty and the sub-table attribute types are Long, long, integer, int, short, short, byte, byte and String, then the sub-table parameters are split according to the sub-table attribute values.
Step 2, judging whether the sub-table attribute name does not exist and the sub-table parameter type is a basic data type array (including String); if not, executing the step 3; if yes, go to step 5.
Step 3, judging whether the sub-table attribute names exist or not and judging whether the sub-table attribute types are basic data types (including String); if yes, executing the step 4; if not, go to step 6.
Step 4, circularly traversing and obtaining each array element through MetaObject objects of the sub-table parameters, wherein the pseudo codes are as follows: metashardingengag argetvalue ("[" +i+ "]); the meta object of each array element is used to obtain its sub-table attribute value, and the pseudo code is as follows: metaitem, getvalue (sharingfieldname); and splitting the sub-table parameter array according to the List < single sub-table attribute value > and the sub-table attribute value of the stacking result.
It should be noted that, the process of obtaining the attribute value of the sub-table is mainly completed by means of the meta object function of Mybatis.
And 5, splitting the sub-table parameters of the array type according to the List < single sub-table attribute value > of the stacking result, and ending.
And step 6, throwing exception, namely, not supporting sub-table and ending.
2) The sub-table parameter is List
i. The sub-table parameters are List, if the sharingFieldName is empty, and the List is Long, integer, short, byte and String, the sub-table parameters are directly split;
if the sub-table parameter is List, if the shardingFieldName is not empty and the sub-table attribute type is Long, long, integer, int, short, short, byte, byte and String, splitting the sub-table parameter according to the sub-table attribute value.
The flow of sub-table parameter reconstruction when the scene sub-table parameter is List is as follows:
step 1, obtaining the sub-table information SbardingFieldInfo of the Mapper method, and splitting the sub-table parameters.
The main contents of the acquired sub-table information shadingfeldinfo are as follows:
sharingargparameterizer dttypes: the parameters of the sub-table are general;
shardingmeldclazz: a sub-table attribute type;
hasshardingefield: whether the sub-table attribute exists;
the sharingfieldname: the sub-table attribute name.
It should be noted that, the sub-table attribute value stacking result is obtained according to the sub-table index calculation, that is, map < sub-table index, list < single sub-table attribute value > >, and sub-table parameter splitting is performed circularly.
The sub-table parameters are annotated by the Mapper method @ ShardingField, and the process mainly describes the splitting process of the sub-table parameters when the sub-table parameters are List.
When the sub-table parameter is List, splitting the sub-table parameter under two conditions, specifically: if the sharingFieldName is empty and the List is generic to Long, integer, short, byte and String, directly splitting the split table parameters; if the sharingFieldName is not empty and the sub-table attribute type needs to be Long, long, integer, int, short, short, byte, byte and String, the sub-table parameters are split according to the sub-table attribute values.
Step 2, judging whether the sub-table attribute names do not exist and the sub-table parameter generic type is a basic data type (including String); if not, executing the step 3; if yes, go to step 5.
Step 3, judging whether the sub-table attribute names exist or not and judging whether the sub-table attribute types are basic data types (including String); if yes, executing the step 4; if not, go to step 6.
Step 4, circularly traversing the List to obtain each set element, and obtaining the sub-table attribute value of the MetaObject object of each set element through the MetaObject object of each set element, wherein the pseudo code is as follows: metaitem, getvalue (sharingfieldname); splitting the List of the sub-table parameters according to the List < single sub-table attribute value > and the sub-table attribute value of the stacking result, and ending.
It should be noted that, the process of obtaining the attribute value of the sub-table is mainly completed by means of the meta object function of Mybatis.
And 5, splitting List type sub-table parameters according to the List < single sub-table attribute value > of the stacking result, and ending.
And step 6, throwing exception, namely, not supporting sub-table and ending.
3) The sub-table parameter is Set
i. The sub-table parameters are Set, if the sharingFieldName is empty, and the Set is Long, integer, short, byte and String, the sub-table parameters are directly split;
if the table attribute type is Long, long, integer, int, short, short, byte, byte and String, splitting the table parameters according to the table attribute value.
The flow of sub-table parameter reconstruction when the scene sub-table parameter is Set is as follows:
step 1, obtaining the sub-table information SbardingFieldInfo of the Mapper method, and splitting the sub-table parameters.
The main contents of the acquired sub-table information shadingfeldinfo are as follows:
sharingargparameterizer dttypes: the parameters of the sub-table are general;
shardingmeldclazz: a sub-table attribute type;
hasshardingefield: whether the sub-table attribute exists;
the sharingfieldname: the sub-table attribute name.
It should be noted that, according to the sub-table attribute value stacking result obtained by the sub-table index calculation, that is, map < sub-table index, list < single sub-table attribute value > >, sub-table parameter splitting is circularly performed; the sub-table parameter is the parameter annotated by the Mapper method @ ShardingField, and the flow mainly describes the splitting process of the sub-table parameter when the sub-table parameter is Set.
When the sub-table parameter is Set, splitting the sub-table parameters under the following two conditions:
if the sharingFieldName is empty and the Set is generic Long, integer, short, byte and String, directly splitting the split table parameters; if the sharingFieldName is not empty and the sub-table attribute type needs to be Long, long, integer, int, short, short, byte, byte and String, the sub-table parameters are split according to the sub-table attribute values.
Step 2, judging whether the sub-table attribute names do not exist and the sub-table parameter generic type is a basic data type (including String); if not, executing the step 3; if yes, go to step 5.
Step 3, judging whether the sub-table attribute names exist or not and judging whether the sub-table attribute types are basic data types (including String); if yes, executing the step 4; if not, go to step 6.
Step 4, circularly traversing the Set to obtain each Set element, and obtaining the sub-table attribute value of the MetaObject object of each Set element through the MetaObject object of each Set element, wherein the pseudo code is as follows: metaitem, getvalue (sharingfieldname); and splitting the sub-table parameter Set according to the List < single sub-table attribute value > and the sub-table attribute value of the stacking result, and ending.
It should be noted that, the process of obtaining the attribute value of the sub-table is mainly completed by means of the meta object function of Mybatis.
And 5, splitting the sub-table parameters of the Set type according to the List < single sub-table attribute value > of the stacking result, and ending.
And step 6, throwing exception, namely, not supporting sub-table and ending.
4) The sub-table parameters are single objects
i. If the sharingFieldName is empty and the type of the single object is Long, long, integer, int, short, short, byte, byte and String, directly returning to the sub-table parameter;
if the sharingFieldName is not empty and the sub-table attribute is an array of base types (including String), list, set, and single object, then the sub-table parameters are split and reconstructed according to the sub-table attribute values.
The flow of the sub-table parameter reconstruction when the scene sub-table parameter is a single object is as follows:
step 1, obtaining sub-table information SbardingFieldInfo of the Mapper method, and splitting and reconstructing sub-table parameters.
The main contents of the acquired sub-table information shadingfeldinfo are as follows:
shardingArgClazz: dividing the parameter types into table;
isshardingefield array: whether the sub-table attribute is an array;
isshardingefield collection: whether the sub-table attributes are aggregated;
shardingmeldclazz: a sub-table attribute type;
the shardingmeldparameterizer dttypes: the sub-table attribute is of a generic type;
hasshardingefield: whether a sub-table attribute exists.
According to the sub-table attribute value stacking result obtained by sub-table index calculation, namely Map < sub-table index, list < single sub-table attribute value > >, sub-table parameter splitting and reconstruction are circularly carried out; the sub-table parameters are annotated by the Mapper method @ SbardingField, and the flow mainly illustrates that when the sub-table parameters are single objects, the sub-table parameters are split and reconstructed in the following two cases:
If the sharingFieldName is empty and the type of the single object is Long, long, integer, int, short, short, byte, byte and String, directly returning to the sub-table parameter; if the sharingFieldName is not empty and the sub-table attribute is an array, list, set and single object of the base type (including String), then the sub-table parameters are split and reconstructed according to the sub-table attribute values.
Step 2, judging whether the sub-table attribute names do not exist and the sub-table parameter generic type is a basic data type (including String); if not, executing the step 3; if yes, go to step 7.
Step 3, judging whether the sub-table attribute names exist, if yes, executing step 4; if not, go to step 6.
Step 4, splitting the sub-table attribute array according to the List < single sub-table attribute value > of the stacking result, wherein the sub-table attribute type is an array, the array type is a basic type array (including String); the attribute type of the sub-table is List, the generalization is basic data type (including String), and sub-table attribute List splitting is carried out according to the List of the stacking result < single sub-table attribute value >; the sub-table attribute type is Set, the generalized type is basic data type (including String), and sub-table attribute Set splitting is carried out according to the List of the stacking result < single sub-table attribute value >; the sub-table attribute type is a single object, and the type is a basic data type (including String), and the splitting is not needed; the new sub-table attribute value is newshardingefield object.
After step 4, step 5 is continued.
Step 5, copying a new sub-table parameter newShardingArg, and reconstructing; by setting the new sub-table attribute value of the MetaObject object of the new sub-table parameter, pseudo codes such as: metanewshardingearg.setvalue (shardingFieldName, newShardingFieldObject); obtaining new sub-table parameters according to MetaObject of the new sub-table parameters, wherein pseudo codes are as follows: metanewshadingarg.getorigin object (), end.
And step 6, throwing exception, namely, not supporting sub-table and ending.
And 7, directly returning the sub-table parameters, and ending.
(VI) sub-table result polymerization
The sub-table result aggregation is mainly to aggregate the library access results after sub-table parameter reconstruction.
As described above, the sub-table index calculation is used for calculating the sub-table index and returning Map < single sub-table attribute value > of the sub-table strategy, and the sub-table index > is subjected to the stacking treatment, and the stacking result is Map < sub-table index >, list < single sub-table attribute value >;
sub-table parameter reconstruction, namely performing cyclic treatment on the Map < sub-table index > and the List < single sub-table attribute value > based on the stacking result, and splitting and reconstructing sub-table parameters;
the method comprises the steps of aggregating sub-table results, resetting the Mapper method parameters (with a Map or a single object structure) packaged by Mybatis based on the sub-table parameters (the parameters are actual parameters of the Mapper method) of each stack of splitting and reconstruction, then calling a programmed method of solicitation, and performing subsequent flow processing, namely obtaining the query or update result of the new sub-table parameters; and simultaneously writing the sub-table index of each stack into the Threadlocal for SQL substitution of the StatementHandler interceptor.
The processing flow of the sub-table result aggregation is as follows:
step 1, defining an aggregation collection collectilist, wherein the aggregation collection is used for summarizing query results; an aggregate collection is defined, which is used to aggregate the updated results.
Step 2, obtaining a sub-table parameter reconstruction to obtain a new sub-table parameter newShardingArg; if the Mapper method parameter type is Map (here, mybatis encapsulated parameter structure), the sub-table parameter is reset, and the pseudo code is as follows: meta paramobject. Setvalue (shardingArgName, newShardingArg); if not Map, directly replacing parameters, and pseudo codes such as: indocationAnargs [1] = newShardingArg.
It should be noted that, the sub-table result aggregation is used for performing cyclic processing on each new sub-table parameter, and the process mainly describes the processing logic of the cyclic body, and mainly includes the following contents:
based on the split and reconstructed sub-table parameters of each stack (the parameters are actual parameters of the Map method), resetting the Map method parameters (with a Map or a single object) packaged by Mybatis, then calling a programmed method of solicitation, and performing subsequent flow processing, namely obtaining the query or update result of the new sub-table parameters; the sub-table index for each heap is written to ThreadLocal for SQL substitution by the StatementHandler interceptor.
And step 3, setting a sub-table context (stored in a ThreadLocal), and setting whether sub-tables and sub-table index data are used for SQL replacement of the StatementHandler interceptor.
And step 4, whether to query the operation or not, if yes, executing the step 5, and if not, executing the step 6.
And 5, calling a programmed method of the solicitation, storing the query result into a collectionList, and then executing the step 7.
And step 6, calling a programmed method of the solicitation, accumulating the updated result into the collectible AffelectRows, and then executing the step 7.
And 7, clearing the context of the sub-table, inquiring or updating the parameters of the next new sub-table, and ending.
The description is given of a statementHandler interceptor, which is mainly a definition logical table name converter, and is used for replacing the logical table name of the sub-table SQL with the actual table name.
The StatementHandler interceptor mainly intercepts the preparation method of the StatementHandler, modifies the table name in the SQL sentence, and the processing flow is as follows:
step 1, obtaining whether the sub-table and sub-table index data from the sub-table context (stored in the ThreadLocal).
It should be noted that, the StatementHandler interceptor intercepts the preparation method of StatementHandler, and the interceptor entry method is Object interrupt (Invocation Invocation), where the information of solicitation is as follows:
Object target: the object is a StatementHandler object, including objects such as RoutingStatementHandler;
method: the method is a preparation method which is called currently;
object [ ] args: is a parameter of the currently called preparation method.
It should be noted that, the sub-table context is stored in the sub-table result aggregation stage, and whether the sub-table and the sub-table index data are stored.
Step 2, judging whether the sub-table value is empty or not; if not, executing the step 3; if yes, go to step 7.
Step 3, since the StatementHandler is proxied, the MetaObject object of the actual StatementHandler object, i.e., the metaRoutingStatementHandler, is acquired through the MetaObject layer-by-layer recursion, and the pseudo code is as follows:
recursively acquiring metastatementhandler.getvalue ("h");
recursively acquiring metastatementhandler.getvalue ("target");
after step 3 is performed, step 4 is continued.
And 4, acquiring a mappdistent object according to the default.
Step 5, taking out sub-table information from a method name- > sub-table information mapping table according to the id of the MappedStatement, and acquiring a basic table name baseName and a sub-table prefix split TableP refix from the sub-table information; acquiring an SQL statement according to the delete. BoundSql.sql attribute of the metaRoutingStatementHandler; replacing a basic table name (namely a logic table name) in the SQL sentence with a sub-table prefix and a sub-table index, namely an actual table name, and marking the actual table name as a shrringSql; the delete. BoundSql.sql attribute of metaRoutingStatementHandler is reset to be set to sharingSql.
And step 6, calling an indication.
And 7, calling the assignment.process without replacing the logical table name, continuing to circulate the flow, and ending.
The invention processes the sub-table logic in the interceptor uniformly, the whole scheme has lower intrusion to the business logic, realizes decoupling with the business logic, and has clear business code logic. The existing system sub-table modification can be quickly supported without specific names or sub-table parameters of specific types, and batch operation is supported.
Corresponding to fig. 1, the embodiment of the present invention further provides a data processing apparatus, where the apparatus is configured to support a specific implementation of the method shown in fig. 1, and a schematic structural diagram of the apparatus is shown in fig. 6, and the specific description is as follows:
an interception unit 501, configured to intercept, by using a preset first interceptor, a currently invoked database access layer method;
the parsing unit 502 is configured to parse the parameter annotation information of the database access layer method, and obtain metadata of the database access layer method, where the metadata includes a method entity mapping table, a method parameter name parser mapping table, a sub-table information mapping table, and an additional information mapping table;
an obtaining unit 503, configured to obtain, based on metadata of the database access layer method, a sub-table parameter, a sub-table attribute value, and a sub-table additional information value from call information of the database access layer method;
A calculating unit 504, configured to obtain a sub-table policy based on a sub-table policy name of the database access layer method, where in the sub-table policy, index calculation is performed on the sub-table attribute value based on the sub-table attribute value, the sub-table additional information value, and the database access layer method information, to obtain a sub-table index result of the sub-table attribute value;
a reconstruction unit 505, configured to reconstruct the sub-table parameters based on the sub-table index result, obtain each reconstructed sub-table parameter and a sub-table index of each reconstructed sub-table parameter, and store the sub-table index of each reconstructed sub-table parameter to a preset sub-table context;
a replacing unit 506, configured to replace, by a preset second interceptor, a logical table name of a structured query language SQL statement corresponding to each of the reconstructed table parameters based on each of table indexes in the table context with an actual table name, so that each of the reconstructed table parameters performs a library access based on the actual table name of the SQL statement, to obtain a library access result of each of the reconstructed table parameters;
and the aggregation unit 507 is configured to aggregate the library access results of each reconstructed sub-table parameter, so as to obtain a final call result of the database access layer method.
In the device provided by the invention, a currently called database access layer method is intercepted by a first interceptor, parameter annotation information of the database access layer method is analyzed, metadata of the database access layer method is obtained, and sub-table parameters, sub-table attribute values and sub-table additional information values are obtained from calling information of the database access layer method based on the metadata of the database access layer method; obtaining a sub-table strategy based on a sub-table strategy name of a database access layer method, wherein in the sub-table strategy, index calculation is carried out on the sub-table attribute value based on the sub-table attribute value, the sub-table additional information value and the database access layer method information, so as to obtain a sub-table index result of the sub-table attribute value; reconstructing sub-table parameters based on sub-table index results and sub-table attribute values to obtain each reconstructed sub-table parameter and sub-table index of each reconstructed sub-table parameter, and storing the sub-table index of each reconstructed sub-table parameter into a sub-table context so that a second interceptor replaces a logical table name of an SQL sentence of each reconstructed sub-table parameter with an actual table name based on the sub-table context so that each reconstructed sub-table parameter accesses a library based on the actual table name of the SQL sentence to obtain an access library result of each reconstructed sub-table parameter; and aggregating all the database access results to obtain the final calling result of the database access layer method. The invention can realize the modification of the sub-table without changing the system, thereby improving the sub-table efficiency of the data.
In another embodiment of the present invention, the parsing unit of the apparatus includes:
the first acquisition subunit is used for acquiring a first parameter in the parameter array attribute of the calling information by the first interceptor and acquiring a bottom layer packaging object based on the first parameter;
the analysis subunit is used for analyzing the identity attribute of the bottom packaging object to obtain a full-limit class name and a method name;
the second obtaining subunit is used for obtaining the byte code object corresponding to the full-limit class name, determining a method entity corresponding to the method name in the byte code object, and caching the determined method entity to obtain a method entity mapping table;
the caching subunit is used for acquiring a method parameter name resolver based on the bottom packaging object, and caching the method parameter name resolver to obtain a method parameter name resolver mapping table;
a third obtaining subunit, configured to obtain sub-table parameter annotation information of the database access layer method from the parameter annotation information, parse sub-table parameters of the database access layer method and sub-table attributes of the sub-table parameters based on the sub-table parameter annotation information to obtain sub-table information, and cache the sub-table information to obtain a sub-table information mapping table;
And the fourth acquisition subunit is used for acquiring the sub-table additional parameter annotation information of the database access layer method from the parameter annotation information, analyzing the sub-table additional parameter of the database access layer method based on the sub-table additional parameter annotation information to obtain sub-table additional information, and caching the sub-table additional information to obtain an additional information mapping table.
In another embodiment provided by the present invention, an acquisition unit of the apparatus includes:
a fifth obtaining subunit, configured to obtain a second parameter in the parameter array attribute of the call information by using the first interceptor, determine a parameter value of the database access layer method from the second parameter, and process the parameter value by using a method parameter name resolver mapping table in metadata of the database access layer method to obtain a parameter array;
a sixth obtaining subunit, configured to obtain a sub-table parameter index of the database access layer method of sub-table information by using a sub-table information mapping table in metadata of the database access layer method;
a seventh obtaining subunit, configured to obtain a sub-table parameter based on the database access layer method sub-table parameter subscript and the parameter array;
The first determining subunit is used for determining a sub-table scene of the sub-table parameters, and obtaining sub-table information corresponding to the sub-table scene, wherein the sub-table scene is one of an array, a list, a set and a single object;
the execution subunit is used for executing the sub-table flow corresponding to the sub-table scene based on the sub-table information to obtain a sub-table attribute value;
and an eighth obtaining subunit, configured to obtain a sub-table additional information value based on the parameter array and an additional information mapping table in metadata of the database access layer method.
In another embodiment provided by the present invention, a computing unit of the apparatus includes:
a ninth obtaining subunit, configured to obtain sub-table information of the database access layer method from the sub-table information mapping table;
and a tenth acquisition subunit, configured to acquire the sub-table policy from the sub-table policy manager based on the sub-table policy name in the sub-table information.
In another embodiment provided by the present invention, a reconstruction unit of the apparatus includes:
a second determining subunit configured to determine whether the sub-table parameter supports a sub-table based on the sub-table information;
the splitting sub-unit is used for splitting the sub-table parameters by applying the pile-up result in the sub-table index result when determining that the sub-table parameters support sub-tables, so as to obtain each reconstruction sub-table parameter;
And the third determination subunit is used for determining the sub-table index of each reconstruction sub-table parameter based on the sub-table index information in the pile-up result.
The embodiment of the invention also provides a storage medium, which comprises stored instructions, wherein the equipment where the storage medium is located is controlled to execute the data processing method when the instructions run.
The embodiment of the present invention further provides an electronic device, whose structural schematic diagram is shown in fig. 7, specifically including a memory 601, and one or more instructions 602, where the one or more instructions 602 are stored in the memory 601, and configured to be executed by the one or more processors 603 to perform the above-mentioned data processing method by executing the one or more instructions 602.
The specific implementation process and derivative manner of the above embodiments are all within the protection scope of the present invention.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for a system or system embodiment, since it is substantially similar to a method embodiment, the description is relatively simple, with reference to the description of the method embodiment being made in part. The systems and system embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method of data processing, comprising:
intercepting a currently called database access layer method through a preset first interceptor;
analyzing the parameter annotation information of the database access layer method to obtain metadata of the database access layer method, wherein the metadata comprises a method entity mapping table, a method parameter name analyzer mapping table, a sub-table information mapping table and an additional information mapping table;
based on the metadata of the database access layer method, obtaining sub-table parameters, sub-table attribute values and sub-table additional information values from the calling information of the database access layer method;
acquiring a sub-table strategy based on a sub-table strategy name of the database access layer method, and in the sub-table strategy, carrying out index calculation on the sub-table attribute value based on the sub-table attribute value, the sub-table additional information value and the database access layer method information to obtain a sub-table index result of the sub-table attribute value;
reconstructing the sub-table parameters based on the sub-table index result to obtain each reconstructed sub-table parameter and a sub-table index of each reconstructed sub-table parameter, and storing the sub-table index of each reconstructed sub-table parameter to a preset sub-table context;
Replacing a logical table name of a Structured Query Language (SQL) statement corresponding to each reconstruction sub-table parameter with an actual table name through a preset second interceptor based on each sub-table index in the sub-table context, so that each reconstruction sub-table parameter accesses a library based on the actual table name of the SQL statement, and obtaining a library access result of each reconstruction sub-table parameter;
and aggregating the database access results of each reconstructed sub-table parameter to obtain a final calling result of the database access layer method.
2. The method according to claim 1, wherein the parsing the parameter annotation information of the database access layer method to obtain metadata of the database access layer method includes:
the first interceptor acquires a first parameter in the parameter array attribute of the calling information and acquires a bottom layer packaging object based on the first parameter;
analyzing the identity attribute of the bottom packaging object to obtain a fully-defined class name and a method name;
acquiring a byte code object corresponding to the full-limit class name, determining a method entity corresponding to the method name in the byte code object, and caching the determined method entity to obtain a method entity mapping table;
Acquiring a method parameter name analyzer based on the bottom layer encapsulation object, and caching the method parameter name analyzer to obtain a method parameter name analyzer mapping table;
the sub-table parameter annotation information of the database access layer method is obtained from the parameter annotation information, the sub-table parameters of the database access layer method and the sub-table attributes of the sub-table parameters are analyzed based on the sub-table parameter annotation information to obtain sub-table information, and the sub-table information is cached to obtain a sub-table information mapping table;
and acquiring sub-table additional parameter annotation information of the database access layer method from the parameter annotation information, analyzing the sub-table additional parameter of the database access layer method based on the sub-table additional parameter annotation information to obtain sub-table additional information, and caching the sub-table additional information to obtain an additional information mapping table.
3. The method according to claim 1, wherein the obtaining the sub-table parameter, the sub-table attribute value, and the sub-table additional information value from the call information of the database access layer method based on the metadata of the database access layer method includes:
The first interceptor acquires a second parameter in the parameter array attribute of the calling information, determines a parameter value of the database access layer method from the second parameter, and processes the parameter value by applying a method parameter name parser mapping table in metadata of the database access layer method to obtain a parameter array;
obtaining sub-table parameter subscripts of the database access layer method of sub-table information by using sub-table information mapping tables in metadata of the database access layer method;
obtaining sub-table parameters based on the sub-table parameter subscript of the database access layer method and the parameter array;
determining a sub-table scene of the sub-table parameters, and acquiring sub-table information corresponding to the sub-table scene, wherein the sub-table scene is one of an array, a list, a set and a single object;
based on the sub-table information, executing a sub-table flow corresponding to the sub-table scene to obtain a sub-table attribute value;
and acquiring sub-table additional information values based on the parameter array and an additional information mapping table in metadata of the database access layer method.
4. The method of claim 1, wherein the obtaining the sub-table policy based on the sub-table policy name of the database access layer method comprises:
Obtaining sub-table information of the database access layer method from the sub-table information mapping table;
and acquiring the sub-table strategy from a sub-table strategy manager based on the sub-table strategy name in the sub-table information.
5. A method according to claim 3, wherein reconstructing the sub-table parameters based on the sub-table index results to obtain the respective reconstructed sub-table parameters and the sub-table index of each of the reconstructed sub-table parameters comprises:
determining whether the sub-table parameters support sub-tables based on the sub-table information;
when the sub-table parameters are determined to support sub-tables, splitting the sub-table parameters by using a pile-up result in the sub-table index result to obtain each reconstructed sub-table parameter;
and determining the sub-table index of each reconstruction sub-table parameter based on the sub-table index information in the stacking result.
6. A data processing apparatus, comprising:
the interception unit is used for intercepting a currently called database access layer method through a preset first interceptor;
the analyzing unit is used for analyzing the parameter annotation information of the database access layer method and obtaining metadata of the database access layer method, wherein the metadata comprises a method entity mapping table, a method parameter name analyzer mapping table, a sub-table information mapping table and an additional information mapping table;
The acquisition unit is used for acquiring sub-table parameters, sub-table attribute values and sub-table additional information values from the calling information of the database access layer method based on the metadata of the database access layer method;
the calculation unit is used for acquiring a sub-table strategy based on the sub-table strategy name of the database access layer method, and in the sub-table strategy, index calculation is carried out on the sub-table attribute value based on the sub-table attribute value, the sub-table additional information value and the database access layer method information to obtain a sub-table index result of the sub-table attribute value;
the reconstruction unit is used for reconstructing the sub-table parameters based on the sub-table index result to obtain each reconstructed sub-table parameter and the sub-table index of each reconstructed sub-table parameter, and storing the sub-table index of each reconstructed sub-table parameter to a preset sub-table context;
the replacing unit is used for replacing the logical table name of the SQL statement corresponding to each reconstruction sub-table parameter with an actual table name based on each sub-table index in the sub-table context through a preset second interceptor so that each reconstruction sub-table parameter accesses a library based on the actual table name of the SQL statement to obtain a library access result of each reconstruction sub-table parameter;
And the aggregation unit is used for aggregating the database access results of each reconstruction sub-table parameter to obtain the final calling result of the database access layer method.
7. The apparatus of claim 6, wherein the parsing unit comprises:
the first acquisition subunit is used for acquiring a first parameter in the parameter array attribute of the calling information by the first interceptor and acquiring a bottom layer packaging object based on the first parameter;
the analysis subunit is used for analyzing the identity attribute of the bottom packaging object to obtain a full-limit class name and a method name;
the second obtaining subunit is used for obtaining the byte code object corresponding to the full-limit class name, determining a method entity corresponding to the method name in the byte code object, and caching the determined method entity to obtain a method entity mapping table;
the caching subunit is used for acquiring a method parameter name resolver based on the bottom packaging object, and caching the method parameter name resolver to obtain a method parameter name resolver mapping table;
a third obtaining subunit, configured to obtain sub-table parameter annotation information of the database access layer method from the parameter annotation information, parse sub-table parameters of the database access layer method and sub-table attributes of the sub-table parameters based on the sub-table parameter annotation information to obtain sub-table information, and cache the sub-table information to obtain a sub-table information mapping table;
And the fourth acquisition subunit is used for acquiring the sub-table additional parameter annotation information of the database access layer method from the parameter annotation information, analyzing the sub-table additional parameter of the database access layer method based on the sub-table additional parameter annotation information to obtain sub-table additional information, and caching the sub-table additional information to obtain an additional information mapping table.
8. The apparatus of claim 6, wherein the acquisition unit comprises:
a fifth obtaining subunit, configured to obtain a second parameter in the parameter array attribute of the call information by using the first interceptor, determine a parameter value of the database access layer method from the second parameter, and process the parameter value by using a method parameter name resolver mapping table in metadata of the database access layer method to obtain a parameter array;
a sixth obtaining subunit, configured to obtain a sub-table parameter index of the database access layer method of sub-table information by using a sub-table information mapping table in metadata of the database access layer method;
a seventh obtaining subunit, configured to obtain a sub-table parameter based on the database access layer method sub-table parameter subscript and the parameter array;
The first determining subunit is used for determining a sub-table scene of the sub-table parameters, and obtaining sub-table information corresponding to the sub-table scene, wherein the sub-table scene is one of an array, a list, a set and a single object;
the execution subunit is used for executing the sub-table flow corresponding to the sub-table scene based on the sub-table information to obtain a sub-table attribute value;
and an eighth obtaining subunit, configured to obtain a sub-table additional information value based on the parameter array and an additional information mapping table in metadata of the database access layer method.
9. A storage medium comprising stored instructions, wherein the instructions, when executed, control a device in which the storage medium is located to perform the data processing method of any one of claims 1-5.
10. An electronic device comprising a memory and one or more instructions, wherein the one or more instructions are stored in the memory and configured to perform the data processing method of any of claims 1-5 by one or more processors.
CN202211114691.9A 2022-09-14 2022-09-14 Data processing method and device, storage medium and electronic equipment Pending CN117743422A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211114691.9A CN117743422A (en) 2022-09-14 2022-09-14 Data processing method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211114691.9A CN117743422A (en) 2022-09-14 2022-09-14 Data processing method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN117743422A true CN117743422A (en) 2024-03-22

Family

ID=90253199

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211114691.9A Pending CN117743422A (en) 2022-09-14 2022-09-14 Data processing method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN117743422A (en)

Similar Documents

Publication Publication Date Title
US7599948B2 (en) Object relational mapping layer
CN102982075B (en) Support to access the system and method for heterogeneous data source
JP5431513B2 (en) Interpreting command scripts using local and extended storage for command indexing
US7386609B2 (en) Method, system, and program for managing devices in a network
KR101365832B1 (en) Data access layer class generator
US7480898B2 (en) System and method for building full batch test environments
US20070074158A1 (en) Method and system for creating reusable software components through a uniform interface
WO2022126983A1 (en) Electronic report file export method, apparatus and device, and storage medium
US7480661B2 (en) Query services for database system
US20090043778A1 (en) Generating etl packages from template
US8019791B2 (en) Method and system for transforming metadata modeled in the common information model into grid control target metadata
WO2012150316A1 (en) Fine-grained relational database access-control policy enforcement using reverse queries
CN106126540A (en) Data base access system and access method thereof
CN108038213A (en) A kind of method of data processing, client, server and system
CN111259067B (en) Method, device and equipment for realizing DAO interface based on Spring
US11061964B2 (en) Techniques for processing relational data with a user-defined function (UDF)
US10140347B2 (en) Exposing data to query generating applications using usage profiles
CN110781183A (en) Method and device for processing incremental data in Hive database and computer equipment
CN112434015A (en) Data storage method and device, electronic equipment and medium
CN111443901A (en) Business expansion method and device based on Java reflection
KR20140048396A (en) System and method for searching file in cloud storage service, and method for controlling file therein
CN108984631A (en) A kind of generation of big data and call method and device
CN117743422A (en) Data processing method and device, storage medium and electronic equipment
CN116204540A (en) Operation log recording method, device, equipment and storage medium
US7085759B2 (en) System and method for communicating data to a process

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination