CN106886568B8 - One kind divides table method, apparatus and electronic equipment - Google Patents

One kind divides table method, apparatus and electronic equipment Download PDF

Info

Publication number
CN106886568B8
CN106886568B8 CN201710023995.7A CN201710023995A CN106886568B8 CN 106886568 B8 CN106886568 B8 CN 106886568B8 CN 201710023995 A CN201710023995 A CN 201710023995A CN 106886568 B8 CN106886568 B8 CN 106886568B8
Authority
CN
China
Prior art keywords
sub
open source
class
data
table model
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.)
Active
Application number
CN201710023995.7A
Other languages
Chinese (zh)
Other versions
CN106886568B (en
CN106886568A (en
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.)
Ireader Technology Co Ltd
Original Assignee
Ireader 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 Ireader Technology Co Ltd filed Critical Ireader Technology Co Ltd
Priority to CN201710023995.7A priority Critical patent/CN106886568B8/en
Publication of CN106886568A publication Critical patent/CN106886568A/en
Application granted granted Critical
Publication of CN106886568B publication Critical patent/CN106886568B/en
Publication of CN106886568B8 publication Critical patent/CN106886568B8/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses one kind to divide table method, apparatus and electronic device, is related to technical field of data processing.The embodiment of the present invention divides table method to include:The multiple sublist model classes of dynamic generation, the sublist model class is registered in the configuration center of Open Framework, select to need the sublist model class for carrying out data manipulation in the sublist model class, and the data manipulation function provided using the Open Framework, corresponding data manipulation is performed to the example of the sublist model class for needing to carry out data manipulation.In addition, the embodiment of the invention also discloses one kind to divide meter apparatus and electronic equipment.By the scheme of the embodiment of the present invention, the efficiency of point table can be effectively improved.

Description

一种分表方法、装置及电子设备Method, device and electronic equipment for dividing meter

技术领域Technical field

[0001]本发明涉及数据处理技术领域,尤其涉及数据库分表处理技术。 [0001] The present invention relates to the field of data processing technology, and in particular to database sub-table processing technology.

背景技术Background technique

[0002] Hibernate是一个基于Java的开源的持久化中间件,对JDBC (Java Data Base Connectivity Java 数据库连接)做了轻量的封装。 [0002] Hibernate is a Java-based open source persistence middleware, which encapsulates JDBC (Java Data Base Connectivity) lightly. 其采用ORM (Object Relation Mapping, 对象关系映射)机制,实现Java对象和关系数据库之间的映射,把sql语句传给数据库,并且把数据库返回的结果封装成对象。 It adopts ORM (Object Relation Mapping, Object Relation Mapping) mechanism to realize the mapping between Java objects and relational databases, pass SQL statements to the database, and encapsulate the results returned by the database into objects. 内部封装了JDBC访问数据库的操作,向上层应用提供了面向对象的数据库访问API。 The operation of JDBC access to the database is encapsulated internally, and an object-oriented database access API is provided to the upper application. 由于其可以以对象的形式操作数据,更换数据库时只要修改配值文件,而不用关心数据库种类,因而提高了开发效率。 Because it can manipulate data in the form of objects, it only needs to modify the configuration file when replacing the database, without worrying about the type of database, thus improving the development efficiency.

[0003] 分表是将一张大表切分为同一个数据库的多张表,抵抗因数据量过大而影响性能的一种方法。 [0003] Table splitting is a method for dividing a large table into multiple tables in the same database to resist the performance impact due to excessive data volume. 发明人在实现本发明的过程中发现,Hi bernat e-Shards开源框架是基于Hibernate的强大的分库框架,但是不支持分表。 In the process of implementing the present invention, the inventor discovered that the Hi Bernat e-Shards open source framework is a powerful sub-library framework based on Hibernate, but does not support sub-tables. Hibernate NamingStrategy是Hibernate 提供的表名替换策略,其可以进行简单的分表操作,但是不能根据实例参数动态决定表名, 一般只能用于按时间进行分表的场景。 Hibernate NamingStrategy is a table name replacement strategy provided by Hibernate. It can perform simple table splitting operations, but the table name cannot be dynamically determined based on instance parameters. Generally, it can only be used in scenarios where tables are split by time. Hibernate Query Interceptor是Hibernate提供的查询拦截器,用户可以在生成sql语句时进行拦截,将相应的表名动态替换成具体的分表, 需要解析sql语句,实现复杂,性能和维护性都较差,而且也不可以根据实例参数动态决定表名,一般只能用户按时间进行分表。 Hibernate Query Interceptor is a query interceptor provided by Hibernate. Users can intercept when generating SQL statements and dynamically replace the corresponding table names with specific sub-tables. SQL statements need to be parsed, which is complex to implement, and has poor performance and maintainability. And it is not possible to dynamically determine the table name based on the instance parameters. Generally, the user can only divide the table by time.

[0004] 因此,需要一种基于Hibernate的更加简单有效的分表处理方法。 [0004] Therefore, there is a need for a simpler and more effective method for table splitting based on Hibernate.

发明内容Summary of the invention

[0005] 有鉴于此,本发明实施例提供了一种分表方法、装置及电子设备,至少部分的解决现有技术中存在的问题。 [0005] In view of this, the embodiments of the present invention provide a method, device and electronic device for dividing a meter, which at least partially solve the problems existing in the prior art.

[0006] 第一方面,本发明实施例提供了一种分表方法,包括: [0006] In the first aspect, an embodiment of the present invention provides a table splitting method, including:

[0007] 动态生成多个子表模型类; [0007] Dynamically generate multiple sub-table model classes;

[0008] 在开源框架的配置中心注册所述子表模型类; [0008] Register the sub-table model class in the configuration center of the open source framework;

[0009] 选择所述子表模型类中需要进行数据操作的子表模型类; [0009] Select the sub-table model class that needs to perform data operations among the sub-table model classes;

[0010] 利用所述开源框架提供的数据操作功能,对所述需要进行数据操作的子表模型类的实例执行相应的数据操作。 [0010] Using the data operation function provided by the open source framework, perform corresponding data operations on the instance of the sub-table model class that needs to perform data operations.

[0011] 根据本发明实施例的一种具体实现方式,在所述动态生成多个子表模型类之前, 所述方法还包括: [0011] According to a specific implementation manner of the embodiment of the present invention, before the dynamically generating multiple sub-table model classes, the method further includes:

[0012] 在所述开源框架中定义单表模型类。 [0012] A single-table model class is defined in the open source framework.

[0013] 根据本发明实施例的一种具体实现方式,所述动态生成多个子表模型类,包括: [0013] According to a specific implementation of the embodiment of the present invention, the dynamically generating multiple sub-table model classes includes:

[0014] 获取所述开源框架关联的数据库的分表需求; [0014] Obtain the sub-table requirements of the database associated with the open source framework;

[0015] 基于所述分表需求,利用第三方开源类库动态生成多个子表模型类。 [0015] Based on the requirements for sub-tables, a third-party open source class library is used to dynamically generate multiple sub-table model classes.

[0016] 根据本发明实施例的一种具体实现方式,所述在开源框架的配置中心注册所述子表模型类,包括: [0016] According to a specific implementation manner of the embodiment of the present invention, the registering the sub-table model class in the configuration center of the open source framework includes:

[0017] 生成所述子表模型类对应的类文件; [0017] generating a class file corresponding to the sub-table model class;

[0018] 将所述类文件保存在所述开源框架的预设扫描位置。 [0018] Save the class files in a preset scanning location of the open source framework.

[0019] 根据本发明实施例的一种具体实现方式,所述在开源框架的配置中心注册所述子表模型类,包括: [0019] According to a specific implementation manner of the embodiment of the present invention, the registering the sub-table model class in the configuration center of the open source framework includes:

[0020] 获取所述开源框架的会话接口文件; [0020] Obtain the session interface file of the open source framework;

[0021] 基于所述会话接口文件,判断所述子表模型类是否采用动态方式进行加载; [0021] Based on the session interface file, determine whether the sub-table model class is loaded in a dynamic manner;

[0022]当所述子表模型类采用动态方式进行加载时,更新所述开源框架的配置文件,并重新创建所述开源框架的会话接口文件。 [0022] When the sub-table model class is loaded in a dynamic manner, the configuration file of the open source framework is updated, and the session interface file of the open source framework is recreated.

[0023] 根据本发明实施例的一种具体实现方式,所述选择所述子表模型类中需要进行数据操作的子表模型类,包括: [0023] According to a specific implementation manner of the embodiment of the present invention, the selecting the sub-table model class that needs to perform data operations among the sub-table model classes includes:

[0024] 基于所述开源框架关联的数据库的分表需求定义散列方法; [0024] A hash method is defined based on the sub-table requirements of the database associated with the open source framework;

[0025] 获取所述开源框架关联的数据库的预设字段; [0025] Acquire preset fields of the database associated with the open source framework;

[0026] 基于所述散列方法对所述预设字段进行数据运算; [0026] performing data operations on the preset fields based on the hash method;

[0027] 根据所述数据运算的结果确定需要进行数据操作的子表模型类。 [0027] According to the result of the data operation, determine the sub-table model class that needs to perform the data operation.

[0028]根据本发明实施例的一种具体实现方式,所述利用所述开源框架提供的数据操作功能,对所述需要进行数据操作的子表模型类的实例执行相应的数据操作,包括: [0028] According to a specific implementation of the embodiment of the present invention, the use of the data operation function provided by the open source framework to perform corresponding data operations on the instance of the sub-table model class that needs to perform data operations includes:

[0029] 使用所述开源框架提供的数据增加、数据删除、数据修改及数据查询功能,显式指定所述需要进行数据操作的子表模型类进行相关数据操作。 [0029] Use the data addition, data deletion, data modification, and data query functions provided by the open source framework to explicitly specify the sub-table model class that needs to perform data operations to perform related data operations.

[0030] 根据本发明实施例的一种具体实现方式,所述利用所述开源框架提供的数据操作功能,对所述需要进行数据操作的子表模型类的实例执行相应的数据操作,还包括: [0030] According to a specific implementation of the embodiment of the present invention, the use of the data operation function provided by the open source framework to perform a corresponding data operation on the instance of the sub-table model class that requires data operation also includes :

[0031] 使用反射方法构建所述需要进行数据操作的子表模型类的模型实例; [0031] Use the reflection method to construct the model instance of the sub-table model class that needs to be operated on data;

[0032] 使用不包含重复元素的类集对所述模型实例进行数据填充。 [0032] The model instance is filled with data using a cluster that does not contain repeated elements.

[0033] 第二方面,本发明实施例还提供了一种分表装置,包括: [0033] In the second aspect, an embodiment of the present invention also provides a meter division device, including:

[0034] 生成模块,用于动态生成多个子表模型类; [0034] The generation module is used to dynamically generate multiple sub-table model classes;

[0035] 注册模块,用于在开源框架的配置中心注册所述子表模型类; [0035] The registration module is used to register the sub-table model class in the configuration center of the open source framework;

[0036] 选择模块,用于选择所述子表模型类中需要进行数据操作的子表模型类; [0036] The selection module is used to select the sub-table model classes that need to perform data operations among the sub-table model classes;

[0037] 执行模块,用于利用所述开源框架提供的数据操作功能,对所述需要进行数据操作的子表模型类的实例执行相应的数据操作。 [0037] The execution module is used to use the data operation function provided by the open source framework to perform corresponding data operations on the instance of the sub-table model class that needs to perform data operations.

[0038] 根据本发明实施例的一种具体实现方式,所述装置还包括: [0038] According to a specific implementation manner of the embodiment of the present invention, the device further includes:

[0039] 定义模块,用于在所述开源框架中定义单表模型类。 [0039] The definition module is used to define a single table model class in the open source framework.

[0040] 根据本发明实施例的一种具体实现方式,所述生成模块,还用于: [0040] According to a specific implementation manner of the embodiment of the present invention, the generating module is further configured to:

[0041] 获取所述开源框架关联的数据库的分表需求; [0041] Obtain the sub-table requirements of the database associated with the open source framework;

[0042] 基于所述分表需求,利用第三方开源类库动态生成多个子表模型类。 [0042] Based on the requirements for sub-tables, a third-party open source class library is used to dynamically generate multiple sub-table model classes.

[0043] 根据本发明实施例的一种具体实现方式,所述注册模块,还用于: [0043] According to a specific implementation manner of the embodiment of the present invention, the registration module is further configured to:

[0044] 生成所述子表模型类对应的类文件; [0044] generating a class file corresponding to the sub-table model class;

[0045] 将所述类文件保存在所述开源框架的预设扫描位置。 [0045] Save the class files in a preset scanning location of the open source framework.

[0046] 根据本发明实施例的一种具体实现方式,所述注册模块,还用于: [0046] According to a specific implementation manner of the embodiment of the present invention, the registration module is further configured to:

[0047] 获取所述开源框架的会话接口文件; [0047] Obtain the session interface file of the open source framework;

[0048]基于所述会话接口文件,判断所述子表模型类是否采用动态方式进行加载; [0048] Based on the session interface file, determine whether the sub-table model class is loaded in a dynamic manner;

[0049]当所述子表模型类采用动态方式进行加载时,更新所述开源框架的配置文件,并重新创建所述开源框架的会话接口文件。 [0049] When the sub-table model class is loaded in a dynamic manner, the configuration file of the open source framework is updated, and the session interface file of the open source framework is recreated.

[0050] 根据本发明实施例的一种具体实现方式,所述选择模块,包括: [0050] According to a specific implementation manner of the embodiment of the present invention, the selection module includes:

[0051] 定义模块,用于基于所述开源框架关联的数据库的分表需求定义散列方法; [0051] A definition module for defining a hashing method based on the sub-table requirements of the database associated with the open source framework;

[0052] 获取模块,用于获取所述开源框架关联的数据库的预设字段; [0052] An acquisition module for acquiring preset fields of the database associated with the open source framework;

[0053]运算模块,用于基于所述散列方法对所述预设字段进行数据运算; [0053] an operation module, configured to perform data operation on the preset field based on the hash method;

[0054]确定模块,用于根据所述数据运算的结果确定需要进行数据操作的子表模型类。 [0054] The determining module is used to determine the sub-table model class that needs to be operated on according to the result of the data operation. [0055]根据本发明实施例的一种具体实现方式,所述执行模块,包括: [0055] According to a specific implementation manner of the embodiment of the present invention, the execution module includes:

[0056]指定模块,用于使用所述开源框架提供的数据增加、数据删除、数据修改及数据查询功能,显式指定所述需要进行数据操作的子表模型类进行相关数据操作。 [0056] The designated module is used to use the data addition, data deletion, data modification, and data query functions provided by the open source framework to explicitly specify the sub-table model classes that need to be operated on to perform related data operations.

[0057]根据本发明实施例的一种具体实现方式,所述执行模块,还包括: [0057] According to a specific implementation manner of the embodiment of the present invention, the execution module further includes:

[0058]构建模块,用于使用反射方法构建所述需要进行数据操作的子表模型类的模型实例; [0058] The building module is used to construct the model instance of the sub-table model class that needs to perform data operations by using the reflection method;

[0059]填充模块,用于使用不包含重复元素的类集对所述模型实例进行数据填充。 [0059] The filling module is used to fill the model instance with data using a cluster that does not contain repeated elements.

[0060] 第三方面,本发明实施例还提供了一种电子设备,该电子设备包括: [0060] In a third aspect, an embodiment of the present invention also provides an electronic device, the electronic device including:

[0061] 至少一个处理器;以及, [0061] at least one processor; and,

[0062] 与该至少一个处理器通信连接的存储器;其中, [0062] A memory communicatively connected with the at least one processor; wherein,

[0063]该存储器存储有可被该至少一个处理器执行的指令,该指令被该至少一个处理器执行,以使该至少一个处理器能够执行前述任第一方面或第一方面的任一实现方式中的分表方法。 [0063] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute any of the foregoing first aspect or any implementation of the first aspect The sub-table method in the mode.

[0064]第四方面,本发明实施例还提供了一种非暂态计算机可读存储介质,该非暂态计算机可读存储介质存储计算机指令,该计算机指令用于使该计算机执行前述第一方面或第一方面的任一实现方式中的分表方法。 [0064] In a fourth aspect, embodiments of the present invention also provide a non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium storing computer instructions, and the computer instructions are used to make the computer execute the aforementioned first Aspect or any implementation of the first aspect.

[0065]第五方面,本发明实施例还提供了一种计算机程序产品,该计算机程序产品包括存储在非暂态计算机可读存储介质上的计算程序,该计算机程序包括程序指令,当该程序指令被计算机执行时,使该计算机执行前述第一方面或第一方面的任一实现方式中的分表方法。 [0065] In a fifth aspect, embodiments of the present invention also provide a computer program product, the computer program product includes a calculation program stored on a non-transitory computer-readable storage medium, the computer program includes program instructions, when the program When the instructions are executed by a computer, the computer is caused to execute the aforementioned first aspect or the table splitting method in any implementation manner of the first aspect.

[0066]本发明实施例提供的分表方法、装置、电子设备、非暂态计算机可读存储介质及计算机程序,通过动态生成多个子表模型类并结合Hibernate的数据操作功能,进而能够在不明显影响性能和维护性的前提下实现了基于Hibernate框架来实现分表0RM的功能。 [0066] The method, device, electronic equipment, non-transitory computer readable storage medium and computer program provided by the embodiments of the present invention can dynamically generate multiple sub-table model classes and combine the data operation function of Hibernate, thereby being able to Under the premise of significantly affecting performance and maintainability, the function of sub-table ORM based on the Hibernate framework is realized. 由于分表过程中能够根据实例参数动态决定表名,用户仅需制定根据实例参数动态决定表名的规则即可,故达到了实现方式简单、可理解性强并大幅减少了学习代价和维护成本的技术效果,总体上提高了分表的效率。 Since the table name can be dynamically determined according to the instance parameters during the table splitting process, the user only needs to formulate the rules for dynamically determining the table name according to the instance parameters, so the realization method is simple, the understandability is strong, and the learning and maintenance costs are greatly reduced. The technical effect of the overall improvement of the efficiency of sub-metering.

附图说明Description of the drawings

[0067]为了更清楚地说明本发明实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。 [0067] In order to more clearly describe the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings needed in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work.

[0068]图1为本发明实施例提供的一种分表方法的流程示意图; [0068] FIG. 1 is a schematic flowchart of a method for dividing a table according to an embodiment of the present invention;

[0069]图2为本发明实施例提供的另一种分表方法的流程示意图; [0069] FIG. 2 is a schematic flow chart of another table splitting method provided by an embodiment of the present invention;

[0070]图3为本发明实施例提供的一种动态加载子表模型类到Hibernate配置中心的流程不意图; [0070] FIG. 3 is a schematic diagram of a process of dynamically loading sub-table model classes to the Hibernate configuration center provided by an embodiment of the present invention;

[0071]图4为本发明实施例提供的一种基于散列的子表模型类选择流程示意图; [0071] FIG. 4 is a schematic diagram of a selection process of a hash-based sub-table model class according to an embodiment of the present invention;

[0072]图5为本发明实施例提供的一种对子表模型类的实例执行相应的数据操作的流程示意图; [0072] FIG. 5 is a schematic diagram of a flow chart of performing corresponding data operations on instances of sub-table model classes according to an embodiment of the present invention;

[0073]图6为本发明实施例提供的一种分表装置的示意性框图; [0073] FIG. 6 is a schematic block diagram of a meter division device according to an embodiment of the present invention;

[0074]图7为本发明实施例提供的另一种分表装置的示意性框图; [0074] FIG. 7 is a schematic block diagram of another meter division device according to an embodiment of the present invention;

[0075]图8为本发明实施例提供的一种选择模块的示意性框图; [0075] FIG. 8 is a schematic block diagram of a selection module according to an embodiment of the present invention;

[0076]图9为本发明实施例提供的一种执行模块的示意性框图; [0076] FIG. 9 is a schematic block diagram of an execution module according to an embodiment of the present invention;

[0077]图10为本发明实施例提供的一种电子设备的结构示意图。 [0077] FIG. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.

具体实施方式Detailed ways

[0078]下面结合附图对本发明实施例进行详细描述。 [0078] The following describes the embodiments of the present invention in detail with reference to the accompanying drawings.

[0079]应当明确,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。 [0079] It should be clear that the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. 基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。 Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.

[0080]图1为本发明实施例提供的一种分表方法,参见图1,该方法包括以下步骤: [0080] FIG. 1 is a table splitting method provided by an embodiment of the present invention. Referring to FIG. 1, the method includes the following steps:

[0081] S101,动态生成多个子表模型类。 [0081] S101, dynamically generating multiple sub-table model classes.

[0082]当数据库中的数据容量发展到一定程度之后,为了提高数据库的响应速度,需要将整个数据库的单个大表拆分成多个小表。 [0082] After the data capacity in the database has developed to a certain extent, in order to improve the response speed of the database, it is necessary to split a single large table of the entire database into multiple small tables. 在进行拆分时,可以采用多种预设规则来进行, 比如: When splitting, a variety of preset rules can be used, such as:

[0083] (1)按自然时间来分表[0083] (1) Dividing tables according to natural time

[0084]如一个业务的统计数据量达到一定的规模(如200万条左右),那么就可以考虑用一年的数据来作为一个表存储,例如,表名为app,那么2010年的数据就是app_2010,app— 2011,. . •。 [0084] If the amount of statistical data of a business reaches a certain scale (such as about 2 million pieces), then one year's data can be considered as a table for storage. For example, if the table is named app, then the data for 2010 is app_2010, app—2011,... •. 当然也可以米用其他时间方式,如按照月来进彳丁来分,如app_2〇l〇_〇l,app_ 2010—02,…。 Of course, you can also use other time methods, such as entering according to the month, such as app_2〇l〇_〇l, app_2010-02,....

[0085] (2)按数字类型hash分表[0085] (2) According to the number type hash table

[0086]举例而言,如果要存储用户的信息,而业务数据的量很大,用单表是不能满足存储需求,那么就可以用用户的编号来进行hash,常见的是用取余操作,如果要分30张表来存储用户的信息,那么用户编号为1的用户1%30 = 1,那么就存在user_01表里,如用户的编号为500,那么500%30 = 20,将此用户的信息存储在user_2〇的表里。 [0086] For example, if you want to store user information, and the amount of business data is very large, and a single table cannot meet the storage requirements, then you can use the user number to hash, and the common one is to use the remaining operation. If you want to divide 30 tables to store user information, then the user 1% 30 = 1 with the user number 1, then it exists in the user_01 table, if the user number is 500, then 500% 30 = 20, this user’s The information is stored in the table of user_20.

[0087] ⑶按md5值来分表[0087] ⑶ According to md5 value to divide the table

[0088]假设要存储用户上传的文件,如果上传量大的话,也会带来系统的瓶颈问题,比如,在一个数据库表格下如果超过20000个文件的话,文件的浏览效率会降低。 [0088] Assuming that files uploaded by users are to be stored, if the upload volume is large, it will also cause system bottlenecks. For example, if there are more than 20,000 files in a database table, the browsing efficiency of files will be reduced. 此时可以用文件的用户名来md5或者用文件的md5校验值来做,可以用!^5的前3位来做hash,这样最多我们就可以得到16~3 = 40%个表,每次在存储文件的时候,就可以用文件名的md5值的前3 位来确定这个文件该存哪张表。 At this time, you can use the user name of the file to md5 or use the md5 checksum of the file to do it. You can use the first 3 digits of !^5 as the hash, so that at most we can get 16~3 = 40% tables. When storing a file, the first 3 digits of the md5 value of the file name can be used to determine which table the file should be stored in.

[0089]上述预设规则生成的每一个表均对应一个子表模型类。 [0089] Each table generated by the aforementioned preset rules corresponds to a sub-table model class. 具体的,可以用ByteBuddy 动态生成多个子表模型类,当然也可以使用cglib或javaassist等其他第三方开源类库,来动态生成多个子表模型类。 Specifically, ByteBuddy can be used to dynamically generate multiple sub-table model classes. Of course, other third-party open source libraries such as cglib or javaassist can also be used to dynamically generate multiple sub-table model classes. 这三个类库都是用了asm这个开源类库,可以动态操作java子节码来构造动态Java类。 These three class libraries all use asm, an open source class library, which can dynamically manipulate java subsection codes to construct dynamic Java classes.

[0090] S102,在开源框架的配置中心注册所述子表模型类。 [0090] S102, register the sub-table model class in the configuration center of the open source framework.

[0091]注册到hibernate配置中心可以采用静态方式加载,也可以采用动态方式加载。 [0091] The registration to the hibernate configuration center can be loaded in a static way, or it can be loaded in a dynamic way. [0092] Hibernate通常是在web容器启动的时候根据相关配置信息,扫描Class文件,然后注册到SessionFactory中,可以操作Java子节码来构造动态Java类,具体为通过编写Java 的汇编指令序列化生成一个类文件,然后使用classloader来加载这个类文件。 [0092] Hibernate usually scans the Class file according to the relevant configuration information when the web container is started, and then registers it in the SessionFactory. The Java subsection code can be manipulated to construct a dynamic Java class, which is specifically generated by writing Java's assembly instruction serialization. A class file, and then use classloader to load this class file.

[0093] 对于在容器启动已经完成后,程序正常运行期间产生的类,由于Hibernate不能识别这个新创建的类,此时不能直接使用Hibernate的接口。 [0093] For the class generated during the normal operation of the program after the container startup has been completed, since Hibernate cannot recognize the newly created class, the Hibernate interface cannot be used directly at this time. 为此可以采用动态注册的方式来进行。 This can be done by means of dynamic registration. 考虑到安全性问题,不再使用原来已经存在的SessionFactory,而是获取SessionFactory,判断子表模型类是否动态加载到JVM中,如果是,则更新当前的Configuration,并重新创建一个SessionFactory。 Taking into account the security issue, instead of using the existing SessionFactory, the SessionFactory is obtained, and it is judged whether the sub-table model class is dynamically loaded into the JVM. If it is, the current Configuration is updated and a SessionFactory is recreated.

[0094] S103,选择所述子表模型类中需要进行数据操作的子表模型类。 [0094] S103: Select a sub-table model class that needs to perform data operations among the sub-table model classes.

[0095]定义散列方法,根据特定的散列参数选择相应的子表模型类,该散列参数可以是模型主键Id,也可以是模型的其他字段,还可以是时间参数等。 [0095] Define a hashing method, and select the corresponding sub-table model class according to a specific hash parameter. The hash parameter can be the model primary key Id, other fields of the model, or time parameters.

[0096] 举例而言,比如对于记录用户的所有购买记录的数据库,如果将所有记录放入到一张表userbuy表中,势必会非常巨大。 [0096] For example, for a database that records all purchase records of users, if all the records are put into one table, the userbuy table, it is bound to be very huge. 所以可以通过对用户id进行分表处理,将不同用户的购买记录放入不同的分表中。 Therefore, the purchase records of different users can be put into different sub-tables by performing sub-table processing on the user id. 具体做法如下: The specific methods are as follows:

[0097] 预估业务量,将最初的userbuy表,扩展为100张相同表结构的userbuy_index表, 原表结构如下: [0097] To estimate the business volume, expand the original userbuy table to 100 userbuy_index tables with the same table structure. The original table structure is as follows:

[0098] 表一userbuy表数据结构[0098] Table 1 Userbuy table data structure

[0099] _ 字段|类型| Null |健值|默认id bigint (20) unsigned NO PRI NULL uid int (10)unsigned NO 0 goods varchar (128) NO num int (10)unsigned NO 0 ctime int (10)unsigned NO 0 [0099] _ Field|Type|Null|Key value|Default id bigint (20) unsigned NO PRI NULL uid int (10)unsigned NO 0 goods varchar (128) NO num int (10)unsigned NO 0 ctime int (10) unsigned NO 0

[0l00]所有的分表采用完全相同的表结构,当需要新增一条分表记录时,过程如下:首先对用户id进行hash计算,得到hash值,该hash值必然是0-99,目的是将对应的用户id数据, 写入到同一张分表中,此时,基于该hash值便可以选取子表模型类。 [0l00] All sub-tables adopt the same table structure. When a new sub-table record needs to be added, the process is as follows: first, perform a hash calculation on the user id to obtain the hash value. The hash value must be 0-99, and the purpose is Write the corresponding user id data into the same sub-table. At this time, the sub-table model class can be selected based on the hash value.

[0101] S104,利用所述开源框架提供的数据操作功能,对所述需要进行数据操作的子表模型类的实例执行相应的数据操作。 [0101] S104. Use the data operation function provided by the open source framework to perform corresponding data operations on the instance of the sub-table model class that needs to perform data operations.

[0102]使用原生的Hibernate数据增加、数据删除、数据修改、及数据查询等数据操作功能,显式指定具体子表模型类进行相关数据操作。 [0102] Use the native Hibernate data operation functions such as data addition, data deletion, data modification, and data query, and explicitly specify specific sub-table model classes to perform related data operations. 通过显示指定分表,使用者可以明确指定是要向哪个分表发起相关数据操作,使用者可以清晰理解数据的物理数据结构。 By displaying the designated sub-table, the user can clearly specify which sub-table to initiate related data operations, and the user can clearly understand the physical data structure of the data.

[0103]具体而言,通过构造子表模型类的实例,并对该子表模型类的实例进行数据操作来来实现数据操作功能。 [0103] Specifically, the data operation function is realized by constructing an instance of the sub-table model class and performing data operations on the instance of the sub-table model class. 构造模型类的实例时,先根据散列参数选择相应的子表模型类,再使用反射方法Class.newlnstance 〇构造对应子类的模型实例,最后再使用set方法填充对象。 When constructing an instance of a model class, first select the corresponding sub-table model class according to the hash parameters, then use the reflection method Class.newlnstance to construct a model instance of the corresponding subclass, and finally use the set method to fill the object.

[0104]在实现分表的过程中,除了上述实施例中的步骤S101〜S104之外,可选的,参见图2,该分表方法还可以包括如下步骤: [0104] In the process of realizing the table division, in addition to steps S101 to S104 in the foregoing embodiment, optionally, referring to FIG. 2, the table division method may further include the following steps:

[0105] S201,在所述开源框架中定义单表模型类。 [0105] S201. Define a single-table model class in the open source framework.

[0106]具体的,可以在Hibernate的配置文件hibernate .cfg. xml中添加如下代码: [0106] Specifically, the following code can be added to the Hibernate configuration file hibernate.cfg.xml:

[0107] <properties> [0107] <properties>

[0108] 〈property name = ''hibernate. hbm2ddl • auto〃value = 〃create〃/> [0108] <property name =''hibernate. hbm2ddl • auto〃value = 〃create〃/>

[0109] </properties〉 [0109] </properties>

[0110]通过在开源框架中定义单表模型类,能够在步骤Sl〇l中动态生成的多个子表模型类时,复用步骤S2〇l中定义的单表模型类代码,在简化代码编写的同时,更便于对代码进行维护。 [0110] By defining the single-table model class in the open source framework, when multiple sub-table model classes are dynamically generated in step S101, the single-table model class code defined in step S201 can be reused to simplify code writing. At the same time, it is easier to maintain the code.

[0111] 本实施例中的分表方法,实现简单,使用简单,有很强的可理解性,大幅减少了学习代价和维护成本,性能接近原生的0RM单表操作。 [0111] The table splitting method in this embodiment is simple to implement, simple to use, has strong comprehensibility, greatly reduces learning costs and maintenance costs, and has performance close to native ORM single-table operations.

[0112]可选的,本发明实施例还提供了一种动态加载子表模型类到Hibernate配置中心的方法,参见图3,该方法包括如下步骤: [0112] Optionally, the embodiment of the present invention also provides a method for dynamically loading the sub-table model class to the Hibernate configuration center. Referring to FIG. 3, the method includes the following steps:

[0113] S301,获取所述开源框架的会话接口文件。 [0113] S301. Obtain a session interface file of the open source framework.

[0m] 对于Hibernate来讲,需要获取SessionFactory接口,具体的,可以通过Configuation 实例创建SessionFactory,如下所示: [0m] For Hibernate, you need to obtain the SessionFactory interface. Specifically, you can create a SessionFactory through a Configuation instance, as shown below:

[0115] Configuration config=new Configuration () .configure (); [0115] Configuration config=new Configuration () .configure ();

[0116] SessionFactory SessionFactory二config.buildSessionFactory 〇; [0116] SessionFactory SessionFactory two config.buildSessionFactory 〇;

[0117] Configuration实例config会根据当前的配置信息,构造SessionFactory实例并返回。 [0117] The Configuration instance config will construct a SessionFactory instance and return it according to the current configuration information.

[0118] S302,基于所述会话接口文件,判断所述子表模型类是否采用动态方式进行加载。 [0118] S302, based on the session interface file, determine whether the sub-table model class is loaded in a dynamic manner.

[0119]具体而言,可以通过SessionFactory 的getAllClassMetadata 方法得到一个Map, Map的key是实体类的名称,value是ClassMetadata对象,通过判断map .keySet ()中是否含有所述子表模型类的方式来判断所述子表模型类是否采用动态方式进行加载。 [0119] Specifically, a Map can be obtained through the getAllClassMetadata method of SessionFactory, where the key of the Map is the name of the entity class, and the value is the ClassMetadata object, by judging whether the sub-table model class is included in the map.keySet() It is determined whether the sub-table model class is loaded in a dynamic manner. 比如: for example:

[0120] M^<String,CI_Metadata>maft.sesSionFacto_ge^^lassM_a_ta0; Set<String> set = map.keySet(); if(!set.contams(entityClass.getName〇)){ } [0120] M^<String,CI_Metadata>maft.sesSionFacto_ge^^lassM_a_ta0; Set<String> set = map.keySet(); if(!set.contams(entityClass.getName〇)){}

[0121] S303,当所述子表模型类采用动态方式进行加载时,更新所述开源框架的配置文件,并重新创建所述开源框架的会话接口文件。 [0121] S303: When the sub-table model class is loaded in a dynamic manner, update the configuration file of the open source framework, and recreate the session interface file of the open source framework.

[0122]具体的,可以通过设置函数configuration.addAnnotatedClass ()更新ffibernate 的配置文件,以及通过设置函数sessionFactoryList.add ()重新创建Hibernate的SessionFactory〇 [0122] Specifically, the configuration file of ffibernate can be updated by the setting function configuration.addAnnotatedClass (), and the SessionFactory of Hibernate can be recreated by setting the function sessionFactoryList.add ().

[0123]通过上述方式,能够通过动态方式加载子表模型类至Hibernate的配置中心。 [0123] Through the above method, the sub-table model class can be dynamically loaded to the configuration center of Hibernate.

[0124]参见图4,本发明实施例还提供了一种基于散列的子表模型类选择方法,包括如下步骤: [0124] Referring to FIG. 4, an embodiment of the present invention also provides a method for selecting a sub-table model class based on a hash, which includes the following steps:

[0125] S401,基于所述开源框架关联的数据库的分表需求定义散列方法。 [0125] S401. Define a hashing method based on the table sub-table requirements of the database associated with the open source framework.

[0126]根据具体的分表需求,定义散列方法,以表一所示的数据库表单结构为例,要把数据库的表分成100个子表,此时,可以选择使用Crc32方式进行hash计算。 [0126] According to specific table splitting requirements, a hash method is defined. Taking the database form structure shown in Table 1 as an example, the database table should be divided into 100 sub-tables. At this time, you can choose to use the Crc32 method for hash calculation.

[0127] S402,获取所述开源框架关联的数据库的预设字段。 [0127] S402. Obtain a preset field of the database associated with the open source framework.

[0128]具体而言,可以采取表一中的任一字段进行hash计算,比如可以选择id作为预设字段。 [0128] Specifically, any field in Table 1 can be used for hash calculation, for example, id can be selected as a preset field.

[0129] S4〇3,基于所述散列方法对所述预设字段进行数据运算。 [0129] S403: Perform data operations on the preset field based on the hash method.

[0130] crc32计算结果为一个10进制数,在不同bit位的操作系统下,得到的值可能会不同,所以对其进行一个统一的处理,然后对这个自然数进行取余计算,取余的除数就是分表数,比如这里为100。 [0130] The calculation result of crc32 is a decimal number. Under different bit operating systems, the obtained value may be different, so a unified process is performed on it, and then the natural number is calculated by taking the remainder, and the remainder is taken The divisor is the number of points, such as 100 here.

[0131] S404,根据所述数据运算的结果确定需要进彳丁数据操作的子表模型类。 [0131] S404: Determine, according to the result of the data operation, the sub-table model class that needs to enter the data operation.

[0132]通过计算数据库的预设字段,这样就得到了一个在〇-99以内的表后缀数index,通过将index数值与子表模型类进行关联,即可确定需要进行数据操作的子表模型类。 [0132] By calculating the preset fields of the database, a table suffix number index within 0-99 is obtained. By associating the index value with the sub-table model class, the sub-table model that needs to be operated on can be determined kind.

[0133] 通过上述实施例中的方法,能够将单个表较为均匀分配到各个子表中。 [0133] Through the method in the foregoing embodiment, a single table can be more evenly distributed to each sub-table.

[0134]参见图5,本发明实施例还提供了一种对子表模型类的实例执行相应的数据操作的方法,包括如下步骤: [0134] Referring to FIG. 5, an embodiment of the present invention also provides a method for performing corresponding data operations on an instance of a sub-table model class, which includes the following steps:

[0135] S501,使用所述开源框架提供的数据增加、数据删除、数据修改及数据查询功能, 显式指定所述需要进行数据操作的子表模型类进行相关数据操作。 [0135] S501: Use the data addition, data deletion, data modification, and data query functions provided by the open source framework to explicitly specify the sub-table model class that needs to perform data operations to perform related data operations.

[0136]使用原生的Hibernate数据增加、数据删除、数据修改、及数据查询等数据操作功能,显式指定具体子表模型类进行相关数据操作。 [0136] Use the native Hibernate data operation functions such as data addition, data deletion, data modification, and data query, and explicitly specify specific sub-table model classes to perform related data operations. 通过显示指定分表,使用者可以明确指定是要向哪个分表发起相关数据操作,使用者可以清晰理解数据的物理数据结构。 By displaying the designated sub-table, the user can clearly specify which sub-table to initiate related data operations, and the user can clearly understand the physical data structure of the data.

[0137] 以子表模型类的删除操作为例,可以采用如下代码进行: [0137] Taking the deletion operation of the sub-table model class as an example, the following code can be used:

[0138] tx = session.beginTransaction (); [0138] tx = session.beginTransaction ();

[0139] user= (UserEntity) session.get (UserEntity.shardFor (”2〃),〃2"); [0139] user= (UserEntity) session.get (UserEntity.shardFor ("2〃), 〃2");

[0140] System.out.println (user.getName()); [0140] System.out.println (user.getName());

[0141] session.delete (user); [0141] session.delete (user);

[0142] tx.commit (); [0142] tx.commit ();

[0143] S502,使用反射方法构建所述需要进行数据操作的子表模型类的模型实例。 [0143] S502, using a reflection method to construct a model instance of the sub-table model class that needs to perform data operations.

[0144]具体的,先根据散列参数选择相应的子表模型类,再使用反射方法Class • newlnstance ()构造对应子类的模型实例。 [0144] Specifically, first select the corresponding sub-table model class according to the hash parameters, and then use the reflection method Class·newlnstance () to construct a model instance of the corresponding sub-class.

[0145] S503,使用不包含重复元素的类集对所述模型实例进行数据填充。 [0145] S503: Use a cluster that does not contain repeated elements to fill the model instance with data.

[0146]具体的,可以采用使用set方法对所述模型实例进行数据填充,比如: [0146] Specifically, the set method can be used to fill the model instance with data, for example:

[0147] UserEntityuser= (UserEntity) session• get (UserEntity • shardFor (〃2〃)," 2"); [0147] UserEntityuser= (UserEntity) session• get (UserEntity• shardFor (〃2〃), "2");

[0148] user•setName (〃user—modified") [0148] user•setName (〃user—modified")

[0149] 通过本实施例中的方法,能够通过显式方式指定所述需要进行数据操作的子表模型类进行相关数据操作。 [0149] Through the method in this embodiment, it is possible to explicitly specify the sub-table model class that needs to perform data operations to perform related data operations.

[0150]图6为本发明实施例提供的一种分表装置,参见图6,该装置包括: [0150] FIG. 6 is a meter division device provided by an embodiment of the present invention. Referring to FIG. 6, the device includes:

[0151]生成模块601,用于动态生成多个子表模型类。 [0151] The generating module 601 is used to dynamically generate multiple sub-table model classes.

[0152]当数据库中的数据容量发展到一定程度之后,为了提高数据库的响应速度,可以将整个数据库的单个大表拆分成多个小表。 [0152] After the data capacity in the database has developed to a certain extent, in order to improve the response speed of the database, a single large table of the entire database can be split into multiple small tables. 在进行拆分时,可以采用多种预设规则来进行, 比如: When splitting, a variety of preset rules can be used, such as:

[0153] (1)按自然时间来分表[0153] (1) Dividing tables according to natural time

[0154]如一个业务的统计数据量达到一定的规模(如2〇0万条左右),那么就可以考虑用一年的数据来作为一个表存储,例如,表名为app,那么2〇10年的数据就是app_2010,app_ 2011,• • •。 [0154] If the amount of statistical data of a business reaches a certain scale (such as about 20,000 items), then one year's data can be considered as a table for storage. For example, if the table is named app, then 2〇10 The data for the year is app_2010, app_ 2011, • • •. 当然也可以采用其他时间方式,如按照月来进行来分,如app_2〇l〇_〇l,app_ 2010—02,___〇 Of course, other time methods can also be used, such as dividing by month, such as app_2〇l〇_〇l, app_ 2010-02, ___〇

[0155] (2)按数字类型hash分表[0155] (2) According to the number type hash table

[0156]举例而言,如果要存储用户的信息,而业务数据的量很大,用单表是不能满足存储需求,那么就可以用用户的编号来进行hash,常见的是用取余操作,如果要分30张表来存储用户的信息,那么用户编号为1的用户1%30 = 1,那么就存在user_01表里,如用户的编号为500,那么500 % 30 = 20,将此用户的信息存储在user_20的表里。 [0156] For example, if you want to store user information, and the amount of business data is large, and a single table cannot meet the storage requirements, you can use the user number to hash, and the common one is to use the remaining operation. If you want to divide 30 tables to store user information, then user 1% 30 = 1 with the user number 1, then it exists in the user_01 table. For example, if the user number is 500, then 500% 30 = 20. The information is stored in the table of user_20.

[0157] (3)按md5值来分表[0157] (3) Divide the table by md5 value

[0158] 假设要存储用户上传的文件,如果上传量大的话,也会带来系统的瓶颈问题,比如,在一个数据库表格下如果超过20000个文件的话,文件的浏览效率会降低。 [0158] Assuming that files uploaded by users are to be stored, if the upload volume is large, it will also cause system bottlenecks. For example, if there are more than 20,000 files in a database table, the browsing efficiency of the files will be reduced. 此时可以用文件的用户名来md5或者用文件的md5校验值来做,可以用md5的前3位来做hash,这样最多我们就可以得到16~3 = 4〇96个表,每次在存储文件的时候,就可以用文件名的md5值的前3 位来确定这个文件该存哪张表。 At this time, you can use the user name of the file to md5 or use the md5 checksum of the file to do it. You can use the first 3 digits of md5 as the hash, so that at most we can get 16~3 = 4〇96 tables, each time When storing a file, you can use the first 3 digits of the md5 value of the file name to determine which table the file should be stored in.

[0159]上述预设规则生成的每一个表均对应一个子表模型类。 [0159] Each table generated by the foregoing preset rules corresponds to a sub-table model class. 具体的,可以用ByteBuddy 动态生成多个子表模型类,当然也可以使用cglib和javaassist第三方开源类库,来动态生成多个子表模型类。 Specifically, you can use ByteBuddy to dynamically generate multiple sub-table model classes, of course, you can also use cglib and javaassist third-party open source class libraries to dynamically generate multiple sub-table model classes. 这三个类库都是用了asm这个开源类库,它可以动态操作java子节码来构造动态Java类These three class libraries all use asm, an open source class library, which can dynamically manipulate java subsection codes to construct dynamic Java classes

[0160]注册模块602,用于在开源框架的配置中心注册所述子表模型类。 [0160] The registration module 602 is used to register the sub-table model class in the configuration center of the open source framework.

[0161]注册到hibernate配置中心可以采用静态方式加载,也可以采用动态方式加载。 [0161] Registering to the hibernate configuration center can be loaded in a static way, or it can be loaded in a dynamic way. [0162] Hibernate通常是在web容器启动的时候根据相关配置信息,扫描Class文件,然后注册到SessionFactory中,可以操作Java子节码来构造动态Java类,具体为通过编写java 的汇编指令序列化生成一个类文件,然后使用class loader来加载这个类文件。 [0162] Hibernate usually scans the Class file according to the relevant configuration information when the web container is started, and then registers it in the SessionFactory. The Java subsection code can be manipulated to construct a dynamic Java class, which is specifically generated by writing java assembly instruction serialization A class file, and then use class loader to load this class file.

[0163]对于在容器启动已经完成后,程序正常运行期间产生的类,由于hi bernate不能识别这个新创建的类,此时不能直接使用hibernate的接口。 [0163] For the class generated during the normal operation of the program after the container startup has been completed, since hibernate cannot recognize this newly created class, the hibernate interface cannot be used directly at this time. 此时可以采用动态注册的方式来进行。 At this time, the method of dynamic registration can be adopted. 考虑到安全性问题,此时不再使用原来的SessionFactory 了,而是获取SessionFactory,判断子表模型类是否动态加载到JVM中,如果是,则更新当前的Configuration,并重亲jf 创建一个SessionFactory。 Taking into account security issues, the original SessionFactory is no longer used at this time, but the SessionFactory is obtained to determine whether the sub-table model class is dynamically loaded into the JVM. If it is, the current Configuration is updated and jf creates a SessionFactory.

[0164]选择模块㈤3,用于选择所述子表模型类中需要进行数据操作的子表模型类。 [0164] The selection module (V3) is used to select the sub-table model class that needs to perform data operations among the sub-table model classes.

[0165] 定义散列方法,根据特定的散列参数选择相应的子表模型类,该散列参数可以是模型主键Id,也可以是模型的其他字段,还可以是时间参数等。 [0165] Define a hash method, and select the corresponding sub-table model class according to a specific hash parameter. The hash parameter can be the model primary key Id, or other fields of the model, or a time parameter.

[0166] 举例而言,比如对于记录用户的所有购买记录的数据库,如果将所有记录放入到一张表userbuy表中,势必会非常巨大。 [0166] For example, for a database that records all purchase records of users, if all the records are put into one table, the userbuy table, it is bound to be very huge. 所以可以通过对用户id进行分表处理,将不同用户的购买记录放入不同的分表中。 Therefore, the purchase records of different users can be put into different sub-tables by performing sub-table processing on the user id. 具体做法如下: The specific methods are as follows:

[0167] 预估业务量,将最初的userbuy表,扩展为100张相同表结构的userbuy_index表, 原表结构如表一所不: [0167] To estimate the business volume, expand the original userbuy table to 100 userbuy_index tables with the same table structure. The original table structure is as shown in Table 1:

[0168] 所有的分表采用完全相同的表结构,当需要新增一条分表记录时,过程如下:首先对用户id进行hash计算,得到hash值,该hash值必然是0-99,目的是将对应的用户id数据, 写入到同一张分表中,此时,基于该hash值便可以选取子表模型类。 [0168] All sub-tables adopt the same table structure. When a new sub-table record needs to be added, the process is as follows: first, perform a hash calculation on the user id to obtain the hash value. The hash value must be 0-99, and the purpose is Write the corresponding user id data into the same sub-table. At this time, the sub-table model class can be selected based on the hash value.

[0169] 执行模块604,用于利用所述开源框架提供的数据操作功能,对所述需要进行数据操作的子表模型类的实例执行相应的数据操作。 [0169] The execution module 604 is configured to use the data operation function provided by the open source framework to perform corresponding data operations on the instance of the sub-table model class that needs to perform data operations.

[0170] 使用原生的Hibernate数据增加、数据删除、数据修改、及数据查询等数据操作功能,显式指定具体子表模型类进行相关数据操作。 [0170] Use the native Hibernate data operation functions such as data addition, data deletion, data modification, and data query to explicitly specify specific sub-table model classes to perform related data operations. 通过显示指定分表,使用者可以明确指定是要向哪个分表发起相关数据操作,使用者可以清晰理解数据的物理数据结构。 By displaying the designated sub-table, the user can clearly specify which sub-table to initiate related data operations, and the user can clearly understand the physical data structure of the data.

[0171] 具体而言,通过构造子表模型类的实例,并对该子表模型类的实例进行数据操作来来实现数据操作功能。 [0171] Specifically, the data manipulation function is realized by constructing an instance of the sub-table model class and performing data operations on the instance of the sub-table model class. 构造模型类的实例时,先根据散列参数选择相应的子表模型类,再使用反射方法Class.newlnstance ()构造对应子类的模型实例,最后再使用set方法填充对象。 When constructing an instance of a model class, first select the corresponding sub-table model class according to the hash parameters, then use the reflection method Class.newlnstance () to construct the model instance of the corresponding sub-class, and finally use the set method to fill the object. 之所以使用反射方法,因为相应的子表模型类是动态定义的。 The reflection method is used because the corresponding sub-table model class is dynamically defined.

[0172] 上述分表装置60,除了包括上述模块之外,可选的,参见图7,分表装置60还可以包括: [0172] In addition to the above-mentioned modules, the above-mentioned meter-dividing device 60 may optionally, referring to FIG. 7, the meter-dividing device 60 may further include:

[0173] 定义模块701,用于在所述开源框架中定义单表模型类。 [0173] The definition module 701 is used to define a single table model class in the open source framework.

[0174] 具体的,可以在Hibernate的配置文件hibernate • cfg • xml中添加如下代码: [0174] Specifically, the following code can be added to the Hibernate configuration file hibernate • cfg • xml:

[0175] <properties> [0175] <properties>

[0176] 〈property name = "hibernate • hbm2ddl • auto"value = "create〃/> [0176] <property name = "hibernate • hbm2ddl • auto"value = "create〃/>

[0177] </properties> [0177] </properties>

[0178] 通过在开源框架中定义单表模型类,能够在步骤S101中动态生成的多个子表模型类时,复用步骤S2〇l中定义的单表模型类代码,在简化代码编写的同时,更便于对代码进行维护。 [0178] By defining the single-table model class in the open source framework, when multiple sub-table model classes are dynamically generated in step S101, the single-table model class code defined in step S201 can be reused, while simplifying code writing , It is easier to maintain the code.

[0179]本实施例中的分表装置,实现简单,使用简单,有很强的可理解性,大幅减少了学习代价和维护成本,性能接近原生的0RM单表操作。 [0179] The meter splitting device in this embodiment is simple to implement, simple to use, has strong comprehensibility, greatly reduces learning costs and maintenance costs, and has performance close to native ORM single meter operations.

[0180] 可选的,参见图8,选择模块603,可以包括: [0180] Optionally, referring to FIG. 8, the selection module 603 may include:

[0181]定义模块8〇1,用于基于所述开源框架关联的数据库的分表需求定义散列方法; [0182]获取模块802,用于获取所述开源框架关联的数据库的预设字段; [0181] The definition module 801 is used to define a hashing method based on the table-splitting requirements of the database associated with the open source framework; [0182] The acquisition module 802 is used to obtain preset fields of the database associated with the open source framework;

[0183]运算模块803,用于基于所述散列方法对所述预设字段进行数据运算; [0183] Operation module 803, configured to perform data operation on the preset field based on the hash method;

[0184]确定模块804,用于根据所述数据运算的结果确定需要进行数据操作的子表模型类。 [0184] The determination module 804 is configured to determine the sub-table model class that needs to perform data operations according to the result of the data operation.

[0185] 可选的,参见图9,执行模块604,可以包括: [0185] Optionally, referring to FIG. 9, the execution module 604 may include:

[0186]指定模块901,用于使用所述开源框架提供的数据增加、数据删除、数据修改及数据查询功能,显式指定所述需要进行数据操作的子表模型类进行相关数据操作; [0186] The specifying module 901 is used to use the data addition, data deletion, data modification and data query functions provided by the open source framework to explicitly specify the sub-table model classes that need to be operated on to perform related data operations;

[0187]构建模块902,用于使用反射方法构建所述需要进行数据操作的子表模型类的模型实例; [0187] The building module 902 is configured to use the reflection method to build the model instance of the sub-table model class that needs to perform data operations;

[0188]填充模块903,用于使用不包含重复元素的类集对所述模型实例进行数据填充。 [0188] The filling module 903 is configured to use a cluster that does not contain repeated elements to fill the model instance with data. [0189]图8-9实施例中各模块的功能与其对应的方法实施例中的内容相对应,在此不再赘述。 [0189] The function of each module in the embodiments of FIGS. 8-9 corresponds to the content in the corresponding method embodiment, and will not be repeated here.

[0190]图10示出了本发明实施例提供的电子设备100的结构示意图,电子设备1〇〇包括至少一个处理器1001 (例如CPU),至少一个输入输出接口1〇〇4,存储器1002,和至少一个通信总线1003,用于实现这些部件之间的连接通信。 [0190] FIG. 10 shows a schematic structural diagram of an electronic device 100 provided by an embodiment of the present invention. The electronic device 100 includes at least one processor 1001 (such as a CPU), at least one input and output interface 1004, and a memory 1002. And at least one communication bus 1003, used to realize the connection and communication between these components. 至少一个处理器1〇01用于执行存储器10〇2 中存储的计算机指令,以使所述至少一个处理器1001能够执行前述任一分表方法的实施例。 The at least one processor 1001 is configured to execute computer instructions stored in the memory 1002, so that the at least one processor 1001 can execute any embodiment of the aforementioned table division method. 存储器1〇〇2为非暂态存储器(non-transitory memory),其可以包含易失性存储器,例如高速随机存取存储器(RAM:Random Access Memory),也可以包括非易失性存储器(nonvolatile memory) ,例如至少一个磁盘存储器。 The memory 1002 is a non-transitory memory (non-transitory memory), which may include a volatile memory, such as a high-speed random access memory (RAM: Random Access Memory), and may also include a non-volatile memory (nonvolatile memory). ), Such as at least one disk storage. 通过至少一个输入输出接口i〇〇4(可以是有线或者无线通信接口)实现与至少一个其他设备或单元之间的通信连接。 The communication connection with at least one other device or unit is realized through at least one input and output interface 1004 (which may be a wired or wireless communication interface).

[0191] 在一些实施方式中,存储器1002存储了程序10021,处理器1001执行程序10021,用于执行前述任一分表方法实施例中的内容。 [0191] In some implementation manners, the memory 1002 stores a program 10021, and the processor 1001 executes the program 10021, which is used to execute the content in any one of the foregoing embodiment of the table splitting method.

[0192] 该电子设备可以以多种形式存在,包括但不限于: [0192] The electronic device may exist in various forms, including but not limited to:

[0193] (1)移动通信设备:这类设备的特点是具备移动通信功能,并且以提供话音、数据通信为主要目标。 [0193] (1) Mobile communication equipment: This type of equipment is characterized by having a mobile communication function, and its main goal is to provide voice and data communication. 这类终端包括:智能手机(例如iPhone)、多媒体手机、功能性手机,以及低端手机等。 Such terminals include: smart phones (such as iPhone), multimedia phones, functional phones, and low-end phones.

[0194] (2)超移动个人计算机设备:这类设备属于个人计算机的范畴,有计算和处理功能,一般也具备移动上网特性。 [0194] (2) Ultra-mobile personal computer equipment: This type of equipment belongs to the category of personal computers, has calculation and processing functions, and generally also has mobile Internet features. 这类终端包括:PDA、MID和UMPC设备等,例如iPad。 Such terminals include: PDA, MID and UMPC devices, such as iPad.

[0195] (3)便携式娱乐设备:这类设备可以显示和播放多媒体内容。 [0195] (3) Portable entertainment equipment: This type of equipment can display and play multimedia content. 该类设备包括:音频、 视频播放器(例如iPod),掌上游戏机,电子书,以及智能玩具和便携式车载导航设备。 Such devices include: audio, video players (such as iPod), handheld game consoles, e-books, as well as smart toys and portable car navigation devices.

[0196] (4)特定服务器:提供计算服务的设备,服务器的构成包括处理器、硬盘、内存、系统总线等,服务器和通用的计算机架构类似,但是由于需要提供高可靠的服务,因此在处理能力、稳定性、可靠性、安全性、可扩展性、可管理性等方面要求较高。 [0196] (4) A specific server: a device that provides computing services. The structure of the server includes a processor, hard disk, memory, system bus, etc. The server is similar to a general computer architecture, but because it needs to provide highly reliable services, it is processing Ability, stability, reliability, security, scalability, manageability and other aspects have high requirements.

[0197] (5)其他具有数据交互功能的电子设备。 [0197] (5) Other electronic devices with data interaction functions.

[0198]需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。 [0198] It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these entities. Or there is any such actual relationship or sequence between operations. 而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。 Moreover, the terms "include", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes those that are not explicitly listed Other elements of, or also include elements inherent to this process, method, article or equipment. 在没有更多限制的情况下,由语句“包括一个......”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。 Without more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other same elements in the process, method, article, or equipment that includes the element.

[0199]本说明书中的各个实施例均采用相关的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。 [0199] The various embodiments in this specification are described in a related manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments.

[0200] 尤其,对于装置实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。 [0200] In particular, as for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for related parts, please refer to the part of the description of the method embodiment.

[0201]在流程图中表示或在此以其他方式描述的逻辑和/或步骤,例如,可以被认为是用于实现逻辑功能的可执行指令的定序列表,可以具体实现在任何计算机可读介质中,以供指令执行系统、装置或设备(如基于计算机的系统、包括处理器的系统或其他可以从指令执行系统、装置或设备取指令并执行指令的系统)使用,或结合这些指令执行系统、装置或设备而使用。 [0201] The logic and/or steps represented in the flowchart or described in other ways herein, for example, can be considered as a sequence table of executable instructions for realizing logical functions, and can be embodied in any computer readable In the medium, for use by an instruction execution system, device, or device (such as a computer-based system, a system including a processor, or other systems that can fetch instructions from the instruction execution system, device, or device and execute the instructions), or execute in combination with these instructions System, device or equipment. 就本说明书而言,〃计算机可读介质〃可以是任何可以包含、存储、通信、传播或传输程序以供指令执行系统、装置或设备或结合这些指令执行系统、装置或设备而使用的装置。 For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transmit a program for use by an instruction execution system, device, or device or in combination with these instruction execution systems, devices, or devices. 计算机可读介质的更具体的示例(非穷尽性列表)包括以下:具有一个或多个布线的电连接部(电子装置),便携式计算机盘盒(磁装置),随机存取存储器(RAM),只读存储器(ROM),可擦除可编辑只读存储器(EPROM或闪速存储器),光纤装置,以及便携式光盘只读存储器(CDR0M)。 More specific examples (non-exhaustive list) of computer readable media include the following: electrical connections (electronic devices) with one or more wiring, portable computer disk cases (magnetic devices), random access memory (RAM), Read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable CD-ROM read-only memory (CDR0M). 另外,计算机可读介质甚至可以是可在其上打印所述程序的纸或其他合适的介质,因为可以例如通过对纸或其他介质进行光学扫描,接着进行编辑、解译或必要时以其他合适方式进行处理来以电子方式获得所述程序,然后将其存储在计算机存储器中。 In addition, the computer-readable medium may even be paper or other suitable medium on which the program can be printed, because it can be used, for example, by optically scanning the paper or other medium, and then editing, interpreting, or other suitable media if necessary. The program is processed in a way to obtain the program electronically and then stored in the computer memory.

[0202]应当理解,本发明的各部分可以用硬件、软件、固件或它们的组合来实现。 [0202] It should be understood that each part of the present invention can be implemented by hardware, software, firmware, or a combination thereof.

[0203]在上述实施方式中,多个步骤或方法可以用存储在存储器中且由合适的指令执行系统执行的软件或固件来实现。 [0203] In the foregoing embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. 例如,如果用硬件来实现,和在另一实施方式中一样,可用本领域公知的下列技术中的任一项或他们的组合来实现:具有用于对数据信号实现逻辑功能的逻辑门电路的离散逻辑电路,具有合适的组合逻辑门电路的专用集成电路,可编程门阵列(PGA),现场可编程门阵列(FPGA)等。 For example, if it is implemented by hardware, as in another embodiment, it can be implemented by any one or a combination of the following technologies known in the art: Discrete logic circuits, application specific integrated circuits with suitable combinational logic gates, programmable gate array (PGA), field programmable gate array (FPGA), etc.

[0204]以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。 [0204] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes within the technical scope disclosed in the present invention. Or replacements should be covered within the protection scope of the present invention. 因此,本发明的保护范围应以权利要求的保护范围为准。 Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims (15)

1. 一种分表方法,其特征在于,包括: 动态生成多个子表模型类; 在开源框架的配置中心注册所述子表模型类; 选择所述子表模型类中需要进行数据操作的子表模型类; 利用所述开源框架提供的数据操作功能,对所述需要进行数据操作的子表模型类例执行相应的数据操作; 其中,所述在开源框架的配置中心注册所述子表模型类,包括: 获取所述开源框架的会话接口文件; 基于所述会话接口文件,判断所述子表模型类是否采用动态方式进行加载; 当所述子表模型类采用动态方式进行加载时,更新所述开源框架的配置文件,并重新创建所述开源框架的会话接口文件。 1. A table splitting method, comprising: dynamically generating a plurality of sub-table model classes; registering the sub-table model class in the configuration center of the open source framework; selecting the sub-table model classes that need to perform data operations Table model classes; use the data operation functions provided by the open source framework to perform corresponding data operations on the sub-table model classes that require data operations; wherein, the sub-table model is registered in the configuration center of the open source framework The class includes: obtaining the session interface file of the open source framework; based on the session interface file, determining whether the sub-table model class is loaded in a dynamic manner; updating when the sub-table model class is loaded in a dynamic manner The configuration file of the open source framework, and the session interface file of the open source framework is recreated. ' ' 2. 根据权利要求1所述的分表方法,其特征在于,在所述动态生成多个子表模型前,所述方法还包括: 在所述开源框架中定义单表模型类。 2. The table segmentation method according to claim 1, wherein before the dynamically generating multiple sub-table models, the method further comprises: defining a single-table model class in the open source framework. 3.根据权利要求1所述的分表方法,其特征在于,所述动态生成多个子表模型类,包括. 获取所述开源框架关联的数据库的分表需求; ' 基于所述分表需求,利用第三方开源类库动态生成多个子表模型类。 3. The table splitting method according to claim 1, wherein the dynamically generating a plurality of sub-table model classes includes: obtaining a table splitting requirement of a database associated with the open source framework;'based on the table splitting requirement, Use third-party open source class libraries to dynamically generate multiple sub-table model classes. 4.根据权利要求1所述的分表方法,其特征在于,所述在开源框架的配置中心注册所述子表模型类,包括: 生成所述子表模型类对应的类文件; 将所述类文件保存在所述开源框架的预设扫描位置。 4. The table segmentation method according to claim 1, wherein the registering the sub-table model class in the configuration center of the open source framework comprises: generating a class file corresponding to the sub-table model class; The class file is stored in the preset scanning position of the open source framework. 5.根据权利要求3所述的分表方法,其特征在于,所述选择所述子表模型类中需要进行数据操作的子表模型类,包括: 基于所述开源框架关联的数据库的分表需求定义散列方法; 获取所述开源框架关联的数据库的预设字段; 基于所述散列方法对所述预设字段进行数据运算; 根据所述数据运算的结果确定需要进行数据操作的子表模型类。 5. The table segmentation method according to claim 3, wherein the selecting the sub-table model class that needs to perform data operations among the sub-table model classes comprises: table sub-table based on the database associated with the open source framework Demand-defined hashing method; obtaining preset fields of the database associated with the open source framework; performing data operations on the preset fields based on the hashing method; determining the sub-tables that require data operations based on the results of the data operations Model class. 6. 根据权利要求1所述的分表方法,其特征在于,所述利用所述开源框架提供的数据操作功能,对所述需要进行数据操作的子表模型类的实例执行相应的数据操作,包括: 使用所述开源框架提供的数据增加、数据删除、数据修改及数据查询功能,显式指定所述需要进行数据操作的子表模型类进行相关数据操作。 6. The table segmentation method according to claim 1, wherein the data operation function provided by the open source framework is used to perform a corresponding data operation on the instance of the sub-table model class that requires data operation, Including: Use the data addition, data deletion, data modification and data query functions provided by the open source framework to explicitly specify the sub-table model class that needs to perform data operations to perform related data operations. 7. 根据权利要求6所述的分表方法,其特征在于,所述利用所述开源框架提供的数据操作功能,对所述需要进行数据操作的子表模型类的实例执行相应的数据操作,还包括: 使用反射方法构建所述需要进行数据操作的子表模型类的模型实例; 使用不包含重复元素的类集对所述模型实例进行数据填充。 7. The table segmentation method according to claim 6, wherein the data operation function provided by the open source framework is used to perform a corresponding data operation on the instance of the sub-table model class that requires data operation, It also includes: using a reflection method to construct a model instance of the sub-table model class that requires data manipulation; and using a class set that does not contain repeated elements to fill the model instance with data. 8. —种分表装置,其特征在于,包括: 生成模块,用于动态生成多个子表模型类; 注册模块,用于在开源框架的配置中心注册所述子表模型类; 选择模块,用于选择所述子表模型类中需要进行数据操作的子表模型类; 执行模块,用于利用所述开源框架提供的数据操作功能,对所述需要进彳了数据探作的子表模型类的实例执行相应的数据操作•, 其中,所述注册模块,还用于: 获取所述开源框架的会话接口文件; 基于所述会话接口文件,判断所述子表模型类是否采用动态方式进行加载; 当所述子表模型类采用动态方式进行加载时,更新所述开源框架的配置文件,并重新创建所述开源框架的会话接口文件。 8. A table splitting device, characterized in that it includes: a generating module for dynamically generating a plurality of sub-table model classes; a registration module for registering the sub-table model classes in the configuration center of the open source framework; a selection module for using To select the sub-table model classes that need to perform data operations among the sub-table model classes; the execution module is used to use the data manipulation functions provided by the open source framework to perform data exploration on the sub-table model classes that need to be processed The instance of executes the corresponding data operation•, where the registration module is also used to: obtain the session interface file of the open source framework; based on the session interface file, determine whether the sub-table model class is loaded in a dynamic manner When the sub-table model class is loaded in a dynamic manner, the configuration file of the open source framework is updated, and the session interface file of the open source framework is recreated. 9. 根据权利要求8所述的分表装置,其特征在于,所述装置还包括: 定义模块,用于在所述开源框架中定义单表模型类。 9. The meter segmentation device according to claim 8, wherein the device further comprises: a definition module, configured to define a single meter model class in the open source framework. 10. 根据权利要求8所述的分表装置,其特征在于,所述生成模块,还用于: 获取所述开源框架关联的数据库的分表需求; 基于所述分表需求,利用第三方开源类库动态生成多个子表模型类。 10. The meter splitting device according to claim 8, wherein the generating module is further configured to: obtain a meter splitting requirement of a database associated with the open source framework; based on the meter splitting requirement, use a third-party open source The class library dynamically generates multiple sub-table model classes. 11. 根据权利要求8所述的分表装置,其特征在于,所述注册模块,还用于: 生成所述子表模型类对应的类文件; 将所述类文件保存在所述开源框架的预设扫描位置。 11. The meter segmentation device according to claim 8, wherein the registration module is further configured to: generate a class file corresponding to the sub-table model class; save the class file in the open source framework Preset scan position. 12. 根据权利要求10所述的分表装置,其特征在于,所述选择模块,包括: 定义模块,用于基于所述开源框架关联的数据库的分表需求定义散列方法; 获取模块,用于获取所述开源框架关联的数据库的预设字段; 运算模块,用于基于所述散列方法对所述预设字段进行数据运算; 确定模块,用于根据所述数据运算的结果确定需要进行数据操作的子表模型类。 12. The table segmentation device according to claim 10, wherein the selection module comprises: a definition module for defining a hash method based on the table segmentation requirements of the database associated with the open source framework; To obtain the preset fields of the database associated with the open source framework; an arithmetic module for performing data operations on the preset fields based on the hashing method; a determining module for determining the need to perform operations based on the results of the data operations The sub-table model class for data manipulation. 13.根据权利要求8所述的分表装置,其特征在于,所述执行模块,包括: 指定模块,用于使用所述开源框架提供的数据增加、数据删除、数据修改及数据查询功能,显式指定所述需要进行数据操作的子表模型类进行相关数据操作。 13. The metering device according to claim 8, wherein the execution module comprises: a designated module for using the data addition, data deletion, data modification and data query functions provided by the open source framework to display The formula specifies the sub-table model class that needs to perform data operations to perform related data operations. 14.根据权利要求13所述的分表装置,其特征在于,所述执行模块,还包括: 构建模块,用于使用反射方法构建所述需要进行数据操作的子表模型类的模型实例; 填充模块,用于使用不包含重复元素的类集对所述模型实例进行数据填充。 14. The table segmentation device according to claim 13, wherein the execution module further comprises: a building module, which is used to construct a model instance of the sub-table model class that needs to perform data operations by using a reflection method; filling The module is used to fill the model instance with data using a cluster that does not contain repeated elements. ' ' 15. —种电子设备,其特征在于,所述电子设备包括: 至少一个处理器;以及, 与所述至少一个处理器通信连接的存储器;其中, 所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行前述任一权利要求卜7所述的分表方法。 15. An electronic device, wherein the electronic device includes: at least one processor; The instructions executed by the processor, the instructions are executed by the at least one processor, so that the at least one processor can execute the table splitting method according to any one of the preceding claims -17. ie.—种非暂态计算机可读存储介质,该非暂态计算机可读存储介质存储计算机指令, 该计算机指令用于使该计算机执行前述任一权利要求1-7所述的分表方法。 ie. A non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the metering method according to any one of the preceding claims 1-7.
CN201710023995.7A 2017-01-12 2017-01-12 One kind divides table method, apparatus and electronic equipment Active CN106886568B8 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710023995.7A CN106886568B8 (en) 2017-01-12 2017-01-12 One kind divides table method, apparatus and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710023995.7A CN106886568B8 (en) 2017-01-12 2017-01-12 One kind divides table method, apparatus and electronic equipment

Publications (3)

Publication Number Publication Date
CN106886568A CN106886568A (en) 2017-06-23
CN106886568B CN106886568B (en) 2018-03-30
CN106886568B8 true CN106886568B8 (en) 2018-05-01

Family

ID=59176381

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710023995.7A Active CN106886568B8 (en) 2017-01-12 2017-01-12 One kind divides table method, apparatus and electronic equipment

Country Status (1)

Country Link
CN (1) CN106886568B8 (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107423387A (en) * 2017-07-19 2017-12-01 北京北信源软件股份有限公司 The method and apparatus of table is divided in a kind of point storehouse based on middleware
CN108108434A (en) * 2017-12-19 2018-06-01 福建中金在线信息科技有限公司 A kind of method and device for managing database
CN108334576A (en) * 2018-01-24 2018-07-27 深圳市金政软件技术有限公司 A kind of data exhibiting system and its method for exhibiting data
CN111026985A (en) * 2019-12-02 2020-04-17 北京齐尔布莱特科技有限公司 Short link generation method, device and server
CN111177148B (en) * 2019-12-06 2023-03-24 南京南瑞水利水电科技有限公司 Method for automatically building and dividing tables of hydropower database
CN111199386A (en) * 2019-12-27 2020-05-26 天阳宏业科技股份有限公司 Workflow engine and implementation method thereof

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101697152A (en) * 2009-10-23 2010-04-21 金蝶软件(中国)有限公司 Database storage system and method and device for splitting data thereof
CN102682044A (en) * 2011-04-14 2012-09-19 天脉聚源(北京)传媒科技有限公司 Method for splitting tables for PHP MYSQL database
CN102867071A (en) * 2012-10-19 2013-01-09 烽火通信科技股份有限公司 Management method for massive network management historical data
CN103678609A (en) * 2013-12-16 2014-03-26 中国科学院计算机网络信息中心 Large data inquiring method based on distribution relation-object mapping processing
CN105550349A (en) * 2015-12-28 2016-05-04 北京邮电大学 Persistent layer device and database operation method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101697152A (en) * 2009-10-23 2010-04-21 金蝶软件(中国)有限公司 Database storage system and method and device for splitting data thereof
CN102682044A (en) * 2011-04-14 2012-09-19 天脉聚源(北京)传媒科技有限公司 Method for splitting tables for PHP MYSQL database
CN102867071A (en) * 2012-10-19 2013-01-09 烽火通信科技股份有限公司 Management method for massive network management historical data
CN103678609A (en) * 2013-12-16 2014-03-26 中国科学院计算机网络信息中心 Large data inquiring method based on distribution relation-object mapping processing
CN105550349A (en) * 2015-12-28 2016-05-04 北京邮电大学 Persistent layer device and database operation method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
数据库动态生成表在Hibernate中映射问题的研究与解决;姚振宇;《计算机与现代化》;20091031(第10期);全文 *

Also Published As

Publication number Publication date
CN106886568B (en) 2018-03-30
CN106886568A (en) 2017-06-23

Similar Documents

Publication Publication Date Title
CN106886568B8 (en) One kind divides table method, apparatus and electronic equipment
WO2014066416A3 (en) Method and apparatus for accelerated format translation of data in a delimited data format
EP2775388A3 (en) Method and apparatus for manipulating data on electronic device display
WO2016029617A1 (en) Four-dimensional non-equilibrium hyperchaotic system and analog circuit, based on five simplest chaotic systems
EP3358529A3 (en) Lightfield rendering based on depths from physically-based volume rendering
WO2016106216A3 (en) Systems and methods for generating virtual contexts
EP2811484A3 (en) Data processing method and electronic device thereof
EP2738807A3 (en) An apparatus including a semiconductor device coupled to a decoupling device
MY189237A (en) Copper paste for joining, method for manufacturing joined body, and method for manufacturing semiconductor device
EP2937813A3 (en) Method of processing content and electronic device using the same
EP2784666A3 (en) Method and device for displaying service pages for executing applications
EP2762999A3 (en) Overdrive voltage for an actuator to generate haptic effects
EP2991003A3 (en) Method and apparatus for classification
EP4332906A3 (en) Game engine on a chip
EP2752760A3 (en) Method of compressing data and devices for performing the same
EP3396532A3 (en) Dynamic precision for neural network compute operations
SG10202102393YA (en) Method, Client Computing Device, and Electronic Device for Displaying Payment Pages
MY188680A (en) Information input method and apparatus
EP2902972A3 (en) Efficient and stable approach to elasticity and collisions for hair animation
WO2016029619A1 (en) Rikitake system-based four-dimensional super-chaotic system having no equilibrium point, and analog circuit
EP2077506A3 (en) Apparatus and methods for editing content on a wireless device
EP3229160A3 (en) Method for configuring a medical instrument, system for con-figuring a medical instrument, computer program product and computer readable medium
MY188518A (en) Method and apparatus for generating quantitative data for biliary tree structures
EP3023740A3 (en) Method, apparatus and computer program product for route matching
EP2945126A3 (en) Graphics processing method and graphics processing apparatus

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
GR01 Patent grant
GR01 Patent grant
CB03 Change of inventor or designer information

Inventor after: Qian Wenpin

Inventor after: Liu Weiping

Inventor after: Wang Liang

Inventor after: Yu Fei

Inventor after: Chen Chao

Inventor before: Qian Wenpin

Inventor before: Yu Fei

Inventor before: Chen Chao

CB03 Change of inventor or designer information
CI03 Correction of invention patent

Correction item: Inventor

Correct: Qian Wenpin|Liu Weiping|Wang Liang|Yu Fei|Chen Chao

False: Qian Wenpin|Yu Fei|Chen Chao

Number: 13-02

Page: The title page

Volume: 34

Correction item: Inventor

Correct: Qian Wenpin|Liu Weiping|Wang Liang|Yu Fei|Chen Chao

False: Qian Wenpin|Yu Fei|Chen Chao

Number: 13-02

Volume: 34

CI03 Correction of invention patent