CN110209349B - Data processing method and terminal equipment - Google Patents

Data processing method and terminal equipment Download PDF

Info

Publication number
CN110209349B
CN110209349B CN201910338717.XA CN201910338717A CN110209349B CN 110209349 B CN110209349 B CN 110209349B CN 201910338717 A CN201910338717 A CN 201910338717A CN 110209349 B CN110209349 B CN 110209349B
Authority
CN
China
Prior art keywords
sector
record
attribute information
writing
data
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.)
Active
Application number
CN201910338717.XA
Other languages
Chinese (zh)
Other versions
CN110209349A (en
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.)
Guangdong Kehua Qiansheng Cloud Computing Technology Co ltd
Original Assignee
Guangdong Kehua Qiansheng Cloud Computing Technology Co ltd
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 Guangdong Kehua Qiansheng Cloud Computing Technology Co ltd filed Critical Guangdong Kehua Qiansheng Cloud Computing Technology Co ltd
Priority to CN201910338717.XA priority Critical patent/CN110209349B/en
Publication of CN110209349A publication Critical patent/CN110209349A/en
Application granted granted Critical
Publication of CN110209349B publication Critical patent/CN110209349B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1008Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices
    • G06F11/1048Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices using arrangements adapted for a specific error detection or correction feature
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input 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/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data

Abstract

The invention is suitable for the technical field of data storage, and provides a data processing method and terminal equipment, wherein the method comprises the following steps: acquiring a first attribute parameter of a record to be written; determining the sector to be written in the record to be written according to the storage category in the first attribute parameter; updating header attribute information of the sector; and writing the record to be written in the sector according to the first attribute parameter and the updated head attribute information of the sector, so that the processing process of the record does not need to use an additional record index unit, the operation is simple, and the problem of data recovery possibly caused by working conditions such as asynchronous data storage of various storage media and the like during power failure in the storage process is effectively solved.

Description

Data processing method and terminal equipment
Technical Field
The invention belongs to the technical field of data storage, and particularly relates to a data processing method and terminal equipment.
Background
Data is usually stored in a memory, and when the amount of data to be stored is large or the data is variable, an address storage method is usually selected to reduce the wear of the memory, that is, an address needs to be changed every time one piece of data is written. Usually, the minimum erase unit of the memory is a sector, and when the address division storage is selected, different storage media or different storage sectors are needed for storing index information, so as to achieve the purpose of data indexing. However, when the data is stored in the address-sharing storage mode, the storage process is complicated, and data recovery is difficult when power is lost in the storage process.
Disclosure of Invention
In view of this, embodiments of the present invention provide a data processing method and a terminal device, so as to solve the problems in the prior art that when data is stored, a storage process is complicated, and data recovery is difficult when power is lost in the storage process.
A first aspect of an embodiment of the present invention provides a data processing method, including:
acquiring a first attribute parameter of a record to be written;
determining the sector to be written in the record to be written according to the storage category in the first attribute parameter;
updating header attribute information of the sector;
and writing the record to be written in the sector according to the first attribute parameter and the updated head attribute information of the sector.
In one embodiment, a record corresponds to a set of data, the record comprising: the data verification method comprises the following steps of identifying data attributes, data content, and valid verification identifications and invalid verification identifications corresponding to the data attributes;
the head of the sector stores the head attribute information and user self-defining information of the sector data;
the header attribute information includes: the storage type number identification, the storage identification and the record length identification.
In an embodiment, before the obtaining the first attribute parameter of the record to be written, the method further includes: acquiring defined sector configuration information;
acquiring head attribute information of an mth sector to be searched, wherein m is more than or equal to 1;
and when the head attribute information of the mth sector to be searched is not matched with the head attribute information of the nth sector to be configured, writing the defined sector configuration information into a storage space corresponding to each identifier of the head attribute information of the nth sector to be configured, wherein n is greater than or equal to 1.
In one embodiment, the updating and storing the header attribute information of the sector includes:
turning over the content corresponding to the storage identification in the head attribute information of the sector;
and updating the head attribute information of the sector according to the first attribute parameter, and storing the updated head attribute information of the sector.
In an embodiment, the writing the record to be written in the sector according to the first attribute parameter and the updated header attribute information of the sector includes:
calculating the total number of the stored records of the sector according to the content corresponding to the record length identification in the updated head attribute information;
acquiring data corresponding to the writing position identification in the first attribute parameter;
when the data corresponding to the writing position identification is more than the total number of the records, writing first data in an interval from the address corresponding to the last record of the sector to the address corresponding to the writing position identification; and
and writing the record to be written in the address corresponding to the writing position identification.
In an embodiment, the writing the record to be written in the sector according to the first attribute parameter and the updated header attribute information of the sector further includes:
when the data corresponding to the writing position identification is less than the total number of records, erasing the record from the address corresponding to the writing position identification to the address interval corresponding to the total number of records, and writing second data from the address corresponding to the writing position identification to the address interval corresponding to the total number of records; and the number of the first and second groups,
writing the record to be written in the address corresponding to the writing position mark;
or, when the data corresponding to the writing position identifier is equal to the total number of records, writing the record to be written into the address corresponding to the writing position identifier.
A second aspect of the embodiments of the present invention provides a method for reading data, including:
acquiring a second attribute parameter of a record to be read;
according to the storage category in the second attribute parameter, acquiring a first sector with the same category as the storage category in the second attribute parameter;
acquiring the head attribute information of the first sector;
calculating the total number of records of the first sector according to the head attribute information of the first sector;
acquiring the address of the record to be read according to the content corresponding to the record number identification to be read in the second attribute parameter and the total number of the records of the first sector;
and reading the record to be read according to the address of the record to be read.
A third aspect of the embodiments of the present invention provides a data processing apparatus, including:
the first acquisition module is used for acquiring a first attribute parameter of a record to be written;
a determining module, configured to determine, according to the storage category in the first attribute parameter, a sector to which the record is to be written;
the processing module is used for updating and storing the head attribute information of the sector;
and the writing module is used for writing the record in the sector according to the first attribute parameter and the head attribute information of the sector.
A fourth aspect of the embodiments of the present invention provides an apparatus for reading data, including:
the second acquisition module is used for acquiring a second attribute parameter of the record to be read;
the second obtaining module is further configured to obtain, according to the storage category in the second attribute parameter, a first sector of a category that is the same as the storage category in the second attribute parameter;
the second obtaining module is further configured to obtain the header attribute information of the first sector;
the calculation module is used for calculating the total number of the first sector records according to the head attribute information of the first sector;
the second obtaining module is further configured to obtain an address of the record to be read according to the content corresponding to the record number identifier to be read in the second attribute parameter and the total number of records in the first sector;
and the reading module is used for reading the record to be read according to the address of the record to be read.
A fifth aspect of embodiments of the present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method according to any one of claims 1 to 6 and the steps of the method according to claim 7 when executing the computer program.
Compared with the prior art, the embodiment of the invention has the following beneficial effects: the embodiment of the invention obtains a first attribute parameter of a record to be written; determining a sector to be written in the record to be written according to the storage category in the first attribute parameter; updating header attribute information of the sector; and writing the record to be written in the sector according to the first attribute parameter and the updated head attribute information of the sector. Through setting up the data structure of record for the processing procedure of record need not to rely on extra record index unit, and easy operation effectively solves the data recovery problem that operating mode such as the multiple storage medium data storage is asynchronous probably brought when losing power in the storage process.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required to be used in the embodiments or the prior art description will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings may be obtained according to these drawings without inventive labor.
Fig. 1 is a schematic flow chart illustrating an implementation of a data processing method according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating a sector initialization procedure according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of sector header attribute information provided by an embodiment of the present invention;
fig. 4 (1) is a schematic diagram of a single-sector iterative rolling mode provided in an embodiment of the present invention;
FIG. 4 (2) is a schematic diagram of a multi-sector incremental storage method according to an embodiment of the present invention;
FIG. 4 (3) is a schematic diagram of a multi-sector overlay memory method according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating a data writing process in a sector according to an embodiment of the present invention;
FIG. 6 is a diagram illustrating a method for reading data according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of an apparatus for processing data according to an embodiment of the present invention;
FIG. 8 is a diagram of an apparatus for reading data according to an embodiment of the present invention;
fig. 9 is a schematic diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
An embodiment of the present invention provides a data processing method, as shown in fig. 1, the method includes the following steps:
step 101, a first attribute parameter of a record to be written is obtained.
The records correspond to a set of data, as shown in the following table:
content providing method and apparatus ValidFlag UserData CRC16_1 CRC16_2
Length of 2 N 2 2
ValidFlag represents a data attribute identifier, and occupies a storage space of 2 characters;
the UserData represents data content identification and occupies the storage space of N characters;
CRC16_1 represents a valid verification identifier corresponding to the data attribute identifier, and occupies a storage space of 2 characters;
CRC16_2 indicates the data attribute identity corresponding to the invalid validation identity and occupies a memory space of 2 characters.
Optionally, when the record is written for the first time, the flag is valid, validFlag =1, CRC16 \ u 1 is the check code of all the preceding bytes, and CRC16_2 is null;
when a record is invalidated, the record is taken out, validFlag is set to 0, CRC16_2 is the check code of all bytes of the record, and the record is rewritten.
The "records" described in all embodiments of the present invention are in the unified format shown above, and the different records are only different in length.
The head of the sector stores the head attribute information and user-defined information of the sector data;
the header attribute information includes: the storage system comprises a storage class number identification, a storage identification and a record length identification.
And 102, determining the sector to be written in the record to be written according to the storage category in the first attribute parameter.
Step 103, updating the header attribute information of the sector.
Optionally, the content corresponding to the storage identifier in the header attribute information of the sector is turned over;
and updating the head attribute information of the sector according to the first attribute parameter, and storing the updated head attribute information of the sector.
And 104, writing the record to be written in the sector according to the first attribute parameter and the updated head attribute information of the sector.
Optionally, the total number of records stored in the sector is calculated according to the content corresponding to the record length identifier in the updated header attribute information;
acquiring data corresponding to the writing position identification in the first attribute parameter;
when the data corresponding to the writing position mark is larger than the total number of the records, writing first data in an interval from an address corresponding to the last record of the sector to an address corresponding to the writing position mark, and writing the record to be written in the address corresponding to the writing position mark.
When the data corresponding to the writing position identification is less than the total number of records, erasing the record from the address corresponding to the writing position identification to the address interval corresponding to the total number of records, and writing second data from the address corresponding to the writing position identification to the address interval corresponding to the total number of records; and the number of the first and second groups,
writing the record to be written in the address corresponding to the writing position mark;
or, when the data corresponding to the writing position identifier is equal to the total number of records, writing the record to be written in the address corresponding to the writing position identifier.
Before step 101, the embodiment of the present invention further includes initializing a sector, specifically including: acquiring defined sector configuration information;
acquiring head attribute information of an mth sector to be searched, wherein m is more than or equal to 0;
and when the head attribute information of the mth sector to be searched is not matched with the defined sector configuration information, writing the defined sector configuration information into a storage space corresponding to each identifier of the head attribute information of the mth sector to be searched.
The data processing method comprises the steps of obtaining a first attribute parameter of a record to be written; determining a sector to be written in the record according to the storage category in the first attribute parameter; updating header attribute information of the sector; and writing the record to be written in the sector according to the first attribute parameter and the updated head attribute information of the sector. Through setting up the data structure of record for the processing procedure of record need not to rely on extra record index unit, and easy operation effectively solves the data recovery problem that operating mode such as the multiple storage medium data storage is asynchronous probably brought when losing power in the storage process.
The embodiment of the invention provides another data processing method, which specifically comprises a sector initialization process and a data writing process in a sector. Two processes are described in detail below, and as shown in fig. 2, the sector initialization process includes the following steps:
step 201, acquiring defined sector configuration information.
Alternatively, the sector configuration information of this category record needs to be defined first. The scheme opens up an address at the head of each writable recording sector for storing the head attribute information and user-defined information of sector data.
As shown in fig. 3, the header attribute information includes: method, type, sectorNum, currentSecNo., storeFlag, overwrite, recordLength, reserve, CRC16.
The Method is a storage mode identifier and occupies a storage space of 1 byte;
the Type is a storage Type number identifier and occupies a storage space of 1 byte;
SectorNum is a sector number identifier distributed for the category, and occupies a storage space of 1 byte;
the CurrentSecNo. is a position number mark of the current sector in the current category and occupies a storage space of 1 byte;
the StoreFlag is a storage identifier and occupies a storage space of 1 byte;
the Overwrite is a writable time identifier, occupies a storage space of 1 byte, and is defined to be writable 16 times at most;
the RecordLength is a record length mark, occupies a storage space of 2 bytes and is the length of user data;
reserve is reserved identification, and occupies 54 bytes of storage space;
the CRC16 is a header information check code identification and occupies a memory space of 2 bytes.
The header attribute information occupies 64 bytes of storage space, the user-defined information can occupy 64 bytes of storage space, the specific stored content and the storage space occupied by each content can be defined by the user, and the initial value is 0xFF and can be changed.
Step 202, setting the sector number to be searched and the sector number to be configured.
Optionally, in order to search all sectors, the number m =0 of the current sector to be searched is set, m is greater than or equal to 0, and after the search is finished, the next sector is searched;
in order to configure header attribute information for all sectors not configured with header attribute information, the label N =0 of the current sector to be configured, where N is greater than or equal to 0, and after the current sector to be configured is configured with the header attribute information, the header attribute information may be continuously configured for the next sector not configured with the header attribute information.
Step 203, acquiring the head attribute information of the mth sector to be searched.
Optionally, m =0, that is, the 1 st sector to be searched is searched first.
Step 204, judging whether the head attribute information of the mth sector to be searched is matched with the defined sector configuration information.
Alternatively, for example, the defined sector configuration information may be that Method is 1, type is 0, and it is assumed that 2 sectors need to be allocated according to the number of records that need to be stored, that is, sectorNum =2. Then, during initialization, firstly searching whether the 1 st sector to be searched (CurrentSecNo. = 0) already exists, where the existing conditions are as follows: method =1, type =0, and CurrentSecNo. =0 in the header attribute information of the sector to be searched.
Optionally, as shown in fig. 2, when the header attribute information of the mth sector to be searched does not match the defined sector configuration information, step 205 is executed, and when the header attribute information of the mth sector to be searched matches the defined sector configuration information, step 208 is executed.
In step 205, the (m + 1) operation is performed.
Optionally, here, the (m + 1) operation may be performed by a counter, when m =1. Optionally, when the head attribute information of the mth sector to be searched is not matched with the defined sector configuration information, it is required to detect whether the head attribute information of the next sector to be searched is matched with the defined sector configuration information or not until all sectors to be searched are detected.
Step 206, determine if m is smaller than the total number of sectors to be searched.
And step 207, when m is greater than the total number of the sectors to be searched, writing the defined sector configuration information into a storage space corresponding to each identifier of the head attribute information of the mth sector to be searched.
Optionally, if all the sectors to be searched are traversed without matching and m is greater than the total number of the sectors to be searched, it is determined that the sector has not been opened, a currently unused sector is opened, and the defined sector configuration information is written into a storage space corresponding to each identifier of the head attribute information of the currently to-be-configured sector, i.e., the mth sector to be searched.
After the present step is performed, the step 208 is continued.
And when m is smaller than the total number of the sectors to be searched, acquiring the head attribute information of the mth sector to be searched, namely, continuing to execute the step 203.
In step 208, it is determined whether all sectors to be configured have been searched.
Optionally, when the head attribute information of the mth sector to be searched matches the defined sector configuration information, it indicates that the sector has been initialized, and then it is determined whether all sectors to be configured have been searched, and when all sectors to be configured have not been searched, step 209 is executed to continue searching for the next sector to be searched, and continue detecting until all sectors to be configured have been detected. And when all the sectors to be configured are searched, ending the current flow.
Step 209, perform m +1 operation.
After step 209 is performed, step 203 is continued.
It should be noted that the sectors in the present scheme may have various ways of storing data, as shown below.
The method I comprises the following steps: and (3) a single-sector iterative rolling storage mode. As shown in fig. 4 (1), one sector can store n records, n being equal to or greater than 1. When records are stored in a single sector, only the most recent nth group of records is valid.
The second method comprises the following steps: multi-sector incremental storage. As shown in fig. 4 (2), m sectors constitute a multi-sector, where m is equal to or greater than 1, and each sector can store n records. The storage types of the records stored by the m sectors are the same. Records of the same type are stored incrementally after a given sector, and each group of records is valid.
The third method comprises the following steps: a multi-sector overlay storage approach. As shown in fig. 4 (3), m sectors constitute a multi-sector, m is equal to or greater than 1, and each sector can store n records. The storage types of the records stored by the m sectors are the same. The same type of record, in which the record is written in a single sector with the data index as an offset, includes two special operations: data after the data index must be cleared to 0xFF; data must be written with 0 between the current address and the address to be written.
As shown in fig. 5, the detailed description of the sector write data flow according to the embodiment of the present invention includes the following steps:
step 501, a first attribute parameter of a record to be written is obtained.
Optionally, the first attribute parameter includes a storage mode identifier, a storage category label identifier, a record pointer to be written, and specific content corresponding to each identifier.
Step 502, determining the sector to be written in the record to be written according to the storage category in the first attribute parameter.
Optionally, searching the latest sector of the first attribute parameter according to the storage category in the first attribute parameter, and judging whether the latest sector is full of records; when this last sector is already fully recorded, the next available sector is searched. When the latest sector is written for the first time, the latest sector can be determined as the sector to be written.
Optionally, whether the sector is the latest sector is determined according to the StoreFlag. For example, the record type has 3 sectors in total, and in the initial unwritten state, the StoreFlag in the header attribute information of each sector is 0xFF. And starting to write the 1 st sector, firstly turning the StoreFlag to 0, continuously writing the 2 nd sector and the 3 rd sector after the sector is completely written, and similarly turning the value of the StoreFlag from 0xFF to 0. After all the data are written, erasing the record written in the 1 st sector, and simultaneously writing the record after turning the StoreFlag to 1. Therefore, only the StoreFlag in the header attribute information of 3 sectors needs to be judged in sequence, and the newest sector can be positioned.
Step 503, the content corresponding to the storage identifier in the header attribute information of the sector is turned over.
Step 504, updating the header attribute information of the sector according to the first attribute parameter, and storing the updated header attribute information of the sector.
As can be understood, the first attribute parameter further includes a storage mode identifier, and content corresponding to the storage mode identifier; storing the category number and storing the content corresponding to the category number, namely the storage category; the data pointer identification and the content corresponding to the data pointer identification; the sector head address mark and the content corresponding to the sector head address mark; and writing the position number identification and writing the data corresponding to the position number identification.
And 505, calculating the total number of the stored records of the sector according to the content corresponding to the record length identifier in the updated head attribute information.
For example, the total number of records stored in a sector is 10.
Step 506, obtaining data corresponding to the writing position number identifier in the first attribute parameter.
Optionally, the writing position number identifies that the corresponding data is a number, for example, the writing position number is 9.
Step 507, judging whether the data corresponding to the writing position number identification is larger than the total number of the records.
Step 508, when the data corresponding to the writing position number is greater than the total number of records, writing the first data in the interval between the address corresponding to the last record of the sector and the address corresponding to the writing position number.
Optionally, when the data corresponding to the writing position number identifier is greater than the total number of records, that is, it indicates that the address to be written in the record to be written is empty, and the current record to be written may be written. According to the characteristic of the multi-sector overlay type storage mode, first data is required to be written between a current address and an address to be written.
Alternatively, the first data may be 0.
Step 509, writing the record to be written into the address corresponding to the writing position number identifier.
Step 510, when the data corresponding to the written position number identifier is less than the total number of records, erasing the record from the address corresponding to the written position number identifier to the address interval corresponding to the total number of records, and writing the second data in the address interval from the address corresponding to the written position identifier to the address interval corresponding to the total number of records.
Optionally, when the data corresponding to the written location number identifier is less than the total number of records, it indicates that the record has been stored in the address corresponding to the location identifier, so according to the characteristic of the multi-sector overlay storage manner, it is necessary to erase the data after the address corresponding to the written location number identifier, and write the second data in the interval after the address corresponding to the written location number identifier, optionally, the second data may be 0xFF. Step 509 is then performed.
When the data corresponding to the written position number identifier is equal to the total number of records, the record to be written is directly written in the address corresponding to the written position number identifier, that is, step 509 is executed.
As shown in fig. 6, the present embodiment provides a data reading method, which includes the following steps:
step 601, acquiring a second attribute parameter of the record to be read.
Optionally, the second attribute parameter includes a storage mode identifier and content corresponding to the storage mode identifier; storing the category number and storing the content corresponding to the category number, namely the storage category; and the record number identification to be read and the content corresponding to the record number identification to be read.
Step 602, obtaining a first sector with the same category as the storage category in the second attribute parameter according to the storage category in the second attribute parameter.
Step 603, obtaining the header attribute information of the first sector.
Step 604, calculating the total number of records in the first sector according to the header attribute information of the first sector.
Optionally, the total number of records in the first sector is calculated according to the content corresponding to the record length identifier in the header attribute information of the first sector. Optionally, the content of RecordLength is obtained, i =0, totalNumSec =0{ }, according to A At present =A First address +L Head part And + i · RecordLength, sequentially reading the content of the storage area except the header attribute information in the first sector, reading the RecordLength bytes each time, then checking the read bytes, executing i + + and totalNumSec + + when the checking is successful until all the bytes in the first sector are read, and returning to totalNumSec, thereby obtaining the total number of records in the first sector.
Step 605, obtaining the address of the record to be read according to the content corresponding to the record number identifier to be read in the second attribute parameter and the total number of the records in the first sector.
Optionally, the number of the corresponding record to be read is obtained according to the identifier of the record number to be read in the second attribute parameter, for example, the number of the corresponding record to be read is obtained as 18. The first sector records a total number of 10. The address of the record to be read is the 8 th record of the 2 nd sector.
Step 606, reading the record to be read according to the address of the record to be read.
Optionally, after step 606, verifying the record to be read is further included, and when the verification is successful, returning a success identifier, and when the verification is failed, returning a failure identifier.
The embodiment of the invention provides a data processing method, which is characterized in that the head attribute information of a sector is initialized, then the record can be written according to the defined attribute information to be written in and the head attribute information of the sector, and the corresponding record is read according to the defined attribute information to be read and the head attribute information of the sector. In this embodiment, each type of data is abstracted to a certain record, and for different types of data, only the lengths are different, and the same scheme is adopted in the storage process. A user only needs to define a data structure needing to be stored, determines a storage mode according to an application scene, can realize the functions of storing, reading, erasing and the like of various types of data, does not need to use an additional recording index unit, simplifies application steps, and effectively solves the problem of data recovery possibly caused by working conditions such as power failure, asynchronous data storage of various storage media and the like in the storage process.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
An embodiment of the present invention provides a data processing apparatus, as shown in fig. 7, the apparatus includes: the system comprises a first acquisition module 701, a determination module 702, a processing module 703 and a writing module 704.
The first obtaining module 701 is configured to obtain a first attribute parameter of a record to be written.
Optionally, the record corresponds to a set of data, and the record includes: the data verification method comprises the following steps of identifying data attributes, data content, and valid verification identifications and invalid verification identifications corresponding to the data attributes;
the head of the sector stores the head attribute information and user-defined information of the sector data;
the header attribute information includes: the storage type number identification, the storage identification and the record length identification.
A determining module 702, configured to determine, according to the storage category in the first attribute parameter, a sector to be written in the record to be written.
A processing module 703, configured to update the header attribute information of the sector.
Optionally, the processing module 703 is configured to flip content corresponding to the storage identifier in the header attribute information of the sector; and updating the head attribute information of the sector according to the first attribute parameter, and storing the updated head attribute information of the sector.
A writing module 704, configured to write the record to be written in the sector according to the first attribute parameter and the updated header attribute information of the sector.
Optionally, the writing module 704 is configured to calculate the total number of stored records in the sector according to the content corresponding to the record length identifier in the updated header attribute information;
acquiring data corresponding to the writing position identification in the first attribute parameter;
when the data corresponding to the writing position mark is larger than the total number of the records, writing first data in an interval from an address corresponding to the last record of the sector to an address corresponding to the writing position mark, and writing the record to be written in the address corresponding to the writing position mark.
When the data corresponding to the writing position identification is smaller than the total number of records, erasing the record from the address corresponding to the writing position identification to the address interval corresponding to the total number of records, writing second data from the address corresponding to the writing position identification to the address interval corresponding to the total number of records, and writing the record to be written in the address corresponding to the writing position identification; or, when the data corresponding to the writing position identifier is equal to the total number of records, writing the record to be written in the address corresponding to the writing position identifier.
The embodiment of the invention provides a data processing device, which comprises an acquisition module, a determination module and a data processing module, wherein the acquisition module is used for acquiring a first attribute parameter of a record to be written, and determining a sector of the record to be written according to the storage category in the first attribute parameter; the processing module updates the head attribute information of the sector; and writing the record to be written in the sector by a writing module according to the first attribute parameter and the updated head attribute information of the sector. In the embodiment, each type of data is abstracted into a certain record, and different types of data are different in length, so that an additional record index unit is not needed in the storage process, the application steps are simplified, and the problem of data recovery possibly caused by working conditions such as power failure and asynchronous data storage of multiple storage media in the storage process is effectively solved.
An embodiment of the present invention provides a data reading apparatus, as shown in fig. 8, the apparatus includes: a second obtaining module 801, a calculating module 802 and a reading module 803.
A second obtaining module 801, configured to obtain a second attribute parameter of a record to be read.
Optionally, the second attribute parameter includes a storage mode identifier and content corresponding to the storage mode identifier; storing the category number and storing the content corresponding to the category number, namely the storage category; and the record number identification to be read, and the content corresponding to the record number identification to be read.
The second obtaining module 801 is further configured to obtain, according to the storage category in the second attribute parameter, a first sector having the same category as the storage category in the second attribute parameter.
The second obtaining module 801 is further configured to obtain header attribute information of the first sector.
A calculating module 802, configured to calculate a total number of records in the first sector according to the header attribute information of the first sector.
Optionally, the total number of records in the first sector is calculated according to the content corresponding to the record length identifier in the header attribute information of the first sector.
The second obtaining module 801 is further configured to obtain an address of the record to be read according to the content corresponding to the record number identifier to be read in the second attribute parameter and the total number of records in the first sector.
Optionally, the number of the corresponding record to be read is obtained according to the identifier of the record number to be read in the second attribute parameter, for example, the number of the corresponding record to be read is obtained as 18. The first sector records a total number of 10. The address of the record to be read is the 8 th record of the 2 nd sector.
The reading module 803 is configured to read the record to be read according to the address of the record to be read.
Optionally, after the record word to be read is read, the record to be read may also be verified, a success identifier is returned when the verification is successful, and a failure identifier is returned when the verification is failed.
In the embodiment, each type of data is abstracted into a certain record, the different types of data are different in length, the same scheme is adopted in the reading process, an additional record index unit is not needed, the application steps are simplified, and the problem of data recovery possibly brought by working conditions such as power failure and asynchronous data storage of various storage media in the storage process is effectively solved.
Fig. 9 is a schematic diagram of a terminal device according to an embodiment of the present invention. As shown in fig. 9, the terminal apparatus 900 of this embodiment includes: a processor 901, a memory 902 and computer programs 903, such as a data processing program and a data reading program, stored in said memory 902 and operable on said processor 901. The processor 901 implements the steps in the above embodiments of data processing and data reading when executing the computer program 903, for example, steps 101 to 104 shown in fig. 1, or steps 201 to 210 shown in fig. 2, steps 501 to 510 shown in fig. 5, and steps 601 to 606 shown in fig. 6. The processor 901 implements the functions of the modules in the device embodiments described above, such as the functions of the modules 701 to 704 shown in fig. 7 and the functions of the modules 801 to 803 shown in fig. 8, when executing the computer program 903.
Illustratively, the computer program 903 may be partitioned into one or more modules that are stored in the memory 902 and executed by the processor 901 to implement the present invention. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which are used for describing the execution process of the computer program 903 in the data processing apparatus or the terminal device 900. For example, the computer program 903 may be divided into a first obtaining module 701, a determining module 702, a processing module 703, and a writing module 704, and specific functions of the modules are shown in fig. 7, which are not described herein again. The computer program 903 may be divided into a second obtaining module 801, a calculating module 802, and a reading module 803, and specific functions of the modules are shown in fig. 8, which are not described in detail herein.
The terminal device 900 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 901, a memory 902. Those skilled in the art will appreciate that fig. 9 is merely an example of a terminal device 900 and is not intended to limit terminal device 900 and may include more or fewer components than those shown, or some of the components may be combined, or different components, e.g., the terminal device may also include input output devices, network access devices, buses, etc.
The Processor 901 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 902 may be an internal storage unit of the terminal device 900, such as a hard disk or a memory of the terminal device 900. The memory 902 may also be an external storage device of the terminal device 900, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like, provided on the terminal device 900. Further, the memory 902 may also include both an internal storage unit and an external storage device of the terminal apparatus 900. The memory 902 is used for storing the computer programs and other programs and data required by the terminal device 900. The memory 902 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. For the specific working processes of the units and modules in the system, reference may be made to the corresponding processes in the foregoing method embodiments, which are not described herein again.
In the above embodiments, the description of each embodiment has its own emphasis, and reference may be made to the related description of other embodiments for parts that are not described or recited in any embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one type of logical function division, and other division manners may be available in actual implementation, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit may be implemented in the form of hardware, or may also be implemented in the form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments described above may be implemented. . Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer-readable medium may contain suitable additions or subtractions depending on the requirements of legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer-readable media may not include electrical carrier signals or telecommunication signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (9)

1. A method of data processing, comprising:
acquiring defined sector configuration information;
acquiring head attribute information of an mth sector to be searched, wherein m is greater than or equal to 0, and the head attribute information comprises: storing a category number identifier, a storage identifier and a record length identifier;
when the head attribute information of the mth sector to be searched is not matched with the defined sector configuration information, writing the defined sector configuration information into a storage space corresponding to each identifier of the head attribute information of the mth sector to be searched;
acquiring a first attribute parameter of a record to be written;
determining a sector to be written in the record to be written according to the storage category in the first attribute parameter;
updating header attribute information of the sector;
and writing the record to be written in the sector according to the first attribute parameter and the updated head attribute information of the sector.
2. The data processing method of claim 1,
a record corresponds to a set of data, the record comprising: the data attribute identification, the data content identification, and the valid verification identification and the invalid verification identification corresponding to the data attribute identification;
the header of the sector stores header attribute information and user-defined information of the sector.
3. The data processing method of claim 2, wherein said updating the header attribute information of the sector comprises:
turning over the content corresponding to the storage identification in the head attribute information of the sector;
and updating the head attribute information of the sector according to the first attribute parameter, and storing the updated head attribute information of the sector.
4. The data processing method according to claim 3, wherein said writing the record to be written in the sector according to the first attribute parameter and the updated header attribute information of the sector comprises:
calculating the total number of the stored records of the sector according to the content corresponding to the record length identification in the updated head attribute information;
acquiring data corresponding to the writing position identification in the first attribute parameter;
when the data corresponding to the writing position mark is larger than the total number of the records, writing first data in an interval from an address corresponding to the last record of the sector to an address corresponding to the writing position mark, and writing the record to be written in the address corresponding to the writing position mark.
5. The data processing method according to claim 4, wherein said writing the record to be written in the sector according to the first attribute parameter and the updated header attribute information of the sector, further comprises:
when the data corresponding to the writing position identification is smaller than the total number of records, erasing the record from the address corresponding to the writing position identification to the address interval corresponding to the total number of records, and writing second data from the address corresponding to the writing position identification to the address interval corresponding to the total number of records; and (c) a second step of,
writing the record to be written in an address corresponding to the writing position identifier; or, when the data corresponding to the writing position identifier is equal to the total number of records, writing the record to be written in the address corresponding to the writing position identifier.
6. A method of data reading, comprising:
acquiring defined sector configuration information;
acquiring head attribute information of an mth sector to be searched, wherein m is greater than or equal to 0, and the head attribute information comprises: storing a category number identifier, a storage identifier and a record length identifier;
when the head attribute information of the mth sector to be searched is not matched with the defined sector configuration information, writing the defined sector configuration information into a storage space corresponding to each identifier of the head attribute information of the mth sector to be searched;
acquiring a second attribute parameter of a record to be read;
according to the storage category in the second attribute parameter, acquiring a first sector with the same category as the storage category in the second attribute parameter;
acquiring the head attribute information of the first sector;
calculating the total number of records of the first sector according to the head attribute information of the first sector;
acquiring the address of the record to be read according to the content corresponding to the record number identification to be read in the second attribute parameter and the total number of the records in the first sector;
and reading the record to be read according to the address of the record to be read.
7. An apparatus for data processing, comprising:
the first acquisition module is used for acquiring the defined sector configuration information; acquiring header attribute information of an mth sector to be searched, wherein m is greater than or equal to 0, and the header attribute information comprises: storing a category number identifier, a storage identifier and a record length identifier; when the head attribute information of the mth sector to be searched is not matched with the defined sector configuration information, writing the defined sector configuration information into a storage space corresponding to each identifier of the head attribute information of the mth sector to be searched;
acquiring a first attribute parameter of a record to be written;
a determining module, configured to determine, according to the storage category in the first attribute parameter, a sector to be written in the record to be written;
a processing module for updating the header attribute information of the sector;
and the writing module is used for writing the record to be written in the sector according to the first attribute parameter and the updated head attribute information of the sector.
8. An apparatus for reading data, comprising:
the second acquisition module is used for acquiring the defined sector configuration information; acquiring head attribute information of an mth sector to be searched, wherein m is greater than or equal to 0, and the head attribute information comprises: storing a category number identifier, a storage identifier and a record length identifier; when the head attribute information of the mth sector to be searched is not matched with the defined sector configuration information, writing the defined sector configuration information into a storage space corresponding to each identifier of the head attribute information of the mth sector to be searched;
acquiring a second attribute parameter of the record to be read;
the second obtaining module is further configured to obtain, according to the storage category in the second attribute parameter, a first sector of a category that is the same as the storage category in the second attribute parameter;
the second obtaining module is further configured to obtain the header attribute information of the first sector;
the calculation module is used for calculating the total number of the first sector records according to the head attribute information of the first sector;
the second obtaining module is further configured to obtain an address of the record to be read according to the content corresponding to the record number identifier to be read in the second attribute parameter and the total number of records in the first sector;
and the reading module is used for reading the record to be read according to the address of the record to be read.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 6 when executing the computer program.
CN201910338717.XA 2019-04-25 2019-04-25 Data processing method and terminal equipment Active CN110209349B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910338717.XA CN110209349B (en) 2019-04-25 2019-04-25 Data processing method and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910338717.XA CN110209349B (en) 2019-04-25 2019-04-25 Data processing method and terminal equipment

Publications (2)

Publication Number Publication Date
CN110209349A CN110209349A (en) 2019-09-06
CN110209349B true CN110209349B (en) 2022-12-09

Family

ID=67786337

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910338717.XA Active CN110209349B (en) 2019-04-25 2019-04-25 Data processing method and terminal equipment

Country Status (1)

Country Link
CN (1) CN110209349B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112506918A (en) * 2020-11-03 2021-03-16 深圳市宏电技术股份有限公司 Data access method, terminal and computer readable storage medium
CN112347002B (en) * 2020-11-13 2023-07-28 杭州芯炬视人工智能科技有限公司 flash data storage method, system, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1280368A (en) * 1999-07-07 2001-01-17 三星电子株式会社 Recording medium for storaging attributive information and method for identifying data by using attributive information
WO2005109427A1 (en) * 2004-05-10 2005-11-17 Matsushita Electric Industrial Co., Ltd. Data recording/reproduction for write-once discs
CN101446921A (en) * 2008-12-23 2009-06-03 青岛海信宽带多媒体技术股份有限公司 Dynamic storage method of Flash memory
CN101546294A (en) * 2009-04-30 2009-09-30 青岛海信宽带多媒体技术有限公司 Method for storing data in Flash memory
CN102693283A (en) * 2012-05-07 2012-09-26 深圳市共进电子股份有限公司 Data partition storage method and system boot method of embedded system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1280368A (en) * 1999-07-07 2001-01-17 三星电子株式会社 Recording medium for storaging attributive information and method for identifying data by using attributive information
WO2005109427A1 (en) * 2004-05-10 2005-11-17 Matsushita Electric Industrial Co., Ltd. Data recording/reproduction for write-once discs
CN101446921A (en) * 2008-12-23 2009-06-03 青岛海信宽带多媒体技术股份有限公司 Dynamic storage method of Flash memory
CN101546294A (en) * 2009-04-30 2009-09-30 青岛海信宽带多媒体技术有限公司 Method for storing data in Flash memory
CN102693283A (en) * 2012-05-07 2012-09-26 深圳市共进电子股份有限公司 Data partition storage method and system boot method of embedded system

Also Published As

Publication number Publication date
CN110209349A (en) 2019-09-06

Similar Documents

Publication Publication Date Title
CN108090168B (en) Universal F2FS file system parsing method, terminal device and storage medium
CN111090663B (en) Transaction concurrency control method, device, terminal equipment and medium
US7725646B2 (en) Method of using a flash memory for a circular buffer
US9772937B2 (en) Data processing method, memory controller and memory storage apparatus
CN107193560B (en) Configuration updating method and device
CN110209349B (en) Data processing method and terminal equipment
CN105988722A (en) Data storage method and embedded system
CN101295281A (en) Memory device and method for limiting access authority of the same
CN112835528A (en) Dirty page refreshing method and device, electronic equipment and storage medium
CN110377276B (en) Source code file management method and device
CN112463020A (en) Data access method, device and equipment based on Flash
CN112463055B (en) Method, system, equipment and medium for optimizing and using L2P table of solid state disk
CN106775481A (en) Method for reading data and equipment
CN112558868A (en) Method, device and equipment for storing configuration data
CN111143240A (en) Image storage method, system and terminal equipment
CN110543434B (en) NAND flash device, memory table management method, device and storage medium
CN109783024B (en) Data storage processing method and device
CN109960611B (en) Data recovery method and device, electronic equipment and machine-readable storage medium
CN112347524A (en) Flash memory programming method and device and electronic equipment
CN112015672A (en) Data processing method, device, equipment and storage medium in storage system
CN112527745B (en) Embedded file system multi-partition analysis method, terminal device and storage medium
CN107632774B (en) Method and device for repairing disk mount
CN111008195A (en) Database free space management method, system, terminal and storage medium
CN113918095B (en) Hybrid cross storage method and device for data and electronic equipment
CN114637626B (en) Method, device and equipment for reducing read-write errors of EEPROM (electrically erasable programmable read-only memory) data and readable storage medium

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 361101 Ma Long Road 457, Torch Garden, Xiamen Torch High-tech Zone, Fujian Province

Applicant after: Kehua Data Co.,Ltd.

Applicant after: XIAMEN KECAN INFORMATION TECHNOLOGY Co.,Ltd.

Address before: 361101 Ma Long Road 457, Torch Garden, Xiamen Torch High-tech Zone, Fujian Province

Applicant before: XIAMEN KEHUAHENGSHENG LIMITED BY SHARE Ltd.

Applicant before: XIAMEN KECAN INFORMATION TECHNOLOGY Co.,Ltd.

TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20221104

Address after: Building 7, No. 39, Nanyun 3rd Road, Guangzhou Hi tech Industrial Development Zone, Guangzhou, Guangdong 510663

Applicant after: GUANGDONG KEHUA QIANSHENG CLOUD COMPUTING TECHNOLOGY Co.,Ltd.

Address before: 361101 Ma Long Road 457, Torch Garden, Xiamen Torch High-tech Zone, Fujian Province

Applicant before: Kehua Data Co.,Ltd.

Applicant before: XIAMEN KECAN INFORMATION TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant