CN114217738A - Dynamic queue type cyclic storage method, device, equipment and medium - Google Patents
Dynamic queue type cyclic storage method, device, equipment and medium Download PDFInfo
- Publication number
- CN114217738A CN114217738A CN202111417181.4A CN202111417181A CN114217738A CN 114217738 A CN114217738 A CN 114217738A CN 202111417181 A CN202111417181 A CN 202111417181A CN 114217738 A CN114217738 A CN 114217738A
- Authority
- CN
- China
- Prior art keywords
- data
- storage
- target data
- description word
- preset
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 53
- 125000004122 cyclic group Chemical group 0.000 title claims description 6
- 238000013507 mapping Methods 0.000 claims description 24
- 238000012545 processing Methods 0.000 claims description 13
- 238000013500 data storage Methods 0.000 claims description 11
- 238000012795 verification Methods 0.000 claims description 10
- 238000004590 computer program Methods 0.000 claims description 8
- 238000007726 management method Methods 0.000 claims description 7
- 230000008569 process Effects 0.000 description 7
- 230000003287 optical effect Effects 0.000 description 6
- 238000010586 diagram Methods 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000013523 data management Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000002093 peripheral effect Effects 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 230000005856 abnormality Effects 0.000 description 1
- 230000004075 alteration Effects 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 230000007774 longterm Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 230000002035 prolonged effect Effects 0.000 description 1
- 230000011218 segmentation Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0608—Saving storage space on storage systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/061—Improving I/O performance
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/0614—Improving the reliability of storage systems
- G06F3/0616—Improving the reliability of storage systems in relation to life time, e.g. increasing Mean Time Between Failures [MTBF]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
- G06F3/064—Management of blocks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0646—Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
- G06F3/0652—Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0655—Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
- G06F3/0659—Command handling arrangements, e.g. command buffers, queues, command scheduling
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application relates to the technical field of embedded equipment storage, and provides a dynamic queue type circular storage method in the embodiment of the application, which comprises the following steps: when target data are received, dividing the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and the length of the target data; determining N first storage spaces corresponding to a plurality of target data blocks; erasing original data in the N first storage spaces; and sequentially writing the target data blocks into the first storage space, and counting until N is equal to 0. Dynamically allocating storage space according to the size of target data; managing an internal storage data structure based on a queue algorithm characteristic first-in first-out mode; the method can simplify the operation of the embedded equipment and the storage and acquisition mode of the state information, effectively simplify the data access operation logic, efficiently utilize the storage space, balance the hardware erasing operation and prolong the service life of the device.
Description
Technical Field
The present application relates to the field of embedded device storage technologies, and in particular, to a dynamic queue type circular storage method, apparatus, device, and medium.
Background
With the development of the technology level, more and more embedded devices go deep into the life of people. As the equipment is applied more and the application scenes and the requirements are more and more complex, the operation information of the product needs to be stored in most cases and is used for product operation and maintenance and information tracking in the later period.
Data storage through embedded devices is a common storage mode, such as file storage, video storage, security monitoring storage and the like, and all-weather data storage is also a common requirement at present.
When data storage is carried out for a long time, circular storage is often used, namely, a mode that new data covers old data is adopted, when the data storage is full, the original old data is usually directly covered, the erasing frequency is high, the long-term work of storage equipment is not facilitated, and the service life of a storage medium is particularly reduced; and the storage efficiency is low easily because the data are large and inconsistent during storage, and the power-off data are easy to lose.
Disclosure of Invention
In view of the problems described above, the present application is directed to providing a dynamic queued loop storage method, apparatus, device and medium that overcomes or at least partially solves the problems described above, comprising:
a dynamic queue type cyclic storage method is used for dynamically and cyclically storing data in an erasable storage medium in an embedded device; the method comprises the following steps:
when target data are received, dividing the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and the length of the target data;
determining N first storage spaces corresponding to a plurality of target data blocks according to a preset dynamic circular queue algorithm;
erasing original data in N first storage spaces according to a preset storage format and the size of the target data block;
and sequentially writing the target data blocks into the first storage spaces, counting the target data blocks, and re-determining N first storage spaces corresponding to a plurality of target data blocks when N is equal to 0.
Further, the step of dividing the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and the length of the target data when the target data is received includes:
when target data are received, obtaining the length of the target data according to the dynamic circular queue algorithm;
dividing the target data into a plurality of data blocks according to the target data length and a preset dynamic circular queue algorithm;
and adding a data head to each data block according to the length of the data block and the dynamic queue algorithm to obtain a plurality of target data blocks, wherein the target data blocks comprise data description words, description word check codes and data contents.
Further, the step of obtaining a plurality of target data blocks by adding a data header to each data block according to the length of the data block and the dynamic queue algorithm includes:
determining the data description word according to the data block length and the data content;
determining the check code of the description word according to the anti-check code of the data description word; wherein,
and the data description word and the description word check code form the data head.
Further, the step of determining, according to a preset dynamic circular queue algorithm, N first storage spaces for storing the plurality of target data blocks includes:
acquiring a first storage area for storing the target data according to a preset dynamic circular queue algorithm; establishing a mapping relation between the storage area and a memory address;
and dividing the first storage area into N first storage spaces according to a preset storage format and the mapping relation.
Further, the method also comprises the following steps:
acquiring a first storage area for storing the target data according to a preset dynamic circular queue algorithm; establishing a mapping relation between the storage area and a memory address;
determining the initial address of each target data block in the memory according to the dynamic circular queue algorithm, and determining the memory space occupied by the target data block in a memory addressing mode;
dividing a first storage area into N first storage spaces according to a preset storage format and the mapping relation;
erasing original data in N first storage spaces according to a preset storage format and the size of the target data block;
synchronizing the target data blocks in the memory space and the first storage space according to the mapping relation; and counted until N ═ 0.
Further, the step of erasing the original data in the N first storage spaces according to a preset storage format and the size of the target data block includes:
according to the regional block-type balanced erasing and writing storage algorithm, sequentially erasing the original data in the N first storage spaces according to the storage time of the original data, specifically, when the original data in the first storage spaces are erased, erasing is performed according to the minimum storage unit page defined in the storage format.
Further, the method also comprises the following steps:
according to a preset dynamic circular queue algorithm, uniformly processing the first storage space through data abstraction to realize the step of dynamic management of the storage space, specifically, adding a data description word for recording data information and a description word check code for checking the validity of data content at the initial address of the first storage space; wherein, the description word check code is an inverse check code of the data description word;
when a target data block is read, reading the data description word and the description word check code according to a front pointer in the dynamic circular queue algorithm;
verifying the data description word according to the description word check code; if the verification is passed, reading the data content of the target data block in the first storage space according to the data description word and a back pointer in the dynamic circular queue algorithm, and returning an effective data length, wherein the effective data length comprises the data description word, the description word check code and the length of the data content; and if the verification fails, sequentially reading the subsequent storage areas until the valid data description words or valid storage end marks are found.
A dynamic queue type cyclic storage device is used for dynamically and cyclically storing data in an erasable storage medium in an embedded device; the device comprises:
the data acquisition module is used for dividing the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and the length of the target data when the target data are received;
the space determining module is used for determining N first storage spaces corresponding to the target data blocks according to a preset dynamic circular queue algorithm;
the space erasing module is used for erasing original data in the N first storage spaces according to a preset storage format and the size of the target data block;
and the data storage module is used for sequentially writing the target data blocks into the first storage space and counting until N is equal to 0.
An apparatus comprising a processor, a memory and a computer program stored on the memory and capable of running on the processor, the computer program when executed by the processor implementing the steps of dynamic queued loop storage as described above.
A computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of dynamic queued loop storage as described above.
The application has the following advantages: in the embodiment of the application, when target data are received, a data head is added according to a preset dynamic circular queue algorithm and the target data length, and the target data containing the data head are added into a preset storage queue; determining a starting address for storing the target data in the storage medium according to the data head and a preset dynamic circular queue algorithm, and allocating a storage space for the target data; if the storage space is enough, writing target data into the storage medium in blocks, finishing storage and modifying a preset storage queue pointer, wherein the storage queue pointer points to the data head and the end address of the storage space; and if the storage space is insufficient, erasing the early data in the storage space according to a preset storage queue pointer until the space occupied by the target data is met. Dynamically allocating storage space according to the size of target data; managing an internal storage data structure based on a queue algorithm characteristic first-in first-out mode; the method can simplify the operation of the embedded equipment and the storage and acquisition mode of the state information, effectively simplify the data access operation logic, efficiently utilize the storage space, balance the hardware erasing operation and prolong the service life of the device.
Drawings
In order to more clearly illustrate the technical solutions of the present application, the drawings needed to be used in the description of the present application will be briefly introduced below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive labor.
FIG. 1 is a flowchart illustrating steps of a dynamic queued loop storage method according to an embodiment of the present disclosure;
FIG. 2 is a block diagram of a dynamic queued loop storage device according to an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a data storage distribution structure in a storage medium according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, the present application is described in further detail with reference to the accompanying drawings and the detailed description. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that, in any embodiment of the present invention, the dynamic queued circular storage method is a method for implementing storage and space management by using a circular queue, and the stored data queued is stored and retrieved, thereby simplifying data management. The queue characteristic is used to store data in first-out. The inside can manage all the data inside only through the front and back position pointers, and new and old data are managed in a loop iteration mode.
Referring to fig. 1, a dynamic queued loop storage method provided by an embodiment of the present application is illustrated, where the method is used for dynamically and cyclically storing data in a rewritable storage medium in an embedded device;
the method comprises the following steps:
s110, when target data are received, dividing the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and the length of the target data;
s120, determining N first storage spaces corresponding to a plurality of target data blocks according to a preset dynamic circular queue algorithm;
s130, erasing original data in the N first storage spaces according to a preset storage format and the size of the target data block;
s140, sequentially writing the target data blocks into the first storage space, and counting until N is equal to 0; when N is equal to 0, that is, the divided N first memory spaces are all occupied, and when data is received again, the spaces are divided again and recounting is performed.
In the embodiment of the application, when target data are received, a data head is added according to a preset dynamic circular queue algorithm and the target data length, and the target data containing the data head are added into a preset storage queue; determining a starting address for storing the target data in the storage medium according to the data head and a preset dynamic circular queue algorithm, and allocating a storage space for the target data; if the storage space is enough, writing target data into the storage medium in blocks, finishing storage and modifying a preset storage queue pointer, wherein the storage queue pointer points to the data head and the end address of the storage space; and if the storage space is insufficient, erasing the early data in the storage space according to a preset storage queue pointer until the space occupied by the target data is met. Dynamically allocating storage space according to the size of target data; managing an internal storage data structure based on a queue algorithm characteristic first-in first-out mode; the method can simplify the operation of the embedded equipment and the storage and acquisition mode of the state information, effectively simplify the data access operation logic, efficiently utilize the storage space, balance the hardware erasing operation and prolong the service life of the device.
Next, a dynamic queued loop storing method in the present exemplary embodiment will be further described.
When the target data is received as stated in step S110, the target data is divided into a plurality of target data blocks according to a preset dynamic circular queue algorithm and the length of the target data.
In an embodiment of the present invention, a specific process of "when the target data is received, dividing the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and a length of the target data" in step S110 may be further described with reference to the following description.
When target data is received, obtaining the target data length according to the dynamic circular queue algorithm;
dividing the target data into a plurality of data blocks according to the target data length and a preset dynamic circular queue algorithm;
and as shown in the following steps, adding a data head to each data block according to the length of the data block and the dynamic queue algorithm to obtain a target data block, wherein the target data block comprises a data description word, a description word check code and data content.
It should be noted that, in order to fully utilize the vector space and overcome the "false overflow" phenomenon, the vector space is thought of as an end-to-end circular ring, and such a vector is called a circular vector. The Queue stored therein is called a Circular Queue (Circular Queue). The circular queue is formed by connecting the head and the tail of the sequence queue and logically viewing a table of storage queue elements as a ring, so that the circular queue is formed, and data management is simplified by storing and taking out the storage data in a queue mode. The queue characteristic is used to store data in first-out. The inside can manage all the data inside only through the front and back position pointers, and new and old data are managed in a loop iteration mode.
As an example, when receiving the target data, according to the dynamic circular queue algorithm, obtaining the target data length, for example, obtaining the target data length through a corresponding structure pointer in a structure of queue pointers, where the structure is as follows:
typedefstruct
{ u32_ t size; // end Address
u32_ t addr; // starting Address
Flashelibridia _ tfrontAddr; // front pointer
u32_ t front; // front pointer Address
Flashelibridia _ clearaddr; // tail pointer
u32_ t real; // tail pointer address
FlashFIFOhead _ t; // Flash queue storage structure.
Dividing the target data into a plurality of data blocks according to the target data length and a preset dynamic circular queue algorithm; and adding a data head to each data block according to the length of the data block and the dynamic queue algorithm to obtain a plurality of target data blocks, wherein the target data blocks comprise data description words, description word check codes and data contents.
In an embodiment of the present invention, the step of obtaining a plurality of target data blocks by adding a data header to each data block according to the length of the data block and the dynamic queue algorithm includes: determining the data description word according to the data block length and the data content; determining the check code of the description word according to the anti-check code of the data description word; the data header is formed by the data description word and the description word check code, and fig. 3 is a schematic diagram of a data storage distribution structure in the storage medium according to an embodiment of the present application. And adding data description words to realize dynamic management of storage space. Namely: when target data is received, the data description words and the description word negation check codes are added to the forefront end of the target data block in a default mode through dividing the data description words and the description word negation check codes into target data blocks, and the target data blocks are stored as a whole, namely, spaces for storing the data description words and the description word check codes are added in front of corresponding storage target data block spaces, wherein the description word check codes are used for recording data content information and effective check codes of the operation.
In step S120, N first storage spaces corresponding to a plurality of target data blocks are determined according to a preset dynamic circular queue algorithm.
In an embodiment of the present invention, a specific process of "determining N first storage spaces corresponding to a plurality of target data blocks according to a preset dynamic circular queue algorithm" in step S120 may be further described with reference to the following description.
Acquiring a first storage area for storing the target data according to a preset dynamic circular queue algorithm; establishing a mapping relation between the storage area and a memory address;
and dividing the first storage area into N first storage spaces according to a preset storage format and the mapping relation.
The size of target data acquired each time is not fixed, after the target data is acquired, space required by a target is dynamically allocated in a memory according to the data length of a number mark, effective data stored in the same space is effectively increased, and because the access efficiency of the memory is higher than that of an external memory (such as a hard disk, a Flash memory, an SD memory and the like), a storage area is divided according to the memory address occupied by the target data in the memory and the address mapping of the external memory such as a Flash memory, and the storage area is divided into N first storage spaces; and writing the target data in the memory into the first storage space according to the mapping relation, thereby improving the data storage efficiency.
In step S130, the original data in the N first storage spaces are erased according to the preset storage format and the size of the target data block.
In an embodiment of the present invention, the specific process of "erasing the original data in the N first storage spaces according to the preset storage format and the target data block size" in step S130 may be further described with reference to the following description.
According to the region block type balanced erasing and writing storage algorithm, sequentially erasing original data in the N first storage spaces according to the storage time of the original data, specifically, when the original data in the first storage spaces are erased, erasing is performed according to a minimum storage unit page defined in the storage format.
As an example, when a storage medium, such as a Flash device, writes target data, it must first be erased, and the minimum unit page erased. The balanced erasing is that the Flash is distributed into N storable spaces according to the minimum erasing size of the Flash and the size of target write-in data, one storage space is consumed for each modification, and when all the storage spaces are consumed, the Flash is erased integrally and counted again. The method effectively reduces the erasing times of the storage medium and prolongs the service life of the device. For example, when the storage medium is in NTFS format, the minimum unit page is 512 bytes, and the minimum single block storage block is 1kByte as in HDFS file system, wherein, as an exemplary illustration, the present application is not limited to the file system in these two formats.
The target data blocks are written into the first storage space in sequence as described in step S140, and counting is performed until N is equal to 0.
In an embodiment of the present invention, a specific process of "sequentially writing the target data block into the first storage space and counting until N is equal to 0" in step S140 may be further described with reference to the following description.
Writing the target data blocks into the first storage space in sequence, and counting until N is equal to 0; when N is equal to 0, that is, the divided N first memory spaces are all occupied, and when data is received again, the spaces are divided again and recounting is performed.
In an embodiment of the present invention, the method further includes: acquiring a first storage area for storing the target data according to a preset dynamic circular queue algorithm; establishing a mapping relation between the storage area and a memory address; determining the initial address of each target data block in the memory according to the dynamic circular queue algorithm, and determining the memory space occupied by the target data block in a memory addressing mode; dividing a first storage area into N first storage spaces according to a preset storage format and the mapping relation; erasing original data in N first storage spaces according to a preset storage format and the size of the target data block; synchronizing the target data blocks in the memory space and the first storage space according to the mapping relation; and counted until N ═ 0.
The storage operation is carried out through the queue position front pointer and the queue position back pointer, so that the data of the memory and the storage medium are synchronized, and the power failure synchronization is realized, namely, the recorded information in the storage medium such as Flash is synchronized into the memory when the equipment is restarted every time. And directly operating and modifying according to the memory during later operation, and synchronously recording the changed information into blocks. By direct memory addressing operation, the operation of external devices is increased and reduced, the information processing speed is increased, and the program operation robustness is enhanced.
In an embodiment of the present invention, the step of erasing the original data in the N first storage spaces according to a preset storage format and the size of the target data block includes: according to the regional block-type balanced erasing and writing storage algorithm, sequentially erasing the original data in the N first storage spaces according to the storage time of the original data, specifically, when the original data in the first storage spaces are erased, erasing is performed according to the minimum storage unit page defined in the storage format.
The storage operation is carried out through the queue position front pointer and the queue position back pointer, and a region block type balanced erasing and writing storage algorithm is used (namely, a large region is divided into a plurality of small blocks according to the storage size, one small block is modified in sequence during each updating, and when all the small blocks are used up, the small blocks are erased in a whole block and written in from the first small block), so that the erasing times of the storage medium are further effectively reduced, and the actual service life of a device is prolonged.
In an embodiment of the present invention, the method further includes: according to a preset dynamic circular queue algorithm, uniformly processing the first storage space through data abstraction to realize the step of dynamic management of the storage space, specifically, adding a data description word for recording data information and a description word check code for checking the validity of data content at the initial address of the first storage space; wherein, the description word check code is an inverse check code of the data description word; when a target data block is read, reading the data description word and the description word check code according to a front pointer in the dynamic circular queue algorithm; verifying the data description word according to the description word check code; if the verification is passed, reading the data content of the target data block in the first storage space according to the data description word and a back pointer in the dynamic circular queue algorithm, and returning an effective data length, wherein the effective data length comprises the data description word, the description word check code and the length of the data content; and if the verification fails, sequentially reading the subsequent storage areas until the valid data description words or valid storage end marks are found.
The data of single operation of the program is abstracted and uniformly processed, and data description words are added to realize dynamic management of the storage space. Namely: and a descriptor and descriptor negation check code storage space is added for the foremost default of each operation data, and is used for recording the content information and the effective check codes of the operation data. And actually reading, namely checking and passing the description information according to the description information and the check code, reading the stored effective content, and returning the effective data length. If the description information and the check fail to be checked, reading the subsequent storage areas in sequence until a valid descriptor is found or valid storage is finished, and preventing data failure of the whole storage area caused by individual data abnormality.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
Referring to fig. 2, a dynamic queued loop storage apparatus provided in an embodiment of the present application is illustrated, where the apparatus is used for dynamically and cyclically storing data in a rewritable storage medium in an embedded device; the device comprises:
the data acquisition module 210 is configured to, when target data is received, divide the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and a length of the target data;
a space determining module 220, configured to determine, according to a preset dynamic circular queue algorithm, N first storage spaces corresponding to a plurality of target data blocks;
the space erasing module 230 is configured to erase original data in the N first storage spaces according to a preset storage format and the size of the target data block;
and a data storage module 240, configured to sequentially write the target data block into the first storage space, and count until N is equal to 0.
In an embodiment of the present invention, the data obtaining module 210 includes:
the data acquisition submodule is used for acquiring the length of the target data according to the dynamic circular queue algorithm when the target data are received;
the data segmentation submodule is used for segmenting the target data into a plurality of data blocks according to the target data length and a preset dynamic circular queue algorithm;
and the data processing submodule is used for adding a data head to each data block according to the length of the data block and the dynamic queue algorithm to obtain a plurality of target data blocks, wherein the target data blocks comprise data description words, description word check codes and data contents.
In an embodiment of the present invention, the data processing sub-module includes:
the data description submodule is used for determining the data description word according to the length of the data block and the data content;
the data check submodule is used for determining the check code of the description word according to the anti-access check code of the data description word; wherein the data description word and the description word check code form the data header.
In an embodiment of the present invention, the space determining module 220 includes:
the storage mapping submodule is used for acquiring a first storage area for storing the target data according to a preset dynamic circular queue algorithm; establishing a mapping relation between the storage area and a memory address;
and the space division submodule is used for dividing the first storage area into N first storage spaces according to a preset storage format and the mapping relation.
In an embodiment of the present invention, the method further includes:
the storage mapping submodule is used for acquiring a first storage area for storing the target data according to a preset dynamic circular queue algorithm; establishing a mapping relation between the storage area and a memory address;
the target determining submodule is used for determining the initial address of each target data block in the memory according to the dynamic circular queue algorithm and determining the memory space occupied by the target data block in a memory addressing mode;
the space division submodule is used for dividing the first storage area into N first storage spaces according to a preset storage format and the mapping relation;
the space erasing module 230 is configured to erase original data in the N first storage spaces according to a preset storage format and the size of the target data block;
a data storage module 240, configured to synchronize the target data blocks in the memory space and the first storage space according to the mapping relationship; and counted until N ═ 0.
In an embodiment of the present invention, the space erasing module 230 includes:
and the space erasing submodule is used for sequentially erasing original data in the N first storage spaces according to the storage time sequence of the original data according to a regional block-type balanced erasing and writing storage algorithm, and specifically, when the original data in the first storage spaces are erased, the original data are erased according to a minimum storage unit page defined in the storage format.
In an embodiment of the present invention, the method further includes:
the abstract processing module is used for processing the first storage space in a unified manner through data abstraction according to a preset dynamic circular queue algorithm to realize the step of dynamic management of the storage space, and specifically, a data description word for recording data information and a description word check code for checking the validity of data content are added to the initial address of the first storage space; wherein, the description word check code is an inverse check code of the data description word;
the reading module is used for reading the data description word and the description word check code according to a front pointer in the dynamic circular queue algorithm when a target data block is read;
the verification module is used for verifying the data description word according to the description word verification code; if the verification is passed, reading the data content of the target data block in the first storage space according to the data description word and a back pointer in the dynamic circular queue algorithm, and returning an effective data length, wherein the effective data length comprises the data description word, the description word check code and the length of the data content; and if the verification fails, sequentially reading the subsequent storage areas until the valid data description words or valid storage end marks are found.
Referring to fig. 4, a computer device of a dynamic queued loop storage method according to the present invention is shown, which may specifically include the following:
the computer device 12 described above is embodied in the form of a general purpose computing device, and the components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/or cache memory 32. Computer device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (commonly referred to as "hard drives"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. The memory may include at least one program product having a set (e.g., at least one) of program modules 42, with the program modules 42 configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules 42, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
The processing unit 16 executes various functional applications and data processing by executing programs stored in the system memory 28, for example, implementing the dynamic queued loop storage method provided by the embodiments of the present invention.
That is, the processing unit 16 implements, when executing the program,: when target data are received, dividing the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and the length of the target data; determining N first storage spaces corresponding to a plurality of target data blocks according to a preset dynamic circular queue algorithm; erasing original data in N first storage spaces according to a preset storage format and the size of the target data block; and sequentially writing the target data blocks into the first storage space, and counting until N is equal to 0.
In an embodiment of the present invention, the present invention further provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor, implements the dynamic queued loop storage method as provided in all embodiments of the present application:
that is, the program when executed by the processor implements: when target data are received, dividing the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and the length of the target data; determining N first storage spaces corresponding to a plurality of target data blocks according to a preset dynamic circular queue algorithm; erasing original data in N first storage spaces according to a preset storage format and the size of the target data block; and sequentially writing the target data blocks into the first storage space, and counting until N is equal to 0.
Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer-readable storage medium or a computer-readable signal medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPOM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with a pointer execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with a pointer execution system, apparatus, or device.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the healthcare worker computer, partly on the healthcare worker computer, as a stand-alone software package, partly on the healthcare worker computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the healthcare worker's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider). The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
While preferred embodiments of the present application have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the true scope of the embodiments of the application.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The foregoing describes in detail a dynamic queued loop storage method, apparatus, device, and medium provided by the present application, and specific examples are applied herein to illustrate the principles and implementations of the present application, and the descriptions of the foregoing examples are only used to help understand the method and core ideas of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.
Claims (10)
1. A dynamic queue type cyclic storage method is characterized in that the method is used for dynamically and cyclically storing data in an erasable storage medium in an embedded device; the method comprises the following steps:
when target data are received, dividing the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and the length of the target data;
determining N first storage spaces corresponding to a plurality of target data blocks according to a preset dynamic circular queue algorithm;
erasing original data in N first storage spaces according to a preset storage format and the size of the target data block;
and sequentially writing the target data blocks into the first storage space, and counting until N is equal to 0.
2. The method according to claim 1, wherein the step of dividing the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and a length of the target data when the target data is received comprises:
when target data are received, obtaining the length of the target data according to the dynamic circular queue algorithm;
dividing the target data into a plurality of data blocks according to the target data length and a preset dynamic circular queue algorithm;
and adding a data head to each data block according to the length of the data block and the dynamic queue algorithm to obtain a plurality of target data blocks, wherein the target data blocks comprise data description words, description word check codes and data contents.
3. The method according to claim 2, wherein the step of obtaining a plurality of target data blocks by appending a data header to each data block according to the data block length and the dynamic queue algorithm comprises:
determining the data description word according to the data block length and the data content;
determining the check code of the description word according to the anti-check code of the data description word; wherein,
and the data description word and the description word check code form the data head.
4. The method according to claim 1, wherein the step of determining N first storage spaces for storing a plurality of target data blocks according to a preset dynamic circular queue algorithm comprises:
acquiring a first storage area for storing the target data according to a preset dynamic circular queue algorithm; establishing a mapping relation between the storage area and a memory address;
and dividing the first storage area into N first storage spaces according to a preset storage format and the mapping relation.
5. The method of claim 4, further comprising:
acquiring a first storage area for storing the target data according to a preset dynamic circular queue algorithm; establishing a mapping relation between the storage area and a memory address;
determining the initial address of each target data block in the memory according to the dynamic circular queue algorithm, and determining the memory space occupied by the target data block in a memory addressing mode;
dividing a first storage area into N first storage spaces according to a preset storage format and the mapping relation;
erasing original data in N first storage spaces according to a preset storage format and the size of the target data block;
synchronizing the target data blocks in the memory space and the first storage space according to the mapping relation; and counted until N ═ 0.
6. The method according to claim 1 or 5, wherein the step of erasing the original data in the N first storage spaces according to a preset storage format and the target data block size comprises:
according to the regional block-type balanced erasing and writing storage algorithm, sequentially erasing the original data in the N first storage spaces according to the storage time of the original data, specifically, when the original data in the first storage spaces are erased, erasing is performed according to the minimum storage unit page defined in the storage format.
7. The method of claim 1, further comprising:
according to a preset dynamic circular queue algorithm, uniformly processing the first storage space through data abstraction to realize the step of dynamic management of the storage space, specifically, adding a data description word for recording data information and a description word check code for checking the validity of data content at the initial address of the first storage space; wherein, the description word check code is an inverse check code of the data description word;
when a target data block is read, reading the data description word and the description word check code according to a front pointer in the dynamic circular queue algorithm;
verifying the data description word according to the description word check code; if the verification is passed, reading the data content of the target data block in the first storage space according to the data description word and a back pointer in the dynamic circular queue algorithm, and returning an effective data length, wherein the effective data length comprises the data description word, the description word check code and the length of the data content; and if the verification fails, sequentially reading the subsequent storage areas until the valid data description words or valid storage end marks are found.
8. A dynamic queue type cyclic storage device is characterized in that the device is used for dynamically and cyclically storing data in an erasable storage medium in an embedded device; the device comprises:
the data acquisition module is used for dividing the target data into a plurality of target data blocks according to a preset dynamic circular queue algorithm and the length of the target data when the target data are received;
the space determining module is used for determining N first storage spaces corresponding to the target data blocks according to a preset dynamic circular queue algorithm;
the space erasing module is used for erasing original data in the N first storage spaces according to a preset storage format and the size of the target data block;
and the data storage module is used for sequentially writing the target data blocks into the first storage space and counting until N is equal to 0.
9. An apparatus comprising a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program when executed by the processor implementing the method of any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111417181.4A CN114217738A (en) | 2021-11-25 | 2021-11-25 | Dynamic queue type cyclic storage method, device, equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111417181.4A CN114217738A (en) | 2021-11-25 | 2021-11-25 | Dynamic queue type cyclic storage method, device, equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114217738A true CN114217738A (en) | 2022-03-22 |
Family
ID=80698449
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111417181.4A Pending CN114217738A (en) | 2021-11-25 | 2021-11-25 | Dynamic queue type cyclic storage method, device, equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114217738A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115190089A (en) * | 2022-05-26 | 2022-10-14 | 中科驭数(北京)科技有限公司 | Message storage method, device, equipment and storage medium |
CN115827653A (en) * | 2022-11-25 | 2023-03-21 | 深圳计算科学研究院 | Pure column type updating method and device for HTAP and mass data |
CN115964002A (en) * | 2023-03-13 | 2023-04-14 | 杭州炬华科技股份有限公司 | Electric energy meter terminal file management method, device, equipment and medium |
CN116028387A (en) * | 2023-01-31 | 2023-04-28 | 惠州市海葵信息技术有限公司 | Data processing method, slave station, master station, and storage medium |
CN116527691A (en) * | 2023-06-27 | 2023-08-01 | 天津中远海运散运数字科技有限公司 | Method, device, equipment and medium for synchronizing ship-shore data |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20150212751A1 (en) * | 2014-01-28 | 2015-07-30 | International Business Machines Corporation | Data storage control apparatus |
CN107608639A (en) * | 2017-10-20 | 2018-01-19 | 深圳益邦阳光有限公司 | Queue-type cycle storage method, electronic equipment and storage medium based on flash memory |
CN111240599A (en) * | 2020-01-17 | 2020-06-05 | 北京马赫谷科技有限公司 | Data stream storage method and device |
CN111930309A (en) * | 2020-07-31 | 2020-11-13 | 中国人民解放军海军工程大学 | File circular storage method and device based on data blocking technology |
CN112181311A (en) * | 2020-10-21 | 2021-01-05 | 深圳市创维软件有限公司 | Cyclic recording method, equipment and storage medium |
-
2021
- 2021-11-25 CN CN202111417181.4A patent/CN114217738A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20150212751A1 (en) * | 2014-01-28 | 2015-07-30 | International Business Machines Corporation | Data storage control apparatus |
CN107608639A (en) * | 2017-10-20 | 2018-01-19 | 深圳益邦阳光有限公司 | Queue-type cycle storage method, electronic equipment and storage medium based on flash memory |
CN111240599A (en) * | 2020-01-17 | 2020-06-05 | 北京马赫谷科技有限公司 | Data stream storage method and device |
CN111930309A (en) * | 2020-07-31 | 2020-11-13 | 中国人民解放军海军工程大学 | File circular storage method and device based on data blocking technology |
CN112181311A (en) * | 2020-10-21 | 2021-01-05 | 深圳市创维软件有限公司 | Cyclic recording method, equipment and storage medium |
Non-Patent Citations (2)
Title |
---|
李用江等: "《计算机组成原理》", 30 November 2003, 《华南理工大学出版社》, pages: 284 - 286 * |
贾永红等: "《数字图像处理实习教程第三版》", 30 November 2016, 《武汉大学出版社》, pages: 56 - 59 * |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115190089A (en) * | 2022-05-26 | 2022-10-14 | 中科驭数(北京)科技有限公司 | Message storage method, device, equipment and storage medium |
CN115190089B (en) * | 2022-05-26 | 2024-03-22 | 中科驭数(北京)科技有限公司 | Message storage method, device, equipment and storage medium |
CN115827653A (en) * | 2022-11-25 | 2023-03-21 | 深圳计算科学研究院 | Pure column type updating method and device for HTAP and mass data |
CN115827653B (en) * | 2022-11-25 | 2023-09-05 | 深圳计算科学研究院 | Pure column type updating method and device for HTAP and mass data |
CN116028387A (en) * | 2023-01-31 | 2023-04-28 | 惠州市海葵信息技术有限公司 | Data processing method, slave station, master station, and storage medium |
CN115964002A (en) * | 2023-03-13 | 2023-04-14 | 杭州炬华科技股份有限公司 | Electric energy meter terminal file management method, device, equipment and medium |
CN116527691A (en) * | 2023-06-27 | 2023-08-01 | 天津中远海运散运数字科技有限公司 | Method, device, equipment and medium for synchronizing ship-shore data |
CN116527691B (en) * | 2023-06-27 | 2023-11-03 | 天津中远海运散运数字科技有限公司 | Method, device, equipment and medium for synchronizing ship-shore data |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114217738A (en) | Dynamic queue type cyclic storage method, device, equipment and medium | |
CN111090628B (en) | Data processing method and device, storage medium and electronic equipment | |
CN102508784B (en) | Data storage method of flash memory card in video monitoring equipment, and system thereof | |
US8627024B2 (en) | Snapshot based replication | |
CN102999436B (en) | The method and apparatus of dynamic partition information is generated in Nand flash memory | |
WO2017107414A1 (en) | File operation method and device | |
CN110865888A (en) | Resource loading method and device, server and storage medium | |
CN112346647B (en) | Data storage method, device, equipment and medium | |
CN111104347B (en) | Heap memory block searching method, device, equipment and storage medium | |
CN116431099B (en) | Data processing method, multi-input-output queue circuit and storage medium | |
CN110908707A (en) | Resource packaging method, device, server and storage medium | |
CN110633046A (en) | Storage method and device of distributed system, storage equipment and storage medium | |
CN111400056A (en) | Message queue-based message transmission method, device and equipment | |
US10803109B2 (en) | Method and device for reading and writing video data in NAS device | |
US9891824B2 (en) | Sub-block input/output (I/O) commands for storage device including byte stream buffer | |
US9817837B2 (en) | Method and system for file storage and access | |
US20210117339A1 (en) | Managing global counters using local delta counters | |
CN115934999A (en) | Video stream data storage method, device and medium based on block file | |
CN111435323A (en) | Information transmission method, device, terminal, server and storage medium | |
CN109189332A (en) | A kind of disk hanging method, device, server and storage medium | |
CN111897745B (en) | Data storage method and device, electronic equipment and storage medium | |
CN109491620B (en) | Storage data rewriting method, device, server and storage medium | |
CN116662603B (en) | Time shaft control method and system based on kafka, electronic equipment and storage medium | |
CN112363778B (en) | Dynamic picture loading method and device, electronic equipment and storage medium | |
CN117271440B (en) | File information storage method, reading method and related equipment based on freeRTOS |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |