CN106886568B - 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
CN106886568B
CN106886568B CN201710023995.7A CN201710023995A CN106886568B CN 106886568 B CN106886568 B CN 106886568B CN 201710023995 A CN201710023995 A CN 201710023995A CN 106886568 B CN106886568 B CN 106886568B
Authority
CN
China
Prior art keywords
sublist
class
model
open framework
data
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
CN106886568A (en
CN106886568B8 (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
Publication of CN106886568B publication Critical patent/CN106886568B/en
Application granted granted Critical
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

Abstract

The embodiment of the invention discloses one kind to divide table method, apparatus and electronic installation, 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, need the example for carrying out the sublist model class of data manipulation to perform corresponding data manipulation to described.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

One kind divides table method, apparatus and electronic equipment
Technical field
The present invention relates to technical field of data processing, more particularly to database to divide list processing technique.
Background technology
Hibernate is a persistence middleware increased income based on Java, to JDBC (Java Data Base Connectivity, Java database connect) do the encapsulation of light weight.Its use ORM (Object Relation Mapping, Object Relation Mapping) mechanism, the mapping between Java object and relational database is realized, sql sentences are transmitted to database, and The result that database returns is packaged into object.Enclosed inside JDBC accesses the operation of database, provides to upper layer application OODB Object Oriented Data Base accesses API.Because it can be with the formal operations data of object, as long as modification is matched somebody with somebody when changing database It is worth file, and without being concerned about database species, thus improve development efficiency.
Table is divided to be by multiple tables that a big table cutting is same database, resistance factor data amount is excessive and influences performance A kind of method.Inventor has found that Hibernate-Shards Open Frameworks are to be based on during the present invention is realized The powerful of Hibernate divides storehouse framework, but does not support a point table.Hibernate NamingStrategy are Hibernate The table name replacement policy of offer, it can simply be divided table handling, but can not determine table name according to instance parameter dynamic, The general scene for being only used for temporally carrying out point table.Hibernate QueryInterceptor are that Hibernate is provided Blocker is inquired about, user can be intercepted when generating sql sentences, by corresponding table name dynamic replacement into specifically dividing table, Need to parse sql sentences, realize complexity, performance and maintainability are all poor, nor can be determined according to instance parameter dynamic Table name, typically can only user temporally carry out a point table.
Therefore, it is necessary to a kind of more simple and effective point of list processing method based on Hibernate.
The content of the invention
In view of this, the embodiments of the invention provide one kind to divide table method, apparatus and electronic equipment, at least part of solution Problems of the prior art.
In a first aspect, the embodiments of the invention provide one kind to divide table method, including:
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;
The data manipulation function provided using the Open Framework, to the sublist model class for needing to carry out data manipulation Example perform corresponding data manipulation.
A kind of specific implementation according to embodiments of the present invention, before the multiple sublist model classes of the dynamic generation, Methods described also includes:
Single table model class defined in the Open Framework.
A kind of specific implementation according to embodiments of the present invention, the multiple sublist model classes of dynamic generation, including:
Obtain the database of the Open Framework association divides table demand;
Divide table demand based on described, increased income the multiple sublist model classes of class libraries dynamic generation using third party.
A kind of specific implementation according to embodiments of the present invention, the configuration center in Open Framework register the son Table model class, including:
Generate class file corresponding to the sublist model class;
The class file is stored in the default scan position of the Open Framework.
A kind of specific implementation according to embodiments of the present invention, the configuration center in Open Framework register the son Table model class, including:
Obtain the session interface file of the Open Framework;
Based on the session interface file, judge whether the sublist model class is loaded using dynamical fashion;
When the sublist model class is loaded using dynamical fashion, the configuration file of the Open Framework is updated, and Re-create the session interface file of the Open Framework.
A kind of specific implementation according to embodiments of the present invention, it is described to select to need into line number in the sublist model class According to the sublist model class of operation, including:
Database based on Open Framework association divides table requirement definition ashing technique;
Obtain the preset field of the database of the Open Framework association;
Data operation is carried out to the preset field based on the ashing technique;
Determined to need the sublist model class for carrying out data manipulation according to the result of the data operation.
A kind of specific implementation according to embodiments of the present invention, the data manipulation provided using the Open Framework Function, the example for carrying out the sublist model class of data manipulation is needed to perform corresponding data manipulation to described, including:
Data increase, data deletion, data modification and the data query function provided using the Open Framework, is explicitly referred to The fixed sublist model class progress associated data operation for needing to carry out data manipulation.
A kind of specific implementation according to embodiments of the present invention, the data manipulation provided using the Open Framework Function, the example for carrying out the sublist model class of data manipulation is needed to perform corresponding data manipulation to described, in addition to:
The model instance for needing to carry out the sublist model class of data manipulation is built using method for reflection;
Data filling is carried out using model instance described in the class set pair not comprising repeat element.
Second aspect, the embodiment of the present invention additionally provide one kind and divide meter apparatus, including:
Generation module, for the multiple sublist model classes of dynamic generation;
Registering modules, the sublist model class is registered for the configuration center in Open Framework;
Selecting module, for selecting to need the sublist model class for carrying out data manipulation in the sublist model class;
Execution module, for the data manipulation function provided using the Open Framework, need to carry out data behaviour to described The example of the sublist model class of work performs corresponding data manipulation.
A kind of specific implementation according to embodiments of the present invention, described device also include:
Definition module, for single table model class defined in the Open Framework.
A kind of specific implementation according to embodiments of the present invention, the generation module, is additionally operable to:
Obtain the database of the Open Framework association divides table demand;
Divide table demand based on described, increased income the multiple sublist model classes of class libraries dynamic generation using third party.
A kind of specific implementation according to embodiments of the present invention, the Registering modules, is additionally operable to:
Generate class file corresponding to the sublist model class;
The class file is stored in the default scan position of the Open Framework.
A kind of specific implementation according to embodiments of the present invention, the Registering modules, is additionally operable to:
Obtain the session interface file of the Open Framework;
Based on the session interface file, judge whether the sublist model class is loaded using dynamical fashion;
When the sublist model class is loaded using dynamical fashion, the configuration file of the Open Framework is updated, and Re-create the session interface file of the Open Framework.
A kind of specific implementation according to embodiments of the present invention, the selecting module, including:
Definition module, divide table requirement definition ashing technique for the database that is associated based on the Open Framework;
Acquisition module, the preset field of the database for obtaining the Open Framework association;
Computing module, for carrying out data operation to the preset field based on the ashing technique;
Determining module, for being determined to need the sublist model class for carrying out data manipulation according to the result of the data operation.
A kind of specific implementation according to embodiments of the present invention, the execution module, including:
Designated module, data increase, data deletion, data modification and data for being provided using the Open Framework are looked into Function is ask, needs the sublist model class for carrying out data manipulation to carry out associated data operation described in Explicit designation.
A kind of specific implementation according to embodiments of the present invention, the execution module, in addition to:
Module is built, for building the model reality for needing to carry out the sublist model class of data manipulation using method for reflection Example;
Module is filled, for carrying out data filling using model instance described in the class set pair not comprising repeat element.
The third aspect, the embodiment of the present invention additionally provide a kind of electronic equipment, and the electronic equipment includes:
At least one processor;And
The memory being connected with least one processor communication;Wherein,
The memory storage has can be by the instruction of at least one computing device, and the instruction is by least one processor Perform, so that at least one processor is able to carry out point in any implementation of foregoing first aspect or first aspect Table method.
Fourth aspect, the embodiment of the present invention additionally provide a kind of non-transient computer readable storage medium storing program for executing, the non-transient meter Calculation machine readable storage medium storing program for executing stores computer instruction, and the computer instruction is used to make the computer perform aforementioned first aspect or the Divide table method in any implementation of one side.
5th aspect, the embodiment of the present invention additionally provide a kind of computer program product, and the computer program product includes The calculation procedure being stored on non-transient computer readable storage medium storing program for executing, the computer program includes programmed instruction, when the program When instruction is computer-executed, the computer is performed in any implementation of aforementioned first aspect or first aspect and divide table Method.
Provided in an embodiment of the present invention point of table method, apparatus, electronic equipment, non-transient computer readable storage medium storing program for executing and meter Calculation machine program, by the multiple sublist model classes of dynamic generation and Hibernate data manipulation function is combined, and then can be not Realized on the premise of significantly affecting performance and maintainability based on Hibernate frameworks to realize a point table ORM function.Due to dividing Table name can be determined during table according to instance parameter dynamic, user only needs to formulate the rule for determining table name according to instance parameter dynamic Then, therefore reached that implementation is simple, intelligibility is strong and the technology effect of study cost and maintenance cost is greatly reduced Fruit, generally improve the efficiency of point table.
Brief description of the drawings
In order to illustrate the technical solution of the embodiments of the present invention more clearly, below by embodiment it is required use it is attached Figure is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the present invention, for this area For those of ordinary skill, on the premise of not paying creative work, other accompanying drawings can also be obtained according to these accompanying drawings.
Fig. 1 is the schematic flow sheet of a kind of point of table method provided in an embodiment of the present invention;
Fig. 2 is the schematic flow sheet that another kind provided in an embodiment of the present invention divides table method;
Fig. 3 is a kind of stream of the dynamic load sublist model class provided in an embodiment of the present invention to Hibernate configuration center Journey schematic diagram;
Fig. 4 is that a kind of sublist model class based on hash provided in an embodiment of the present invention selects schematic flow sheet;
Fig. 5 is the flow that a kind of example to sub- table model class provided in an embodiment of the present invention performs corresponding data manipulation Schematic diagram;
Fig. 6 is the schematic block diagram of a kind of point of meter apparatus provided in an embodiment of the present invention;
Fig. 7 is the schematic block diagram that another kind provided in an embodiment of the present invention divides meter apparatus;
Fig. 8 is a kind of schematic block diagram of selecting module provided in an embodiment of the present invention;
Fig. 9 is a kind of schematic block diagram of execution module provided in an embodiment of the present invention;
Figure 10 is the structural representation of a kind of electronic equipment provided in an embodiment of the present invention.
Embodiment
The embodiment of the present invention is described in detail below in conjunction with the accompanying drawings.
It will be appreciated that described embodiment is only part of the embodiment of the present invention, rather than whole embodiments.Base Embodiment in the present invention, those of ordinary skill in the art obtained under the premise of creative work is not made it is all its Its embodiment, belongs to the scope of protection of the invention.
Fig. 1 is that one kind provided in an embodiment of the present invention divides table method, and referring to Fig. 1, this method comprises the following steps:
S101, the multiple sublist model classes of dynamic generation.
When the data capacity development in database to a certain extent after, in order to improve the response speed of database, it is necessary to The single big table of whole database is split into multiple small tables.When being split, can be carried out using a variety of preset rules, Such as:
(1) table is divided by natural time
Statistics amount such as a business reaches certain scale (such as 2,000,000 or so), then can considers to use The data of 1 year are used as a table storage, for example, table name is app, then the data of 2010 are exactly app_2010, app_ 2011 ....Other times mode can certainly be used, is such as carried out according to the moon to divide, such as app_2010_01, app_ 2010_02 ....
(2) table is divided by numeric type hash
For example, if to store the information of user, and the amount of business datum is very big, is that can not meet to store with single table Demand, then can carries out hash with the numbering of user, it can be common that operated with remainder, if to divide 30 tables to store The information of user, then Customs Assigned Number is 1 user 1%30=1, then be there is in user_01 tables, as the numbering of user is 500, then 500%30=20, the information of this user is stored in user_20 table.
(3) table is divided by md5 values
Assuming that to store the file of user's upload, if upload amount is big, the bottleneck problem of system is also brought along, than Such as, if it exceeds if 20000 files under a database table, the browse efficiency of file can reduce.It can now use The user name of file is carried out md5 or made of the md5 check values of file, can be hash with first 3 of md5, so most We can be obtained by 16^3=4096 table, every time when storage file, it is possible to preceding the 3 of the md5 values of filename To determine this file, which table this deposits for position.
Each table of above-mentioned preset rules generation corresponds to a sub- table model class.Specifically, ByteBuddy can be used The multiple sublist model classes of dynamic generation, naturally it is also possible to increased income class libraries, come using other third parties such as cglib or javaassist The multiple sublist model classes of dynamic generation.These three class libraries are all with this class libraries of increasing income of asm, can be saved with dynamic operation Java Code constructs Dynamic Java class.
S102, the sublist model class is registered in the configuration center of Open Framework.
Being registered to hibernate configuration center can use static mode to load, and dynamical fashion can also be used to load.
Hibernate is typically to scan class files, then according to relevant configuration information when web container starts It is registered in SessionFactory, Java section codes can be operated and construct Dynamic Java class, specifically by writes Java Assembly instruction serializing generation one class file, then load this class file using classloader.
After the completion of starting in container, caused class during normal program operation, because Hibernate can not know The class of this other new establishment, it now can not directly use Hibernate interface.For this can by the way of dynamic registration come Carry out.In view of safety issue, original existing SessionFactory is not used, but obtain SessionFactory, judges whether sublist model class is dynamically loaded into JVM, if it is, updating currently Configuration, and re-create a SessionFactory.
S103, select to need the sublist model class for carrying out data manipulation in the sublist model class.
Ashing technique is defined, corresponding sublist model class is selected according to specific hash parameter, the hash parameter can be Model major key Id or model other fields, can also be time parameter etc..
For example, the database of all purchaser records such as record user, if all records are put into , will certainly be very huge in one table userbuy table.So can be by carrying out a point list processing to user id, by different user Purchaser record be put into different divide in table.Specific practice is as follows:
Portfolio is estimated, by initial userbuy tables, expands to the userbuy_index tables of 100 identical table structures, Former table structure is as follows:
The userbuy list data structure of table one
Field Type Null Key value Acquiescence
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
All divides table to use identical table structure, and when needing newly-increased point of token record, process is as follows:First Hash calculating is carried out to user id, obtains hash values, the hash values necessarily 0-99, it is therefore an objective to by corresponding user id data, It is written in same point table, now, can be to choose sublist model class based on the hash values.
S104, the data manipulation function provided using the Open Framework, to the sublist for needing to carry out data manipulation The example of model class performs corresponding data manipulation.
Use the data manipulation work(such as primary Hibernate data increase, data deletion, data modification and data query Can, the specific sublist model class of Explicit designation carries out associated data operation.Divide table by showing to specify, user can clearly specify It is which to divide table initiate associated data operation to, user can clearly understand the physical data structure of data.
Specifically, by the example of constructor table model class, and data manipulation is carried out to the example of the sublist model class To realize data manipulation function.During the example of tectonic model class, corresponding sublist model class is first selected according to hash parameter, then The model instance of corresponding subclass is constructed using method for reflection Class.newInstance (), finally reuses the filling of set methods Object.
During realization divides table, in addition to step S101~S104 in above-described embodiment, optionally, referring to figure 2, this divides table method to comprise the following steps:
S201, single table model class defined in the Open Framework.
Specifically, following code can be added in Hibernate configuration file hibernate.cfg.xml:
< properties >
< property name=" hibernate.hbm2ddl.auto " value=" create "/>
</properties >
By single table model class defined in Open Framework, can in step S101 dynamic generation multiple sublist models During class, single table model category code defined in de-multiplexing steps S201, while simplified code is write, it is more convenient for carrying out code Safeguard.
Divide table method in the present embodiment, realize simple, using simple, have very strong intelligibility, be greatly reduced Practise cost and maintenance cost, performance is close to the primary mono- table handlings of ORM.
Optionally, the embodiment of the present invention additionally provides a kind of dynamic load sublist model class to Hibernate configuration center Method, referring to Fig. 3, this method comprises the following steps:
S301, obtain the session interface file of the Open Framework.
, it is necessary to obtain SessionFactory interfaces for Hibernate, specifically, can pass through Configuation examples create SessionFactory, as follows:
Configuration config=new Configuration () .configure ();
SessionFactory sessionFactory=config.buildSessionFactory ();
Configuration examples config can construct SessionFactory examples simultaneously according to current configuration information Return.
S302, based on the session interface file, judge whether the sublist model class is loaded using dynamical fashion.
Specifically, a Map can be obtained by SessionFactory getAllClassMetadata methods, Map key is the title of entity class, and value is ClassMetadata objects, by judging whether contain in map.keySet () There is the mode of the sublist model class to judge whether the sublist model class is loaded using dynamical fashion.Such as:
S303, when the sublist model class is loaded using dynamical fashion, update the configuration text of the Open Framework Part, and re-create the session interface file of the Open Framework.
Specifically, can be by setting function configuration.addAnnotatedClass () to update Hibernate Configuration file, and by setting function sessionFactoryList.add () to re-create Hibernate's SessionFactory。
By the above-mentioned means, sublist model class can be loaded by dynamical fashion to Hibernate configuration center.
Referring to Fig. 4, the embodiment of the present invention additionally provides a kind of sublist model class system of selection based on hash, including as follows Step:
S401, the database based on Open Framework association divide table requirement definition ashing technique.
Divide table demand according to specific, ashing technique is defined, by taking the database table single structure shown in table one as an example, number It is divided into 100 sublists according to the table in storehouse, at this point it is possible to select to carry out hash calculating using crc32 modes.
S402, obtain the preset field of the database of the Open Framework association.
Specifically, the either field in table one can be taken to carry out hash calculating, for example id can be selected as default Field.
S403, data operation is carried out to the preset field based on the ashing technique.
Crc32 result of calculations are a 10 system numbers, and under the operating system of different bit positions, obtained value may not Together, so carrying out a unified processing to it, remainder calculating then is carried out to this natural number, the divisor of remainder is exactly a point table Number, for example be 100 here.
S404, determined to need the sublist model class for carrying out data manipulation according to the result of the data operation.
By calculating the preset field of database, a table suffix number index within 0-99 has thus been obtained, has been led to Cross and be associated index numerical value and sublist model class, you can it is determined that needing to carry out the sublist model class of data manipulation.
By the method in above-described embodiment, single table can be more evenly distributed in each sublist.
Referring to Fig. 5, the embodiment of the present invention additionally provides a kind of example to sub- table model class and performs corresponding data manipulation Method, comprise the following steps:
S501, the data increase provided using the Open Framework, data deletion, data modification and data query function, The sublist model class for carrying out data manipulation is needed to carry out associated data operation described in Explicit designation.
Use the data manipulation work(such as primary Hibernate data increase, data deletion, data modification and data query Can, the specific sublist model class of Explicit designation carries out associated data operation.Divide table by showing to specify, user can clearly specify It is which to divide table initiate associated data operation to, user can clearly understand the physical data structure of data.
By taking the deletion action of sublist model class as an example, following code can be used to carry out:
Tx=session.beginTransaction ();
User=(UserEntity) session.get (UserEntity.shardFor (" 2 "), " 2 ");
System.out.println(user.getName());
session.delete(user);
tx.commit();
S502, the model instance for needing to carry out the sublist model class of data manipulation is built using method for reflection.
Specifically, first selecting corresponding sublist model class according to hash parameter, method for reflection is reused The model instance of the corresponding subclass of Class.newInstance () constructions.
S503, data filling is carried out using model instance described in the class set pair not comprising repeat element.
Data filling is carried out to the model instance using set methods specifically, can use, such as:
UserEntityuser=(UserEntity) session.get (UserEntity.shardFor (" 2 "), " 2″);
user.setName(″user_modified″)
By the method in the present embodiment, the sublist mould for needing to carry out data manipulation can be specified by explicit way Type class carries out associated data operation.
Fig. 6 is that one kind provided in an embodiment of the present invention divides meter apparatus, and referring to Fig. 6, the device includes:
Generation module 601, for the multiple sublist model classes of dynamic generation.
When the data capacity development in database to a certain extent after, can be with order to improve the response speed of database The single big table of whole database is split into multiple small tables.When being split, can be carried out using a variety of preset rules, Such as:
(1) table is divided by natural time
Statistics amount such as a business reaches certain scale (such as 2,000,000 or so), then can considers to use The data of 1 year are used as a table storage, for example, table name is app, then the data of 2010 are exactly app_2010, app_ 2011 ....Other times mode can certainly be used, is such as carried out according to the moon to divide, such as app_2010_01, app_ 2010_02 ....
(2) table is divided by numeric type hash
For example, if to store the information of user, and the amount of business datum is very big, is that can not meet to store with single table Demand, then can carries out hash with the numbering of user, it can be common that operated with remainder, if to divide 30 tables to store The information of user, then Customs Assigned Number is 1 user 1%30=1, then be there is in user_01 tables, as the numbering of user is 500, then 500%30=20, the information of this user is stored in user_20 table.
(3) table is divided by md5 values
Assuming that to store the file of user's upload, if upload amount is big, the bottleneck problem of system is also brought along, than Such as, if it exceeds if 20000 files under a database table, the browse efficiency of file can reduce.It can now use The user name of file is carried out md5 or made of the md5 check values of file, can be hash with first 3 of md5, so most We can be obtained by 16^3=4096 table, every time when storage file, it is possible to preceding the 3 of the md5 values of filename To determine this file, which table this deposits for position.
Each table of above-mentioned preset rules generation corresponds to a sub- table model class.Specifically, ByteBuddy can be used The multiple sublist model classes of dynamic generation, naturally it is also possible to increased income class libraries using cglib and javaassist third parties, dynamically to give birth to Into multiple sublist model classes.These three class libraries are all with this class libraries of increasing income of asm, and it can be with dynamic operation Java section codes Construct Dynamic Java class
Registering modules 602, the sublist model class is registered for the configuration center in Open Framework.
Being registered to hibernate configuration center can use static mode to load, and dynamical fashion can also be used to load.
Hibernate is typically to scan class files, then according to relevant configuration information when web container starts It is registered in SessionFactory, Java section codes can be operated and construct Dynamic Java class, specifically by writes java Assembly instruction serializing generation one class file, then load this class file using classloader.
After the completion of starting in container, caused class during normal program operation, because hibernate can not know The class of this other new establishment, it now can not directly use hibernate interface.Now can by the way of dynamic registration come Carry out.In view of safety issue, original SessionFactory is not used now, but obtain SessionFactory, judges whether sublist model class is dynamically loaded into JVM, if it is, updating currently Configuration, and re-create a SessionFactory.
Selecting module 603, for selecting to need the sublist model class for carrying out data manipulation in the sublist model class.
Ashing technique is defined, corresponding sublist model class is selected according to specific hash parameter, the hash parameter can be Model major key Id or model other fields, can also be time parameter etc..
For example, the database of all purchaser records such as record user, if all records are put into , will certainly be very huge in one table userbuy table.So can be by carrying out a point list processing to user id, by different user Purchaser record be put into different divide in table.Specific practice is as follows:
Portfolio is estimated, by initial userbuy tables, expands to the userbuy_index tables of 100 identical table structures, Former table structure is as shown in Table 1:
All divides table to use identical table structure, and when needing newly-increased point of token record, process is as follows:First Hash calculating is carried out to user id, obtains hash values, the hash values necessarily 0-99, it is therefore an objective to by corresponding user id data, It is written in same point table, now, can be to choose sublist model class based on the hash values.
Execution module 604, for the data manipulation function provided using the Open Framework, need to carry out data to described The example of the sublist model class of operation performs corresponding data manipulation.
Use the data manipulation work(such as primary Hibernate data increase, data deletion, data modification and data query Can, the specific sublist model class of Explicit designation carries out associated data operation.Divide table by showing to specify, user can clearly specify It is which to divide table initiate associated data operation to, user can clearly understand the physical data structure of data.
Specifically, by the example of constructor table model class, and data manipulation is carried out to the example of the sublist model class To realize data manipulation function.During the example of tectonic model class, corresponding sublist model class is first selected according to hash parameter, then The model instance of corresponding subclass is constructed using method for reflection Class.newInstance (), finally reuses the filling of set methods Object.Why method for reflection is used, because corresponding sublist model class is dynamic definition.
Above-mentioned point of meter apparatus 60, in addition to including above-mentioned module, optionally, referring to Fig. 7, meter apparatus 60 is divided to wrap Include:
Definition module 701, for single table model class defined in the Open Framework.
Specifically, following code can be added in Hibernate configuration file hibernate.cfg.xml:
< properties >
< property name=" hibernate.hbm2ddl.auto " value=" create "/>
</properties >
By single table model class defined in Open Framework, can in step S101 dynamic generation multiple sublist models During class, single table model category code defined in de-multiplexing steps S201, while simplified code is write, it is more convenient for carrying out code Safeguard.
Divide meter apparatus in the present embodiment, realize simple, using simple, have very strong intelligibility, be greatly reduced Practise cost and maintenance cost, performance is close to the primary mono- table handlings of ORM.
Optionally, referring to Fig. 8, selecting module 603, can include:
Definition module 801, divide table requirement definition ashing technique for the database that is associated based on the Open Framework;
Acquisition module 802, the preset field of the database for obtaining the Open Framework association;
Computing module 803, for carrying out data operation to the preset field based on the ashing technique;
Determining module 804, for being determined to need the sublist model for carrying out data manipulation according to the result of the data operation Class.
Optionally, referring to Fig. 9, execution module 604, can include:
Designated module 901, for data increase, data deletion, data modification and the number provided using the Open Framework According to query function, the sublist model class for carrying out data manipulation is needed to carry out associated data operation described in Explicit designation;
Module 902 is built, for building the mould for needing to carry out the sublist model class of data manipulation using method for reflection Type example;
Module 903 is filled, for carrying out data filling using model instance described in the class set pair not comprising repeat element.
Content in Fig. 8-9 embodiments in the corresponding embodiment of the method for the function of each module is corresponding, herein no longer Repeat.
Figure 10 shows the structural representation of electronic equipment 100 provided in an embodiment of the present invention, and electronic equipment 100 is included extremely A few processor 1001 (such as CPU), at least one input/output interface 1004, memory 1002, and at least one communication Bus 1003, for realizing the connection communication between these parts.At least one processor 1001 is used to perform memory 1002 The computer instruction of middle storage, so that at least one processor 1001 is able to carry out the implementation of foregoing any point of table method Example.Memory 1002 is non-transient memory (non-transitory memory), and it can include volatile memory, example Such as high-speed random access memory (RAM:Random Access Memory), nonvolatile memory (non-can also be included Volatile memory), a for example, at least magnetic disk storage.(can have by least one input/output interface 1004 Line or wireless communication interface) realize and the communication connection between at least one other equipment or unit.
In some embodiments, memory 1002 stores program 10021, the configuration processor 10021 of processor 1001, uses Content in the foregoing any point of table embodiment of the method for execution.
The electronic equipment can exist in a variety of forms, include but is not limited to:
(1) mobile communication equipment:The characteristics of this kind equipment is that possess mobile communication function, and to provide speech, data Communicate as main target.This Terminal Type includes:Smart mobile phone (such as iPhone), multimedia handset, feature mobile phone, and it is low Hold mobile phone etc..
(2) super mobile personal computer equipment:This kind equipment belongs to the category of personal computer, there is calculating and processing work( Can, typically also possess mobile Internet access characteristic.This Terminal Type includes:PDA, MID and UMPC equipment etc., such as iPad.
(3) portable entertainment device:This kind equipment can show and play content of multimedia.The kind equipment includes:Audio, Video player (such as iPod), handheld device, e-book, and intelligent toy and portable car-mounted navigation equipment.
(4) particular server:The equipment for providing the service of calculating, the composition of server include processor, hard disk, internal memory, are Bus of uniting etc., server is similar with general computer architecture, but due to needing to provide highly reliable service, therefore handling Ability, stability, reliability, security, scalability, manageability etc. require higher.
(5) other electronic equipments with data interaction function.
It should be noted that herein, such as first and second or the like relational terms are used merely to a reality Body or operation make a distinction with another entity or operation, and not necessarily require or imply and deposited between these entities or operation In any this actual relation or order.Moreover, term " comprising ", "comprising" or its any other variant are intended to Nonexcludability includes, so that process, method, article or equipment including a series of elements not only will including those Element, but also the other element including being not expressly set out, or it is this process, method, article or equipment also to include Intrinsic key element.In the absence of more restrictions, the key element limited by sentence " including one ... ", it is not excluded that Other identical element in the process including the key element, method, article or equipment also be present.
Each embodiment in this specification is described by the way of related, identical similar portion between each embodiment Divide mutually referring to what each embodiment stressed is the difference with other embodiment.
For device embodiment, because it is substantially similar to embodiment of the method, so the comparison of description is simple Single, the relevent part can refer to the partial explaination of embodiments of method.
Expression or logic and/or step described otherwise above herein in flow charts, for example, being considered use In the order list for the executable instruction for realizing logic function, may be embodied in any computer-readable medium, for Instruction execution system, device or equipment (such as computer based system including the system of processor or other can be held from instruction The system of row system, device or equipment instruction fetch and execute instruction) use, or combine these instruction execution systems, device or set It is standby and use.For the purpose of this specification, " computer-readable medium " can any can be included, store, communicate, propagate or pass Defeated program is for instruction execution system, device or equipment or the dress used with reference to these instruction execution systems, device or equipment Put.The more specifically example (non-exhaustive list) of computer-readable medium includes following:Electricity with one or more wiring Connecting portion (electronic installation), portable computer diskette box (magnetic device), random access memory (RAM), read-only storage (ROM), erasable edit read-only storage (EPROM or flash memory), fiber device, and portable optic disk is read-only deposits Reservoir (CDROM).In addition, computer-readable medium, which can even is that, to print the paper of described program thereon or other are suitable Medium, because can then enter edlin, interpretation or if necessary with it for example by carrying out optical scanner to paper or other media His suitable method is handled electronically to obtain described program, is then stored in computer storage.
It should be appreciated that each several part of the present invention can be realized with hardware, software, firmware or combinations thereof.
In the above-described embodiment, multiple steps or method can use storage to be performed in memory and by suitable instruction The software or firmware that system performs are realized.If for example, being realized with hardware, with another embodiment, can use Any one of following technology well known in the art or their combination are realized:With for realizing logic work(to data-signal The discrete logic of the logic gates of energy, there is the application specific integrated circuit of suitable combinational logic gate circuit, programmable gate Array (PGA), field programmable gate array (FPGA) etc..
The foregoing is only a specific embodiment of the invention, but protection scope of the present invention is not limited thereto, any Those familiar with the art the invention discloses technical scope in, the change or replacement that can readily occur in, all should It is included within the scope of the present invention.Therefore, protection scope of the present invention should be defined by scope of the claims.

Claims (16)

1. one kind divides table method, it is characterised in that including:
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;
The data manipulation function provided using the Open Framework, to the reality for needing to carry out the sublist model class of data manipulation Example performs corresponding data manipulation;
Wherein, the configuration center in Open Framework registers the sublist model class, including:
Obtain the session interface file of the Open Framework;
Based on the session interface file, judge whether the sublist model class is loaded using dynamical fashion;
When the sublist model class is loaded using dynamical fashion, the configuration file of the Open Framework is updated, and again Create the session interface file of the Open Framework.
2. according to claim 1 point of table method, it is characterised in that the multiple sublist model classes of the dynamic generation it Before, methods described also includes:
Single table model class defined in the Open Framework.
3. according to claim 1 point of table method, it is characterised in that the multiple sublist model classes of dynamic generation, including:
Obtain the database of the Open Framework association divides table demand;
Divide table demand based on described, increased income the multiple sublist model classes of class libraries dynamic generation using third party.
4. according to claim 1 point of table method, it is characterised in that described in the configuration center registration in Open Framework Sublist model class, including:
Generate class file corresponding to the sublist model class;
The class file is stored in the default scan position of the Open Framework.
5. according to claim 3 point of table method, it is characterised in that need to carry out in the selection sublist model class The sublist model class of data manipulation, including:
Database based on Open Framework association divides table requirement definition ashing technique;
Obtain the preset field of the database of the Open Framework association;
Data operation is carried out to the preset field based on the ashing technique;
Determined to need the sublist model class for carrying out data manipulation according to the result of the data operation.
6. according to claim 1 point of table method, it is characterised in that the data provided using the Open Framework are grasped Make function, need the example for carrying out the sublist model class of data manipulation to perform corresponding data manipulation to described, including:
Data increase, data deletion, data modification and the data query function provided using the Open Framework, Explicit designation institute The sublist model class that stating needs to carry out data manipulation carries out associated data operation.
7. according to claim 6 point of table method, it is characterised in that the data provided using the Open Framework are grasped Make function, need the example for carrying out the sublist model class of data manipulation to perform corresponding data manipulation to described, in addition to:
The model instance for needing to carry out the sublist model class of data manipulation is built using method for reflection;
Data filling is carried out using model instance described in the class set pair not comprising repeat element.
8. one kind divides meter apparatus, it is characterised in that including:
Generation module, for the multiple sublist model classes of dynamic generation;
Registering modules, the sublist model class is registered for the configuration center in Open Framework;
Selecting module, for selecting to need the sublist model class for carrying out data manipulation in the sublist model class;
Execution module, for the data manipulation function provided using the Open Framework, need to carry out data manipulation to described The example of sublist model class performs corresponding data manipulation;
Wherein, the Registering modules, are additionally operable to:
Obtain the session interface file of the Open Framework;
Based on the session interface file, judge whether the sublist model class is loaded using dynamical fashion;
When the sublist model class is loaded using dynamical fashion, the configuration file of the Open Framework is updated, and again Create the session interface file of the Open Framework.
9. according to claim 8 point of meter apparatus, it is characterised in that described device also includes:
Definition module, for single table model class defined in the Open Framework.
10. according to claim 8 point of meter apparatus, it is characterised in that the generation module, be additionally operable to:
Obtain the database of the Open Framework association divides table demand;
Divide table demand based on described, increased income the multiple sublist model classes of class libraries dynamic generation using third party.
11. according to claim 8 point of meter apparatus, it is characterised in that the Registering modules, be additionally operable to:
Generate class file corresponding to the sublist model class;
The class file is stored in the default scan position of the Open Framework.
12. according to claim 10 point of meter apparatus, it is characterised in that the selecting module, including:
Definition module, divide table requirement definition ashing technique for the database that is associated based on the Open Framework;
Acquisition module, the preset field of the database for obtaining the Open Framework association;
Computing module, for carrying out data operation to the preset field based on the ashing technique;
Determining module, for being determined to need the sublist model class for carrying out data manipulation according to the result of the data operation.
13. according to claim 8 point of meter apparatus, it is characterised in that the execution module, including:
Designated module, for data increase, data deletion, data modification and the data query work(provided using the Open Framework Can, need the sublist model class for carrying out data manipulation to carry out associated data operation described in Explicit designation.
14. according to claim 13 point of meter apparatus, it is characterised in that the execution module, in addition to:
Module is built, for building the model instance for needing to carry out the sublist model class of data manipulation using method for reflection;
Module is filled, for carrying out data filling using model instance described in the class set pair not comprising repeat element.
15. a kind of electronic equipment, it is characterised in that the electronic equipment includes:
At least one processor;And
The memory being connected with least one processor communication;Wherein,
The memory storage has can be by the instruction of at least one computing device, and the instruction is by least one place Manage device to perform, so that at least one processor is able to carry out dividing table method described in foregoing any claim 1-7.
16. a kind of non-transient computer readable storage medium storing program for executing, non-transient computer readable storage medium storing program for executing storage computer instruction, The computer instruction is used to make to divide table method described in the foregoing any claim 1-7 of computer execution.
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 true CN106886568B (en) 2018-03-30
CN106886568B8 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
CN106886568A (en) 2017-06-23
CN106886568B8 (en) 2018-05-01

Similar Documents

Publication Publication Date Title
CN106886568B (en) One kind divides table method, apparatus and electronic equipment
CN103365646B (en) Form user-defined, logical definition and processing method based on script engine
CN103544074B (en) The method of calibration of a kind of business and device
CN102713904B (en) The method and apparatus utilizing scalable data structure
US10915532B2 (en) Supporting a join operation against multiple NoSQL databases
US8418142B2 (en) Architecture for data validation
CN103377038B (en) The description of customizing form and list analytic method
US7720831B2 (en) Handling multi-dimensional data including writeback data
CN104750727B (en) A kind of column memory storage inquiry unit and column memory storage querying method
CN101566986A (en) Method and device for processing data in online business processing
US9176997B2 (en) Universe migration from one database to another
CN104408073B (en) Data manipulation method and device
US9053134B2 (en) View variants in database schema mapping
CN111124405B (en) Implementation method and system for online form design supporting front-end and back-end decoupling
CN104881490A (en) WEB form data access method and system
CN109906597A (en) To with data set that restricted data set and untethered system are stored and fetched from cloud network
US20200401623A1 (en) Autolayout of visualizations based on graph data
US11036797B2 (en) Efficient storage and utilization of a hierarchical data set
US20240004853A1 (en) Virtual data source manager of data virtualization-based architecture
US10235191B2 (en) Application specific configurable graphical user interface
US11157467B2 (en) Reducing response time for queries directed to domain-specific knowledge graph using property graph schema optimization
CN103049494B (en) Method and device for storing table of extensible markup language (XML) file
CN103561083A (en) Data processing method for Internet of things
CN106940714A (en) A kind of data processing method, device and electronic equipment
CN111506552A (en) Dynamic database design method and system of tree structure

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
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

CI03 Correction of invention patent
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