CN102169460A - Method and device for managing variable length data - Google Patents

Method and device for managing variable length data Download PDF

Info

Publication number
CN102169460A
CN102169460A CN2010101155478A CN201010115547A CN102169460A CN 102169460 A CN102169460 A CN 102169460A CN 2010101155478 A CN2010101155478 A CN 2010101155478A CN 201010115547 A CN201010115547 A CN 201010115547A CN 102169460 A CN102169460 A CN 102169460A
Authority
CN
China
Prior art keywords
data
data recording
module
elongated
storage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN2010101155478A
Other languages
Chinese (zh)
Inventor
甘景全
贺毅
李利
杨大勇
张平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Aisino Corp
Original Assignee
Aisino Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Aisino Corp filed Critical Aisino Corp
Priority to CN2010101155478A priority Critical patent/CN102169460A/en
Publication of CN102169460A publication Critical patent/CN102169460A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to a method for managing variable length data, which comprises a variable length data storage process. The method comprises the following steps: dividing a storage space of a storage module into a plurality of storage units with same sizes in turn; establishing a data record which contains the record information and a data part, wherein the data part is the to-be-stored variable length data, and the record information indicates the length of the data record; storing the data record, by writing the data record into the storage units of the storage module in turn according to an address pointer supplied by a pointer module; and updating the address pointer, by pointing at a second address blank in the storage module by the address pointer after completely writing the last data block of the data record, and then writing the second address blank into the pointer module. A device for managing variable length data comprises a control module and a storage component, wherein the storage component comprises the storage module and the pointer module, and the control module is respectively connected to the storage module and the pointer module.

Description

Elongated data managing method and device
Technical field
The present invention relates to the data management of embedded system, particularly a kind of implementation method and device of variable length data management.
Background technology
At present, along with the development of embedded device, its environment of applications becomes increasingly complex, and the demand of Chan Shenging is storage and the management to a large amount of storage data efficients thereupon.Because the built-in terminal hardware resource is limited, its memory size is often smaller.
In order in embedded device, to store data, a kind of file system has been proposed in the prior art.Generally, in the field of database, be to utilize embedded database that the data in the storer are managed with data storage, according to Principles of Database, the data classification that needs are managed is subdivided into tables of data, index and data; Utilize file system to create list file, index file and data file, be used for management data list information, index information and data message respectively.Usually, file system provides api function for upper layer application, is used to realize interpolation, modification and the deletion action of data.
Embedded database is that unit is kept on the storer with the table, and field is a data unit in the data-base recording, and elongated data represent that promptly the data length of field is unfixed, can dynamic change.Elongated data storage in the embedded device, it normally is the internal memory that elongated data are prepared fixed size, in order to satisfy the needs of elongated data, described regular length is bigger usually, no matter actual how many internal memories that used of this field, this field can occupy a bigger memory field all the time, causes memory usage low, and waste is serious.
For example, existing tax controlling equipment generally adopts the data record method of regular length, first kind of promptly above-mentioned disposal route when the storage invoice data.Development need along with tax collection and administration, tax controlling equipment needs the unfixed invoice data of record length, how under the hardware condition of resource-constrained, to realize high as far as possible elongated data storage capacities, store managing detailed catalogue as much as possible, become the technical matters that present tax controlling equipment is badly in need of solution for invoice anticounterfeiting provides foundation as much as possible.
Summary of the invention
The objective of the invention is to, solve the low technical matters of storage space utilization factor in the existing elongated data storage technology.
For achieving the above object, the invention provides a kind of elongated data managing method, described method comprises elongated date storage method, step is:
Step a1 is divided into the storage unit of a plurality of identical sizes successively with the storage space of memory module, and the capacity of described storage unit is defined as cell block;
Step a2, the construction data record, described data recording comprises recorded information and data division, described data division indicates the length of this data recording for needing the elongated data of storage in the described recorded information;
Described data recording is made of a plurality of data blocks; With described cell block is that described data recording is cut apart successively in unit, forms described a plurality of data block;
Step a3 stores described data recording, and the address pointer that provides according to pointer module writes described data recording the storage unit of described memory module successively; Described address pointer points to first address blank of described memory module;
Step a4 upgrades described address pointer; After having write last blocks of data piece of described data recording, the data recording that described address pointer increases current storage takies the length of storage space, points to second address blank in the described memory module, and described second address blank is write pointer module.
The present invention also provides a kind of elongated data administrator, is made of control module and memory bank; Described memory bank is made up of memory module and pointer module; Described control module is connected with described pointer module with described memory module respectively;
Described memory module storage data recording; Deposit an address pointer in the described pointer module, described address pointer points to the address blank of described memory module;
Described control module operation access program, the elongated data recording of described access program access provides the interface of other routine access, and the described memory bank of initialization, reads or wipe described memory bank;
Described control module reads or writes the address pointer in the described pointer module, the address of pointing to according to described address pointer to the data recording in the described memory module inquire about, read-write and deletion action.
Beneficial effect of the present invention is that the elongated data recording of storing in the storer is end to end, continuously storage.Can in finite storage space, store elongated data as much as possible, and can conveniently increase, deletion, query note, not by any file system and database, both saved storage resources, saved processor resource again.
Description of drawings
Fig. 1 is the structural representation of elongated data administrator;
Fig. 2 is the process flow diagram of elongated date storage method;
Fig. 3 is the synoptic diagram of memory module division and data recording storage;
Fig. 4 is the process flow diagram of elongated data recording querying method;
Fig. 5 is the process flow diagram of elongated data recording delet method;
Fig. 6 is the structural drawing of the elongated data storage device of the embodiment of the invention one;
Fig. 7 is the physical storage structure synoptic diagram of the memory module of the embodiment of the invention one;
Fig. 8 is the process flow diagram of the elongated date storage method of the embodiment of the invention one;
Fig. 9 is the synoptic diagram that memory module is divided and data recording is stored of the embodiment of the invention one;
Figure 10 is the process flow diagram of the elongated data enquire method of the embodiment of the invention one;
Figure 11 is the structural drawing of the elongated data storage device of the embodiment of the invention two;
Figure 12 is the process flow diagram of the elongated date storage method of the embodiment of the invention two;
Figure 13 is the synoptic diagram that memory module is divided and data recording is stored of the embodiment of the invention two;
Figure 14 is the process flow diagram of the elongated data enquire method of the embodiment of the invention two.
Description of reference numerals:
The elongated data administrator of 10-; The 11-control module; The 12-memory bank; The 121-memory module; The 122-pointer module.
Embodiment
Below in conjunction with accompanying drawing, technical solution of the present invention is described in further detail, advantage of the present invention and characteristics can more clearly be presented.But method and apparatus of the present invention is not subjected to the restriction of following embodiment, and available various similar mode realizes.
Thought of the present invention provide a kind of miniature, store the solution of elongated data efficiently, the form of pre-defined elongated data recording, with the elongated data preparation of storage is specific data recording structure, make the length of data recording corresponding with the amount of physical memory of storer, thereby the elongated data recording of storing in the storer is end to end, continuously storage.Can in finite storage space, store elongated data as much as possible, and can conveniently increase, deletion, query note, not by any file system and database, both saved storage resources, saved processor resource again.
Figure 1 shows that the structural representation of the elongated data administrator of the present invention.Elongated data administrator 10 comprises control module 11 and memory bank 12.Memory bank 12 is made of memory module 121 and pointer module 122.Control module 11 is connected with pointer module 122 with memory module 121 respectively.
Memory bank 12 is the carrier of storage data, semiconductor storage body FLASH chip for example, disk etc.Wherein, memory module 121 is used to store data recording.Deposit an address pointer in the pointer module 122, described address pointer points to certain address blank of memory module 121, when depositing data recording in, can begin to write backward from this address blank, and after storage was finished, this address pointer was extended to new address blank backward.This address pointer points to the start address of memory module 121 under the original state.
Move access program in the control module 11, described access program is used for the elongated data recording of access, and the interface of other routine access externally is provided, internally to memory bank 12 initialization, read or wipe.Control module 11 reads or writes the address pointer in the pointer module 122, the address of pointing to according to described address pointer to the data recording in the memory module 121 inquire about, read-write and deletion action.
Elongated data managing method of the present invention comprises storage, inquiry and the delet method of elongated data.
Figure 2 shows that the process flow diagram of elongated date storage method, comprising:
Step 201 is divided into the storage unit of a plurality of identical sizes successively with the storage space of memory module 121, and the capacity of described each storage unit is defined as cell block; As shown in Figure 3, the storage space of memory module 121 is divided into a plurality of storage unit 1, storage unit 2, storage unit 3...... successively.
Step 202, initialization memory bank 12; Control module 11 is carried out access programs, and memory module 121 is all wiped, and the start address of memory module 121 is write pointer module 122.
Step 203, the construction data record; Control module 11 is carried out access program, and the elongated data configuration that needs are stored becomes a data recording;
Described data recording comprises recorded information and data division, and described data division indicates the length of this data recording for needing the elongated data of storage in the described recorded information;
Described data recording is made of a plurality of data blocks; With described cell block is that described data recording is cut apart successively in unit, forms described a plurality of data block; Specifying a fixed position in the first blocks of data piece is described recorded information; The length of described data recording is described data recording with described cell block is the piece number of the unit data block of cutting apart generation successively;
When the deficiency of the data division in last blocks of data piece whole unit piece, be designated as a module unit piece; Preferably, in the end the afterbody of a blocks of data piece increases filling information, constitutes a complete cell block.
As shown in Figure 3, data recording A comprises the first blocks of data piece A1, the second blocks of data piece A2 and the 3rd blocks of data piece A3, and a fixed position of specifying the first blocks of data piece A1 is recorded information A11, and the length that recorded information A11 indicates data recording A is 3 module unit pieces; Part among the data recording A except that recorded information A11 is for needing the elongated data of storage;
Data recording B comprises the first blocks of data piece B1, the second blocks of data piece B2, the 3rd blocks of data piece B3 and the 4th blocks of data piece B4, one fixed position of specifying the first blocks of data piece B1 is recorded information B11, and the length that recorded information B11 indicates data recording B is 4 module unit pieces; Wherein the not enough whole unit piece of the data division among the 4th blocks of data piece B4 increases filling information B41 at the 4th data block B4 afterbody, constitutes the whole unit piece; Part among the data recording B except that recorded information B11 and filling information B41 is for needing the elongated data of storage.
Step 204, the access program of control module 11 read the length of this data recording from the recorded information of the first blocks of data piece of this data recording;
Step 205, the address pointer that control module 11 provides according to pointer module 122 writes this data recording the storage unit of memory module 121 successively;
As shown in Figure 3, the data block A1 of data recording A, A2 and A3 successively write storage unit 1 to storage unit 3; The data block B1 of data recording B, B2, B3 and B4 successively write storage unit 4 to storage unit 7.
Step 206, the scheduler pointer; After having write last blocks of data piece of this data recording, the data recording that address pointer increases current storage takies the length of storage space, point to an address blank in the memory module 121, access program writes pointer module 122 as new address pointer with this address;
Step 207, control module 11 also need to judge whether to continue storage; If then execution in step 203, if not, then execution in step 208, finish.
Fig. 4 is the process flow diagram of the method for the elongated data recording of inquiry, comprising:
Step 401, control module 11 definition one search address pointer, the initial value of described search address pointer is the start address of memory module 121;
Step 402, control module 11 be according to search address pointer inquiry memory module 121, obtains the length of this data recording according to the recorded information of the first blocks of data piece of current data record;
Step 403, control module 11 are according to the length of this data recording, and the storage unit that this data recording takies in the retrieve stored module 121 judges whether to meet search condition successively;
If eligible then read this data recording, obtain Query Result; If ineligible then execution in step 404;
Step 404, retrieved last blocks of data piece of this data recording after, the search address pointer increases the length that current data retrieved record takies storage space;
Step 405 judges whether address pointer current in search address pointer and the pointer module 122 is identical, if different, then execution in step 402; If identical then finish, return the information of no matched record, the elongated data recording that expression has been stored all travels through, but does not have Query Result.
Fig. 5 is the process flow diagram of elongated data recording delet method, comprising:
Step 501, control module 11 is called access program and is inquired about, and obtains the memory address of the data recording that will delete in the memory module 121 and the length of data recording;
Step 502, control module 11 is called access program, the cell erase that the data recording that will delete in the memory module 121 is taken;
Step 503, access program are rewritten as the address pointer in the pointer module 122 start address of deleted data recording.
According to elongated data managing method of the present invention, with the data configuration of variable-length is the data recording with certain data structure, take the storage space of memory module during storage continuously, make the data recording of different length end to end, storage continuously, can improve the utilization rate of storage space, inquiry and deletion action easily are provided simultaneously.
Below in conjunction with concrete embodiment content of the present invention is described in detail.
Embodiment one
As shown in Figure 6, be the structural drawing of the elongated data storage device of the embodiment of the invention one.
Memory bank in the present embodiment comprises Samsung NAND FLASH chip, and model is K9F1G08U0M and storage chip AT24C01.Wherein K9F1G08U0M stores data recording as memory module; AT24C01 is as pointer module, memory address pointer.
I/O0~I/O7 of K9F1G08U0M, RE, WE, ALE, CLE pin are connected with control module respectively.Wherein I/O0~I/O7 is 8 input and output pins, and RE is a read operation control pin, and WE is a write operation control pin, and ALE is an address latch control pin, and CLE latchs the control pin for order.Control module by the level of control CLE, ALE, WE, RE pin, is carried out control word operation, address function, write operation or read operation to K9F1G08U0M respectively.I/O0~I/O7 is the multiplexing port of data, address, order.Be based on page or leaf to K9F1G08U0M inner write data, the command word of K9F1G08U0M, address and data all are by parallel port line I/O0~I/O7 time-sharing operation under the effect of control signal.
The serial data pin SDA of AT24C01 is connected with control module respectively with serial clock pin SCL.But the SDA two-way transfer of data, SCL provides serial clock.Control module reads or writes address pointer by SDA, point to an address blank of K9F1G08U0M storage space.
Move access program in the control module, described access program is used for the elongated data recording of access, and the interface of other routine access externally is provided, internally to K9F1G08U0M and AT24C01 initialization, read or wipe.Control module reads or writes the address pointer among the AT24C01, the address of pointing to according to described address pointer to the data recording among the K9F1G08U0M inquire about, read-write and deletion action.
The K9F1G08U0M capacity is the 128M byte, is divided into 1024 BLOCK, and as shown in Figure 7, each BLOCK is divided into 64 pages again, and every page comprises (2048+64) byte.Wherein every page preceding 2048bytes is the data field, is used to store data; Back 64bytes is the free area.The data bit of K9F1G08U0M is 8.
According to the physical storage structure of K9F1G08U0M, every page of K9F1G08U0M is divided into 4 storage unit, the definition unit block length is 512 bytes, then can store 4 blocks of data for every page of K9F1G08U0M.Correspondingly, be unit partition data record successively with " 512 byte ", it is the piece number of the unit data block of cutting apart generation successively that the length of data recording is designated as with described " 512 byte "; When the deficiency of the data division in last blocks of data piece whole unit piece, in the end the afterbody of a blocks of data piece increases by 0, constitutes a complete cell block.And being defined as the sign of this data record size of expression in first the 3rd byte of every data recording, unit is a piece.
Moving access program in the control module, is predefined data record format with the elongated data preparation that receives, and length all is the integral multiple of 512 bytes.For former data recording less than 512 bytes, to handle by 512 bytes, the position of back sky fills up 0.Then when data recording is long, can take a plurality of pages or leaves.
0x00~0x03 space of AT24C01 is used as the address pointer of depositing sensing K9F1G08U0M data field, and address pointer is defined as 4 byte lengths, and for example 0 address is 0x00000000, and " 0x " represents sexadecimal notation.When the K9F1G08U0M data field was sky, address pointer pointed to the reference position of K9F1G08U0M data field.After data recording of every preservation, address pointer all will move backward according to the physical length that writes down.
Figure 8 shows that process flow diagram according to the elongated date storage method of the embodiment of the invention one.Comprise step:
Step 801, it is 512 bytes of memory unit that the storage space of K9F1G08U0M is divided into size successively, the size that is defined as cell block is 512 bytes; As shown in Figure 9, be about to every page of K9F1G08U0M and be divided into 4 storage unit.
Step 802, initialization; Call the NAND FLASH program of wiping earlier whole BLOCK of K9F1G08U0M are wiped, call the program of wiping of AT24C01 again its whole spaces are wiped, write 0x00000000 to 0x00~0x03 address of AT24C01, as the initial address of storage data.
Step 803, the structure record; Control module is carried out access program, and the elongated data configuration that needs are stored becomes a data recording, and the length of data recording is the integral multiple of 512 bytes;
As shown in Figure 9, data recording C comprises the first blocks of data piece C1 and the second blocks of data piece C2, and the 3rd byte of specifying the first blocks of data piece C1 is recorded information C11, and the length that recorded information C11 indicates data recording C is 2 module unit pieces; Part among the data recording C except that recorded information C11 is for needing the elongated data of storage;
Data recording D comprises the first blocks of data piece D1, the second blocks of data piece D2, the 3rd blocks of data piece D3 and the 4th blocks of data piece D4, the 3rd byte of specifying the first blocks of data piece D1 is recorded information D11, and the length that recorded information D11 indicates data recording D is 4 module unit pieces; Wherein the not enough whole unit piece of the data division among the 4th blocks of data piece D4 increases filling information D41 (00000) at the 4th data block D4 afterbody, constitutes the whole unit piece; Part among the data recording D except that recorded information D11 and filling information D41 is for needing the elongated data of storage.
Step 804 reads the length of this data recording from the recorded information of this data recording, judge whether the remaining space of the page or leaf of the current BLOCK of K9F1G08U0M can hold this data recording;
Compare according to the piece number after the remaining space conversion of the page or leaf of the piece number of data recording and the current BLOCK of NAND FLASH, whether the piece number of judgment data record is less than the piece number of the idle storage unit of the page or leaf of current BLOCK, if then execution in step 805, the storage data; If not, promptly when the piece number after the remaining page or leaf conversion of the BLOCK of NAND FLASH was not enough to deposit this record, then execution in step 806.
As shown in Figure 9, data recording C is stored in storage unit 1 and the storage unit 2 of the page1 of BLOCK1.If current need storage be recorded as data recording D, this record length of indication is 4 cell blocks among the recorded information D11 among the data recording D.Piece number after the conversion of BLOCK1 residue page or leaf can be stored data recording D, execution in step 805.
As shown in Figure 9, data recording E is stored in storage unit 1 and the storage unit 2 of the page4 of BLOCK1.If current need storage be recorded as data recording F, this record length of indication is 3 cell blocks among the recorded information F11 among the data recording F.Only idle 2 storage unit of the page4 of BLOCK1, then the piece number after the conversion of BLOCK1 residue page or leaf is not enough to store data recording F, execution in step 806.
Step 805, the storage data; Data recording is write the position that address pointer points in the mode of appending.
From AT24C01, read address pointer, begin to K9F1G08U0M, to write successively data recording from the address that address pointer points to then.
Step 806, address pointer is pointed to the reference position of next BLOCK, this data recording is stored among the next BLOCK, guarantee that any data recording do not cross over two BLOCK storage, doing like this is to carry out for deletion data operation and the convenient of data query operation.
Step 807 will be moved behind the address pointer, after the size of moving be the length of the data recording of current storage;
The result of (start address of this record+512 * this record block number) as new address blank, is write back to the address pointer memory block of AT24C01.
Step 808, control module judge whether to continue storage, if then execution in step 803, if not, then execution in step 809, finish.
Elongated data enquire method according to embodiment one, it is 0 address from K9F1G08U0M, each bar first address according to variable-length record jumps successively, retrieve every data recording one by one, up to finding qualified data, when search address has jumped to when equating with the address of current address pointer record, the existing variable-length record data of expression are traversal but there be not the result entirely.
Figure 10 is according to the process flow diagram of the method for the elongated data recording of inquiry of embodiment one, comprising:
Step 1001, control module define a search address pointer, and the initial value of described search address pointer is the start address of K9F1G08U0M storage space;
Step 1002, control module judge according to search address pointer inquiry K9F1G08U0M whether current storage space is idle, and if not, then execution in step 1003, if then execution in step 1004;
Step 1003 is obtained the length of this data recording according to the recorded information of the first blocks of data piece of current data record;
Step 1004 is with the reference position of next BLOCK of search address pointed;
Step 1005, control module are retrieved the storage unit that this data recording takies among the K9F1G08U0M successively according to the length of this data recording, judge whether to meet search condition;
If eligible then read this data recording, obtain Query Result; If ineligible then execution in step 1006;
Step 1006, after having retrieved last blocks of data piece of this data recording, the search address pointer increases the length that current data retrieved record takies storage space, with (start address of this record+512 * this record block number) as new search address pointer;
Step 1007 judges whether address pointer current among search address pointer and the AT24C01 is identical, if different, then execution in step 1002; If identical then finish, return the information of no matched record, the elongated data recording that expression has been stored all travels through, but does not have Query Result.
According to the elongated data-erasure method of embodiment one, be BLOCK execution according to NAND FLASH K9F1G08U0M, the BLOCK at the elongated data recording place that will delete wipes, and then the first address of this BLOCK is write 0x00~0x03 of AT24C01.
Embodiment two
Different with embodiment one is that the memory module among the embodiment two is EEPROM (Electrically Erasable Programmable Read Only Memo) EEPROM (Electrically Erasable Programmable Read-Only Memory).
Memory bank in the present embodiment comprises AT24C1024 and AT24C01.Wherein AT24C1024 stores data recording as memory module; AT24C01 is as pointer module, memory address pointer.
As shown in figure 11, be the structural drawing of the elongated data storage device of the embodiment of the invention two.
AT24C1024 and AT24C01 are based on the iic bus agreement, and control module articulates AT24C1024 and AT24C01 by iic bus.The serial data pin SDA of AT24C1024 is connected with control module respectively with serial clock pin SCL, and same, the serial data pin SDA of AT24C01 is connected with control module respectively with serial clock pin SCL.
Move access program in the control module, according to sequential difference gating AT24C1024 and AT24C01.For pointer module AT24C01, control module reads or writes address pointer by SDA, points to an address blank of AT24C1024 storage space.For memory module AT24C1024, control module reads or writes data recording by SDA, according to the address pointer among the AT24C01, and the operation that the data recording among the AT24C1024 is inquired about, stored and deletes.
AT24C1024 can carry out " piece " erasable, programming, also can carry out erasable, the programming operation of byte.In the present embodiment, be set to by byte erasable.
AT24C1024 is a serial EEPROM, and memory capacity is 128Kbits, and the memory block is made of 512 page, and each page includes 256 byte.
According to the physical storage structure of AT24C1024, be 1 storage unit with every Pageview of AT24C1024, the definition unit block length is 256 bytes, then can store 1 blocks of data for every page of AT24C1024.Correspondingly, be unit partition data record successively with " 256 byte ", it is the piece number of the unit data block of cutting apart generation successively that the length of data recording is designated as with described " 256 byte "; When the deficiency of the data division in last blocks of data piece whole unit piece, in the end the afterbody of a blocks of data piece increases by 0, constitutes a complete cell block.And being defined as the sign of this data record size of expression in first the 3rd byte of every data recording, unit is a piece.
Moving access program in the control module, is predefined data record format with the elongated data preparation that receives, and length all is the integral multiple of 256 bytes.For former data recording less than 256 bytes, to handle by 256 bytes, the position of back sky fills up 0.Then when data recording is long, can take a plurality of pages or leaves.
0x00~0x03 space of AT24C01 is used as the address pointer of depositing sensing AT24C1024 data field, and address pointer is defined as 4 byte lengths, and for example 0 address is 0x00000000, and " 0x " represents sexadecimal notation.When the AT24C1024 data field was sky, address pointer pointed to the reference position of AT24C1024 data field.After data recording of every preservation, address pointer all will move backward according to the physical length that writes down.
Figure 12 shows that process flow diagram according to the elongated date storage method of the embodiment of the invention one.Comprise step:
Step 1201, it is 256 bytes of memory unit that the storage space of AT24C1024 is divided into size successively, the size that is defined as cell block is 256 bytes; As shown in figure 12, soon every Pageview of AT24C1024 is 1 storage unit.
Step 1202, initialization; Call the program of wiping earlier whole spaces of AT24C1024 and AT24C01 are wiped, write 0x00000000, as the initial address of storage data to 0x00~0x03 address of AT24C01.
Step 1203, the structure record; Control module is carried out access program, and the elongated data configuration that needs are stored becomes a data recording, and the length of data recording is the integral multiple of 256 bytes;
As shown in figure 13, data recording G comprises the first blocks of data piece G1 and the second blocks of data piece G2, and the 3rd byte of specifying the first blocks of data piece G1 is recorded information G11, and the length that recorded information G11 indicates data recording G is 2 module unit pieces; Part among the data recording G except that recorded information G11 is for needing the elongated data of storage;
Data recording H comprises the first blocks of data piece H1, the second blocks of data piece H2, the 3rd blocks of data piece H3 and the 4th blocks of data piece H4, the 3rd byte of specifying the first blocks of data piece H1 is recorded information H11, and the length that recorded information H11 indicates data recording H is 4 module unit pieces; Wherein the not enough whole unit piece of the data division among the 4th blocks of data piece H4 increases filling information H41 (00000) at the 4th data block H4 afterbody, constitutes the whole unit piece; Part among the data recording H except that recorded information H11 and filling information H41 is for needing the elongated data of storage.
Step 1204, the storage data; Data recording is write the position that address pointer points in the mode of appending.
From AT24C01, read address pointer, begin to AT24C1024, to write successively data recording from the address that address pointer points to then.
Step 1205 will be moved behind the address pointer, after the size of moving be the length of the data recording of current storage;
The result of (start address of this record+256 * this record block number) as new address blank, is write back to the address pointer memory block of AT24C01.
Step 1206, control module judge whether to continue storage, if then execution in step 1203, if not, then execution in step 1207, finish.
Elongated data enquire method according to embodiment two, it is 0 address from the AT24C1024 storage space, each bar first address according to variable-length record jumps successively, retrieve every data recording one by one, up to finding qualified data, when search address has jumped to when equating with the address of current address pointer record, the existing variable-length record data of expression are traversal but there be not the result entirely.
Figure 14 is according to the process flow diagram of the method for the elongated data recording of inquiry of embodiment two, comprising:
Step 1401, control module define a search address pointer, and the initial value of described search address pointer is the start address of AT24C1024 storage space;
Step 1402 is obtained the length of this data recording according to the recorded information of the first blocks of data piece of current data record;
Step 1403, control module are retrieved the storage unit that this data recording takies in the AT24C1024 storage space successively according to the length of this data recording, judge whether to meet search condition;
If eligible then read this data recording, obtain Query Result; If ineligible then execution in step 1404;
Step 1404, after having retrieved last blocks of data piece of this data recording, the search address pointer increases the length that current data retrieved record takies storage space, with (start address of this record+256 * this record block number) as new search address pointer;
Step 1405 judges whether address pointer current among search address pointer and the AT24C01 is identical, if different, then execution in step 1402; If identical then finish, return the information of no matched record, the elongated data recording that expression has been stored all travels through, but does not have Query Result.
According to the elongated data-erasure method of embodiment two, be to carry out according to the byte of AT24C1024 to wipe, the page or leaf at the elongated data recording place that will delete is wiped, and first address that then will this page or leaf writes 0x00~0x03 of AT24C01.
Preferably, the present invention can be applicable in the tax-control cash register.Tax-control cash register requires can a large amount of invoice datas of reliable memory, so the invoice storage administration is a key function.Elongatedly be meant invoice length different because of each invoice head and the contained information detail of invoice, the size of the storage space that takies is also inequality.For example, every shared storage space of invoice is hundreds of byte or several kilobyte.
Use elongated data managing method of the present invention and device, every invoice constitutes a data recording, and the position that the invoice data of variable-length is stored in storer is end to end, and storer does not have redundant space, perhaps redundant space is reduced as far as possible.Tax-control cash register need not installed embedded database and file system, and can easily increase, delete, inquire about the invoice record.
Though the memory module in the concrete enforcement of the present invention is that example is described with NAND flash and EEPROM, the technical scheme of elongated date storage method of the present invention and device also can be used on other memory device that similar operations characteristic is arranged.When specific implementation, need thought according to the present invention to make adaptability revision.
The above only is preferred embodiment of the present invention, only is illustrative for the purpose of the present invention, and nonrestrictive.Those skilled in the art is understood, and can carry out many changes to it in the spirit and scope that claim of the present invention limited, revise, even equivalence, but all will fall within the scope of protection of the present invention.

Claims (10)

1. an elongated data managing method is characterized in that, described method comprises elongated date storage method, and step is:
Step a1 is divided into the storage unit of a plurality of identical sizes successively with the storage space of memory module, and the capacity of described storage unit is defined as cell block;
Step a2, the construction data record, described data recording comprises recorded information and data division, described data division indicates the length of this data recording for needing the elongated data of storage in the described recorded information;
Described data recording is made of a plurality of data blocks; With described cell block is that described data recording is cut apart successively in unit, forms described a plurality of data block;
Step a3 stores described data recording, and the address pointer that provides according to pointer module writes described data recording the storage unit of described memory module successively; Described address pointer points to first address blank of described memory module;
Step a4 upgrades described address pointer; After having write last blocks of data piece of described data recording, the data recording that described address pointer increases current storage takies the length of storage space, points to second address blank in the described memory module, and described second address blank is write pointer module.
2. elongated data managing method according to claim 1 is characterized in that, among the step a2 of described elongated date storage method, the length of described data recording is for described cell block being the piece number that the data block of described data recording generation is cut apart successively in unit.
3. elongated data managing method according to claim 1 is characterized in that, among the step a2 of described elongated date storage method, when the deficiency of the data division in last blocks of data piece whole unit piece, is designated as a module unit piece.
4. elongated data managing method according to claim 1 is characterized in that, among the step a2 of described elongated date storage method, specifying a fixed position in the first blocks of data piece is described recorded information.
5. according to each described elongated data managing method of claim 1 to 4, it is characterized in that also comprise elongated data enquire method, step is:
Step b1 inquires about described memory module according to a search address pointer, obtains the length of described data recording according to the recorded information of described data recording; Described search address pointer initial value is the start address of described memory module;
Step b2 according to the length of described data recording, retrieves the storage unit that data recording takies described in the described memory module successively, judges whether to meet search condition;
Step b3, retrieved last blocks of data piece of described data recording after, described search address pointer increases the length that current data retrieved record takies storage space;
Step b4 judges whether address pointer current in described search address pointer and the described pointer module is identical, if different, execution in step b2 then; If it is identical then finish.
6. according to each described elongated data managing method of claim 1 to 4, it is characterized in that also comprise elongated data-erasure method, step is:
Step c1 reads the memory address of the data recording that will delete in the described memory module and the length of data recording;
Step c2, the cell erase that the described data recording that will delete is taken;
Step c3 is rewritten as the address pointer in the described pointer module start address of deleted data recording.
7. an elongated data administrator is characterized in that, is made of control module and memory bank; Described memory bank is made up of memory module and pointer module; Described control module is connected with described pointer module with described memory module respectively;
Described memory module storage data recording; Deposit an address pointer in the described pointer module, described address pointer points to the address blank of described memory module;
Described control module operation access program, the elongated data recording of described access program access provides the interface of other routine access, and the described memory bank of initialization, reads or wipe described memory bank;
Described control module reads or writes the address pointer in the described pointer module, the address of pointing to according to described address pointer to the data recording in the described memory module inquire about, read-write and deletion action.
8. elongated data administrator according to claim 7 is characterized in that the storage space of described memory module is divided into the storage unit of a plurality of identical sizes successively, and the capacity of described storage unit is defined as cell block.
9. elongated data administrator according to claim 8 is characterized in that described data recording comprises recorded information and data division, and described data division indicates the length of this data recording for needing the elongated data of storage in the described recorded information;
Described data recording is made of a plurality of data blocks; With described cell block is that described data recording is cut apart successively in unit, forms described a plurality of data block.
10. elongated data administrator according to claim 9 is characterized in that, during data division in last blocks of data piece of described data recording is not enough whole unit piece, is designated as a module unit piece.
CN2010101155478A 2010-02-26 2010-02-26 Method and device for managing variable length data Pending CN102169460A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2010101155478A CN102169460A (en) 2010-02-26 2010-02-26 Method and device for managing variable length data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2010101155478A CN102169460A (en) 2010-02-26 2010-02-26 Method and device for managing variable length data

Publications (1)

Publication Number Publication Date
CN102169460A true CN102169460A (en) 2011-08-31

Family

ID=44490624

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2010101155478A Pending CN102169460A (en) 2010-02-26 2010-02-26 Method and device for managing variable length data

Country Status (1)

Country Link
CN (1) CN102169460A (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902727A (en) * 2012-09-07 2013-01-30 上海申瑞继保电气有限公司 Displacement storage method of variable data structure
CN103605485A (en) * 2013-11-29 2014-02-26 深圳市道通科技有限公司 Variable-length data storing method and device
CN103902228A (en) * 2012-12-27 2014-07-02 航天信息股份有限公司 Variable-length data accessing method
CN104850507A (en) * 2014-02-18 2015-08-19 腾讯科技(深圳)有限公司 Data caching method and data caching device
CN106776106A (en) * 2016-11-11 2017-05-31 南京南瑞集团公司 A kind of date storage method based on NandFlash
CN108268218A (en) * 2018-01-10 2018-07-10 北京思特奇信息技术股份有限公司 A kind of wiring method and read method of the elongated data segment based on network code
CN108459969A (en) * 2018-02-28 2018-08-28 南京邮电大学 Data storage and transmission method in 64 multiple-core servers of one kind
CN110188140A (en) * 2019-05-09 2019-08-30 广州视源电子科技股份有限公司 Data pull method, apparatus, storage medium and computer equipment
CN110765128A (en) * 2019-09-17 2020-02-07 江苏海平面数据科技有限公司 Optimized storage method based on large-scale GPS data
CN111159202A (en) * 2019-12-30 2020-05-15 深信服科技股份有限公司 Data processing method, virtual device, equipment and storage medium
CN113227984A (en) * 2018-12-22 2021-08-06 华为技术有限公司 Processing chip, method and related equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1173367A (en) * 1997-08-29 1999-03-16 Fujitsu Ltd Storage control device
US6088777A (en) * 1997-11-12 2000-07-11 Ericsson Messaging Systems, Inc. Memory system and method for dynamically allocating a memory divided into plural classes with different block sizes to store variable length messages
CN101094183A (en) * 2007-07-25 2007-12-26 杭州华三通信技术有限公司 Buffer memory management method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1173367A (en) * 1997-08-29 1999-03-16 Fujitsu Ltd Storage control device
US6088777A (en) * 1997-11-12 2000-07-11 Ericsson Messaging Systems, Inc. Memory system and method for dynamically allocating a memory divided into plural classes with different block sizes to store variable length messages
CN101094183A (en) * 2007-07-25 2007-12-26 杭州华三通信技术有限公司 Buffer memory management method and device

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102902727B (en) * 2012-09-07 2016-05-04 上海申瑞继保电气有限公司 The displacement storage means of changeable data structure
CN102902727A (en) * 2012-09-07 2013-01-30 上海申瑞继保电气有限公司 Displacement storage method of variable data structure
CN103902228A (en) * 2012-12-27 2014-07-02 航天信息股份有限公司 Variable-length data accessing method
CN103605485A (en) * 2013-11-29 2014-02-26 深圳市道通科技有限公司 Variable-length data storing method and device
CN103605485B (en) * 2013-11-29 2017-01-18 深圳市道通科技股份有限公司 Variable-length data storing method and device
CN104850507A (en) * 2014-02-18 2015-08-19 腾讯科技(深圳)有限公司 Data caching method and data caching device
CN104850507B (en) * 2014-02-18 2019-03-15 腾讯科技(深圳)有限公司 A kind of data cache method and data buffer storage
CN106776106A (en) * 2016-11-11 2017-05-31 南京南瑞集团公司 A kind of date storage method based on NandFlash
CN108268218B (en) * 2018-01-10 2021-02-02 北京思特奇信息技术股份有限公司 Writing method and reading method of variable length data segment based on network coding
CN108268218A (en) * 2018-01-10 2018-07-10 北京思特奇信息技术股份有限公司 A kind of wiring method and read method of the elongated data segment based on network code
CN108459969A (en) * 2018-02-28 2018-08-28 南京邮电大学 Data storage and transmission method in 64 multiple-core servers of one kind
CN108459969B (en) * 2018-02-28 2020-08-04 南京邮电大学 Data storage and transmission method in 64-bit multi-core server
CN113227984A (en) * 2018-12-22 2021-08-06 华为技术有限公司 Processing chip, method and related equipment
CN113227984B (en) * 2018-12-22 2023-12-15 华为技术有限公司 Processing chip, method and related equipment
CN110188140A (en) * 2019-05-09 2019-08-30 广州视源电子科技股份有限公司 Data pull method, apparatus, storage medium and computer equipment
CN110765128A (en) * 2019-09-17 2020-02-07 江苏海平面数据科技有限公司 Optimized storage method based on large-scale GPS data
CN110765128B (en) * 2019-09-17 2024-02-23 江苏海平面数据科技有限公司 Optimized storage method based on large-scale GPS data
CN111159202A (en) * 2019-12-30 2020-05-15 深信服科技股份有限公司 Data processing method, virtual device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN102169460A (en) Method and device for managing variable length data
US7450420B2 (en) Reclaiming data storage capacity in flash memories
EP1920335B1 (en) Reclaiming data storage capacity in flash memory systems
CN101147119B (en) Direct data file storage implementation techniques in flash memories
CN101027651B (en) FAT analysis for optimized sequential cluster management
US7669003B2 (en) Reprogrammable non-volatile memory systems with indexing of directly stored data files
CN102508784B (en) Data storage method of flash memory card in video monitoring equipment, and system thereof
US7761648B2 (en) Caching method for NAND flash translation layer
CN103164490B (en) A kind of efficient storage implementation method of not fixed-length data and device
US20060218347A1 (en) Memory card
CN107239526B (en) File system implementation method, defragmentation method and operation position positioning method
CN101164037A (en) Direct data file storage in flash memories
CN101147133A (en) Direct file data programming and deletion in flash memories
CN101968795A (en) Cache method for file system with changeable data block length
WO2007019197A2 (en) Management of memory blocks that directly store data files
CN103646063A (en) Satellite-borne high-speed file management system
CN103365786A (en) Data storage method, device and system
CN103186617A (en) Data storage method and device
CN109558333A (en) Solid storage device NameSpace with variable additional storage space (OP)
CN111522507A (en) Low-delay file system address space management method, system and medium
WO2016106757A1 (en) Method for managing storage data, storage manager and storage system
CN114036079B (en) Mapping table compression method and system, memory controller, solid state disk and data reading method
CN103309619A (en) NAND Flash memory data storage method
CN102541753B (en) A kind of read-write optimization method of in-line memory
CN101783814A (en) Metadata storing method for mass storage system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20110831