Summary of the invention
Fundamental purpose of the present invention is to provide a kind of management method and device of memory database, to solve the lower problem of the transmission speed of magnetic disc i/o in the prior art at least.
According to an aspect of the present invention, a kind of management method method of memory database is provided, it comprises: record storage area and bit map area are set in memory database, and wherein, whether the bit in the above-mentioned bit map area indicates the storage unit in the above-mentioned record storage area idle; According to above-mentioned bit map area the storage unit in the above-mentioned record storage area is carried out bookkeeping.
Further, according to above-mentioned bit map area the storage unit in the above-mentioned record storage area being carried out bookkeeping comprises: when the operation information indication that receives is carried out deletion action to first storage unit in the above-mentioned record storage area, the value of bit corresponding with above-mentioned first storage unit in the above-mentioned bit map area is arranged to indicate the above-mentioned first storage unit free time, wherein, above-mentioned first storage unit comprises one or more storage unit.
Further, according to above-mentioned bit map area the storage unit in the above-mentioned record storage area being carried out bookkeeping also comprises: when the operation information indication that receives is carried out retouching operation to first storage unit in the above-mentioned record storage area, above-mentioned first storage unit is carried out above-mentioned deletion action, above-mentioned first storage unit is carried out inserted operation again.
Further, above-mentioned first storage unit being carried out the insertion operation comprises: the idle storage unit of searching the address minimum according to sequence of addresses; Amended first storage unit is inserted in the idle storage unit of the above-mentioned address minimum that finds.
Further, above-mentionedly in memory database, the record storage area is set and bit map area comprises: divide record storage area in the above-mentioned memory database according to the operating system page or leaf, wherein, the one or more storage unit in the corresponding above-mentioned record storage area of aforesaid operations system page.
Further, in memory database, be provided with after record storage area and the bit map area, also comprise: on disk, create record storage area and the bit map area identical with bit map area with above-mentioned record storage area.
Further, after the storage unit in the above-mentioned record storage area being carried out bookkeeping according to above-mentioned bit map area, also comprise: reach predetermined threshold value if carry out the quantity of the storage unit of bookkeeping, perhaps, the last bookkeeping of carrying out of distance surpasses preset time, then the record storage area in the above-mentioned memory database and bit map area is synchronized to record storage area and bit map area on the above-mentioned disk.
According to a further aspect in the invention, a kind of management devices of memory database is provided, and it comprises: the unit is set, is used at memory database record storage area and bit map area being set, whether wherein, the bit in the above-mentioned bit map area is indicated the storage unit in the above-mentioned record storage area idle; Administrative unit is used for according to above-mentioned bit map area the storage unit of above-mentioned record storage area being carried out bookkeeping.
Further, above-mentioned management unit pack is drawn together: module is set, be used for when the operation information indication that receives is carried out deletion action to first storage unit of above-mentioned record storage area, the value of bit corresponding with above-mentioned first storage unit in the above-mentioned bit map area is arranged to indicate the above-mentioned first storage unit free time, wherein, above-mentioned first storage unit comprises one or more storage unit.
Further, the above-mentioned module that is provided with also is used for when the operation information indication that receives is carried out retouching operation to first storage unit of above-mentioned record storage area above-mentioned first storage unit being carried out above-mentioned deletion action; Above-mentioned administrative unit also comprises: search module, be used for searching the idle storage unit of address minimum according to sequence of addresses when the operation information indication that receives is carried out retouching operation to first storage unit of above-mentioned record storage area; Insert module is used for amended first storage unit is inserted into the idle storage unit of the above-mentioned address minimum that finds.
By the present invention, adopted bit map area to indicate the storage unit in the memory database whether occupied, thereby when storage unit being managed operation, can only operate bit map area, and storage unit is not operated, thereby reduced the time of addressing and renewal, solved the lower problem of transmission speed of magnetic disc i/o in the prior art.
Embodiment
Hereinafter will describe the present invention with reference to the accompanying drawings and in conjunction with the embodiments in detail.Need to prove that under the situation of not conflicting, embodiment and the feature among the embodiment among the application can make up mutually.
Embodiment 1
Fig. 1 is that it comprises the steps: according to the process flow diagram of the management method of the memory database of the embodiment of the invention
S102 is provided with record storage area and bit map area in memory database, wherein, whether the bit in the above-mentioned bit map area indicates the storage unit in the above-mentioned record storage area idle;
S104 carries out bookkeeping according to above-mentioned bit map area to the storage unit in the above-mentioned record storage area.
By the present invention, adopted bit map area to indicate the storage unit in the memory database whether occupied, thereby when storage unit being managed operation, can only operate bit map area, and storage unit is not operated, thereby reduced the time of addressing and renewal, solved the lower problem of transmission speed of magnetic disc i/o in the prior art.
Preferably, according to described bit map area the storage unit in the described record storage area being carried out bookkeeping comprises: when the operation information indication that receives is carried out deletion action to first storage unit in the described record storage area, the value of bit corresponding with described first storage unit in the described bit map area is arranged to indicate the described first storage unit free time, wherein, described first storage unit comprises one or more storage unit.That is to say, when carrying out the deletion action of storage unit, the data in unactual this storage unit of deletion, but the value of bit corresponding with this storage unit in the described bit map area is arranged to indicate the described first storage unit free time.By the method in the present embodiment, need the data in synchronization amount to narrow down to one or more bits deletion action, thereby reduced the data volume of I/O, improved the transmission speed of magnetic disc i/o.
For example, the value of bit is 0 o'clock, represents its pairing storage unit free time; The value of bit is 1 o'clock, represents that its pairing storage unit is occupied.When carrying out the deletion action of first storage unit, bit position 0 that will be corresponding with first storage unit, and do not delete data in first storage unit.
Preferably, according to described bit map area the storage unit in the described record storage area being carried out bookkeeping also comprises: when the operation information indication that receives is carried out retouching operation to first storage unit in the described record storage area, described first storage unit is carried out described deletion action, described first storage unit is carried out inserted operation again.By the method in the present embodiment, reduced the data volume of the I/O when carrying out retouching operation, further improved the transmission speed of magnetic disc i/o.
Preferably, described first storage unit being carried out the insertion operation comprises: the idle storage unit of searching the address minimum according to sequence of addresses; Amended first storage unit is inserted in the idle storage unit of the described address minimum that finds.In present embodiment, increase progressively the idle storage unit of preferential searching according to sequence of addresses, like this, be tending towards focusing in the continuous address realm with regard to having guaranteed the Data Update in the record storage area, shortened the time of addressing, improve the efficient of timing disk then.
Preferably, describedly in memory database, the record storage area is set and bit map area comprises: divide record storage area in the described memory database according to the operating system page or leaf, wherein, the one or more storage unit in corresponding described record storage area of described operating system page or leaf.By present embodiment, be the dividing elements storage unit with the operating system page or leaf, help improving the efficiency of management of operating system.
Preferably, in memory database, be provided with after record storage area and the bit map area, also comprise: on disk, create record storage area and the bit map area identical with bit map area with described record storage area.By present embodiment, the record storage area in the memory database and bit map area synchronization map in disk, have further been guaranteed the security of data in EMS memory.
Preferably, after the storage unit in the described record storage area being carried out bookkeeping according to described bit map area, also comprise: reach predetermined threshold value if carry out the quantity of the storage unit of bookkeeping, perhaps, the last bookkeeping of carrying out of distance surpasses preset time, then the record storage area in the described memory database and bit map area is synchronized to record storage area and bit map area on the described disk.By present embodiment, can control the synchronous time neatly.
Embodiment 2
In the present embodiment, the management method of internal storage data may further comprise the steps:
S1, create a plurality of memory tables at memory database, each memory table comprises record storage area and bit map area, wherein, the data recording in the storage unit preservation memory table is used in the record storage area, bit map area is used for the operating position of keeping records memory block storage unit, and bit map area is with the operating position of a storage unit of a BIT bit representation.
S2, the corresponding stored file of the memory table of establishment memory database on disk.Preferably, storage file on the disk comprises data, the data in the bit map area, the control information in the record storage area of memory table, wherein, control information comprises one of following information: the skew of memory table record length, version information, record storage area, the skew of bit map area.
S3, the mapping between the storage file on the establishment disk and the memory table of memory database, memory database conducts interviews to the storage file on the disk by the internal memory pointer.Preferably, each memory table can corresponding memory file map section, perhaps, and the corresponding memory file map section of a plurality of memory tables.
S4 when revising mapping memory file map section, promptly finishes the operation of a timing disk.In the present invention, the memory file map section just is equivalent to disk file, promptly is modification to disk file to the modification of this map section.
S5 when the storage unit in the internal memory is made amendment, creates the dirty data buffer zone in internal memory, wherein, the dirty data buffer zone is used to write down the dirty data (that is the data in the storage unit that, is modified) of corresponding memory table.Preferably, dirty data comprise following one of at least: the data that the new data that interior thick Table I D, memory table insert, memory table are revised, dirty data are in the length of the skew of memory table data field, dirty number, the bit map area of memory table.Preferably, each memory table can corresponding dirty data buffer zone, perhaps, and the corresponding dirty data buffer zone of a plurality of memory tables.
S6 when memory table is carried out increase, deletion, retouching operation, writes the dirty data buffer zone with the data that change.
S7 when the dirty data of dirty data district storage reaches threshold value, when perhaps the last time interval of revising the memory file map section of distance surpasses threshold value, then carries out the data sync in the File mapping district to the disk, dirty data district.
Preferably, the dirty data district reads the dirty data record one by one to the data sync in File mapping district, according to memory table ID, dirty data skew, dirty data length with the deviation post of dirty data record copies to File mapping district correspondence; The direct integral body of data bitmap in the dirty data district copies the data bitmap district in File mapping district to.
S8, after all records in dirty data district all were synchronized to the File mapping district, the district emptied with dirty data.
In the present embodiment, in order to reduce the data total amount of timing disk.The memory table management has increased bit map area, and whether this district takies by a memory table storage unit of BIT bit-identify.When carrying out memory table stored record deletion, only need to upgrade one or more BIT position, avoided like this removing of physical memory location is handled.Thereby need the data in synchronization amount to narrow down to a BIT position deletion action, having reduced is the I/O data quantity transmitted, has improved the transmission speed of I/O.
In order to improve the addressing efficient of disk,, change to deletion action and insert operation the data modification request of memory table.That is, carry out above-mentioned deletion action earlier, then, amended data are being inserted operation.In carrying out the insertion operating process, increase progressively the idle storage unit of preferential searching (for example, seeking the idle storage unit of address minimum) according to sequence of addresses, then, amended data are inserted in the idle storage unit that is searched out.So just guaranteed that the storage unit after the renewal in the record storage area focuses in the continuous address realm, improves the efficient of timing disk then.
When memory database restarted, synchronous integrality and the correctness of chkdsk at first comprised the version of checking file, internal memory record length, check information etc.After inspection is passed through, according to the bit map area data in the control information load document in the file, recorded data zone data bit map area and recorded data zone at memory table.Take sign according to bit map area at last, sweep record data field is one by one created the index of memory table again.
Embodiment 3
The present invention also provides a kind of embodiment of management devices of memory database, and it can use the management method among the above-mentioned enforcement 1-2 to come the data in the memory database are managed.
Fig. 2 is a kind of preferred construction synoptic diagram according to the management devices of the memory database of the embodiment of the invention, it comprises: unit 202 is set, be used for record storage area and bit map area being set at memory database, whether wherein, the bit in the described bit map area is indicated the storage unit in the described record storage area idle; Administrative unit 204 is used for according to described bit map area the storage unit of described record storage area being carried out bookkeeping.
By the present invention, adopted bit map area to indicate the storage unit in the memory database whether occupied, thereby when storage unit being managed operation, can only operate bit map area, and storage unit is not operated, thereby reduced the time of addressing and renewal, solved the lower problem of transmission speed of magnetic disc i/o in the prior art.
Preferably, described administrative unit comprises 204: module 2041 is set, be used for when the operation information indication that receives is carried out deletion action to first storage unit of described record storage area, the value of bit corresponding with described first storage unit in the described bit map area is arranged to indicate the described first storage unit free time, wherein, described first storage unit comprises one or more storage unit.That is to say, when carrying out the deletion action of storage unit, the data in unactual this storage unit of deletion, but the value of bit corresponding with this storage unit in the described bit map area is arranged to indicate the described first storage unit free time.By the method in the present embodiment, need the data in synchronization amount to narrow down to one or more bits deletion action, thereby reduced the data volume of I/O, improved the transmission speed of magnetic disc i/o.
Preferably, the described module 2041 that is provided with also is used for when the operation information indication that receives is carried out retouching operation to first storage unit of described record storage area described first storage unit being carried out described deletion action; Described administrative unit 204 also comprises: search module 2042, be used for searching the idle storage unit of address minimum according to sequence of addresses when the operation information indication that receives is carried out retouching operation to first storage unit of described record storage area; Insert module 2043 is used for amended first storage unit being inserted in the idle storage unit of the described address minimum that finds being provided with after 2041 pairs of described first storage unit of module carry out described deletion action.In present embodiment, increase progressively the idle storage unit of preferential searching according to sequence of addresses, like this, be tending towards focusing in the continuous address realm with regard to having guaranteed the Data Update in the record storage area, improve the efficient of timing disk then.
Preferably, describedly in memory database, the record storage area is set and bit map area comprises: divide record storage area in the described memory database according to the operating system page or leaf, wherein, the one or more storage unit in corresponding described record storage area of described operating system page or leaf.By present embodiment, be the dividing elements storage unit with the operating system page or leaf, help improving the efficiency of management of operating system.
Preferably, be provided with in memory database after record storage area and the bit map area, the management devices of above-mentioned memory database is created record storage area and the bit map area identical with bit map area with described record storage area on disk.By present embodiment, the record storage area in the memory database and bit map area synchronization map in disk, have further been guaranteed the security of data in EMS memory.
Preferably, after the storage unit in the described record storage area being carried out bookkeeping according to described bit map area, reach predetermined threshold value if carry out the quantity of the storage unit of bookkeeping, perhaps, the last bookkeeping of carrying out of distance surpasses preset time, and the management devices of above-mentioned memory database is synchronized to record storage area and bit map area on the described disk with the record storage area in the described memory database and bit map area.By present embodiment, can control the synchronous time neatly.
Embodiment 4
Fig. 3 is the another kind of preferred construction synoptic diagram according to the management devices of the memory database of the embodiment of the invention, and it comprises: configuration management element 302, initialization administrative unit 304, memory table administrative unit 306, File mapping administrative unit 308, internal storage data district 310, memory file map section 312 and mapped file 314.The annexation of said elements as shown in Figure 3.
Configuration management element 302 realizes the management of memory database information configuration, comprises the store path of memory table size, disk mapped file etc.;
Initialization administrative unit 304 realizes memory database process creation, memory headroom application and notice memory table administrative unit and File mapping administrative unit establishment memory table and creates map section etc.;
Memory table administrative unit 306 realizes the establishment of memory table and the memory table access interface externally is provided, as memory table inquiry, modification, deletion etc.;
File mapping administrative unit 308 realizes the establishment of memory file map section and the management that dirty data is synchronized to disk file;
Internal storage data district 310 preserves memory table and dirty data district;
Memory file map section 312 is the memory file mapping of disk file at the database process internal memory;
Mapped file 314 is the synchronous documents of each memory table of memory database at disk.
Above-mentioned several administrative unit specific implementation both can be unified setting, also can realize in process mode independently, can select organizational form flexibly according to the design needs when specifically implementing.
The management devices of the memory database in the present embodiment adopts the memory file mapping to realize that the memory table data arrive the synchronously quick of disk, have improved the data security of memory database; And it is synchronous to need not to carry out active and standby memory database data, has reduced equipment cost and plant maintenance complexity.In addition, also provide memory table bitmap management, data modification operation conversion process, idle storage unit, further improved database disk net synchronization capability according to sequence of addresses addressing management.
In sum, adopt scheme of the present invention, can effectively improve the disaster tolerance ability and the disk synchronizing capacity of all-memory database, have very strong versatility.The present invention uses in short message center system, plays tangible optimization function.
Obviously, those skilled in the art should be understood that, above-mentioned each module of the present invention or each step can realize with the general calculation device, they can concentrate on the single calculation element, perhaps be distributed on the network that a plurality of calculation element forms, alternatively, they can be realized with the executable program code of calculation element, thereby, they can be stored in the memory storage and carry out by calculation element, and in some cases, can carry out step shown or that describe with the order that is different from herein, perhaps they are made into each integrated circuit modules respectively, perhaps a plurality of modules in them or step are made into the single integrated circuit module and realize.Like this, the present invention is not restricted to any specific hardware and software combination.
The above is the preferred embodiments of the present invention only, is not limited to the present invention, and for a person skilled in the art, the present invention can have various changes and variation.Within the spirit and principles in the present invention all, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.