A horizontal table splitting method and device, electronic equipment and storage medium

By obtaining the business type of the business table and performing horizontal table partitioning, creating a partitioning implementation class and storing it in the Spring container, and using index values ​​to associate with the proxy class interface, the problem of high repetitive code in horizontal table partitioning of the database is solved, and the flexibility and maintainability of the code are improved.

CN115599787BActive Publication Date: 2026-05-15PING AN BANK CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PING AN BANK CO LTD
Filing Date
2022-10-25
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing technologies suffer from high levels of duplicate and redundant code, as well as low code flexibility when performing horizontal table partitioning in databases. In particular, the code readability and maintainability are poor, and modifications are frequent when performing multi-table queries.

Method used

Horizontal table partitioning is performed by obtaining the business type of the business table, creating implementation classes for the partitioning and storing them in the Spring container, using index values ​​to associate with proxy class interfaces, and inheriting the data access object interface in the Spring container to implement the table partitioning operation.

Benefits of technology

It reduces the amount of duplicate and redundant code, improves the flexibility, readability and maintainability of the code, and simplifies the operation of the business logic layer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115599787B_ABST
    Figure CN115599787B_ABST
Patent Text Reader

Abstract

The application discloses a horizontal table splitting method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring the service type of all data of a service table, performing a horizontal table splitting operation on the service table according to the service type to obtain a plurality of sub-tables; establishing the implementation class of each sub-table and the index value corresponding to the implementation class according to the service type of each sub-table, and storing the implementation class of each sub-table into a spring container, wherein each implementation class shares one data access object interface; associating the index value with a preset proxy class interface, and making the proxy class interface inherit the data access object interface in the spring container, so as to find the implementation class of the corresponding sub-table in the spring container through the index value. The application solves the technical problems of high repeated code amount and redundant code amount and low code flexibility in the current table splitting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, specifically to a horizontal table partitioning method, apparatus, electronic device, and storage medium. Background Technology

[0002] When a single table's data volume increases too rapidly or reaches tens or even hundreds of millions of records, the database will experience performance bottlenecks, manifesting as a large number of blocked requests, slower SQL operations, and storage problems. However, if the single database storage does not experience storage bottlenecks and there is no need for database-level sharding, how can we leverage application-level capabilities to implement horizontal table partitioning to avoid creating large tables without increasing system complexity?

[0003] The typical solution is to divide the database into multiple tables based on specific functional levels. Each table has a corresponding mapper mapping and DAO layer. When the business logic layer performs DML operations on the database, it calls the corresponding JavaBean interface class to operate on the object.

[0004] However, as the number of tables increases and the redundant code in the DAO layer also increases, especially when multi-table queries are required on the overall table, the readability and maintainability of the code become increasingly worse (previously, when using large tables, only one table needed to be operated on, but now multiple tables need to be operated on).

[0005] The problems arising from existing technologies are obvious, specifically...

[0006] Problem 1: The multiple DAO layer interface classes resulting from horizontal table partitioning have a lot of hard-coded code and poor flexibility.

[0007] Question 2: Redundant code causes difficulties in code maintenance;

[0008] Question 3: The changes to the original code's business logic layer are quite significant.

[0009] Therefore, there is an urgent need for a table partitioning method that can reduce the amount of duplicate and redundant code and improve the flexibility of the code. Summary of the Invention

[0010] The purpose of this invention is to overcome the above-mentioned technical deficiencies and provide a horizontal table partitioning method, apparatus, electronic device and storage medium applicable to financial technology or other related technical fields, solving the technical problems of high amount of duplicate and redundant code and low code flexibility in the prior art when partitioning tables.

[0011] To achieve the above-mentioned technical objectives, the present invention adopts the following technical solution:

[0012] In a first aspect, the present invention provides a method for horizontal table partitioning, comprising the following steps:

[0013] Retrieve the business type of all data in the business table, and perform horizontal table partitioning on the business table according to the business type to obtain multiple partitioned tables;

[0014] Based on the business type of each sub-table, establish the implementation class of each sub-table and the index value corresponding to the implementation class, and store the implementation class of each sub-table in the Spring container. Each implementation class shares a data access object interface.

[0015] The index value is associated with a preset proxy class interface, and the proxy class interface inherits the data access object interface in the Spring container, so as to find the corresponding implementation class of the table partitioning in the Spring container through the index value.

[0016] In some embodiments, the business type for obtaining all data in the business table, and the horizontal partitioning of the business table according to the business type to obtain multiple partitioned tables, include:

[0017] Obtain the attribute tags of all data in the business table, and determine the business type of all data in the business table based on the attribute tags;

[0018] Based on the preset database sharding and table partitioning principles, data with the same business type are allocated to the same partitioned table to obtain multiple partitioned tables storing data with different business types.

[0019] In some embodiments, according to preset database sharding and table partitioning principles, data of the same business type are allocated to the same partitioned table to obtain multiple partitioned tables storing data of different business types, including:

[0020] Generate database sharding and table partitioning scripts based on preset database sharding and table partitioning principles;

[0021] Run the database sharding and table partitioning script to allocate data of the same business type to the same partitioned table, resulting in multiple partitioned tables storing data of different business types.

[0022] In some embodiments, the step of establishing implementation classes for each sub-table and corresponding index values ​​for each implementation class based on the business type of each sub-table, and storing the implementation classes of each sub-table in the Spring container, includes:

[0023] Based on the number of each partition table, create an index value that is the same as the number of partition tables, and assign it to each partition table;

[0024] Based on the business type of the partitioned table, an implementation class for the partitioned table is created, and the implementation class is associated with the index value;

[0025] The implementation classes of each of the aforementioned tables are stored in a pre-defined Spring container.

[0026] In some embodiments, the index value is unique, and each index value corresponds to a unique implementation class.

[0027] In some embodiments, the index value is an enumeration class associated with the business type.

[0028] In some embodiments, the horizontal table partitioning method further includes:

[0029] Update the business table, determine whether new business type data has been added to the business table, if so, create a new sub-table, a sub-table implementation class and an index value corresponding to the implementation class according to the new business type, store the implementation class in the Spring container, and associate the new index value with the preset proxy class interface.

[0030] Secondly, the present invention provides a horizontal table division device, comprising:

[0031] The table partitioning module is used to obtain the business type of all data in the business table, and perform horizontal table partitioning operation on the business table according to the business type to obtain multiple partitioned tables;

[0032] A module is established to create implementation classes for each sub-table and corresponding index values ​​for each implementation class based on the business type of each sub-table, and to store the implementation classes of each sub-table in the Spring container. Each implementation class shares a data access object interface.

[0033] The association module is used to associate the index value with a preset proxy class interface, and to make the proxy class interface inherit the data access object interface in the Spring container, so as to find the corresponding implementation class of the table partitioning in the Spring container through the index value.

[0034] Thirdly, the present invention also provides an electronic device, comprising: a processor and a memory;

[0035] The memory stores computer programs that can be executed by the processor;

[0036] When the processor executes the computer program, it implements the steps in the horizontal table partitioning method described above.

[0037] Fourthly, the present invention also provides a computer-readable storage medium storing one or more programs that can be executed by one or more processors to implement the steps in the horizontal table partitioning method described above.

[0038] Compared with existing technologies, the horizontal table partitioning method, apparatus, electronic device, and storage medium provided by this invention first obtain the business types of all data in a business table, then perform horizontal table partitioning on the business table according to the business types to obtain multiple partitions. Next, based on the business types of each partition, an implementation class and an index value corresponding to each implementation class are established, and the implementation classes of each partition are stored in a Spring container. Finally, the index value is associated with a preset proxy class interface, and the proxy class interface inherits the data access object interface in the Spring container, so that the corresponding implementation class of the partition can be found in the Spring container through the index value. By combining the database layer and the application layer to implement horizontal table partitioning, the problem of needing to write code multiple times for multiple business scenarios is solved. Compared with traditional table partitioning methods, the amount of repetitive and redundant code is greatly reduced, while the flexibility of the code is improved. Attached Figure Description

[0039] Figure 1 This is a flowchart of the horizontal table partitioning method provided in an embodiment of the present invention;

[0040] Figure 2 This is a flowchart of step S100 in the horizontal table partitioning method provided in this embodiment of the invention;

[0041] Figure 3 This is a flowchart of step S200 in the horizontal table partitioning method provided in this embodiment of the invention;

[0042] Figure 4 This is a schematic diagram of the functional modules of the horizontal table sub-metering device provided in an embodiment of the present invention;

[0043] Figure 5 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation

[0044] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0045] Please see Figure 1 , Figure 1This is a flowchart illustrating a horizontal table partitioning method provided by an embodiment of the present invention. The horizontal table partitioning method of the present invention can be used for horizontal table partitioning in databases in the banking and other financial fields to reduce the amount of duplicate and redundant code generated during table partitioning, thereby improving code flexibility. The horizontal table partitioning method of the present invention can be executed by an electronic device capable of receiving or sending data. This electronic device can be various electronic devices with a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptops, and desktop servers. Figure 1 As shown, the method specifically includes the following steps S100 to S300.

[0046] S100. Obtain the business type of all data in the business table, and perform horizontal table partitioning on the business table according to the business type to obtain multiple partitioned tables.

[0047] In this embodiment, the private equity post-investment service platform needs to send a large number of SMS messages, WeChat messages, and intranet emails to clients and financial managers every day. Previously, the SMS, WeChat, and email tables were all large tables, which may have caused database performance bottlenecks during use. Therefore, this embodiment of the invention performs table partitioning on the business table according to the business type of the data to avoid performance bottlenecks, large number of request blocking, slow SQL operations, storage problems, and other issues that affect database usage.

[0048] For example, taking the horizontal partitioning of the SMS table as an example, the SMS master table is horizontally partitioned into 7 tables based on business scenarios: Product Announcement Report SMS Table (XpSmsInfoCpggbgDAOImpl), Product Open Day SMS Table (XpSmsInfoCpkfrDAOImpl), Asset Maturity Acceptance SMS Table (XpSmsInfoDqcjDAOImpl), Product Maturity SMS Table (XpSmsInfoDqDAOImpl), Refund SMS Table (XpSmsInfoTpDAOImpl), Product Early Maturity SMS Table (XpSmsInfoTqdqDAOImpl), and Performance Compensation Accrual SMS Table (XpSmsInfoYjbcjtDAOImpl). The SMS master table is divided according to the business scenarios described in each data point to achieve the purpose of horizontal table partitioning.

[0049] S200. Based on the business type of each sub-table, establish the implementation class of each sub-table and the index value corresponding to the implementation class, and store the implementation class of each sub-table in the Spring container. The implementation classes of each sub-table share a data access object interface.

[0050] In this embodiment, Spring's ApplicationObjectSupport interface class is introduced, combined with Java's polymorphism to design a proxy class to implement horizontal table partitioning. This not only solves the performance bottleneck of large tables but also improves code flexibility, readability, and maintainability. Specifically, in this embodiment, multiple partitioned DAOs are injected into the Spring container. These multiple partitioned DAOs implement the same interface, XpSmsInfoBaseDao. Therefore, all implementation classes of this interface can be obtained using the following code:

[0051] Map<String,XpSmsInfoBaseDao> smsProcessors=applicationContext.getBeansOfType(XpSmsInfoBaseDao.class);

[0052] In addition, in this embodiment, the obtained multiple implementation classes are placed into the proxy global variable (Map) xpSmsInfoBaseDaoImpls. The business layer only needs to pass in the corresponding index value to obtain the implementation class of DAO, thereby achieving the purpose of indirectly operating the DAO implementation class.

[0053] S300. Associate the index value with a preset proxy class interface, and make the proxy class interface inherit the data access object interface in the Spring container, so as to find the corresponding implementation class of the table partitioning in the Spring container through the index value.

[0054] In this embodiment, the proxy class that the business logic layer depends on inherits the SMS DAO layer interface class, and obtains the SMS table DAO implementation class corresponding to the business scenario from the Spring container according to the index value, which solves the problem of a large amount of redundant code caused by horizontal table partitioning.

[0055] This invention achieves the same ultimate goal of horizontal table partitioning by combining the DB layer and the application layer: reducing database load and shortening query time. The designed proxy class implements DML operations on the SMS table, solving the problem of a large amount of redundant code caused by horizontal table partitioning, improving code readability and maintainability. By operating the database through the proxy, it is the same as operating on large tables in the past. The business logic layer does not need to care about which table the data is read from or written to, keeping the code clean.

[0056] This invention first obtains the business types of all data in a business table. Based on these business types, the business table is horizontally partitioned to obtain multiple sub-tables. Then, based on the business types of each sub-table, an implementation class and its corresponding index value are created. These implementation classes are stored in a Spring container. Finally, the index value is associated with a preset proxy class interface, and this proxy class interface inherits from the data access object interface in the Spring container. This allows the corresponding implementation class of the sub-table to be found within the Spring container using the index value. By combining the database layer and the application layer to implement horizontal partitioning, the problem of needing to write multiple code snippets for multiple business scenarios is solved. Compared to traditional partitioning methods, the amount of repetitive and redundant code is significantly reduced, while code flexibility is improved.

[0057] In some embodiments, please refer to Figure 2 Step S200 specifically includes:

[0058] S210. Obtain the attribute tags of all data in the business table, and determine the business type of all data in the business table based on the attribute tags;

[0059] S220. Based on the preset database sharding and table partitioning principles, allocate data of the same business type to the same partitioned table to obtain multiple partitioned tables storing data of different business types.

[0060] In this embodiment, all data in the business table is first analyzed to obtain its attribute tags. The attribute tags are used to identify the business type to which the business table belongs, such as product announcement report, product open day, asset maturity acceptance, product maturity, ticket refund, product early maturity, performance fee accrual, etc. The attribute tags can quickly classify all data in the business table.

[0061] Once the attribute tags are obtained, table partitioning can be performed according to the preset database partitioning and table partitioning principles, allocating data with the same business type to the same partitioned table, thereby achieving the purpose of table partitioning.

[0062] The sharding principles can be customized by the user, as long as data of the same business type is assigned to the same shard. For example, the sharding principle is based on the attribute tags, specifically the time field within the attribute tags. For instance, when sharding, data of the same business type is assigned to the same shard, and then the data in the shard is sorted according to the time field, resulting in a neatly sorted shard.

[0063] In some embodiments, step S220 specifically includes:

[0064] Generate database sharding and table partitioning scripts based on preset database sharding and table partitioning principles;

[0065] Run the database sharding and table partitioning script to allocate data of the same business type to the same partitioned table, resulting in multiple partitioned tables storing data of different business types.

[0066] In this embodiment, a database sharding script is generated according to a preset database sharding and table partitioning principle. The database sharding and table partitioning script is a file used to perform database sharding and table partitioning operations. The database sharding and table partitioning script can identify the attribute tags of the file data and extract the time field and business type. Then, it performs database sharding and table partitioning operations based on the business type and time field to obtain the table partitioning required by the user.

[0067] In some embodiments, please refer to Figure 3 Step S300 specifically includes:

[0068] S310. Based on the number of each sub-table, create an index value that is the same as the number of sub-tables, and assign it to each sub-table;

[0069] S320. Based on the business type of the partitioned table, establish the implementation class of the partitioned table and associate the implementation class with the index value;

[0070] S330. Store the implementation classes of each of the sub-tables into a preset Spring container.

[0071] In this embodiment, Spring's ApplicationObjectSupport interface class is introduced, combined with Java's polymorphism to design a proxy class to implement horizontal table partitioning. Firstly, to quickly locate the implementation class of each partitioned table, each implementation class has a unique index value. This index value allows for quick retrieval of the corresponding implementation class through the unique shared data access object interface of each implementation class, thus enabling the query operation. The index value can be set according to user needs, as long as it facilitates querying.

[0072] In some embodiments, the index value is unique, and each index value corresponds to a unique implementation class.

[0073] In this embodiment, to avoid finding multiple implementation classes with the same index value, the implementation class is set to unique, and each index value corresponds to only one implementation class. Therefore, when the business logic layer inputs a unique index value, only the implementation class of the unique table will be found, thus facilitating user queries. Of course, in other embodiments, the index value may not be set to unique, that is, one index value can find multiple implementation classes, but in this case, the user needs to manually filter the required implementation class.

[0074] In some embodiments, the index value is an enumeration class associated with the business type.

[0075] For example, when the business logic layer indirectly calls the DAO to operate the database via a proxy, the usage is similar to operating a large table in the DAO; it only requires adding an enumeration value parameter representing the business scenario. The code is shown below:

[0076] entity.setBizScene(BizSceneEnum.CPKFR); / / Set the business scenario enumeration.

[0077] By combining the database layer and the application layer to achieve horizontal table partitioning, the design concept is similar to Spring AOP aspect-oriented programming, which solves the problem of having to write code multiple times for multiple business scenarios.

[0078] In some embodiments, the horizontal table partitioning method further includes:

[0079] Update the business table, determine whether new business type data has been added to the business table, if so, create a new sub-table, a sub-table implementation class and an index value corresponding to the implementation class according to the new business type, store the implementation class in the Spring container, and associate the new index value with the preset proxy class interface.

[0080] In this embodiment, when a new business scenario requires the creation of a corresponding sharded table, it is only necessary to add one more business scenario enumeration value as an input parameter. Developers only need to create the database table and maintain the corresponding SQLMapper.xml mapping file. There is no need to rewrite redundant DAO layer code, which saves developers' energy and allows them to focus more on writing business logic layer code.

[0081] The technical solution provided by this invention first obtains the business types of all data in a business table. Then, it performs horizontal partitioning on the business table based on these business types to obtain multiple partitioned tables. Next, based on the business types of each partitioned table, it establishes an implementation class for each partitioned table and an index value corresponding to that implementation class. These implementation classes are then stored in a Spring container. Finally, the index values ​​are associated with a preset proxy class interface, and this proxy class interface inherits from the data access object interface in the Spring container. This allows the corresponding implementation class of the partitioned table to be found within the Spring container using the index value. By combining the database layer and the application layer to implement horizontal partitioning, the problem of needing to write code multiple times for multiple business scenarios is solved. Compared with traditional partitioning methods, the amount of repetitive and redundant code is greatly reduced, while the flexibility of the code is improved.

[0082] Another embodiment of the present invention provides a horizontal table division device; please refer to [link to relevant documentation]. Figure 4 The horizontal table partitioning device includes a code partitioning module 11, a creation module 12, and an association module 13.

[0083] The table partitioning module 11 is used to obtain the business type of all data in the business table, and perform horizontal table partitioning operation on the business table according to the business type to obtain multiple partitioned tables.

[0084] The module 12 is used to create implementation classes for each sub-table and corresponding index values ​​for each implementation class according to the business type of each sub-table, and to store the implementation classes of each sub-table in the Spring container. Each implementation class shares a data access object interface.

[0085] The association module 13 is used to associate the index value with a preset proxy class interface and make the proxy class interface inherit the data access object interface in the Spring container, so as to find the corresponding implementation class of the table partitioning in the Spring container through the index value.

[0086] This invention first obtains the business types of all data in a business table. Based on these business types, the business table is horizontally partitioned to obtain multiple sub-tables. Then, based on the business types of each sub-table, an implementation class and its corresponding index value are created. These implementation classes are stored in a Spring container. Finally, the index value is associated with a preset proxy class interface, and this proxy class interface inherits from the data access object interface in the Spring container. This allows the corresponding implementation class of the sub-table to be found within the Spring container using the index value. By combining the database layer and the application layer to implement horizontal partitioning, the problem of needing to write code multiple times for multiple business scenarios is solved. Compared to traditional partitioning methods, the amount of repetitive and redundant code is greatly reduced, while code flexibility is improved.

[0087] It should be noted that the module referred to in this invention refers to a series of computer program instruction segments that can perform specific functions. It is more suitable than a program for describing the execution process of metadata completeness detection. For the specific implementation of each module, please refer to the corresponding method embodiments above, which will not be repeated here.

[0088] In some embodiments, the table partitioning module 11 includes an attribute tag acquisition unit and an allocation unit.

[0089] The attribute tag acquisition unit is used to acquire the attribute tags of all data in the business table, and determine the business type of all data in the business table based on the attribute tags.

[0090] The allocation unit is used to allocate data of the same business type to the same partition table according to the preset database sharding and table partitioning principles, so as to obtain multiple partition tables storing data of different business types.

[0091] In some embodiments, the allocation unit is specifically used for:

[0092] Generate a database sharding and table partitioning script based on the preset database sharding and table partitioning principles;

[0093] Run the database sharding and table partitioning script to allocate data of the same business type to the same partitioned table, resulting in multiple partitioned tables storing data of different business types.

[0094] In some embodiments, the establishment module 12 includes an index value creation unit, an implementation class creation unit, and a storage unit.

[0095] The index value creation unit is used to create index values ​​equal to the number of sub-tables, and allocate them to each sub-table.

[0096] The implementation class creation unit is used to create an implementation class for the partitioned table according to the business type of the partitioned table, and associate the implementation class with the index value.

[0097] The storage unit is used to store the implementation classes of each of the partitioned tables into a preset Spring container.

[0098] In some embodiments, the index value is unique, and each index value corresponds to a unique implementation class.

[0099] In some embodiments, the index value is an enumeration class associated with the business type.

[0100] In some embodiments, the horizontal table partitioning device further includes an update module, used to update the business table, determine whether new business type data has been added to the business table, and if so, create a new partition, a partition implementation class, and an index value corresponding to the implementation class according to the new business type, store the implementation class in the Spring container, and associate the new index value with a preset proxy class interface.

[0101] Another embodiment of the present invention provides an electronic device, such as... Figure 5 As shown, the electronic device 10 includes:

[0102] One or more processors 110 and memory 120, Figure 5 The following description uses a processor 110 as an example. The processor 110 and the memory 120 can be connected via a bus or other means. Figure 5 Taking the example of a connection between China and Israel via a bus.

[0103] Processor 110 is used to perform various control logics of electronic device 10. It can be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), microcontroller, ARM (Acorn RISC Machine) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. Furthermore, processor 110 can also be any conventional processor, microprocessor, or state machine. Processor 110 can also be implemented as a combination of computing devices, such as a combination of DSP and microprocessor, multiple microprocessors, one or more microprocessors combined with DSP and / or any other such configuration.

[0104] The memory 120, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions corresponding to the horizontal table partitioning method in the embodiments of the present invention. The processor 110 executes various functional applications and data processing of the electronic device 10 by running the non-volatile software programs, instructions, and units stored in the memory 120, thereby implementing the horizontal table partitioning method in the above-described method embodiments.

[0105] The memory 120 may include a program storage area and a data storage area. The program storage area may store applications required for the operating platform and at least one function; the data storage area may store data created based on the use of the electronic device 10. Furthermore, the memory 120 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 120 may optionally include memory remotely located relative to the processor 110, and these remote memories may be connected to the electronic device 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0106] One or more units are stored in memory 120. When executed by one or more processors 110, they perform the horizontal partitioning method in any of the above method embodiments, for example, the method described above. Figure 1 The method steps S100 to S300.

[0107] Another embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions that are executed by one or more processors, for example, to perform the above-described instructions. Figure 1 The method steps S100 to S300.

[0108] As an example, computer-readable storage media can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) as external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The memory components or memories disclosed in the operating environment described herein are intended to include one or more of these and / or any other suitable types of memory.

[0109] In summary, the horizontal table partitioning method, apparatus, electronic device, and storage medium provided by this invention first obtain the business types of all data in a business table. Then, based on the business types, the business table is horizontally partitioned to obtain multiple partitions. Next, based on the business types of each partition, an implementation class and its corresponding index value are established. These implementation classes are stored in a Spring container. Finally, the index values ​​are associated with a preset proxy class interface, and the proxy class interface inherits the data access object interface in the Spring container. This allows the corresponding implementation class of the partition to be found in the Spring container using the index value. By combining the database layer and the application layer to implement horizontal table partitioning, the problem of needing to write code multiple times for multiple business scenarios is solved. Compared with traditional table partitioning methods, the amount of repetitive and redundant code is greatly reduced, while the flexibility of the code is improved.

[0110] The specific embodiments of the present invention described above do not constitute a limitation on the scope of protection of the present invention. Any other corresponding changes and modifications made in accordance with the technical concept of the present invention should be included within the scope of protection of the claims of the present invention.

Claims

1. A method for horizontal table partitioning, characterized in that, Includes the following steps: Retrieve the business type of all data in the business table, and perform horizontal table partitioning on the business table according to the business type to obtain multiple partitioned tables; Based on the business type of each sub-table, establish the implementation class of each sub-table and the index value corresponding to the implementation class, and store the implementation class of each sub-table in the Spring container. Each implementation class shares a data access object interface. Associate the index value with a preset proxy class interface, and make the proxy class interface inherit the data access object interface in the Spring container, so as to find the corresponding implementation class of the table partitioning in the Spring container through the index value; The step of establishing implementation classes for each sub-table and corresponding index values ​​for each implementation class based on the business type of each sub-table, and storing the implementation classes of each sub-table in the Spring container, includes: Based on the number of each partition table, create an index value that is the same as the number of partition tables, and assign it to each partition table; Based on the business type of the partitioned table, an implementation class for the partitioned table is created, and the implementation class is associated with the index value; The implementation classes of each of the aforementioned tables are stored in a pre-defined Spring container; The proxy class that the business logic layer depends on inherits the DAO layer interface class, and obtains the corresponding DAO implementation class for the business scenario from the Spring container based on the index value.

2. The horizontal table partitioning method according to claim 1, characterized in that, The business type that retrieves all data from the business table, based on the business type, performs a horizontal table partitioning operation on the business table to obtain multiple partitioned tables, including: Obtain the attribute tags of all data in the business table, and determine the business type of all data in the business table based on the attribute tags; Based on the preset database sharding and table partitioning principles, data with the same business type are allocated to the same partitioned table to obtain multiple partitioned tables storing data with different business types.

3. The horizontal table partitioning method according to claim 2, characterized in that, Based on the preset database sharding and table partitioning principles, data with the same business type is allocated to the same partitioned table, resulting in multiple partitioned tables storing data with different business types, including: Generate database sharding and table partitioning scripts based on preset database sharding and table partitioning principles; Run the database sharding and table partitioning script to allocate data of the same business type to the same partitioned table, resulting in multiple partitioned tables storing data of different business types.

4. The horizontal table partitioning method according to claim 1, characterized in that, Each index value is unique, and each index value corresponds to a unique implementation class.

5. The horizontal table partitioning method according to claim 1, characterized in that, The index value is an enumeration class related to the business type.

6. The horizontal table partitioning method according to claim 1, characterized in that, Also includes: Update the business table, determine whether new business type data has been added to the business table, if so, create a new sub-table, a sub-table implementation class and an index value corresponding to the implementation class according to the new business type, store the implementation class in the Spring container, and associate the new index value with the preset proxy class interface.

7. A horizontal metering device, characterized in that, include: The table partitioning module is used to obtain the business type of all data in the business table, and perform horizontal table partitioning operation on the business table according to the business type to obtain multiple partitioned tables; A module is established to create implementation classes for each sub-table and corresponding index values ​​for each implementation class based on the business type of each sub-table, and to store the implementation classes of each sub-table in the Spring container. Each implementation class shares a data access object interface. The association module is used to associate the index value with a preset proxy class interface, and make the proxy class interface inherit the data access object interface in the Spring container, so as to find the corresponding implementation class of the table partitioning in the Spring container through the index value; The establishment module includes an index value creation unit, an implementation class creation unit, and a storage unit. The index value creation unit is used to create index values ​​equal to the number of each sub-table, and allocate them to each sub-table; The implementation class creation unit is used to create an implementation class for the partitioned table according to the business type of the partitioned table, and associate the implementation class with the index value; The storage unit is used to store the implementation classes of each of the partitioned tables into a preset Spring container; The proxy class that the business logic layer depends on inherits the DAO layer interface class, and obtains the corresponding DAO implementation class for the business scenario from the Spring container based on the index value.

8. An electronic device, characterized in that, include: Processor and memory; The memory stores computer programs that can be executed by the processor; When the processor executes the computer program, it implements the steps in the horizontal table partitioning method as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs, which can be executed by one or more processors to implement the steps in the horizontal table partitioning method as described in any one of claims 1-6.