Insertion, the delet method of a kind of internal storage data storage system and internal storage data
Technical field
The present invention relates to a kind of internal storage data storage mode, relate to the dynamic memory of internal storage data and search fast.
Background technology
For dynamic data storage in the internal memory, generally adopt following dual mode:
A. application at any time, the mechanism that discharges at any time when needs insert data, applies for that then a new internal memory is used for store data; When deleted data, then discharge this piece internal memory.
When B. inserting data, the same A of processing mode; Different is during deleted data, not to be direct releasing memory, but to stamp delete flag for the core position that when having new data to insert again, then from first to last scan whole data field, discovery has the memory field of delete flag, then is placed on this position to new data.
In a single day mode A handles simple, but runs into frequent insertion deletion action, then can cause the frequent application and the release of internal memory, and frequent system call meeting reduces the efficient of operations such as insertion, deletion.
Though mode B can avoid frequent internal memory application and release,, along with the increase of data volume; Each when inserting data, all to scan whole data field, can confirm that just which blocks of data district played delete flag; This will consume cpu resource greatly, significantly reduce the efficient of inserting operation.
Summary of the invention
Technical matters to be solved by this invention provides a kind of new internal storage data storage system and the insertion and the delet method of internal storage data, reducing frequent application and the release to internal memory, and reduces the consumption of cpu resource, improves the operating efficiency to internal storage data.
The present invention solves the problems of the technologies described above the internal storage data storage system that is provided, and comprises the data block that is arranged in the internal memory and the free list corresponding with said data block; Said data block is used to store many data recording, when certain bar data recording of storing in to said data block is carried out deletion action, does not discharge the shared memory field of this data recording, only this data recording is done delete flag; Said free list is used for storing said data block memory field coordinate information that do not taken by data recording and that stamp delete flag.
The beneficial effect of above-mentioned data-storage system is: utilize the delete flag that gets beat up of which position in the free list recording data blocks; When inserting new data; Can find a clear position fast through free list; Avoid scanning whole data field, thereby both can effectively reduce the frequent application and the release of internal memory, can improve insertion and the deletion speed of application program again internal storage data.
Further, first byte of said data recording is the delete flag position, when certain bar data recording of storing in to said data block is carried out deletion action, only on the delete flag position of this data recording, does delete flag.
Adopt the beneficial effect of above-mentioned further scheme to be, be convenient to the data record is carried out deletion action.
Further, the capacity of said data block store data recording is 100000.
Adopt the beneficial effect of above-mentioned further scheme to be; The storage space of each 100000 data recording of data block application is when inserting or during deletion action, only the record space to these 100000 data scans; After the storage space of treating these 100000 data recording takes; Apply for the storage space of 100000 new data recording again, new storage space is scanned and operates, thereby avoided whole internal storage data district is scanned; Reduce the resource consumption of CPU, improved operating efficiency.
The insertion method of internal storage data provided by the invention comprises the steps:
Step 1: in the inquiry free list whether a memory field coordinate information is arranged, if having then execution in step 2, otherwise execution in step 3;
Step 2: new data records is stored in the memory field of the pairing data block of this memory field coordinate information, and this memory field coordinate information is deleted from free list;
Step 3: the new data block of application from internal memory, and the foundation free list corresponding with new data block are stored in new data recording in this new data block and upgrade said free list.
The beneficial effect of above-mentioned internal storage data insertion method is: utilize free list to write down operable memory field coordinate information, substitute the scanning to internal memory through the inquiry to free list, thereby saved cpu resource, improved the efficient of inserting operation.
Further; Said step 3 comprises: the new data block of application from internal memory; New data records is stored in first memory field of this data block; Set up the free list corresponding, and will write this free list except this first other memory field coordinate informations memory field with new data block.
Further; Said step 3 comprises: the new data block of application from internal memory; Set up the free list corresponding with this new data block; And memory field coordinate informations all in the new data block write this free list, new data records is stored in the memory field of the pairing data block of article one coordinate record of this free list, and article one coordinate record of free list is deleted from free list.
The delet method of internal storage data provided by the invention comprises: in the data block the data recording that will delete do delete flag; With in the data block the coordinate information of the shared memory field of the data recording that will delete write the pairing space list of this data block.
The beneficial effect of above-mentioned internal storage data delet method is: saved the internal memory operation time, thereby accelerated internal storage data deletion speed.
Description of drawings
The data storage area structural representation that Fig. 1 forms for data block in the internal storage data storage system of the present invention;
Fig. 2 is the structural representation of free list in the internal storage data storage system of the present invention;
Fig. 3 is the process flow diagram of an embodiment of internal storage data insertion method of the present invention;
Fig. 4 is the process flow diagram of an embodiment of internal storage data delet method of the present invention.
Embodiment
Below in conjunction with accompanying drawing principle of the present invention and characteristic are described, institute gives an actual example and only is used to explain the present invention, is not to be used to limit scope of the present invention.
Internal storage data storage system of the present invention comprises the data block that is arranged in the internal memory and the free list corresponding with said data block; Said data block is used to store many data recording, when certain bar data recording of storing in to said data block is carried out deletion action, does not discharge the shared memory field of this data recording, only this data recording is done delete flag; Said free list is used for storing said data block memory field coordinate information that do not taken by data recording and that stamp delete flag.
As an embodiment, as shown in Figure 1, each data block can be stored 100,000 data recording, and a plurality of data blocks have been formed a big data storage area.In the data block; The 1st byte of every data recording is the delete flag position, and the back is right after the value of each field, when delete data record; Do not discharge its shared memory headroom; Only on this delete flag position, mark (like the 0 expression deletion of delete flag position, delete flag position 1 is illustrated in usefulness), can reuse this partial memory space when treating follow-up insertion data.
Fig. 2 has represented free list structure corresponding with said data block in the specific embodiment of the invention.The space of data storage area is carried out to piece application (as shown in Figure 1), applies for that at every turn a data block stores 100,000 records, and pairing data field, the space coordinate of temporarily not using in the data block is filled out in the free list shown in Figure 2.When certain the bar data recording in the data block is deleted, its corresponding data field coordinate also will be filled out in the free list.When adding data recording, check at first whether free list is empty, if be not empty, then from free list, take out a data field coordinate, and the data recording that will newly add writes in the corresponding data field of this coordinate.After a data block record among Fig. 1 had been expired, it is empty that a free list among its pairing Fig. 2 also will become; When applying for a new data block once more, will through one of the pointed among Fig. 2 new with the corresponding free list of data block of application once more.
To above-mentioned internal storage data storage system, the present invention also provides a kind of insertion method and delet method of internal storage data.
Internal storage data provided by the invention inserts method step and comprises:
Step 1: in the inquiry free list whether a memory field coordinate information is arranged, if having then execution in step 2, otherwise execution in step 3;
Step 2: new data records is stored in the memory field of the pairing data block of this memory field coordinate information, and this memory field coordinate information is deleted from free list;
Step 3: the new data block of application from internal memory, and the foundation free list corresponding with new data block are stored in new data recording in this new data block and upgrade said free list.
Fig. 3 is the process flow diagram (wherein the memory block of application can be stored 100,000 data recording) of an embodiment of above-mentioned internal storage data insertion method; Wherein, The implementation of step 3 is: the new data block of application from internal memory; New data records is stored in first memory field of this data block, sets up the free list corresponding, and will write this free list except this first other memory field coordinate informations memory field with new data block.
In addition; Step 3 can also realize in the following manner: the new data block of application from internal memory; Set up the free list corresponding with this new data block; And memory field coordinate informations all in the new data block write this free list, new data records is stored in the memory field of the pairing data block of article one coordinate record of this free list, and article one coordinate record of free list is deleted from free list.
As shown in Figure 4, the delet method of internal storage data provided by the invention comprises: in the data block the data recording that will delete do delete flag; With in the data block the coordinate information of the shared memory field of the data recording that will delete write the pairing space list of this data block.
Utilize above-mentioned internal storage data storage system to adopt the insertion and the delet method of above-mentioned internal storage data, once apply for the space of 100,000 data recording, can effectively avoid frequent application and release, prevent owing to increasing of memory fragmentation wastes internal memory to internal memory; In addition, come not have in the management data district memory headroom of use, when inserting new data records, can on free list, obtain an idle position of writing down fast through free list, faster more than 5 times than all data fields of direct scanning.
The above is merely preferred embodiment of the present invention, and is in order to restriction the present invention, not all within spirit of the present invention and principle, any modification of being done, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.