Database implementation method, device and equipment
Technical field
The application is related to database technical field, more particularly to a kind of database implementation method, device and equipment.
Background technology
Database is to come tissue, storage and the warehouse for managing data according to data structure.When accessing database first, lead to
Some key messages of database can be often read in internal memory, and carry out a series of initialization operation, it is follow-up to realize
It is normal to access.How speed that database first access is improved, and reduces EMS memory occupation to turn into urgent problem to be solved.
The content of the invention
In view of this, the application provides a kind of database implementation method, device and equipment.
Specifically, the application is achieved by the following technical solution:
A kind of database implementation method, including:
Determine original row to be combined;
For each record of tables of data, the train value of the original row to be combined is merged according to rule is merged
Processing, obtain merging train value;
Corresponding insertion merges train value in the merging row of the tables of data.
A kind of database implementation method, including:
Train value is read from the tables of data of database;
Judge whether the train value that reads is merging train value after multiple original train values merge;
If the train value read obtains target train value to merge train value, according to regular reverse resolution is merged.
A kind of database realizing device, including:
Row determining unit, determine original row to be combined;
Train value combining unit, it is regular by the original row to be combined according to merging for each record of tables of data
Train value merge processing, obtain merge train value;
Train value inserts unit, the corresponding insertion merging train value in the merging row of the tables of data.
A kind of database realizing device, including:
Train value reading unit, train value is read from the tables of data of database;
Merge judging unit, whether the train value for judging to read is merging train value after multiple original train values merge;
Train value resolution unit, if the train value read obtains target to merge train value, according to regular reverse resolution is merged
Train value.
A kind of database realizing equipment, including:
Processor;
For storing the memory of machine-executable instruction;
Wherein, can by reading and performing the machine corresponding with the control logic of database realizing of the memory storage
Execute instruction, the processor are prompted to:
Determine original row to be combined;
For each record of tables of data, the train value of the original row to be combined is merged according to rule is merged
Processing, obtain merging train value;
Corresponding insertion merges train value in the merging row of the tables of data.
A kind of database realizing equipment, including:
Processor;
For storing the memory of machine-executable instruction;
Wherein, can by reading and performing the machine corresponding with the control logic of database realizing of the memory storage
Execute instruction, the processor are prompted to:
Train value is read from the tables of data of database;
Judge whether the train value that reads is merging train value after multiple original train values merge;
If the train value read obtains target train value to merge train value, according to regular reverse resolution is merged.
The application is when disposing database it can be seen from above description, for each record of tables of data, Ke Yigen
The train value of original row to be combined is merged into processing according to rule is merged, obtains merging train value, and in the merging of the tables of data
Corresponding insertion merges train value in row, reduces the number of columns of tables of data, and then reduces the number of columns of the main table of system, and reduction is visited first
Ask that read-write during database to key message takes, improve the speed accessed first, while the occupancy to internal memory can also be reduced.
Brief description of the drawings
Fig. 1 is a kind of schematic flow sheet of database implementation method shown in the exemplary embodiment of the application one.
Fig. 2 is the schematic flow sheet of another database implementation method shown in the exemplary embodiment of the application one.
Fig. 3 is a kind of structural representation for database realizing device shown in the exemplary embodiment of the application one.
Fig. 4 is a kind of block diagram of database realizing device shown in the exemplary embodiment of the application one.
Fig. 5 is a structural representation of the another kind shown in the exemplary embodiment of the application one for database realizing device
Figure.
Fig. 6 is the block diagram of another database realizing device shown in the exemplary embodiment of the application one.
Embodiment
Here exemplary embodiment will be illustrated in detail, its example is illustrated in the accompanying drawings.Following description is related to
During accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represent same or analogous key element.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with the application.On the contrary, they be only with it is such as appended
The example of the consistent apparatus and method of some aspects be described in detail in claims, the application.
It is only merely for the purpose of description specific embodiment in term used in this application, and is not intended to be limiting the application.
" one kind " of singulative used in the application and appended claims, " described " and "the" are also intended to including majority
Form, unless context clearly shows that other implications.It is also understood that term "and/or" used herein refers to and wrapped
Containing the associated list items purpose of one or more, any or all may be combined.
It will be appreciated that though various information, but this may be described using term first, second, third, etc. in the application
A little information should not necessarily be limited by these terms.These terms are only used for same type of information being distinguished from each other out.For example, do not departing from
In the case of the application scope, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as
One information.Depending on linguistic context, word as used in this " if " can be construed to " ... when " or " when ...
When " or " in response to determining ".
,, can be to the main table of system when accessing SQLite databases first by taking SQLite databases as an example in correlation technique
The create sentences of sqlite_master memory storages such as are segmented, parsed at the operation, to generate a resident internal storage structure.
The internal storage structure is used for some summary infos for depositing SQLite databases, such as:Show, index name, trigger name etc..
The number of columns of tables of data is more in SQLite databases, and it is more to may result in sqlite_master row, accesses SQLite first
The read-write operation of database is more, so as to cause the speed that accesses first low, while takes substantial amounts of internal memory.
In view of the above-mentioned problems, the application provides a kind of database realizing scheme, by the row in the tables of data of merging data storehouse,
To reduce the number of columns of the main table of system, so as to improve the speed that database accesses first, and memory headroom is saved.
Fig. 1 is a kind of schematic flow sheet of database implementation method shown in the exemplary embodiment of the application one.
It refer to Fig. 1, the database implementation method can apply the organizer deployment in database to be used for tissue number
According to the electronic equipment in storehouse, include following steps:
Step 101, original row to be combined are determined.
In the present embodiment, the original list shows that database organizer plans the row of deployment when organizing tables of data, than
Such as:Row for storing URL (Uniform Resource Locator, URL) etc..
In the present embodiment, the less original row of inquiry times can be defined as original row to be combined, so as to follow-up
Inquiry operation.In practical implementations, the original row that access frequency can be less than to threshold value are defined as original row to be combined, its
In, the access frequency can be configured by developer.
As an example it is assumed that database is used for the related data for storing certain APP (Application, application program), the number
There are an original URL arranged for storing a conventional button icon in the APP user interfaces, the original row according to the tables of data in storehouse
Generally only after user downloads the APP, it is queried, then the original row can be defined as to be combined original when starting first
Row.
Certainly, those skilled in the art can also determine original row to be combined using other modes, such as:According to warp
Specified original row to be combined etc. are tested, the application is not particularly limited to this.
Step 102, for each record of tables of data, according to the regular train value by the original row to be combined of merging
Processing is merged, obtains merging train value.
In the present embodiment, the merging rule can according to train value, (train value represents certain in this record by developer
One row value) particular type be configured.In one example, if the train value of original row to be combined is character string,
Then splicing merging directly can be carried out to above-mentioned original train value.
| Record |
Original row 1 to be combined |
Original row 2 to be combined |
Original row 3 to be combined |
| 25 |
Hdfh |
46 |
Dfh98 |
Table 1
As an example it is assumed that determine that certain tables of data has 3 original row to be combined, the 25th article of record of the tables of data this
The train value of 3 original row to be combined is as shown in table 1, after this 3 original train values are merged, can obtain merging train value
“Hdfh,46,Dfh98”。
, can first will be to be combined if the train value of original row to be combined is not all character string in another example
Original train value is spliced together, and then carries out serializing processing to splicing result, and splicing result is converted into binary numeral,
The binary data is exactly the merging train value obtained after merging treatment.Wherein, serializing is handled and can freely realized, the application couple
This is not particularly limited.
In the present embodiment, it is identified for ease of access equipment pairing and train value, can is to merge train value addition to merge
Flag bit, such as:It can be realized by adding the modes such as a spcial character before or after the merging train value.
Step 103, corresponding insertion merges train value in the merging row of the tables of data.
Based on abovementioned steps 102, after being merged to the train value of original row, it can will merge train value and correspondingly be inserted into conjunction
In side by side.The row for merging row and planning deployment when organizing tables of data independently of the database side of knitting in the tables of data.
Please continue to refer to the embodiment shown in Fig. 1, by taking SQLite databases as an example, data base organization side is in deployment database
When, for each record of tables of data, URL, pictorial information etc. can not be accessed or accessed frequency is less original
Row train value is merged, and the merging train value obtained after merging storage is merged in row to preassigned, reduces tables of data
Number of columns, and then reduce sqlite_master number of columns.When accessing SQLite databases first, before merging
Reduce read-write operation, improve access rate, while the occupancy to internal memory can also be reduced.
The application is when disposing database it can be seen from above description, for each record of tables of data, Ke Yigen
The train value of original row to be combined is merged into processing according to rule is merged, obtains merging train value, and in the merging of the tables of data
Corresponding insertion merges train value in row, reduces the number of columns of tables of data, and then reduces the number of columns of the main table of system, and reduction is visited first
Ask that read-write during database to key message takes, improve the speed accessed first, while the occupancy to internal memory can also be reduced.
Based on the Merge Scenarios shown in Fig. 1, the application also provides a kind of database implementation method, for data base querying.
The database implementation method can be applied in the access device, and the access equipment can be intelligent terminal, tablet personal computer, PC
Machine etc..Fig. 2 is refer to, the database implementation method includes following steps:
Step 201, train value is read from the tables of data of database.
In the present embodiment, access of the access equipment to database can include:Read access and write access, wherein, write visit
Asking to include:Insertion, modification etc..Whether read access or write access are required to read from the data table related of database
Data, for ease of description, the data read can be referred to as to train value (train value represents certain value for being recorded in a certain row).
Step 202, whether the train value for judging to read is merging train value after multiple original train values merge.
Based on abovementioned steps 201, after train value is read, it can be determined that merging mark whether is carried in the train value
Position, if not carrying, the train value that can determine to read is not to merge train value, can be entered according to the implementation in correlation technique
Row processing.If the train value read, which carries, merges flag bit, it is to merge train value that can illustrate the train value, and then performs step
203。
Step 203, if the train value read is merges train value, target train value is obtained according to regular reverse resolution is merged.
Based on the judged result of abovementioned steps 202, after it is determined that the train value read is to merge train value, merging can be parsed
Train value, the original train value before being merged, this target train value accessed is then found in original train value.
Exemplified by merging rule and be serializing processing, in this step, for merging train value, inverted sequence first can be carried out to it
Rowization processing, the merging train value after serializing is handled are reduced to multiple original train values, then looked into multiple original train values
Find the target train value of this access.
After target train value is found, if read access, then it can be inserted in field corresponding to Object;If
Write access, then write operation can be carried out to the target train value according to the write access, after write operation is finished, according to merging
Rule merges the non-targeted train value in new target train value and the merging train value, obtains new merging train value, uses
The new merging train value for merging train value and replacing the tables of data storage.
For example, still by taking the original train value shown in table 1 as an example, recorded for this, data base organization side is in tissue number
During according to storehouse, serializing processing is carried out to the original train value of original row 1,2 and 3 to be combined, obtains merging train value 1.In this reality
Apply in example, access equipment is read based on write access merges train value 1, then carries out unserializing processing to the merging train value, can
So that the merging train value 1 to be reduced to the original train value shown in table 1.Assuming that the write access is to need original train value 2 being revised as
" 48 ", then original train value 2 can be revised as " 48 " by access equipment by " 46 ", and then access equipment continuation can be to original row
The train value " Dfh98 " of the new train value " 48 " of 1 train value " Hdfh ", original row 2 and original row 3 is spliced, and then carries out sequence
Rowization processing, it is assumed that obtain merging train value 2 after serializing processing, then access equipment merging train value 2 is corresponding to update the data table
In merging train value 1, so as to realize the write access of pairing and train value.
In the present embodiment, based on train value merge after database, the application access equipment still can carry out read access,
Write access.
Corresponding with the embodiment of the database implementation method shown in earlier figures 1, present invention also provides database realizing
The embodiment of device.
The embodiment of the application database realizing device can be applied on an electronic device.Device embodiment can be by soft
Part is realized, can also be realized by way of hardware or software and hardware combining.Exemplified by implemented in software, as a logical meaning
On device, be to be read corresponding computer program instructions in nonvolatile memory by the processor of electronic equipment where it
Get what operation in internal memory was formed.For hardware view, as shown in figure 3, the electronics where the application database realizing device
A kind of hardware structure diagram of equipment, except the processor shown in Fig. 3, internal memory, network interface and nonvolatile memory it
Outside, the electronic equipment in embodiment where device can also include other hardware generally according to the actual functional capability of the electronic equipment,
This is repeated no more.
Fig. 4 is a kind of block diagram of database realizing device shown in the exemplary embodiment of the application one.
Fig. 4 is refer to, the database realizing device 300 can be applied in the electronic equipment shown in earlier figures 3, including
Have:Row determining unit 301, train value combining unit 302 and train value insertion unit 303.
Wherein, row determining unit 301, original row to be combined are determined;
Train value combining unit 302, will be described to be combined original according to rule is merged for each of tables of data record
The train value of row merges processing, obtains merging train value;
Train value inserts unit 303, the corresponding insertion merging train value in the merging row of the tables of data.
Optionally, the row determining unit 301, by access frequency be less than threshold value original row be defined as it is to be combined original
Row.
Optionally, the train value combining unit 302, will be described to be combined original for each of tables of data record
The train value of row carries out serializing processing, and the binary numeral obtained after serializing is handled is defined as the merging train value.
Optionally, the train value combining unit 302, also addition merges flag bit in the merging train value, for accessing
Equipment identifies.
Corresponding with the embodiment of the database implementation method shown in earlier figures 2, present invention also provides database realizing
The embodiment of device.
The embodiment of the application database realizing device can be applied on the access device.Device embodiment can be by soft
Part is realized, can also be realized by way of hardware or software and hardware combining.Exemplified by implemented in software, as a logical meaning
On device, be to be read corresponding computer program instructions in nonvolatile memory by the processor of access equipment where it
Get what operation in internal memory was formed.For hardware view, as shown in figure 5, being accessed where the application database realizing device
A kind of hardware structure diagram of equipment, except the processor shown in Fig. 5, internal memory, network interface and nonvolatile memory it
Outside, the access equipment in embodiment where device can also include other hardware generally according to the actual functional capability of the access equipment,
This is repeated no more.
Fig. 6 is a kind of block diagram of database realizing device shown in the exemplary embodiment of the application one.
Fig. 6 is refer to, the database realizing device 500 can be applied in the access equipment shown in earlier figures 5, including
Have:Train value reading unit 501, merge judging unit 502, train value resolution unit 503 and train value writing unit 504.
Wherein, train value reading unit 501, train value is read from the tables of data of database;
Merge judging unit 502, whether the train value for judging to read is merging train value after multiple original train values merge;
Train value resolution unit 503, if the train value read obtains mesh to merge train value, according to regular reverse resolution is merged
Mark train value.
Optionally, the merging judging unit 502, including:Whether the train value for judging to read carries merging flag bit;
When the train value read carries merging flag bit, it is determined that the train value read is the merging train value after multiple original train values merging.
Optionally, the merging rule includes:, will be to be combined multiple original for each of tables of data record
The train value of row carries out serializing processing;
The train value resolution unit 503, pairing and train value carry out unserializing processing, obtain target train value.
Optionally, the access frequency of the original row to be combined is less than threshold value.
Optionally, the train value reading unit, based on write access, train value is read from the tables of data of database;
Train value writing unit 504, write operation is carried out to the target train value according to the write access;Performed in write operation
Bi Hou, the non-targeted train value in new target train value and the merging train value is merged according to the rule that merges, obtained
To new merging train value;With the new merging train value for merging train value and replacing the tables of data and storing.
The function of unit and the implementation process of effect specifically refer to and step are corresponded in the above method in said apparatus
Implementation process, it will not be repeated here.
For device embodiment, because it corresponds essentially to embodiment of the method, so related part is real referring to method
Apply the part explanation of example.Device embodiment described above is only schematical, wherein described be used as separating component
The unit of explanation can be or may not be physically separate, can be as the part that unit is shown or can also
It is not physical location, you can with positioned at a place, or can also be distributed on multiple NEs.Can be according to reality
Need to select some or all of module therein to realize the purpose of application scheme.Those of ordinary skill in the art are not paying
In the case of going out creative work, you can to understand and implement.
System, device, module or the unit that above-described embodiment illustrates, it can specifically be realized by computer chip or entity,
Or realized by the product with certain function.One kind typically realizes that equipment is computer, and the concrete form of computer can
To be personal computer, laptop computer, cell phone, camera phone, smart phone, personal digital assistant, media play
In device, navigation equipment, E-mail receiver/send equipment, game console, tablet PC, wearable device or these equipment
The combination of any several equipment.
Corresponding with the embodiment of the database implementation method shown in earlier figures 1, it is real that the application also provides a kind of database
Existing equipment, the database realizing equipment include:Processor and the memory for storing machine-executable instruction.Wherein, locate
Reason device and memory are generally connected with each other by internal bus.In other possible implementations, the equipment is also possible to wrap
External interface is included, can be communicated with other equipment or part.
In the present embodiment, by reading and performing the corresponding with the control logic of database realizing of the memory storage
Machine-executable instruction, the processor is prompted to:
Determine original row to be combined;
For each record of tables of data, the train value of the original row to be combined is merged according to rule is merged
Processing, obtain merging train value;
Corresponding insertion merges train value in the merging row of the tables of data.
Optionally, it is determined that during original row to be combined, the processor is prompted to:
The original row that access frequency is less than to threshold value are defined as original row to be combined.
Optionally, for each of tables of data record, according to merging rule by the row of the original row to be combined
When value merges processing, the processor is prompted to:
For each record of tables of data, the train value of the original row to be combined is subjected to serializing processing, and will
The binary numeral obtained after serializing processing is defined as the merging train value.
Optionally, the processor is also prompted to:
Addition merges flag bit in the merging train value, so that access equipment identifies.
Corresponding with the embodiment of the database implementation method shown in earlier figures 1, the application also provides a kind of computer can
Storage medium is read, is stored thereon with computer program, the program realizes following steps when being executed by processor:
Determine original row to be combined;
For each record of tables of data, the train value of the original row to be combined is merged according to rule is merged
Processing, obtain merging train value;
Corresponding insertion merges train value in the merging row of the tables of data.
Optionally, the determination original row to be combined, including:
The original row that access frequency is less than to threshold value are defined as original row to be combined.
Optionally, each record for tables of data, it is regular by the original row to be combined according to merging
Train value merges processing, including:
For each record of tables of data, the train value of the original row to be combined is subjected to serializing processing, and will
The binary numeral obtained after serializing processing is defined as the merging train value.
Optionally, in addition to:
Addition merges flag bit in the merging train value, so that access equipment identifies.
Corresponding with the embodiment of the database implementation method shown in earlier figures 2, it is real that the application also provides a kind of database
Existing equipment, the database realizing equipment include:Processor and the memory for storing machine-executable instruction.Wherein, locate
Reason device and memory are generally connected with each other by internal bus.In other possible implementations, the equipment is also possible to wrap
External interface is included, can be communicated with other equipment or part.
In the present embodiment, by reading and performing the corresponding with the control logic of database realizing of the memory storage
Machine-executable instruction, the processor is prompted to:
Train value is read from the tables of data of database;
Judge whether the train value that reads is merging train value after multiple original train values merge;
If the train value read obtains target train value to merge train value, according to regular reverse resolution is merged.
Optionally, when whether the train value for judging to read is the merging train value after multiple original train values merge, the place
Reason device is prompted to:
Whether the train value for judging to read carries merging flag bit;
If the train value read, which carries, merges flag bit, it is determined that after the train value read merges for multiple original train values
Merge train value.
Optionally, the merging rule includes:, will be to be combined multiple original for each of tables of data record
The train value of row carries out serializing processing;
When obtaining target train value according to the regular reverse resolution of merging, the processor is prompted to:
Pairing and train value progress unserializing processing, obtain target train value.
Optionally, the access frequency of the original row to be combined is less than threshold value.
Optionally, when train value is read in the tables of data from database, the processor is prompted to:
Based on write access, train value is read from the tables of data of database;
The processor is also prompted to:Write operation is carried out to the target train value according to the write access;
After write operation is finished, according to the rule that merges by new target train value and the merging train value
Non-targeted train value merges, and obtains new merging train value;
With the new merging train value for merging train value and replacing the tables of data and storing.
Corresponding with the embodiment of the database implementation method shown in foregoing 2, the application also provides a kind of computer-readable
Storage medium, computer program is stored thereon with, the program realizes following steps when being executed by processor:
Train value is read from the tables of data of database;
Judge whether the train value that reads is merging train value after multiple original train values merge;
If the train value read obtains target train value to merge train value, according to regular reverse resolution is merged.
Optionally, it is described to judge whether the train value that reads is merging train value after multiple original train values merge, including:
Whether the train value for judging to read carries merging flag bit;
If the train value read, which carries, merges flag bit, it is determined that after the train value read merges for multiple original train values
Merge train value.
Optionally, the merging rule includes:, will be to be combined multiple original for each of tables of data record
The train value of row carries out serializing processing;
It is described that target train value is obtained according to the regular reverse resolution of merging, including:
Pairing and train value progress unserializing processing, obtain target train value.
Optionally, the access frequency of the original row to be combined is less than threshold value.
Optionally, train value is read in the tables of data from database, including:
Based on write access, train value is read from the tables of data of database;
Methods described also includes:
Write operation is carried out to the target train value according to the write access;
After write operation is finished, according to the rule that merges by new target train value and the merging train value
Non-targeted train value merges, and obtains new merging train value;
With the new merging train value for merging train value and replacing the tables of data and storing.
The preferred embodiment of the application is the foregoing is only, not limiting the application, all essences in the application
God any modification, equivalent substitution and improvements done etc., should be included within the scope of the application protection with principle.