Summary of the invention
Based on this, it is necessary in view of the above technical problems, provide a kind of data fragmentation for being capable of providing data-handling efficiency
Method, apparatus, computer equipment and storage medium.
A kind of data fragmentation method, which comprises
According to the value of virtual field, data in the database are carried out partitioned storage and establish the subregion to index,
Obtain subregion index;Wherein, the value of the corresponding virtual field of each subregion;
It is indexed according to the subregion, data fragmentation is carried out to the subregion;Wherein, the data fragmentation is to the subregion
Data inquired and selected, it is described inquiry and selection after data be put into fragment.
In one of the embodiments, the method also includes: into the middle table of database add virtual field;Pass through
The value of the virtual field is calculated in relevant field relevant to business datum in the middle table.
The number of the virtual field is greater than or equal to the number of the fragment in one of the embodiments,.
In one of the embodiments, the method also includes: obtain virtual field fragmentation schema mark, the virtual word
Section fragmentation schema mark is for distinguishing normal fragmentation schema and virtual field fragmentation schema;According to the virtual field fragmentation schema
Mark selects normal fragmentation schema or virtual field fragmentation schema to carry out data fragmentation to the subregion.
In one of the embodiments, the method also includes: receive service processing result;According to the business processing knot
Fruit rejects virtual field from the data after fragment, obtains reduced data;The reduced data is migrated to historical data
Library or error database.
The service processing result includes business processing successful information and/or business processing in one of the embodiments,
Failure information.
It is described according to the service processing result in one of the embodiments, the data after the fragment are rejected empty
Quasi- field, obtains reduced data, comprising:
According to the service processing result, SQL assembly query statement is generated;
Data according to virtual field defined in the SQL assembly query statement and literary name allusion quotation, after obtaining fragment;
The virtual field is rejected from the data after the fragment, obtains reduced data;Wherein, in the literary name allusion quotation
Including the definition to the virtual field.
A kind of processing method of business, which comprises
By the data after fragment, input parameter, and incoming traffic assembly interface are defined as according to literary name allusion quotation;
The business assembly interface is handled business according to the input parameter, and feedback traffic processing result.
A kind of data fragmentation device, described device include:
Index establishes module, for the value according to virtual field, carries out partitioned storage and right to data in the database
The subregion establishes index, obtains subregion index;Wherein, the value of the corresponding virtual field of each subregion;
Fragment module carries out data fragmentation to the subregion for indexing according to the subregion;Wherein, the data point
Piece is that the data of the subregion are inquired and selected, and the data after the inquiry and selection are put into fragment.
A kind of computer equipment, including memory and processor, the memory are stored with computer program, the processing
Device performs the steps of when executing the computer program
According to the value of virtual field, data in the database are carried out partitioned storage and establish the subregion to index;
Wherein, the value of the corresponding virtual field of each subregion;
It is indexed according to the subregion, data fragmentation is carried out to the subregion, the data fragmentation is used for the subregion
Data are inquired and are selected, and the data after the inquiry and selection are put into fragment.
A kind of computer readable storage medium, is stored thereon with computer program, and the computer program is held by processor
It is performed the steps of when row
According to the value of virtual field, data in the database are carried out partitioned storage and establish the subregion to index;
Wherein, the value of the corresponding virtual field of each subregion;
It is indexed according to the subregion, data fragmentation is carried out to the subregion, the data fragmentation is used for the subregion
Data are inquired and are selected, and the data after the inquiry and selection are put into fragment.
Above-mentioned data fragmentation method, device, computer equipment and storage medium, by adding virtual field pair in middle table
Database carry out subregion, and according to the value of virtual field to the subregion establish index, by index come to carry out data fragmentation,
It avoids passing through full table inquiry and carries out data fragmentation, improve the treatment effeciency of data.
Specific embodiment
It is with reference to the accompanying drawings and embodiments, right in order to which the objects, technical solutions and advantages of the application are more clearly understood
The application is further elaborated.It should be appreciated that specific embodiment described herein is only used to explain the application, not
For limiting the application.
In one embodiment, as shown in Figure 1, providing a kind of data fragmentation method, comprising the following steps:
Step S120 carries out partitioned storage to data in the database and to the subregion according to the value of virtual field
Index is established, subregion index is obtained.Wherein, the value of the corresponding virtual field of each subregion.
Wherein, the number of the subregion is identical as the number of the value of the virtual field, according to the value of the virtual field
Corresponding subregion can be found, realizes and the subregion is indexed.Virtual field is equivalent to data dictionary, according to the virtual word
The value of section can quickly find corresponding subregion.
Specifically, the virtual field be it is multiple, tables of data is divided into multiple subregions according to multiple virtual fields.Example
Such as, it is worth the virtual field for 0, then corresponds to subregion 0, be worth the virtual field for 1, then corresponds to subregion 1, and so on, being worth is 3
Virtual field, then correspond to subregion 3.
Step S130 is indexed according to the subregion, carries out data fragmentation to the subregion;Wherein, the data fragmentation is
The data of the subregion are inquired and selected, the data after the inquiry and selection are put into fragment.
It wherein, include the data of at least one subregion according to the data that the data fragmentation obtains, according to the subregion rope
Draw, the data of multiple subregions can be obtained, it can be by partition data described in index selection into fragment.For example, there are four
A subregion is respectively as follows: subregion 0, subregion 1, subregion 2 and subregion 3, by selecting in 1 to the first fragment of index selection subregion 0 and subregion
It selects in 3 to the second fragment of subregion 2 and subregion.
For example, inquiry and the case statement of general existing subregion are as follows:
Select*from ins_user where mod (user_id, 4)=1;Indicate inquiry and selection user_id mould 4
Remaining 1 data, be equivalent to and ins_user table data be divided into 4.
The inquiry of subregion and case statement in the present embodiment the method are as follows:
Select*from ins_user where mod_id=1;Indicate inquiry and select virtual field value for 1 divide
Area, wherein the virtual field expression formula added in middle table is mod (user_id, 4), and Ins_user table increases virtual field newly
mod_id。
A kind of data fragmentation method in one of the embodiments, further includes: added into the middle table of database virtual
Field;The value of the virtual field is calculated by relevant field relevant to business datum in the middle table.
Wherein, the middle table of the database includes multiple relevant fields.For example, relevant field is user_id, indicate to use
The ID number at family.Wherein, the calculation method of the value of the virtual field is obtained using the method for modulus, and the size of mould is according to business
The data volume of generation determines.Specifically, by MOD function mod, by the dividend that is used as of the relevant field, of subregion
Number is used as divisor, and the number of value of the remainder being calculated as virtual field, the subregion is the size of mould.It is described virtual
The value of field is stored in variable mod_id.
The number of the virtual field is greater than or equal to the number of the fragment in one of the embodiments,.
A kind of data fragmentation method in one of the embodiments, further includes: virtual field fragmentation schema mark is obtained,
The virtual field fragmentation schema mark is for distinguishing normal fragmentation schema and virtual field fragmentation schema;According to the virtual word
Section fragmentation schema mark, selects normal fragmentation schema or virtual field fragmentation schema to carry out data fragmentation to the subregion.
Wherein, normal fragmentation schema refers to the existing data fragmentation method generallyd use, and virtual field fragmentation schema refers to
Be data fragmentation method employed in the embodiment of the present application.In the present embodiment, due to using TF frame, in TF frame inlet
Virtual field fragmentation schema is arranged to identify.
In one embodiment, as shown in Fig. 2, a kind of data fragmentation method, further includes:
Step S131 receives service processing result.
Wherein, the service processing result includes business processing successful information and/or business processing failure information.
Step S132 rejects virtual field from the data after fragment according to the service processing result, obtains processed
Data.
Wherein, the data after fragment be from subregion inquire and select, the data of subregion due to being added to virtual field,
Virtual field mod_id is only used for the condition of where sentence, but there can be no inside the data of insert, update column,
And it cannot modify to the value of virtual field mod_id, wherein virtual field mod_id is stored in data dictionary.This reality
It applies example and inquiry table dictionary is needed using TF frame, by table dictionary information come assembled subsequent operation sentence (insert, update
Deng), if virtual field mod_id not rejected, it will appear mistake in subsequent assembled action statement (insert, update etc.).
Step S133 migrates the reduced data to historical data base or error database.
Wherein, when service processing result is business processing successful information, the reduced data is migrated to history number
According to table;When service processing result is business processing failure information, the reduced data is migrated to wrong data table.
The method through this embodiment can migrate reduced data, avoid after reprocessing the fragment
Data.
It is described according to the service processing result in one of the embodiments, the data after the fragment are rejected empty
Quasi- field, obtains reduced data, comprising: according to the service processing result, generates SQL assembly query statement;According to described
Virtual field defined in SQL assembly query statement and literary name allusion quotation, the data after obtaining fragment;From the data after the fragment
The virtual field is rejected, reduced data is obtained;Wherein, in the literary name allusion quotation include definition to the virtual field.
Specifically, SQL assembly query statement is select*from so1.TEST_MOD_PART_FOR_TF where
mod_id in(0,1);Indicate inquiry and select virtual field value for 0 and 1 subregion.
In above-mentioned data fragmentation method, subregion is carried out to database by adding virtual field in middle table, and according to void
The value of quasi- field, which establishes the subregion, to be indexed, and, to data fragmentation is carried out, avoids passing through full table inquiry by indexing to carry out
Data fragmentation improves the treatment effeciency of data.
In one embodiment, as shown in figure 3, providing a kind of processing method of business, which comprises
Data after fragment are defined as input parameter, and incoming traffic assembly interface according to literary name allusion quotation by step S210.
Wherein, the data after fragment are scattered, need to be input parameter to data processing, be spelled by business assembly interface
Dress up complete data mode.
Step S220, the business assembly interface are handled business according to the input parameter, and at feedback traffic
Manage result.
Wherein, the service processing result includes business processing successful information and/or business processing failure information.Business packet
Include but be not limited to sales data inquiry, the inquiry of marketing data query, customer satisfaction with services.
It should be understood that although each step in the flow chart of Fig. 1-3 is successively shown according to the instruction of arrow,
These steps are not that the inevitable sequence according to arrow instruction successively executes.Unless expressly stating otherwise herein, these steps
Execution there is no stringent sequences to limit, these steps can execute in other order.Moreover, at least one in Fig. 1-3
Part steps may include that perhaps these sub-steps of multiple stages or stage are not necessarily in synchronization to multiple sub-steps
Completion is executed, but can be executed at different times, the execution sequence in these sub-steps or stage is also not necessarily successively
It carries out, but can be at least part of the sub-step or stage of other steps or other steps in turn or alternately
It executes.
In one embodiment, as shown in figure 4, providing a kind of data fragmentation device, comprising: index establishes module 320
With fragment module 330, in which:
Index establishes module 320, for the value according to the virtual field, carries out subregion to data in the database and deposits
It stores up and the subregion is established and index;Wherein, the value of the corresponding virtual field of each subregion.
Fragment module 330 carries out data fragmentation, the data fragmentation to the subregion for indexing according to the subregion
It is inquired and is selected for the data to the subregion.
A kind of data fragmentation device in one of the embodiments, further includes: adding module 310, for database
Virtual field is added in middle table, is calculated by relevant field relevant to business datum in the middle table described virtual
The value of field.
The number of the virtual field is greater than or equal to the number of the fragment in one of the embodiments,.
A kind of data fragmentation device in one of the embodiments, further includes: identifier acquisition module obtains void for setting
Quasi- field fragmentation schema mark, the virtual field fragmentation schema mark is for distinguishing normal fragmentation schema and virtual field fragment
Mode;Mode selection module selects normal fragmentation schema or virtual field for identifying according to the virtual field fragmentation schema
Fragmentation schema carries out data fragmentation to the subregion.
Wherein, normal fragmentation schema refers to the existing data fragmentation method generallyd use, and virtual field fragmentation schema refers to
Be data fragmentation method employed in the embodiment of the present application.In the present embodiment, due to using TF frame, in TF frame inlet
Virtual field fragmentation schema is arranged to identify.
A kind of data fragmentation device in one of the embodiments, further includes: Service Processing Structure receiving module is used for
Receive service processing result;Virtual field rejects module, for being picked from the data after fragment according to the service processing result
Except virtual field, reduced data is obtained;Transferring module, for migrating the reduced data to historical data base or mistake
Accidentally database.
Wherein, when service processing result is business processing successful information, the reduced data is migrated to history number
According to table;When service processing result is business processing failure information, the reduced data is migrated to wrong data table.
It includes: that query statement establishes unit that the virtual field, which rejects module, in one of the embodiments, is used for basis
The service processing result generates SQL assembly query statement;Fragment data acquiring unit, for being inquired according to the SQL assembly
Virtual field defined in sentence and literary name allusion quotation, the data after obtaining fragment;Data culling unit, for after the fragment
The virtual field is rejected in data, obtains reduced data;It wherein, include determining the virtual field in the literary name allusion quotation
Justice.
Specific about data fragmentation device limits the restriction that may refer to above for data fragmentation method, herein not
It repeats again.Modules in above-mentioned data fragmentation device can be realized fully or partially through software, hardware and combinations thereof.On
Stating each module can be embedded in the form of hardware or independently of in the processor in computer equipment, can also store in a software form
In memory in computer equipment, the corresponding operation of the above modules is executed in order to which processor calls.
In one embodiment, a kind of computer equipment is provided, which can be server, internal junction
Composition can be as shown in Figure 5.The computer equipment include by system bus connect processor, memory, network interface and
Database.Wherein, the processor of the computer equipment is for providing calculating and control ability.The memory packet of the computer equipment
Include non-volatile memory medium, built-in storage.The non-volatile memory medium is stored with operating system, computer program and data
Library.The built-in storage provides environment for the operation of operating system and computer program in non-volatile memory medium.The calculating
The database of machine equipment is used for storage service data.The network interface of the computer equipment is used to pass through network with external terminal
Connection communication.To realize a kind of data fragmentation method when the computer program is executed by processor.
It will be understood by those skilled in the art that structure shown in Fig. 5, only part relevant to application scheme is tied
The block diagram of structure does not constitute the restriction for the computer equipment being applied thereon to application scheme, specific computer equipment
It may include perhaps combining certain components or with different component layouts than more or fewer components as shown in the figure.
In one embodiment, a kind of computer equipment, including memory and processor are provided, is stored in memory
Computer program, the processor perform the steps of when executing computer program
According to the value of virtual field, data in the database are carried out partitioned storage and establish the subregion to index,
Obtain subregion index;Wherein, the value of the corresponding virtual field of each subregion;
It is indexed according to the subregion, data fragmentation is carried out to the subregion;Wherein, the data fragmentation is to the subregion
Data inquired and selected, it is described inquiry and selection after data be put into fragment.
In one embodiment, reception service processing result is also performed the steps of when processor executes computer program;
According to the service processing result, virtual field is rejected from the data after fragment, obtains reduced data;It will be described processed
Data Migration is to historical data base or error database.
In one embodiment, a kind of computer readable storage medium is provided, computer program is stored thereon with, is calculated
Machine program performs the steps of when being executed by processor
According to the value of virtual field, data in the database are carried out partitioned storage and establish the subregion to index,
Obtain subregion index;Wherein, the value of the corresponding virtual field of each subregion;
It is indexed according to the subregion, data fragmentation is carried out to the subregion;Wherein, the data fragmentation is to the subregion
Data inquired and selected, it is described inquiry and selection after data be put into fragment.
In one embodiment, it is also performed the steps of when computer program is executed by processor and receives business processing knot
Fruit;According to the service processing result, virtual field is rejected from the data after fragment, obtains reduced data;By described in
Data Migration is handled to historical data base or error database.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with
Relevant hardware is instructed to complete by computer program, the computer program can be stored in a non-volatile computer
In read/write memory medium, the computer program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein,
To any reference of memory, storage, database or other media used in each embodiment provided herein,
Including non-volatile and/or volatile memory.Nonvolatile memory may include read-only memory (ROM), programming ROM
(PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM) or flash memory.Volatile memory may include
Random access memory (RAM) or external cache.By way of illustration and not limitation, RAM is available in many forms,
Such as static state RAM (SRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate sdram (DDRSDRAM), enhancing
Type SDRAM (ESDRAM), synchronization link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM
(RDRAM), direct memory bus dynamic ram (DRDRAM) and memory bus dynamic ram (RDRAM) etc..
Each technical characteristic of above embodiments can be combined arbitrarily, for simplicity of description, not to above-described embodiment
In each technical characteristic it is all possible combination be all described, as long as however, the combination of these technical characteristics be not present lance
Shield all should be considered as described in this specification.
The several embodiments of the application above described embodiment only expresses, the description thereof is more specific and detailed, but simultaneously
It cannot therefore be construed as limiting the scope of the patent.It should be pointed out that coming for those of ordinary skill in the art
It says, without departing from the concept of this application, various modifications and improvements can be made, these belong to the protection of the application
Range.Therefore, the scope of protection shall be subject to the appended claims for the application patent.