A data processing method, terminal device and storage medium
By extracting storage tags from the first storage space to the second storage space in the LittleFS file system and constructing a tag linked list, an identifier-tag mapping table, and a file identifier linked list, the problem of low read/write performance and low data processing efficiency of the LittleFS file system when resource utilization is low is solved, thus improving performance and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-25
- Publication Date
- 2026-04-03
AI Technical Summary
While ensuring low resource utilization, the LittleFS file system suffers from low read/write performance and low data processing efficiency, which affects user experience and the execution efficiency of upper-layer applications.
The first storage tag is extracted from the first storage space and transferred to the second storage space. A tag linked list is generated based on the first storage tag. By traversing the tag linked list, an identifier-tag mapping table and a file identifier linked list are constructed to complete the data processing.
By reducing disk I/O operations, the read/write performance and data processing efficiency of the file system are improved, thereby enhancing the intelligence of terminal devices.
Smart Images

Figure CN116841958B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of embedded file system technology, and in particular to a data processing method, terminal device, and storage medium. Background Technology
[0002] LittleFS is a small file system with features such as wear leveling, power-loss protection, and suitability for scenarios with limited non-volatile memory and read-only memory (ROM). It is widely used in file management within embedded file systems.
[0003] In the design of the LittleFS file system, some file system performance was sacrificed in order to ensure extremely low resource utilization. For example, the LittleFS file system only reads two metadata items for comparison at a time, which reduces file read and write performance and data processing efficiency to some extent.
[0004] Therefore, how to improve the read / write performance and data processing efficiency of the LittleFS file system while ensuring low resource utilization has become an urgent problem to be solved. Summary of the Invention
[0005] This application provides a data processing method, a terminal device, and a storage medium that can improve the read / write performance and data processing efficiency of the LittleFS file system, thereby enhancing the intelligence of the terminal device.
[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows:
[0007] This application provides a data processing method, the method comprising:
[0008] The first storage tag is extracted from the first storage space and transferred to the second storage space, and a tag linked list is generated based on the first storage tag; wherein, the first storage tag is used to store information to be processed;
[0009] By traversing each of the first storage tags in the tag linked list, an identifier-tag mapping table and a file identifier linked list are constructed;
[0010] Data processing of the information to be processed is completed based on the tag linked list, the identifier and tag mapping table, and the file identifier linked list.
[0011] Furthermore, embodiments of this application provide a terminal device, which includes: an extraction unit, a generation unit, a construction unit, and a processing unit.
[0012] The extraction unit is used to extract the first storage tag from the first storage space to the second storage space; wherein the first storage tag is used to store information to be processed;
[0013] The generation unit is used to generate a tag linked list based on the first stored tag;
[0014] The construction unit is used to construct an identifier and tag mapping table and a file identifier linked list by traversing each of the first storage tags in the tag linked list;
[0015] The processing unit is used to perform data processing on the information to be processed based on the tag chain, the identifier and tag mapping table, and the file identifier chain.
[0016] Furthermore, this application provides a terminal device, which includes a processor and a memory storing processor-executable instructions. When the instructions are executed by the processor, the method described above is implemented.
[0017] Furthermore, embodiments of this application provide a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements the method described above.
[0018] The beneficial effects of this invention are:
[0019] (1) The information to be processed is extracted from the first storage space (such as the disk) to the second storage space for processing, thereby reducing the number of disk I / O operations and thus improving the read and write performance of the file system;
[0020] (2) After retrieving the information to be processed from the first storage space to the second storage space (such as memory), a tag linked list, an identifier-tag mapping table, and a file identifier linked list can be constructed in the second storage space based on the first storage tag corresponding to the information to be processed. Data processing is then completed in the second storage space through the tag linked list, the identifier-tag mapping table, and the file identifier linked list, thereby improving processing efficiency through data processing in memory. In other words, the data processing method proposed in this application embodiment can improve data processing efficiency, thereby enhancing the intelligence of the terminal device. Attached Figure Description
[0021] Figure 1 This is a schematic diagram of the implementation process of the data processing method. Figure 1 ;
[0022] Figure 2 This is a diagram illustrating how a tag linked list is constructed.
[0023] Figure 3 This is a schematic diagram of the tag linked list structure;
[0024] Figure 4 This is a schematic diagram of the structure of the identifier and label mapping table;
[0025] Figure 5 A schematic diagram of the file identifier linked list structure;
[0026] Figure 6 Illustration of the construction of the identifier-label mapping table Figure 1 ;
[0027] Figure 7 Illustration of the construction of the identifier-label mapping table Figure 2 ;
[0028] Figure 8 A schematic diagram illustrating the construction of a file identifier linked list;
[0029] Figure 9 Illustration of the construction of the identifier-label mapping table Figure 3 ;
[0030] Figure 10 Illustration of the construction of the identifier-label mapping table Figure 4 ;
[0031] Figure 11 A schematic diagram illustrating the construction process of the identifier and tag mapping table and the file identifier linked list;
[0032] Figure 12 This is a schematic diagram of the implementation process of the data processing method. Figure 2 ;
[0033] Figure 13 This is a schematic diagram of the implementation process of the data processing method. Figure 3 ;
[0034] Figure 14 This is a schematic diagram of the composition structure of the terminal device proposed in the embodiments of this application. Figure 1 ;
[0035] Figure 15 This is a schematic diagram of the composition structure of the terminal device proposed in the embodiments of this application. Figure 2 . Detailed Implementation
[0036] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only for explaining the relevant application and not for limiting the application. Furthermore, it should be noted that, for ease of description, only the parts related to the relevant application are shown in the accompanying drawings.
[0037] With the rapid development of mobile terminal technology, a compact and flexible file system is crucial for many embedded devices. However, using a file system and pairing it with the right storage technology (such as external flash memory or SD cards) can be challenging. The LittleFS file system, a block-device-based file system for embedded systems, is increasingly favored for its wear leveling, power-loss protection, and extremely low resource utilization, and is being widely adopted in various data processing fields.
[0038] In the design of the LittleFS file system, some file system performance was sacrificed to ensure extremely low resource utilization. For example, LittleFS only reads two metadata items at a time for comparison, which reduces file read / write performance and data processing efficiency to some extent, making its performance inferior to file systems like FATFS when reading and writing files. This, in turn, seriously affects the user experience and the execution efficiency of upper-layer applications.
[0039] Related technologies have proposed file system optimization schemes, but common optimization schemes are complex to implement and do not significantly improve performance.
[0040] Therefore, how to improve the read / write performance and data processing efficiency of the LittleFS file system while ensuring low resource utilization has become an urgent problem to be solved.
[0041] To address the aforementioned issues, in the embodiments of this application, the terminal device extracts a first storage tag from the first storage space to the second storage space and generates a tag linked list based on the first storage tag. The first storage tag is used to store information to be processed. An identifier-to-tag mapping table and a file identifier linked list are constructed by traversing each first storage tag in the tag linked list. Data processing of the information to be processed is completed based on the tag linked list, the identifier-to-tag mapping table, and the file identifier linked list. Therefore, in the embodiments of this application, when processing data based on an embedded file system such as the LittleFS file system, the information to be processed can be extracted from the first storage space to the second storage space for processing. Specifically, a tag linked list, an identifier-to-tag mapping table, and a file identifier linked list can be constructed in the second storage space based on the first storage tag corresponding to the information to be processed. Data processing is completed in the second storage space through these linked lists, thereby reducing disk I / O operations and improving processing efficiency through in-memory data processing. In other words, the data processing method proposed in the embodiments of this application can improve the read / write performance and data processing efficiency of the LittleFS file system, thereby enhancing the intelligence of the terminal device.
[0042] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0043] One embodiment of this application provides a data processing method that can be applied to a terminal device. Figure 1 This is a schematic diagram of the implementation process of the data processing method. Figure 1 ,like Figure 1 As shown, the method for terminal devices to process data may include the following steps:
[0044] Step 101: Extract the first storage tag from the first storage space to the second storage space, and generate a tag linked list based on the first storage tag; wherein, the first storage tag is used to store the information to be processed.
[0045] In embodiments of this application, the terminal device may select to extract the first storage tag from the first storage space to the second storage space, and then generate a tag linked list based on the first storage tag.
[0046] For example, in some embodiments, the terminal device can extract a first storage tag from a first storage space to a second storage space based on an embedded file system, and then generate a tag linked list based on the first storage tag. The embedded file system can be any file system such as LittleFS or FATFS.
[0047] The LittleFS file system enables embedded systems with limited ROM and RAM resources to still possess basic file system functions such as power-loss recovery and wear leveling. LittleFS is a minimalist embedded file system adapted for NOR flash memory. Its file system structure and operating mechanism result in a more compact storage structure and lower RAM consumption during operation.
[0048] The basic file system storage structure starts with the SuperBlock, then finds the root node, and gradually expands into a tree-like file system structure based on the root node. LittleFS is similar, starting with the SuperBlock and the root directory to build a tree-like storage structure. The difference is that in LittleFS, the root (" / ") is directly appended to the SuperBlock, sharing the same metadata pair.
[0049] LittleFS uses metadata pairs to store directory information, superblock information, file information, and inline file data, which is the core data structure of its design. Each metadata pair corresponds to two physical blocks, and each block records a revision count. The block with the larger revision count stores newer content; each time data in the block is updated, the revision count is incremented by 1. The advantage of using two blocks is that when one block cannot hold the updated content, the data can be compressed and transferred to the other block (e.g., through a compaction operation), avoiding direct corruption of the original data.
[0050] Each superblock and directory has one or more corresponding metadata pairs, which record information related to the superblock or directory. For example, the metadata pair corresponding to a directory may store file information within that directory.
[0051] It should be noted that in the embodiments of this application, both the first storage space and the second storage space are used for data storage, and the first storage space and the second storage space can be different storage elements.
[0052] For example, in some embodiments, the first storage space may be a hard disk, such as a magnetic disk, and the second storage space may be memory, such as RAM.
[0053] In other words, in the embodiments of this application, based on the LittleFS file system, the terminal device can choose to extract the first storage tag containing the information to be processed from the original storage space (such as a disk) to a new storage space (such as memory) for subsequent data processing.
[0054] It should be noted that, in the embodiments of this application, the first storage tag can be used to store information to be processed.
[0055] For example, in some embodiments based on the LittleFS file system, the first storage tag can be a tag. Metadata stores information in units of tags. A tag is a unit of information stored in metadata, and its structure includes information such as tag validity bits, type, ID, and length. The content stored differs for different types of tags. Typically, the corresponding data content follows the tag. For example, the data following a CTZSTRUCT type tag stores the file size and the block number where the file skip table header is located.
[0056] Furthermore, in the embodiments of this application, based on the LittleFS file system, after retrieving the first storage tag from the first storage space to the second storage space, a tag list can be generated in the second storage space based on the first storage tag. The tag list can store storage tags; for example, the tag list can be a tag_list list, which stores different tags.
[0057] It should be noted that when generating a tag list based on the first storage tag, the first storage tag can be filtered according to a preset filtering rule to obtain the filtered first storage tag; then the filtered first storage tag can be added to the tag list.
[0058] It is understood that, in the embodiments of this application, the preset filtering rules can be pre-set strategies or requirements for filtering tags.
[0059] For example, in some embodiments, the preset filtering rules may include different storage tag types. For instance, the preset filtering rules may include create and delete types. When filtering the first storage tag using the preset filtering rules, the corresponding storage tag type can be used to filter the first storage tag. For example, the first storage tag that meets the storage tag type can be retained, or the first storage tag that meets the storage tag type can be deleted.
[0060] Exemplary, in some embodiments, Figure 2 This is a diagram illustrating how a tag-linked list is constructed, such as... Figure 2 As shown, tags and their corresponding data (information to be processed) can be extracted first using any method of loading tags (disk or memory). Then, tags are filtered according to filtering conditions (preset filtering rules, such as SPLICE, which includes two types: Create and delete). Type1(tag) can identify the first type corresponding to the tag. The filtered tags are then saved to the tag_list linked list. Based on the preset filtering conditions, the tag IDs can be adjusted to ensure the relative order between IDs. For example, if Type1(tag) is create, the corresponding ID should be incremented by 1; if Type1(tag) is delete, the corresponding ID should be set to 0 because it is being deleted. Conversely, if Type1(tag) is neither create nor delete, the tag is directly saved to the tag_list linked list.
[0061] Exemplary, in some embodiments, Figure 3 This is a schematic diagram of the structure of a tag-linked list, such as... Figure 3As shown, for a tag linked list, such as the tag_list linked list, each tag stores data to be processed and related information. The construction and traversal methods of the tag_list linked list can be arbitrary.
[0062] Step 102: Construct an identifier-tag mapping table and a file identifier linked list by traversing each first storage tag in the tag linked list.
[0063] In the embodiments of this application, after the terminal device extracts the first storage tag from the first storage space to the second storage space and generates a tag linked list based on the first storage tag, it can further construct an identifier-tag mapping table and a file identifier linked list by traversing each first storage tag in the tag linked list.
[0064] It should be noted that, in the embodiments of this application, the identifier and tag mapping table can store file identifier information and corresponding storage tags. For example, the identifier and tag mapping table can be a tag_hash_table, which stores the IDs of different files and their corresponding tags and other information.
[0065] It is understood that, in the embodiments of this application, when storing file identification information and corresponding storage tags based on the identifier and tag mapping table, a key-value pair format can be used, that is, the structure of each element in the identifier and tag mapping table can be in the form of a key-value pair. Here, the key can be file identification information, i.e., the file's id, and the corresponding value can be information such as the file's tag.
[0066] It should be noted that, in the embodiments of this application, the file identifier linked list can store file identifier information. For example, the file identifier linked list can be a file_id_list, which stores the IDs of different files.
[0067] Exemplary, in some embodiments, Figure 4 This is a schematic diagram of the structure of the identifier and label mapping table, such as... Figure 4 As shown, for the identifier and tag mapping table, such as the hash table of tag_hash_table, the file's ID (such as ID1, ID2, etc.) is used as the key of the dictionary, and the tag list (i.e. tag_list) corresponding to the ID is used as the value. That is, the file identifier information and the tag list form key-value pairs stored in tag_hash_table.
[0068] Exemplary, in some embodiments, Figure 5 This is a schematic diagram of the file identifier linked list structure, such as... Figure 5 As shown, for a file identifier linked list, such as the file_id_list linked list, the file_id_list linked list is used to store file identifier information (such as ID), and its construction and traversal methods can be arbitrary.
[0069] Furthermore, in the embodiments of this application, Figure 6 Illustration of the construction of the identifier-label mapping table Figure 1 ,like Figure 6 As shown, the method by which a terminal device constructs an identifier-tag mapping table and a file identifier linked list by traversing each first storage tag in the tag linked list may include the following steps:
[0070] Step 201: For any first storage tag in the tag chain, if the first storage tag meets the type requirement, determine the first file identification information corresponding to the first storage tag.
[0071] In the embodiments of this application, the tag list is traversed. For any first storage tag in the tag list, it can be determined whether the first storage tag meets the type requirement. If the first storage tag meets the type requirement, the first file identification information corresponding to the first storage tag can be further determined.
[0072] It should be noted that, in the embodiments of this application, the terminal device can sequentially traverse each first storage tag in the tag chain list, first determine whether the first storage tag meets the type requirement conditions, and then perform subsequent data processing based on the determination result.
[0073] It is understood that, in the embodiments of this application, when determining whether the first storage tag meets the type requirement conditions, the first type corresponding to the first storage tag can be compared with the first preset type. If the first type corresponding to the first storage tag is the same as the first preset type, it can be determined that the first storage tag meets the type requirement conditions; if the first type corresponding to the first storage tag is different from the first preset type, it can be determined that the first storage tag does not meet the type requirement conditions.
[0074] It should be noted that, in the embodiments of this application, the first preset type is used to determine whether the stored tag meets the type requirement conditions. The first preset type can be any pre-set tag type.
[0075] Furthermore, in the embodiments of this application, after the terminal device traverses the tag list and determines whether any first storage tag in the tag list meets the type requirement, if the first storage tag does not meet the type requirement, the terminal device can continue to traverse the next first storage tag in the tag list, that is, continue to traverse the next storage tag in the tag list.
[0076] Furthermore, in the embodiments of this application, for any first storage tag in the tag chain, if the first storage tag meets the type requirement, then the first file identification information corresponding to the first storage tag can be further determined.
[0077] In other words, in the embodiments of this application, after determining that the first type corresponding to the first storage tag is the same as the first preset type, the first storage tag can be further processed. Specifically, the file identifier corresponding to the first storage tag, i.e., the first file identifier information, can be extracted first, and then data processing can be performed based on the first file identifier information.
[0078] For example, in some embodiments, the tag_list linked list (tag linked list) can be traversed sequentially. First, it is determined whether the type condition of each tag (first storage tag) meets the requirements. If it does, the id (first file identification information) in the tag is retrieved.
[0079] Accordingly, in some embodiments, after determining whether the type condition of a tag (first storage tag) meets the requirements, if it does not meet the requirements, the process continues to traverse the next tag.
[0080] Step 202: If the identifier and tag mapping table includes the first key information corresponding to the first file identifier information, determine the current value information corresponding to the first key information.
[0081] In the embodiments of this application, for any first storage tag in the tag chain, after determining the first file identifier information corresponding to the first storage tag when the first storage tag meets the type requirement, the terminal device can further query the identifier and tag mapping table according to the first file identifier information, and determine the current value information corresponding to the first key information when the identifier and tag mapping table includes the first key information corresponding to the first file identifier information.
[0082] It should be noted that, in the embodiments of this application, when querying the identifier and tag mapping table, the first key information corresponding to the first file identifier information can be determined first, and then the key-value pairs stored in the identifier and tag mapping table can be queried. If the first key information is found in the identifier and tag mapping table, the value corresponding to the first key information, i.e., the current value information, can be further determined.
[0083] For example, in some embodiments, for a tag (first storage tag) that meets the requirements in the tag_list (tag list), after retrieving the id (first file identification information) from the tag, the tag_hash_table (identifier and tag mapping table) is searched for a key (first key information) corresponding to the id; if a key corresponding to the id is found in the tag_hash_table, then the value corresponding to the key of that id can be further determined (current value information).
[0084] Step 203: If there is no current storage tag of the deletion type in the current tag list corresponding to the current value information, and there is no current storage tag of the same type as the first storage tag in the current tag list, add the first storage tag to the current tag list.
[0085] In the embodiments of this application, when the identifier and tag mapping table includes the first key information corresponding to the first file identifier information, after determining the current value information corresponding to the first key information, if there is no current storage tag of deletion type in the current tag chain corresponding to the current value information, and there is no current storage tag of the same type as the first storage tag in the current tag chain, the terminal device may further add the first storage tag to the current tag chain.
[0086] It should be noted that, in the embodiments of this application, after determining the current value information corresponding to the first key information, the current tag list corresponding to the current value information can be obtained first, and then it can be determined whether there is a current storage tag of the deletion type in the current tag list. If there is no current storage tag of the deletion type in the current tag list corresponding to the current value information, then it can be further determined whether the type of the current storage tag in the current tag list is the same as the first type corresponding to the first storage tag. If it is determined that there is no current storage tag of the same type as the first storage tag in the current tag list, then the terminal device can add the first storage tag to the current tag list corresponding to the first key information.
[0087] For example, in some embodiments, if the key corresponding to the id (first key information) is found in the tag_hash_table, after determining the value corresponding to the key of the id (current value information), it can be first determined whether the tag (current stored tag) in the corresponding current tag list is of type delete.
[0088] Accordingly, in some embodiments, after determining that the tag (current stored tag) in the corresponding current tag list is not of type delete, it can be further determined that the tag (current stored tag) in the current tag list and the tag (first stored tag) to be added to the identifier and tag mapping table are of the same type. After determining that the tag (current stored tag) in the corresponding current tag list and the tag (first stored tag) to be added to the identifier and tag mapping table are of different types, the first stored tag can be directly added to the current tag list.
[0089] In other words, in some embodiments, after determining that the tag (current stored tag) in the current tag list is not of type delete and is different from the type of the tag (first stored tag) to be added to the identifier and tag mapping table, the first stored tag can be added to the current tag list corresponding to the first key information. Further, in embodiments of this application, during the construction of the identifier and tag mapping table, in addition to comparing the types of the current stored tag in the current tag list and the first stored tag to be added to the identifier and tag mapping table, the type of the current stored tag in the current tag list can also be compared with a pre-set stored tag type, such as a second preset type.
[0090] For example, in some embodiments, after determining that the tag (current stored tag) in the current tag list is not of type delete and that the type of the current stored tag is different from the second preset type, the first stored tag can be added to the current tag list corresponding to the first key information.
[0091] Furthermore, in the embodiments of this application, Figure 7 Illustration of the construction of the identifier-label mapping table Figure 2 ,like Figure 7 As shown, for any first storage tag in the tag chain, after determining the first file identifier information corresponding to the first storage tag, i.e., after step 201, the method for the terminal device to construct an identifier-tag mapping table and a file identifier chain by traversing each first storage tag in the tag chain may include the following steps:
[0092] Step 204: If the identifier and tag mapping table does not include the first key information corresponding to the first file identifier information, add the first key information to the identifier and tag mapping table, and determine the first value information corresponding to the first key information in the identifier and tag mapping table according to the first storage tag.
[0093] In the embodiments of this application, for any first storage tag in the tag chain, after determining the first file identifier information corresponding to the first storage tag when the first storage tag meets the type requirement, the terminal device can further query the identifier and tag mapping table according to the first file identifier information. If the identifier and tag mapping table does not include the first key information corresponding to the first file identifier information, the first key information is added to the identifier and tag mapping table. Then, the first value information corresponding to the first item information is further determined in the identifier and tag mapping table according to the first storage tag.
[0094] It should be noted that, in the embodiments of this application, when querying the identifier and tag mapping table, the first key information corresponding to the first file identifier information can be determined first, and then the key-value pairs stored in the identifier and tag mapping table can be queried. If the first key information cannot be found in the identifier and tag mapping table, that is, there is no first key information in the identifier and tag mapping table, then the first key information can be created in the identifier and tag mapping table, and the value corresponding to the first key information, that is, the first value information, can be generated based on the first stored tag and related data.
[0095] For example, in some embodiments, for a tag (first stored tag) that meets the requirements in the tag_list (tag list), after retrieving the id (first file identifier information) from the tag, the system searches in the tag_hash_table (identifier and tag mapping table) for a key (first key information) corresponding to the id; if no key corresponding to the id is found in the tag_hash_table, then a key corresponding to the id can be created (first key information), and the tag and the corresponding data can be stored in the value corresponding to the id (first value information).
[0096] Furthermore, in the embodiments of this application, Figure 8 A diagram illustrating the construction of a file identifier linked list, such as... Figure 8 As shown, for any first storage tag in the tag chain, after determining the first file identifier information corresponding to the first storage tag, i.e., after step 201, the method for the terminal device to construct an identifier-tag mapping table and a file identifier chain by traversing each first storage tag in the tag chain may include the following steps:
[0097] Step 205: If the first key information corresponding to the first file identifier information is not included in the identifier and tag mapping table, store the first file identifier information in the file identifier linked list.
[0098] In the embodiments of this application, for any first storage tag in the tag chain, after determining the first file identification information corresponding to the first storage tag when the first storage tag meets the type requirement, the terminal device can further query the identifier and tag mapping table according to the first file identification information. If the identifier and tag mapping table does not include the first key information corresponding to the first file identification information, the first file identification information can be stored in the file identification chain while adding the first key information to the identifier and tag mapping table.
[0099] It should be noted that, in the embodiments of this application, the file identifiers stored in the file identifier linked list can meet certain order requirements. For example, the values of the file identifiers stored in the file identifier linked list can be in descending order, or the values of the file identifiers stored in the file identifier linked list can be in ascending order.
[0100] Accordingly, in the embodiments of this application, in order to ensure the storage order of the file identifiers stored in the file identifier linked list, an insertion method with sorting can be selected to store the first file identifier information into the file identifier linked list. For example, the tail insertion method can be selected to store the first file identifier information into the file identifier linked list.
[0101] For example, in some embodiments, for a tag (first stored tag) that meets the requirements in the tag_list linked list (tag linked list), after retrieving the id (first file identification information) from the tag, the tag_hash_table (identifier and tag mapping table) is searched for a key (first key information) corresponding to the id; if no key corresponding to the id is found in the tag_hash_table, then while creating a new key (first key information) corresponding to the id, the id (first file identification information) can also be inserted into the file_id_list linked list (file identification linked list) using the tail insertion method.
[0102] Furthermore, in the embodiments of this application, Figure 9 Illustration of the construction of the identifier-label mapping table Figure 3 ,like Figure 9 As shown, when the identifier and tag mapping table includes the first key information corresponding to the first file identifier information, after determining the current value information corresponding to the first key information, i.e. after step 202, the method by which the terminal device constructs the identifier and tag mapping table and the file identifier linked list by traversing each first storage tag in the tag linked list may include the following steps:
[0103] Step 206: If there is a current storage tag of deletion type in the current tag chain list corresponding to the current value information, delete the current value information.
[0104] In the embodiments of this application, when the identifier and tag mapping table includes the first key information corresponding to the first file identifier information, after determining the current value information corresponding to the first key information, if there is a current storage tag of deletion type in the current tag chain list corresponding to the current value information, the current value information can be deleted.
[0105] It should be noted that, in the embodiments of this application, after determining the current value information corresponding to the first key information, the current tag list corresponding to the current value information can be obtained first, and then it can be determined whether there is a current storage tag of deletion type in the current tag list. If there is a current storage tag of deletion type in the current tag list corresponding to the current value information, then the current value information can be deleted, that is, the current tag list corresponding to the current value information can be deleted.
[0106] For example, in some embodiments, if a key with the corresponding ID is found in the tag_hash_table (first key information), after determining the value corresponding to the key with that ID (current value information), it can first be determined whether the tag (current stored tag) in the corresponding current tag list is of type delete. After determining that the tag (current stored tag) in the corresponding current tag list is of type delete, the value corresponding to the key with that ID (current value information) can be deleted, that is, the entire tag list can be deleted.
[0107] It is understood that in the embodiments of this application, deleting the current tag list that includes the current storage tag of the deletion type can indicate that the corresponding file has been deleted, and its tag does not need to be written back to the disk.
[0108] Step 207: Determine the first value information corresponding to the first key information in the identifier and tag mapping table based on the first storage tag.
[0109] In the embodiments of this application, if there is a current storage tag of deletion type in the current tag chain list corresponding to the current value information, after deleting the current value information, the first value information corresponding to the first key information can be further determined in the identifier and tag mapping table according to the first storage tag.
[0110] It should be noted that, in the embodiments of this application, if there is a current storage tag of deletion type in the current tag chain corresponding to the current value information, then after deleting the current value information, a new tag chain can be constructed using the first storage tag, thereby determining the first value information corresponding to the first piece of information, that is, the first value information corresponding to the first key information can be newly created in the identifier and tag mapping table based on the first storage tag.
[0111] For example, in some embodiments, after determining that the tag (current stored tag) in the corresponding current tag list is of type delete and deleting the value (current value information) corresponding to the key of the id, it is possible to construct a tag list for the id using the first stored tag, thereby creating the corresponding first value information.
[0112] Furthermore, in the embodiments of this application, Figure 10 Illustration of the construction of the identifier-label mapping table Figure 4 ,like Figure 10 As shown, when the identifier and tag mapping table includes the first key information corresponding to the first file identifier information, after determining the current value information corresponding to the first key information, i.e. after step 202, the method by which the terminal device constructs the identifier and tag mapping table and the file identifier linked list by traversing each first storage tag in the tag linked list may include the following steps:
[0113] Step 208: If there is a current storage tag of the same type as the first storage tag in the current tag linked list corresponding to the current value information, delete the current storage tag of the same type as the first storage tag.
[0114] In the embodiments of this application, when the identifier and tag mapping table includes the first key information corresponding to the first file identifier information, after determining the current value information corresponding to the first key information, if there is a current storage tag of the same type as the first storage tag in the current tag chain corresponding to the current value information, the current storage tag of the same type as the first storage tag can be deleted from the current tag chain.
[0115] It should be noted that, in the embodiments of this application, after determining the current value information corresponding to the first key information, the current tag list corresponding to the current value information can be obtained first, and then it can be determined whether there is a current storage tag of the same type as the first storage tag in the current tag list. If there is a current storage tag of the same type as the first storage tag in the current tag list corresponding to the current value information, then the current storage tag can be deleted from the current tag list.
[0116] For example, in some embodiments, if a key with the corresponding ID (first key information) is found in the tag_hash_table, after determining the value corresponding to that key (current value information), it can first be determined whether the tag (current stored tag) in the corresponding current tag list is of the same type as the tag (first stored tag) to be added to the identifier-tag mapping table. After determining that the tag (current stored tag) in the corresponding current tag list is of the same type as the tag (first stored tag) to be added to the identifier-tag mapping table, the tag (current stored tag) of the same type can be deleted.
[0117] Step 209: Add the first storage tag to the current tag chain.
[0118] In the embodiments of this application, if there is a current storage tag of the same type as the first storage tag in the current tag chain corresponding to the current value information, after deleting the current storage tag of the same type as the first storage tag, the first storage tag can be further added to the current tag chain.
[0119] For example, in some embodiments, after determining that the tag (current stored tag) in the corresponding current tag list is of the same type as the tag (first stored tag) to be added to the identifier and tag mapping table, and deleting the tag (current stored tag) of the same type, the first stored tag can be added to the current tag list corresponding to the corresponding first key information.
[0120] Furthermore, in the embodiments of this application, during the construction of the identifier and tag mapping table, in addition to comparing the types of the current stored tag in the current tag chain and the first stored tag to be added to the identifier and tag mapping table, the type of the current stored tag in the current tag chain can also be compared with a preset stored tag type, such as a second preset type.
[0121] For example, in some embodiments, after determining that the type of the tag (current stored tag) in the corresponding current tag list is the same as the second preset type, the tag (current stored tag) of the same type can be deleted, and then the first stored tag can be added to the current tag list corresponding to the first key information.
[0122] Exemplary, in some embodiments, Figure 11 This is a diagram illustrating the construction process of the identifier-tag mapping table and the file identifier linked list, as shown below. Figure 11As shown, first, a linked list `file_id_list` (file identifier linked list) is constructed to store the file IDs in the tags and maintain the relative order between the original IDs. A hash table `tag_hash_table` (identifier-tag mapping table) is created, where the file IDs are used as keys in the dictionary, and the corresponding tag linked lists are used as values. The `tag_list` linked list is traversed sequentially, first checking if the type condition of each tag meets the requirements. If it does, the ID in the tag is retrieved, and then it is checked whether there is a key with the corresponding ID in the `tag_hash_table`. If not, a new key with the ID is created, and the tag and corresponding data are stored in the value corresponding to that ID. Simultaneously, the ID is inserted into the `file_id_list` linked list using tail insertion. If it exists, it is checked whether the tag type is `delete`. If it is of type delete, then delete the value corresponding to the id, that is, delete the entire tag list; if it is not of type delete, then read the tag list corresponding to the id, and determine whether the tag in the tag list is the same as or of type 1 as the tag to be added. If the same tag exists, then delete the same tag, then add the tag to the tag list of the id, and then continue to execute the third step until the tag_list is traversed.
[0123] Step 103: Complete the data processing of the information to be processed based on the tag linked list, the identifier and tag mapping table, and the file identifier linked list.
[0124] In the embodiments of this application, after the terminal device constructs an identifier-to-tag mapping table and a file identifier chain by traversing each first storage tag in the tag chain, it can complete the data processing of the information to be processed based on the tag chain, the identifier-to-tag mapping table, and the file identifier chain.
[0125] It should be noted that, in the embodiments of this application, the terminal device can store metadata and file content by constructing three data structures: a tag linked list, an identifier and tag mapping table, and a file identifier linked list, thereby completing the data processing of the information to be processed.
[0126] Furthermore, in the embodiments of this application, Figure 12 This is a schematic diagram of the implementation process of the data processing method. Figure 2 ,like Figure 12 As shown, the method by which a terminal device processes data of information to be processed based on a tag linked list, an identifier-tag mapping table, and a file identifier linked list may include the following steps:
[0127] Step 301: For any second file identifier in the file identifier linked list, if the value of the second file identifier satisfies the preset value range, determine the second value information corresponding to the second key information in the identifier and tag mapping table according to the second key information corresponding to the second file identifier.
[0128] In the embodiments of this application, the terminal device can first traverse the file identifier linked list. For any second file identifier information in the file identifier linked list, it can first determine whether the value of the second file identifier information meets the preset value range, that is, determine whether the value of the second file identifier information is within the preset value range. If it does, it can further determine the second key information corresponding to the second file identifier information and determine the second value information corresponding to the second key information in the identifier and tag mapping table.
[0129] It should be noted that, in the embodiments of this application, a one-to-one key-value pair is stored in the identifier and tag mapping table. For the second key information corresponding to the second file information, the corresponding second value information can be determined in the identifier and tag mapping table.
[0130] It should be noted that, in the embodiments of this application, the second file identification information can be the file identification information stored in the file identification chain list. The second file identification information can be the same as or different from the second file identification information.
[0131] It is understood that, in the embodiments of this application, for any second file identifier in the file identifier linked list, after determining whether the value of the second file identifier meets the preset value range, if it does not, then it is possible to choose to continue reading the next file identifier in the file identifier linked list. That is, for any second file identifier in the file identifier linked list, if the value of the second file identifier does not meet the preset value range, the next second file identifier in the identifier and tag mapping table is traversed.
[0132] It should be noted that, in the embodiments of this application, the preset value range is used to restrict and filter file identification information.
[0133] For example, in some embodiments, assuming the preset value range is [3, 6], if the value of the second file identifier is 3, it can be determined that the value of the second file identifier meets the preset value range; if the value of the second file identifier is 2, it can be determined that the value of the second file identifier does not meet the preset value range.
[0134] It should be noted that, in the embodiments of this application, the file identifier chain can store file identifier information in a preset order based on the values of the file identifier information. This preset order can be either descending order of values or ascending order of values.
[0135] For example, in some embodiments, the tags (second file identification information) stored in the tag_hash_table (identifier and tag mapping table) can be submitted according to the storage order of the ids (second file identification information) in the file_id_list linked list (file identifier linked list), that is, written back to the disk (first storage space). First, it is determined whether the current id (second file identification information) is within the specified id range (preset value range). If it does not, the next id is retrieved. If it does, the corresponding key (second key information) is found in the tag_hash_table using the id, and then its value (second value information) is retrieved, that is, the second value information corresponding to the second key information is determined, until the file_id_list linked list is traversed.
[0136] Step 302: For any second storage tag in the tag chain corresponding to the second value information, determine the callback function if the second storage tag meets the type requirement.
[0137] In the embodiments of this application, for any second file identifier information in the file identifier linked list, if the value of the second file identifier information meets the preset value range, after determining the second value information corresponding to the second key information in the identifier and tag mapping table according to the second key information corresponding to the second file identifier information, the tag linked list corresponding to the second value information can be determined first, and then any second storage tag in the tag linked list corresponding to the second value information can be traversed. For the second storage tag, it can be determined whether the type requirement condition is met first, and if it is determined that the second storage tag meets the type requirement condition, the callback function can be further determined.
[0138] It should be noted that, in the embodiments of this application, the second storage tag can be any storage tag in the tag linked list that identifies the tag in the tag mapping table as a key-value pair and corresponds to the second value information corresponding to the second key information generated from the second file identifier information. The second storage tag can be the same as or different from the second storage tag.
[0139] It is understood that, in the embodiments of this application, when determining whether the second storage tag meets the type requirement conditions, the second type corresponding to the second storage tag can be compared with the first preset type. If the second type corresponding to the second storage tag is the same as the first preset type, it can be determined that the second storage tag meets the type requirement conditions; if the second type corresponding to the second storage tag is different from the first preset type, it can be determined that the second storage tag does not meet the type requirement conditions.
[0140] Furthermore, in the embodiments of this application, when the terminal device traverses the tag chain corresponding to the second value information in the identifier and tag mapping table, for any second storage tag in the tag chain corresponding to the second value information, after determining whether the second storage tag meets the type requirement condition, if the second storage tag does not meet the type requirement condition, the terminal device can continue to traverse the next second storage tag in the tag chain corresponding to the second value information until the tag chain corresponding to the second value information is completely traversed.
[0141] For example, in some embodiments, after finding the corresponding key (second key information) and corresponding value (second value information) in the tag_hash_table based on the id (second file identification information), the tag list to be submitted (the tag list corresponding to the second value information) can be determined, and then the tag list corresponding to the second value information is traversed. Next, it can be determined whether the type of the tag (second storage tag) in the tag list (the tag list corresponding to the second value information) meets the requirements. If it does, the corresponding callback function is called; if it does not, the next tag (second storage tag) is retrieved until the traversal is complete.
[0142] Step 303: Process the second storage tag according to the return value of the callback function to complete the data processing of the information to be processed.
[0143] In the embodiments of this application, for any second storage tag in the tag chain corresponding to the second value information, if the second storage tag meets the same type requirement, after determining the callback function, the second storage tag can be further processed according to the return value of the callback function, thereby completing the data processing of the information to be processed.
[0144] Furthermore, in the embodiments of this application, when processing the second storage tag according to the return value of the callback function, if the return value is the first value, the second storage tag is written back from the second storage space to the first storage space; if the return value is the second value, the second value is returned.
[0145] It should be noted that, in the embodiments of this application, if the return value of the callback function is the first value, it can be considered that the processing of the second storage tag is normal; if the return value of the callback function is the second value, it can be considered that the processing of the second storage tag is abnormal.
[0146] It should be noted that, in the embodiments of this application, the first value and the second value can be any two different values. For example, the first value can be 0 and the second value can be -1.
[0147] For example, in some embodiments, after calling the corresponding callback function, the return value of the callback function can be determined first. If the return value of the callback function is 0, then the submission of the second storage tag can continue, that is, the second storage tag is written back to the first storage space.
[0148] For example, in some embodiments, after calling the corresponding callback function, the return value of the callback function can be determined first. If the return value of the callback function is negative, then the file system can be given the return value to perform subsequent operations.
[0149] Furthermore, in the embodiments of this application, Figure 13 This is a schematic diagram of the implementation process of the data processing method. Figure 3 ,like Figure 13 As shown, after completing the data processing of the information to be processed based on the tag linked list, the identifier and tag mapping table, and the file identifier linked list, i.e. after step 103, the method for the terminal device to process data may further include the following steps:
[0150] Step 104: Delete the tag list, the identifier and tag mapping table, and the file identifier list in the second storage space.
[0151] In the embodiments of this application, after the data processing of the information to be processed is completed based on the tag list, the identifier and tag mapping table, and the file identifier list, the terminal device may choose to delete the tag list, the identifier and tag mapping table, and the file identifier list in the second storage space.
[0152] It is understood that, in the embodiments of this application, after completing the processing and operation of the storage tags, the resource occupancy rate can be reduced by deleting the tag list, the identifier and tag mapping table, and the file identifier list. That is, the tag list, the identifier and tag mapping table, and the file identifier list can be deleted in the second storage space, thereby releasing the resources occupied in the second storage space.
[0153] For example, in some embodiments, after completing the tag operation, in order to reduce resource usage, the RAM memory (second storage space) occupied by file_id_list (file identifier linked list), tag_hash_table (identifier and tag mapping table), and tag_list (tag linked list) can be released in sequence, and unused RAM resources can be reclaimed.
[0154] In summary, the data processing method proposed in steps 101 to 104, 201 to 209, and 301 to 303 extracts the first storage tag containing the information to be processed from the first storage space (such as a disk) to the second storage space (such as memory). The processing of the information to be processed is completed by constructing a tag linked list, an identifier-tag mapping table, and a file identifier linked list. On the one hand, this reduces the number of disk I / O operations, and on the other hand, processing in memory improves the processing speed, thereby improving the read and write performance of the LittleFS file system.
[0155] In other words, the data processing method proposed in this application can utilize additional resources when resources permit, thereby improving the read and write performance of the LittleFS file system. Specifically, for the native LittleFS file system, additional RAM resources can be allocated to sequentially read all metadata to be processed into memory for processing, instead of comparing only two metadata entries at a time as in the native LittleFS file system. This not only reduces disk I / O operations but also improves processing speed by processing in memory.
[0156] It is understood that the data processing method proposed in this application can sequentially extract the tag data structure used to store metadata and other information from the LittleFS file system into memory. Three data structures are designed: file_id_list, tag_hash_table, and tag_list. For tag_hash_table, each element is a key-value pair, where the key is the ID of each file and the value is information such as the tag of that file. Thus, metadata and file content can be stored through these three data structures.
[0157] This application provides a data processing method in which a terminal device extracts a first storage tag from a first storage space to a second storage space and generates a tag linked list based on the first storage tag. The first storage tag is used to store information to be processed. An identifier-to-tag mapping table and a file identifier linked list are constructed by traversing each first storage tag in the tag linked list. Data processing of the information to be processed is completed based on the tag linked list, the identifier-to-tag mapping table, and the file identifier linked list. Therefore, in this application's embodiment, when processing data based on an embedded file system such as the LittleFS file system, the information to be processed can be extracted from the first storage space to the second storage space for processing. The tag linked list, identifier-to-tag mapping table, and file identifier linked list can be constructed in the second storage space based on the first storage tag corresponding to the information to be processed. Data processing is completed in the second storage space through these linked lists, thereby reducing disk I / O operations and improving processing efficiency through in-memory data processing. In other words, the data processing method proposed in this application can improve the read / write performance and data processing efficiency of the LittleFS file system, thereby enhancing the intelligence of the terminal device.
[0158] Based on the above embodiments, this application provides a data processing method, which is an optimization method for the LittleFS file system. This method primarily improves the read and write performance of the LittleFS file system by consuming some resources when resources allow. Specifically, a relatively conservative strategy is adopted for the native LittleFS, while this application also considers the additional use of RAM resources (second storage space). Therefore, it is considered that all metadata to be processed (information to be processed) can be sequentially read into memory (second storage space) for processing, instead of comparing only two metadata entries at a time as in the native LittleFS file system. This not only reduces the number of disk (second storage space) I / O operations but also improves processing speed by processing in memory.
[0159] It should be noted that in the embodiments of this application, the tag (storage label) is a data structure in the LittleFS file system used to store metadata and other information. Based on the original LittleFS scheme, three data structures were designed: file_id_list (file identifier linked list), tag_hash_table (identifier-tag mapping table), and tag_list (tag linked list). The most crucial of these is tag_hash_table, where each element is a key-value pair, with the key being the ID of each file and the value being information such as the file's tag. By storing metadata and file content through these three data structures, the LittleFS file system is optimized.
[0160] For example, in some embodiments, the tag (first storage tag) and the corresponding data (information to be processed) can be retrieved first by any method of loading the tag (disk or memory), and at the same time, filtering conditions (preset filtering rules) can be selected to filter the tag, and then the tag is saved to the tag_list linked list (tag linked list).
[0161] For example, in some embodiments, a new file_id_list linked list (file identifier linked list) is created to store the file IDs (first file identifier information) in the tag and to save the relative order between the original IDs; a new tag_hash_table hash table (identifier and tag mapping table) is created, in which the file ID is used as the key of the dictionary and the tag linked list corresponding to the ID is used as the value to save the tag that will be written back to the disk (first storage space) at the end.
[0162] For example, in some embodiments, the tag_list linked list is traversed sequentially. First, it is determined whether the type condition of each tag (first storage tag) meets the requirements. If it does, the id (first file identification information) in the tag is retrieved, and a key (first key information) with the corresponding id is searched in the tag_hash_table. If it does not meet the requirements, the next tag is traversed until the traversal of the tag_list linked list is completed.
[0163] For example, in some embodiments, if the key corresponding to the id (first key information) is not found in the tag_hash_table, the corresponding key will be created, and the tag (first storage label) and the corresponding data (information to be processed) will be stored in the value (first value information) corresponding to the id (first file identification information). At the same time, the id (first file identification information) will be inserted into the file_id_list linked list using the tail insertion method.
[0164] For example, in some embodiments, if a key with the corresponding id (first key information) is found in the tag_hash_table, the type of the tag (the currently stored tag in the current tag list corresponding to the first key information) is determined to be delete. If it is delete, the value corresponding to the id, i.e., the entire tag list (current tag list), is deleted. In other words, the file has been deleted, and its tag does not need to be written back to the disk.
[0165] For example, in some embodiments, if the current stored tag in the current tag list corresponding to the first key information is not of type delete, then the tag list (current tag list) corresponding to the id is read, and it is determined whether the tag (current stored tag) in the tag list is the same as or of type 1 as the tag (first stored tag) to be added. If there is a tag (current stored tag) of the same type, then the same tag (current stored tag) is deleted, and then the tag (first stored tag) is added to the tag list of the id. Then the traversal of the tag_list list continues until the tag_list traversal is completed.
[0166] For example, in some embodiments, the tags stored in the tag_hash_table are committed according to the storage order of the IDs in the file_id_list linked list, i.e., written back to disk. First, it is determined whether the current ID (second file identification information) is within the specified ID range (preset value range). If it does not, the next ID (second file identification information) is retrieved. If it does, the corresponding second key information and second value information are determined, until the file_id_list linked list is traversed.
[0167] For example, in some embodiments, the corresponding key (second key information) is found in the tag_hash_table using the id (second file identifier information), and then its value (second value information) is retrieved, which is the tag list to be submitted (the tag list corresponding to the second value information), and it is traversed. Next, it is determined whether the tag (second storage tag) type in the tag list (the tag list corresponding to the second value information) meets the requirements. If it does, the corresponding callback function is called; if it does not, the next tag (second storage tag) is retrieved, and so on, until the tag list corresponding to the second value information is traversed. Then, the tags stored in the tag_hash_table are submitted according to the storage order of the id in the file_id_list list, until the file_id_list list is traversed.
[0168] For example, in some embodiments, the return value of the callback function is determined. If the return value is 0 (the first value), execution continues. If the return value of the callback function is negative (the second value), the value is returned and handed over to the file system for subsequent operations.
[0169] For example, in some embodiments, after completing the operation on the tag, in order to reduce resource usage, it is necessary to release the RAM memory occupied by file_id_list, tag_hash_table, and tag_list in sequence, and reclaim the unused RAM resources.
[0170] In summary, the data processing method proposed in this application extracts the first storage tag containing the information to be processed from the first storage space (such as a disk) to the second storage space (such as memory), and completes the processing of the information to be processed by constructing a tag linked list, an identifier-tag mapping table, and a file identifier linked list. On the one hand, it can reduce the number of disk I / O operations, and on the other hand, processing in memory can improve the processing speed, thereby improving the read and write performance of the LittleFS file system.
[0171] In other words, the data processing method proposed in this application can utilize additional resources when resources permit, thereby improving the read and write performance of the LittleFS file system. Specifically, for the native LittleFS file system, additional RAM resources can be allocated to sequentially read all metadata to be processed into memory for processing, instead of comparing only two metadata entries at a time as in the native LittleFS file system. This not only reduces disk I / O operations but also improves processing speed by processing in memory.
[0172] It is understood that the data processing method proposed in this application can sequentially extract the tag data structure used to store metadata and other information from the LittleFS file system into memory. Three data structures are designed: file_id_list, tag_hash_table, and tag_list. For tag_hash_table, each element is a key-value pair, where the key is the ID of each file and the value is information such as the file's tag. Thus, metadata and file content can be stored through these three data structures.
[0173] This application provides a data processing method in which a terminal device extracts a first storage tag from a first storage space to a second storage space and generates a tag linked list based on the first storage tag. The first storage tag is used to store information to be processed. An identifier-to-tag mapping table and a file identifier linked list are constructed by traversing each first storage tag in the tag linked list. Data processing of the information to be processed is completed based on the tag linked list, the identifier-to-tag mapping table, and the file identifier linked list. Therefore, in this application's embodiment, when processing data based on an embedded file system such as the LittleFS file system, the information to be processed can be extracted from the first storage space to the second storage space for processing. The tag linked list, identifier-to-tag mapping table, and file identifier linked list can be constructed in the second storage space based on the first storage tag corresponding to the information to be processed. Data processing is completed in the second storage space through these linked lists, thereby reducing disk I / O operations and improving processing efficiency through in-memory data processing. In other words, the data processing method proposed in this application can improve the read / write performance and data processing efficiency of the LittleFS file system, thereby enhancing the intelligence of the terminal device.
[0174] Based on the above embodiments, in another embodiment of this application... Figure 14 This is a schematic diagram of the composition structure of the terminal device proposed in the embodiments of this application. Figure 1 ,like Figure 14 As shown, the terminal device 10 proposed in this application embodiment may include an extraction unit 111, a generation unit 112, a construction unit 113, and a processing unit 114.
[0175] The extraction unit 111 is used to extract the first storage tag from the first storage space to the second storage space; wherein, the first storage tag is used to store information to be processed;
[0176] The generation unit 112 is used to generate a tag linked list based on the first stored tag;
[0177] The construction unit 113 is used to construct an identifier and tag mapping table and a file identifier linked list by traversing each of the first storage tags in the tag linked list;
[0178] The processing unit 114 is used to perform data processing on the information to be processed based on the tag chain, the identifier and tag mapping table, and the file identifier chain.
[0179] In the embodiments of this application, further, Figure 15 This is a schematic diagram of the composition structure of the terminal device proposed in the embodiments of this application. Figure 2 ,like Figure 15As shown, the terminal device 10 proposed in this application embodiment may further include a processor 121, a memory 122 storing instructions executable by the processor 121, and further, the terminal device 10 may also include a communication interface 123 and a bus 124 for connecting the processor 121, the memory 122 and the communication interface 123.
[0180] In the embodiments of this application, the processor 121 can be at least one of the following: Application-Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), Central Processing Unit (CPU), Controller, Microcontroller, and Microprocessor. It is understood that for different devices, the electronic device used to implement the above-mentioned processor function can also be other types, and this application embodiment does not specifically limit this. The terminal device 10 may also include a memory 122, which can be connected to the processor 121. The memory 122 is used to store executable program code, which includes computer operation instructions. The memory 122 may include high-speed RAM memory and may also include non-volatile memory, such as at least two disk drives.
[0181] In embodiments of this application, bus 124 is used to connect communication interface 123, processor 121, and memory 122, as well as the mutual communication between these devices.
[0182] In embodiments of this application, memory 122 is used to store instructions and data.
[0183] Furthermore, in an embodiment of this application, the processor 121 is configured to extract the first storage tag from the first storage space to the second storage space, and generate a tag linked list based on the first storage tag; wherein, the first storage tag is used to store information to be processed; an identifier-tag mapping table and a file identifier linked list are constructed by traversing each of the first storage tags in the tag linked list; and data processing of the information to be processed is completed based on the tag linked list, the identifier-tag mapping table, and the file identifier linked list.
[0184] In practical applications, the aforementioned memory 122 can be volatile memory, such as random-access memory (RAM); or non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); or a combination of the above types of memory, and provide instructions and data to the processor 121.
[0185] Furthermore, in this embodiment, the functional modules can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional module.
[0186] If the integrated unit is implemented as a software functional module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the method of this embodiment. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0187] This application provides a terminal device that extracts a first storage tag from a first storage space to a second storage space and generates a tag linked list based on the first storage tag. The first storage tag is used to store information to be processed. An identifier-to-tag mapping table and a file identifier linked list are constructed by traversing each first storage tag in the tag linked list. Data processing of the information to be processed is completed based on the tag linked list, the identifier-to-tag mapping table, and the file identifier linked list. Therefore, in this application's embodiment, when processing data based on an embedded file system such as the LittleFS file system, the information to be processed can be extracted from the first storage space to the second storage space for processing. The tag linked list, identifier-to-tag mapping table, and file identifier linked list can be constructed in the second storage space based on the first storage tag corresponding to the information to be processed. Data processing is completed in the second storage space through these linked lists, thereby reducing disk I / O operations and improving processing efficiency through in-memory data processing. In other words, the data processing method proposed in this application's embodiment can improve the read / write performance and data processing efficiency of the LittleFS file system, thereby enhancing the intelligence of the terminal device.
[0188] This application provides a computer-readable storage medium storing a program thereon, which, when executed by a processor, implements the data processing method described above.
[0189] Specifically, the program instructions corresponding to a data processing method in this embodiment can be stored on storage media such as optical discs, hard disks, and USB flash drives. When the program instructions corresponding to a data processing method in the storage media are read or executed by an electronic device, the following steps are included:
[0190] The first storage tag is extracted from the first storage space and transferred to the second storage space, and a tag linked list is generated based on the first storage tag; wherein, the first storage tag is used to store information to be processed;
[0191] By traversing each of the first storage tags in the tag linked list, an identifier-tag mapping table and a file identifier linked list are constructed;
[0192] Data processing of the information to be processed is completed based on the tag linked list, the identifier and tag mapping table, and the file identifier linked list.
[0193] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.
[0194] This application is described with reference to schematic and / or block diagrams of implementations of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block of the schematic and / or block diagrams can be implemented by computer program instructions, and combinations of blocks in the schematic and / or block diagrams can be implemented. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the schematic and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0195] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in the implementation flow diagram. Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0196] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0197] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application.
Claims
1. A data processing method, characterized in that, The method includes: The first storage tag is extracted from the first storage space and transferred to the second storage space, and a tag linked list is generated based on the first storage tag; wherein, the first storage tag is used to store information to be processed; By traversing each of the first storage tags in the tag linked list, an identifier-tag mapping table and a file identifier linked list are constructed; Data processing of the information to be processed is completed based on the tag linked list, the identifier and tag mapping table, and the file identifier linked list. The step of constructing an identifier-tag mapping table and a file identifier linked list by traversing each of the first storage tags in the tag linked list includes: For any first storage tag in the tag chain, if the first storage tag meets the type requirement, determine the first file identification information corresponding to the first storage tag; If the identifier and tag mapping table includes the first key information corresponding to the first file identifier information, determine the current value information corresponding to the first key information; If there is no current storage tag of the deletion type in the current tag chain corresponding to the current value information, and there is no current storage tag of the same type as the first storage tag in the current tag chain, then the first storage tag is added to the current tag chain.
2. The method according to claim 1, characterized in that, The method further includes: If the first type corresponding to the first storage tag is the same as the first preset type, it is determined that the first storage tag meets the type requirement condition; If the first type corresponding to the first storage tag is different from the first preset type, it is determined that the first storage tag does not meet the type requirement.
3. The method according to claim 2, characterized in that, The method further includes: For any first storage tag in the tag list, if the first storage tag does not meet the type requirement, continue traversing the next first storage tag in the tag list.
4. The method according to claim 1, characterized in that, The step of constructing an identifier-tag mapping table and a file identifier linked list by traversing each of the first stored tags in the tag linked list includes: If the identifier and tag mapping table does not include the first key information corresponding to the first file identifier information, the first key information is added to the identifier and tag mapping table, and the first value information corresponding to the first key information is determined in the identifier and tag mapping table according to the first storage tag.
5. The method according to claim 1, characterized in that, The step of constructing an identifier-tag mapping table and a file identifier linked list by traversing each of the first stored tags in the tag linked list includes: If the first key information corresponding to the first file identifier information is not included in the identifier and tag mapping table, the first file identifier information is stored in the file identifier linked list.
6. The method according to claim 1, characterized in that, The method further includes: If a current stored tag of deletion type exists in the current tag chain list corresponding to the current value information, the current value information is deleted; The first value information corresponding to the first key information is determined based on the first stored tag in the identifier and tag mapping table.
7. The method according to claim 1, characterized in that, The method further includes: If a current storage tag of the same type as the first storage tag exists in the current tag chain corresponding to the current value information, delete the current storage tag of the same type as the first storage tag. Add the first storage tag to the current tag chain list.
8. The method according to any one of claims 1-7, characterized in that, The data processing of the information to be processed based on the tag linked list, the identifier and tag mapping table, and the file identifier linked list includes: For any second file identifier in the file identifier chain, if the value of the second file identifier satisfies a preset value range, the second value information corresponding to the second key information is determined in the identifier and tag mapping table according to the second key information corresponding to the second file identifier. For any second storage tag in the tag chain corresponding to the second value information, if the second storage tag meets the type requirement, a callback function is determined. The second storage tag is processed according to the return value of the callback function to complete the data processing of the information to be processed.
9. The method according to claim 8, characterized in that, The method further includes: For any second file identifier in the file identifier linked list, if the value of the second file identifier does not meet the preset value range, the next second file identifier in the identifier and tag mapping table is traversed.
10. The method according to claim 8, characterized in that, The method further includes: For any second storage tag in the tag linked list corresponding to the second value information, if the second storage tag does not meet the type requirement, traverse the next second storage tag in the tag linked list corresponding to the second value information.
11. The method according to claim 8, characterized in that, The step of processing the second stored tag based on the return value of the callback function includes: If the return value is the first value, then the second storage tag is written back from the second storage space to the first storage space; If the return value is the second value, then the second value is returned.
12. The method according to any one of claims 1-7, 9-11, characterized in that, The step of generating a tag linked list based on the first stored tag includes: The first storage tag is filtered according to the preset filtering rules to obtain the filtered first storage tag; The filtered first storage tag is added to the tag chain list.
13. The method according to any one of claims 1-7, 9-11, characterized in that, After completing the data processing of the information to be processed based on the tag linked list, the identifier and tag mapping table, and the file identifier linked list, the method further includes: Delete the tag list, the identifier and tag mapping table, and the file identifier list from the second storage space.
14. A terminal device, characterized in that, The terminal device includes: an extraction unit, a generation unit, a construction unit, and a processing unit. The extraction unit is used to extract the first storage tag from the first storage space to the second storage space; wherein the first storage tag is used to store information to be processed; The generation unit is used to generate a tag linked list based on the first stored tag; The construction unit is used to construct an identifier and tag mapping table and a file identifier linked list by traversing each of the first storage tags in the tag linked list; The processing unit is used to perform data processing on the information to be processed based on the tag chain, the identifier and tag mapping table, and the file identifier chain; The construction unit is configured to, for any first storage tag in the tag chain, determine the first file identifier information corresponding to the first storage tag if the first storage tag meets the type requirement; determine the current value information corresponding to the first key information if the identifier and tag mapping table includes the first key information corresponding to the first file identifier information; and add the first storage tag to the current tag chain if there is no current storage tag of the deletion type in the current tag chain corresponding to the current value information, and if there is no current storage tag of the same type as the first storage tag in the current tag chain.
15. A terminal device, characterized in that, The terminal device includes a processor and a memory storing processor-executable instructions, which, when executed by the processor, implement the method as described in any one of claims 1-13.
16. A computer-readable storage medium having a program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-13.
Citation Information
Patent Citations
File management method and apparatus, and machine readable storage medium
CN108255915A
Message forwarding method, data processing method, device and network system
CN110351188A