Indexing method, program product, medium, and electronic device

By using a 2-layer directory structure in the file system, using file index to find slots in the first layer directory and obtain the associated segments, and indexing in the second layer directory, the problem of low index efficiency when the number of files is large, and the implementation of the implementation of Efficient response of the file system.

CN119493769APending Publication Date: 2025-02-21HUAWEI TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311037094.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-15
Publication Date
2025-02-21

AI Technical Summary

Technical Problem

As the number of files increases, the time for indexing to the specific file index information address in the existing file index structure implemented by the cardinality tree or hash table increases infinitely, resulting in the time for the file system to respond to user file operations longer, and the efficiency is decline.

Method used

File management is performed using a 2-layer directory structure. The first layer directory contains a certain number of slots, and the second layer directory contains a certain number of segments, each segment includes the same number of slots. Find the corresponding slot in the first layer directory through file index, obtain the associated segment, and then index it in the second layer directory to obtain the file index information address.

Benefits of technology

Since the number of slots in each segment is fixed, the time to obtain the file index information address is upper limit, which solves the problem of low index efficiency when there are too many files and maintains the efficient response of the file system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119493769A_ABST
    Figure CN119493769A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, in particular to an indexing method, a program product, a medium and electronic equipment. According to the method, a two-layer directory structure is used for file management, a first layer directory comprises a certain number of slots, a second layer directory comprises a certain number of segments, each segment comprises the same number of slots, and the slots in the segments are used for storing file index information addresses. During specific indexing, a corresponding slot is found in the multiple slots in the first-layer catalogue according to the file index, and the slot is provided with a corresponding segment; and according to the file index, indexing in the corresponding segment of the second-layer directory to obtain an index result. Due to the fact that the number of the slots in each segment is the same, after any file index is obtained and the segment storing the file index information address is found according to the file index, the indexing time in each segment is within an upper limit range, and the problem that the indexing efficiency is low under the condition that the number of the files is large is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an indexing method, a program product, a medium and an electronic device. Background Art

[0002] The operating system of the electronic device has a file system for storing and managing files. In addition, in the file system, each file index corresponds to a specific file one by one. For example, the file index is the file name, and each file has a corresponding unique file name. When the file system detects that the user performs a specific file operation, such as querying a file, inserting a file, deleting a file, changing the file content, etc., the file is operated based on the specific file index.

[0003] For example, if a user wants to search for a file, the file system obtains the specific file name that the user wants to search for, uses the file name as a file index, obtains a specific file index information address based on the file index, finds the file index information based on the file index address, and then obtains the specific file based on the file index information. The file index information includes information such as the storage space address pointing to the specific file, the file name, and the file time.

[0004] Currently, the file index structure can be constructed through data structures such as radix tree and hash table. After the file system obtains the specific file index, it finds the specific file index information address in the constructed file index structure, obtains the file index information according to the file index information address, and thus obtains the specific file.

[0005] However, as the number of files increases, the number of file indexes also increases accordingly. The time it takes for the file system to index a specific file index information address in the file index structure implemented by the currently used radix tree, hash table and other data structures, and then find the specific file index information according to the file index information address will also increase infinitely, resulting in a longer time for the file system to respond to user file operations and a decrease in efficiency. For example, in the file index structure implemented by the radix tree, due to the large number of files, the number of file index information addresses is also correspondingly large, and the depth of the radix tree increases accordingly, which makes the file system take a longer time to access the specific file index information address in the file index structure, thereby resulting in a longer time for the file system to respond to user file operations and a decrease in efficiency. Summary of the invention

[0006] In order to solve the above problems, the present application provides an indexing method, a program product, a medium and an electronic device. In the method, a two-layer directory structure is used for file management. The first-layer directory includes a certain number of slots, the second-layer directory includes a certain number of segments, each segment includes the same number of slots, each slot in the first-layer directory has a segment associated with it in the second-layer directory, and the slots in the segment are used to store the file index information address. In the specific indexing process, the corresponding slot is found in multiple slots in the first-layer directory according to the file index, and the segment associated with it in the second-layer directory is obtained according to the corresponding slot; then the corresponding segment in the second-layer directory is indexed according to the file index to obtain the index result. Since the number of slots in each segment is the same, after obtaining any file index, when the segment storing the file index information address is found according to the file index, the indexing time in each segment has an upper limit range, thereby solving the problem of low indexing efficiency when the number of files is large.

[0007] In a first aspect, an embodiment of the present application provides an indexing method, which is applied to an electronic device, comprising: obtaining a first file index (for example, the first file index is the file index hereinafter, which can be a file name, etc.), the first file index including a first index part L1 (for example, the first index part L1 is a slot index identifier in the file index hereinafter) and a second index part L2 (for example, the second index part L2 is an identification identifier in the file index hereinafter); according to the first index part L1, m first-level directory elements (for example, the first-level directory is the first-level directory hereinafter) in a first-level directory (for example, the first-level directory is the first-level directory hereinafter) are searched. A first-level directory element S1n is determined in n second-level directory elements (for example, the second-level directory is the second-level directory hereinafter) of the second-level directory (for example, the second-level directory is the second-level directory hereinafter), wherein, in the n second-level directory elements (for example, the second-level directory element is the segment in the second-level directory hereinafter), there is a second-level directory element S2m associated with the first-level directory element S1n, and the n second-level directory elements each include p index information spaces X1-Xp (for example, the index information space is the slot in the segment in the second-level directory hereinafter); based on the second index part L2 and the p index information spaces X1-Xp of the second-level directory element S2m, the file corresponding to the first file index is obtained.

[0008] It can be understood that after obtaining any file index, the slot corresponding to the first-level directory is found according to the slot index identifier in the file index. At this time, the specific segment address pointing to the second-level directory can be obtained according to the slot. After finding the segment storing the address of the file index information, the slots in the segment are traversed according to the identification identifier in the file index. If the identification information in a certain slot is successfully matched with the identification identifier in the file index, the pointer pointing to the specific file index information in the slot is used as the file index information address corresponding to the file index; then the file index information is obtained according to the file index information address, and the specific file is obtained according to the file index information. It can be understood that since the number of slots in a segment is fixed, for each file index, there is an upper limit range for the indexing time in each segment, thereby solving the problem of low indexing efficiency when the number of files is large.

[0009] In a possible implementation of the first aspect above, p index information spaces X1-Xp constitute j bucket index spaces T1-Tj (for example, the bucket index space is the bucket below), and each bucket index space includes i index information spaces, where i*j=p; and the first file index also includes a third index part L3 (for example, the third index part L3 is the bucket index identifier below).

[0010] It can be understood that in some embodiments, in order to reduce the number of indexing in the segment when finding the slot corresponding to the file index in each segment, each segment can be divided into multiple buckets with the same number of slots. At this time, the bucket in the corresponding segment can be directly found according to the bucket index identifier, and then the corresponding bucket can be traversed, thereby further speeding up the indexing speed.

[0011] In a possible implementation of the first aspect above, based on the second index part L2 and the p index information spaces X1-Xp of the secondary directory element S2m, a file corresponding to the first file index is obtained, including: according to the third index part L3, selecting the first bucket index space Td corresponding to the third index part L3 from the j bucket index spaces T1-Tj of the secondary directory element S2m; based on the second index part L2 and the i index information spaces of the first bucket index space Td, obtaining the file corresponding to the first file index, wherein the i index information spaces of the first bucket index space Td belong to the p index information spaces X1-Xp of the secondary directory element S2m.

[0012] For example, after searching for the corresponding segment address from the first-level directory, the corresponding bucket in the corresponding segment can be indexed according to the corresponding bucket index identifier in the file index. By traversing, the specific identification identifier in the file index is compared with the specific identification information corresponding to the specific slot. For example, the identification information includes information such as fingerprint and file name length.

[0013] In a possible implementation of the first aspect above, based on the i index information spaces of the second index part L2 and the first bucket index space Td, a file corresponding to the first file index is obtained, including: selecting the first index information space Xc corresponding to the second index part L2 from the first bucket index space Td; based on the first index information address Dt in the selected first index information space Xc (for example, the first index information address is a pointer to specific file index information in the slot of the segment below, that is, the file index information address), obtaining the file corresponding to the first file index.

[0014] In a possible implementation of the first aspect above, based on the second index part L2 and i index information spaces of the first bucket index space Td, a file corresponding to the first file index is obtained, including: the index information space corresponding to the second index part L2 is not found in the first bucket index space Td; in the secondary directory element S2m, the second index information space Xq corresponding to the second index part L2 is found in the second bucket index space Tv associated with the first bucket index space Td as the first index information space Xc.

[0015] It can be understood that if there is no identification information of the slot in the current bucket that can be successfully matched, the specific overflow information in the slot including the overflow information and the overflow position (i.e., there is an overflow) in the current bucket can be checked again to find the associated bucket and continue searching in the associated bucket.

[0016] In a possible implementation of the first aspect above, the method also includes: obtaining a second file index, the second file index including a fourth index part L4 (for example, the fourth index part L4 is a slot index identifier in the file index hereinafter) and a fifth index part L5 (for example, the second index part L5 is an identification identifier in the file index hereinafter); according to the fourth index part L4, determining a first-level directory element S1p from the m first-level directory elements in the first-level directory; based on the fifth index part L5, it is impossible to obtain the file corresponding to the second file index through the second-level directory element S2u associated with the first-level directory element S1p.

[0017] It is understandable that when a file needs to be inserted, a search for a file with the same name can be performed first. If no file with the same name is found, the file is inserted.

[0018] In a possible implementation of the first aspect above, based on the fifth index part L5, the file corresponding to the second file index cannot be obtained through the secondary directory element S2u associated with the first-level directory element S1p, including: the index information space corresponding to the fifth index part L5 is not included in the secondary directory element S2u associated with the first-level directory element S1p; or, the second index information space Xh corresponding to the fifth index part L5 is included in the secondary directory element S2u associated with the first-level directory element S1p, and the file corresponding to the second index information address Ds in the second index information space Xh does not match the file corresponding to the second file index.

[0019] In a possible implementation of the first aspect above, the method also includes: there is at least one free index information space in the p index information spaces X1-Xp corresponding to the secondary directory element S2u (for example, the secondary directory element S2u is the search segment below); the first relevant content of the file corresponding to the second file index is stored in the first free index information space Xk in the at least one free index information space, wherein the first relevant content is used for matching the second file index and for finding the file index information of the file corresponding to the second file index.

[0020] It is understandable that if there is at least one free slot in the segment of the second-level directory corresponding to searching for files with the same name, then the relevant information of the file to be inserted can be directly filled into the free slot, which is more convenient. The first related content at least includes the pointer to the specific file index information (i.e., the file index information address) and the identification information for matching (such as fingerprint, file name length, version, etc.) described below.

[0021] In a possible implementation of the first aspect above, it also includes: there is no free index information space in the p index information spaces X1-Xp corresponding to the secondary directory element S2u, and the secondary directory element S2u is associated with at least 2 first-level directory elements among the m first-level directory elements in the first-level directory; one secondary directory element S2k is added to the second-level directory (for example, a segment is added), and the secondary directory element S2k has an associated first-level directory element S1k in the first-level directory, wherein before the secondary directory element S2k is added to the second-level directory, the first-level directory element S1k is associated with the secondary directory element S2u, and the first-level directory element S1k is the same as or different from the first-level directory element S1p.

[0022] It is understandable that if there are no free slots in the segment in the second-level directory when searching for files with the same name, a segment needs to be expanded to increase storage space. When the number of files increases, the file system adds a preset number of segments in the second-level directory (i.e., expands the capacity), and the number of slots in the added segments is the same as the number of slots in the previous segments, and the slots in the first-level directory are associated with the segments in the second-level directory. At this time, the time from file system index to file index is still within the upper limit mentioned before when no new segments were added.

[0023] In a possible implementation of the first aspect above, among the p index information spaces X1-Xp of the secondary directory element S2u, f index information spaces Xf1-Xff correspond to the first-level directory element S1k, and the method also includes: migrating the contents of the f index information spaces Xf1-Xff to the f index information spaces Xf1-Xff in the secondary directory element S2k; and, corresponding to the first-level directory element S1k being the first-level directory element S1p, storing the first relevant content of the file corresponding to the second file index in the free index information space in the secondary directory element associated with the first-level directory element S1p.

[0024] It can be understood that since the search segment when searching for files with the same name is associated with multiple slots in the first-level directories, different slots in the segment will actually correspond to different slots in the first-level directory. When a new segment is added, the slot records corresponding to the slots in the first-level directory associated with the newly added segment in the original search segment can be migrated to the new segment, and the slot records in the original segment can be deleted. At this time, the records corresponding to the files to be inserted can be stored in the segment associated with the slots in the first-level directory corresponding to the slot index identifier obtained during the original search, so that the subsequent indexing process can be carried out in an orderly manner.

[0025] In a possible implementation of the first aspect above, the method also includes: there is no free index information space in the p index information spaces X1-Xp corresponding to the secondary directory element S2u, and the secondary directory element S2u is associated with only one first-level directory element S1p among the m first-level directory elements in the first-level directory; the m first-level directory elements in the first-level directory are increased to 2*m first-level directory elements (for example, the number of slots in the first-level directory is increased), and the secondary directory element S2u is associated with two first-level directory elements S1t and S1o; one secondary directory element S2w is added to the second-level directory, and the secondary directory element S2w has an associated first-level directory element S1z in the first-level directory, wherein the first-level directory element S1z is any one of the first-level directory elements S1t and S1o.

[0026] It is understandable that if there is no corresponding slot in the first-level directory associated with the segment added to the second-level directory, the number of slots in the first-level directory needs to be increased. At this time, when a segment is added to the second-level directory, there will be slots in the first-level directory associated with the segment in the second-level directory, so that more file information corresponding to more files can be stored.

[0027] In a possible implementation of the first aspect above, in the p index information spaces X1-Xp of the secondary directory element S2u, f index information spaces Xf1-Xff correspond to the first-level directory element S1z, and the method also includes: migrating the contents of the f index information spaces Xf1-Xff to the f index information spaces Xf1-Xff in the secondary directory element S2w; and obtaining the sixth index part L6 in the second file index (for example, the sixth index part L6 is the slot index identifier re-acquired below), wherein the sixth index part L6 includes the first and fourth index parts L4, and the sixth index part L6 corresponds to the first-level directory element S1d in the first-level directory, wherein the first-level directory element S1d is any one of the first-level directory elements S1t and S1o; storing the first relevant content of the file corresponding to the second file index in the free storage information space in the secondary directory element associated with the first-level directory element S1d.

[0028] It can be understood that when the number of slots in the first-level directory increases, the bit number of the slot index identifier will also change. At this time, it is necessary to re-acquire the slot index identifier, and move some records in the search segment in the original second-level directory into the new segment according to the new slot index identifier. Then, the records corresponding to the files to be inserted are stored in the segment associated with the slot in the first-level directory corresponding to the new slot index identifier.

[0029] In a possible implementation of the first aspect, the first-level directory and the second-level directory are stored in at least one of a dynamic random access memory and a non-volatile memory.

[0030] In a second aspect, an embodiment of the present application provides an indexing device, including:

[0031] A first acquisition module, the first acquisition module is used to acquire a first file index, the first file index includes a first index part L1 and a second index part L2; a first determination module, the first determination module is used to determine a first-level directory element S1n from m first-level directory elements in the first-level directory according to the first index part L1, wherein, among the n second-level directory elements in the second-level directory, there is a second-level directory element S2m associated with the first-level directory element S1n, and the n second-level directory elements each include p index information spaces X1-Xp; a second acquisition module, the second acquisition module is used to obtain a file corresponding to the first file index based on the second index part L2 and the p index information spaces X1-Xp of the second-level directory element S2m.

[0032] In a third aspect, an embodiment of the present application provides an electronic device, characterized in that it includes: one or more processors; one or more memories; one or more memories storing one or more programs, and when the one or more programs are executed by one or more processors, the electronic device executes any indexing method such as the first aspect and any of the various implementations of the first aspect.

[0033] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having instructions stored thereon. When the instructions are executed on a computer, the computer executes an indexing method such as the first aspect and any one of the various implementations of the first aspect described above.

[0034] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions, characterized in that when the computer program product is run on a computer, the computer is enabled to execute any indexing method as described in the first aspect and any of the various implementations of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1A According to some embodiments of the present application, a schematic diagram of a 3-layer radix tree index structure is shown;

[0036] Figure 1B According to some embodiments of the present application, a schematic diagram of a specific process of creating an index corresponding to a file to be inserted in a file index structure when a file system performs a file insertion operation is shown;

[0037] Figure 2 According to some embodiments of the present application, a hash representation scheme is shown;

[0038] Figure 3A According to some embodiments of the present application, a 2-layer directory structure is shown;

[0039] Figure 3B According to some embodiments of the present application, another 2-layer directory structure is shown;

[0040] Figure 3C According to some embodiments of the present application, a 2-layer directory structure with divided buckets is shown;

[0041] Figure 4A According to some embodiments of the present application, a method is shown in which Figure 3C Taking the two-layer directory structure shown as an example, a schematic diagram of the specific contents stored in the slots in each layer of the directory;

[0042] Figure 4B According to some embodiments of the present application, a corresponding Figure 3C Schematic diagram of the newly added segment D3 in the second-level directory;

[0043] Figure 4C According to some embodiments of the present application, a schematic diagram of initializing a 2-layer directory structure is shown;

[0044] Figure 5 According to some embodiments of the present application, a schematic diagram of a specific process of a file system finding a file index information address (i.e., a pointer) according to a file index is shown in a case where each segment in a second-layer directory is divided into multiple buckets;

[0045] Fig. 6A According to some embodiments of the present application, a schematic diagram of a specific process of a file system adding a file index information address (i.e., a pointer) according to a file index in a two-layer directory index structure, where each segment in the second-layer directory is divided into multiple buckets, is shown;

[0046] Figure 6B According to some embodiments of the present application, a schematic diagram of intra-segment slot record migration is shown;

[0047] Figure 6C According to some embodiments of the present application, a schematic diagram after adding a slot in the first-level directory is shown;

[0048] Fig.6D According to some embodiments of the present application, a schematic diagram after adding a segment in the second-level directory is shown;

[0049] Fig. 7A According to some embodiments of the present application, a schematic diagram of an indexing system architecture is shown;

[0050] Figure 7B According to some embodiments of the present application, a schematic diagram of an indexing device is shown;

[0051] Figure 8 According to some embodiments of the present application, a schematic diagram of the effects of various file systems in different directory application scenarios is shown;

[0052] Fig. 9According to some embodiments of the present application, a schematic diagram of the hardware structure of an electronic device is shown. DETAILED DESCRIPTION

[0053] The illustrative embodiments of the present application include, but are not limited to, an indexing method, a program product, a medium, and an electronic device.

[0054] The technical solution of the present application is described in detail below with reference to the accompanying drawings.

[0055] As mentioned above, the time it takes for the file system to index a specific file index information address in the file index structure implemented by the currently used radix tree, hash table and other data structures will also increase infinitely, resulting in a longer time for the file system to respond to user file operations and reduced efficiency.

[0056] In some embodiments, a file index structure may be constructed through a radix tree, so that the file index information address is obtained in the radix tree according to the file index. For example, the file name is used as the file index, the file index information address is indexed in the radix tree according to the file name, and then the specific file index information is indexed according to the file index information address. The file index information may be organized in the form of a log when stored.

[0057] For example, Figure 1A According to some embodiments of the present application, a schematic diagram of a three-layer radix tree index structure is shown. Figure 1A As shown, the radix tree has multiple nodes, one node can be associated with multiple other nodes, and the leaf nodes of the tree (such as node 31 in the figure) store the address pointing to the file index information. Specifically, each node may include multiple slots, such as slot a, slot b, slot c, etc., and each slot may store the address pointing to the next node. Figure 1A As shown in , the slot a of node 1 can store an address pointing to node 21, the slot a of node 21 can store an address pointing to node 31, and the slot a of node 31 can store an address pointing to file index information C1. When the file system obtains the file name, the file operation can be performed in the radix tree according to the file name. It can be understood that a, b, and c are used to distinguish the difference in numerical values ​​and do not represent specific numerical values. For example, a, b, and c can correspond to specific hash values ​​0, 1, 2, etc.

[0058] The following takes the file name "aaa" as an example, combined with Figure 1A The specific process of searching for the file index information address corresponding to the file name in the radix tree and then indexing the file index information is described. Specifically, after the file system receives the file name "aaa", according to the first bit "a" in the following example Figure 1AIn the node 1 shown in the figure, slot a is found, and the "address of node 21" is obtained in slot a. At this time, slot a corresponding to the second bit "a" of the file name is searched in node 21; according to slot a of node 21, the "address of node 31" is obtained. At this time, slot a corresponding to the third bit "a" of the file name is searched in node 31, and then the "address of file index information C1" is obtained in slot a of node 31, thereby obtaining the file index information C1 corresponding to the file name "aaa".

[0059] It is understandable that the number of files in the file system will increase as the file system performs insertion operations. Figure 1B FIG. 2 shows a schematic diagram of a specific process of creating an index corresponding to a file to be inserted in a file index structure when a file system performs a file insertion operation. The specific process is as follows:

[0060] S101, searching for files with the same name in the current index structure according to the file name.

[0061] It can be understood that when the index structure is a radix tree, the file with the same name can be found through the specific process of searching the file index information address corresponding to the file name in the radix tree as described above.

[0062] S102, determine whether a file with the same name can be found, if not found, proceed to S103, otherwise proceed to S104.

[0063] It is understandable that if a file with the same name is found, there is no need to insert the file into the file system, that is, there is no need to insert the corresponding file index information into the index structure, then S104 is entered, indicating that the insertion failed. If no file with the same name is found, then S103 is entered to perform subsequent insertion operations.

[0064] S103, apply for space, create a file index corresponding to the file index information, and update the index structure.

[0065] It can be understood that when a new file needs to be inserted, a space will be allocated in the file system to store the file index information. At this time, when the index structure is a radix tree, space is applied for adding nodes to the radix tree. The node contains the file index information address associated with the file index information, and the radix tree structure is updated.

[0066] S104, insertion failed.

[0067] It is understandable that as the number of files increases, the number of file indexes corresponding to the file index information that need to be created also increases, the number of nodes in the radix tree increases, and the depth of the radix tree increases. When the file system performs file operations such as query or insertion based on the file index (for example, file name), the time required increases and the efficiency decreases.

[0068] In other embodiments, a file index structure may be constructed through a hash table, and the file index information address may be indexed in the hash table according to the file index, thereby obtaining specific file index information according to the file index information address. For example, in this case, the file name is still used as the file index, and the file index information address is indexed in the hash table according to the file name. Figure 2 A schematic diagram of a hash table is shown. The hash table has 512 buckets, each of which corresponds to a hash value, referred to as a hash bucket. Each hash bucket corresponds to multiple nodes, which are organized in the form of a linked list. A node may include a file name, a file index information address, and an address pointing to the next node and other information. Figure 2 In the example, hash bucket 0 corresponds to node 1 and node 2.

[0069] The following still takes the file name "aaa" as an example, combined with Figure 2 The specific process of searching the hash table for the file index information address corresponding to the file name is described. Specifically, after the file system receives the file name "aaa", it is assumed that the hash value of the hash bucket corresponds to the hash value of the file name. Assuming that the last 9 digits of the specific hash value of the hash value of the file name "aaa" are all 0, find hash bucket 0, and then traverse each node in the hash bucket. For example, compare the file name with the file name in node 1. If they are consistent, obtain the corresponding file index information address. Otherwise, continue to compare with the file name in node 2 based on the next node address in node 1 to see if they are consistent.

[0070] It is understandable that the number of files in the file system will increase as the file system inserts files. Figure 1B When the index structure is implemented by a hash table, corresponding to S101 in the above step, at this time, the file system will follow the above-mentioned steps in the following example. Figure 2 The query process in the hash table shown is not repeated here. Corresponding to S102 and S104 in the above steps, the specific process is essentially the same and is not repeated here. Corresponding to the above step S103, it can be understood that in the search process corresponding to step S101, the file name used for the search will correspond to the value of a specific hash bucket. At this time, a space will be applied and inserted between the hash bucket and the subsequent connected node as a newly added node. The node stores the file name corresponding to the file, the file index information address, the next node address and other information.

[0071] It is understandable that as the number of files increases, more file index information needs to be created, the number of nodes in the hash table increases, and the chain structure corresponding to each hash bucket becomes longer. When the file system performs file operations such as querying or inserting based on the file index (for example, the file name), it takes longer to traverse the nodes in the corresponding hash bucket, and the time required for the file system to perform file operations increases, which reduces efficiency.

[0072] Therefore, in order to solve the problem of low indexing efficiency when the number of files is large, the present application proposes an index structure, which adopts a two-layer directory structure. The first-layer directory includes m slots, and the second-layer directory includes n segments. Each segment includes the same number of slots. Each slot in the first-layer directory has a segment associated with it in the second-layer directory. The slots in the segment are used to store file index information addresses, so that the file index information can be found according to the file index information addresses.

[0073] Correspondingly, the present application proposes an indexing method, which performs indexing based on the proposed index structure. After the file system obtains the file index, it finds the corresponding slot in multiple slots in the first-level directory according to the file index, and obtains the segment associated with it in the second-level directory according to the corresponding slot; then it indexes the corresponding segment in the second-level directory according to the file index to obtain the index result.

[0074] It is understandable that, since the number of slots in each segment is the same, after obtaining any file index, when the segment storing the address of the file index information is found according to the file index, there is an upper limit range for the indexing time in each segment.

[0075] For example, Figure 3A As shown, the first-level directory includes 4 slots F0 to F3, and the second-level directory includes 3 segments, segments D0 to D2, each of which has 16 slots. Slots F0 and F1 in the first-level directory correspond to segments D0 and D1 in the second-level directory, respectively. The remaining 2 slots in the first-level directory, slots F2 and F3, are associated with segment D2 in the second-level directory. Since the number of slots in each segment is 16, the file system finds the corresponding slot in the first-level directory according to the file index, and when searching in the segment corresponding to the slot, it indexes at most 16 times in the segment. For example, after the file system obtains a file name, it obtains the slot corresponding to the first-level directory according to the file name as slot F0. At this time, the corresponding segment of the second-level directory obtained according to slot F0 is segment D0. At this time, the slots are traversed in order according to the file name in segment D2. Assuming that the file index information address corresponding to the file name is stored in the last slot of the segment, it is necessary to index 16 times in the segment.

[0076] When the number of files increases, the file system only needs to add a preset number of segments in the second-level directory (i.e., expand the capacity), the number of slots in the added segments is the same as the number of slots in the previous segments, and the slots in the first-level directory are associated with the segments in the second-level directory. At this time, the time for the file system to index a file is still within the upper limit mentioned before when no new segments are added.

[0077] For ease of understanding, the content corresponding to the file stored in the slot of each layer of the directory is called a "record", where the record in the slot in the second layer of the directory includes the file index information address, the specific file name length used to match the specific file index (for example, the file name), and the feature segment data used to compare with the file index.

[0078] For example, Figure 3B In the figure, a segment D3 is added to the second-level directory, and segment D3 corresponds to slot F3 in the first-level directory. Multiple slots in segment D3 are used to store records corresponding to specific files, and the records include data such as file index information addresses. Assume that the file index information address corresponding to the newly added file is stored in the last slot corresponding to segment D3. At this time, when the file system obtains the file name of the newly added file, it obtains the slot corresponding to the first-level directory as slot F3 according to the file name. At this time, the record corresponding to the file name is indexed in the segment D3 associated with slot F3 in a sequential traversal manner. At this time, it needs to be indexed 16 times, and the file index information address is obtained in the last slot. It can be understood that at this time, the upper limit of the number of indexes in the second-level directory is still 16 times.

[0079] It is understandable that if there is no corresponding slot in the first-level directory related to the segment added to the second-level directory, the number of slots in the first-level directory needs to be increased, which will be explained in detail below.

[0080] It is understandable that as the number of files increases, although the file index information that needs to be created also increases, in the two-layer directory structure of the file system, the time for indexing the corresponding file index information address is still within a certain range and will not increase indefinitely as the number of files increases. This makes the time required for the file system to perform file operations within a certain range, thereby improving indexing efficiency.

[0081] It is understandable that in some embodiments, in order to facilitate the process of finding the slots corresponding to the file index in each segment and reduce the number of indexing in the segment, each segment can be divided into multiple buckets with the same number of slots. After obtaining the file index, after finding the corresponding slot in the first-level directory according to the file index, the segment corresponding to the file index in the second-level directory can be obtained, and then the slots in the corresponding bucket in the segment are indexed according to the relevant information of the bucket in the file index, so as to obtain the index result.

[0082] For example, Figure 3C As shown in the figure, each segment in the second-level directory is divided into 4 buckets, each bucket has 4 slots, and bucket T0 shown in the figure has 4 slots. When the file system obtains the information of the corresponding bucket in the segment corresponding to the file index in the second-level directory, it only needs to traverse the slots in the bucket, and at most index 4 times to get the index result.

[0083] It can be understood that in other embodiments, between different buckets in the same segment, there may be a situation where the slot of one bucket contains the file index information address corresponding to another bucket. When the file system cannot find the file index information address in the slots of the current bucket, it can check whether there is information of another bucket associated with the bucket. If so, it can search in the other bucket based on the information of the associated other bucket to obtain the index result.

[0084] It can be understood that the structure of the buckets in the second level directory in this application is similar to Figure 2 The structure of the buckets in the hash table is different.

[0085] It can be understood that for the two-layer directory structure proposed in this application, the two-layer directory structure can be stored in different memories respectively. For example, the first-layer directory can be stored in dynamic random access memory (DRAM), and the second-layer directory can be stored in non-volatile memory (NVM); for another example, the first-layer directory and the second-layer directory can be stored in DRAM, and for another example, the first-layer directory and the second-layer directory can be stored in non-volatile memory NVM. For example, Figure 3C It is shown in FIG. 1 that the first-level directory is placed in DRAM and the second-level directory is placed in NVM.

[0086] It is understandable that in order to further improve the efficiency of file operations in high-concurrency scenarios, hardware transactional memory (HTM) can be used for file operations.

[0087] It is understandable that the file system supports multiple threads, and the multiple threads are parallel. Each thread includes multiple file operations, and the multiple file operations within the thread are serial. It is understandable that at the same time, there may be a situation where the same file operation is executed corresponding to multiple threads, and this will involve the change of data in the file system corresponding to the file operation. For example, when it is necessary to delete or insert a file, it will involve the change of data in the index structure of the file system. At this time, in a shared memory environment, HTM makes different parallel execution threads transactional, that is, only one thread is allowed to change the data in the index structure of the file system (for example, the record in the slot) at the same time, but all threads can be executed at the same time. When a thread changes data, its modification is visible to other threads. Other executing threads will check whether the modified data executed conflicts with the currently changed data. If a conflict occurs, the currently changed data and the modified data executed are not counted, and the two threads will redo it.

[0088] Specifically, in an embodiment of the present application, a file operation will correspond to multiple code segments (hereinafter referred to as "file sub-operations" for the convenience of explanation). For example, when performing a file insertion operation, the file system will perform multiple file sub-operations. Among them, the file sub-operation may include querying the corresponding slot in the first-level directory according to the slot index identifier of the file index, and may include multiple file sub-operations such as expansion operations. Among them, the expansion operation may include expanding the first-level directory or expanding the second-level directory, and the expansion of the first-level directory is to increase the number of slots in the first-level directory, and the expansion of the second-level directory is to increase the segments in the second-level directory. For the convenience of explanation, the file sub-operation for expanding the first-level directory or the file sub-operation for expanding the second-level directory is referred to as "expansion file sub-operation".

[0089] It is understandable that the file system may be configured with HTM, and the HTM may be enabled when the thread in the file system involves a relatively critical file sub-operation. For example, when performing a file insertion operation, the HTM may be enabled when the file sub-operation is configured to increase the number of slots in the first-level directory, increase the segment in the second-level directory, or change the record of the corresponding file in the file index structure.

[0090] For example, specifically for the expansion file sub-operation (i.e., the expansion of the first-level directory or the second-level directory mentioned above), when multiple threads need to perform the same expansion file sub-operation, the expansion file sub-operations of multiple threads are all deemed to have failed, and then each thread of the file system continues to try to perform the corresponding expansion file sub-operation (i.e., roll back) in the future. It is understandable that when HTM is enabled, multiple threads may still fail in the expansion file sub-operation after multiple attempts. After multiple attempts fail, atomic operations can be enabled at this time. Among them, atomic operations can ensure that multiple threads will not conflict by locking. It is understandable that since multiple threads cannot always conflict, the performance of concurrent execution of multi-threaded parallel programs is improved in high-concurrency scenarios, thereby greatly improving the efficiency of file system operations on files.

[0091] It can be understood that the file indexing method and file indexing structure proposed in the present application can be used in various environments, including but not limited to asynchronous dram refresh (ADR), enhanced asynchronous dram refresh (eADR), etc. In addition, the file indexing method and file indexing structure proposed in the present application can be used in various file systems, including but not limited to Euler file system (EulerFS), Nova file system, etc.

[0092] It can be understood that the index structure and index method mentioned in the present application can be used in various file systems and applied to various electronic devices, including but not limited to mobile phones, tablet computers, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), servers, etc. The embodiments of the present invention do not impose any restrictions on the type of electronic devices.

[0093] Figure 4A According to some embodiments of the present application, a method is shown in which Figure 3C Taking the two-layer directory structure shown as an example, a schematic diagram of the specific content stored in the slots in each layer of the directory. It can be understood that the records in the slots of each layer include metadata and specific data.

[0094] For the sake of convenience in distinction, the metadata in the slots of the first-layer directory is called "first metadata", and the specific data in the slots of the first-layer directory is called "first data"; the metadata in the slots of the second layer is called "second metadata", and the specific data in the slots of the second layer is called "second data".

[0095] For the slots in the first-level directory, the first metadata stores the local depth and the lock used for the atomic operation mentioned above (for the convenience of explanation, the lock is called the "atomic operation lock"). Among them, the local depth in the first metadata is used in the process of adding segments (i.e., expansion) in the second-level directory to identify whether it is necessary to add slots to the first-level directory for association with the newly added segments. It can be understood that in some embodiments of the present application, whether the local depth in the first-level directory is consistent with the global depth is used to determine whether the slots in the first-level directory need to be expanded. When the local depth in the slot is consistent with the value of the global depth, it indicates that there is a one-to-one correspondence between the slot and the segment in the second-level directory. When the local depth in the slot is less than the value of the global depth, it indicates that the slot has the same segment associated with some other slots / slots in the first layer in the second-level directory.

[0096] For example, Figure 3C In the first-level directory, there are 4 slots, of which the global depth is 2, and slot F0 corresponds one-to-one with segment D0, so the local depth of slot F0 is 2.

[0097] For another example, slot F2 and slot F3 correspond to the same segment D2, and the local depth of slot F2 is 1.

[0098] The global depth is calculated as follows: global depth G=lgM, where M is the number of slots in the first-level directory.

[0099] The calculation of the local depth of a specific slot (e.g., slot S) can be: Assume that, in the first-level directory, for the current slot S, the slot S is associated with the same segment in the second-level directory as X slots in the first-level directory, and X+1 is a multiple of 2, that is, X+1=2 k , k is 0, 1, ..., n. At this time, the local depth corresponding to the slot S is B=Gk. It can be understood that the above calculation formula of the local depth is only for understanding. In the specific implementation process, the formula can be used for calculation or not.

[0100] It can be understood that the global depth and local depth of each slot corresponding to the first-level directory change as the file system expands the first-level directory or the second-level directory.

[0101] Each time the first-level directory is expanded, the number of slots in the first-level directory doubles, and the corresponding global depth is +1.

[0102] Each time the second-level directory is expanded, the number of segments in the second-level directory increases by 1, and the local depth of the slot of the first-level directory associated with the newly added segment in the second-level directory is the original local depth + 1. It can be understood that before the expansion, the first-level directory slot corresponding to the newly added segment in the second-level directory is associated with the same segment as other slots. In this case, after the expansion, the local depth of the slot associated with the same segment is also +1.

[0103] For example, Figure 4B For the corresponding Figure 3C Schematic diagram of adding segment D3 to the second-level directory in . When the file system cannot find the corresponding record in segment D2, segment D3 is added. At this time, segment D3 uses slot F3 associated with the original segment D2. At this time, the local depth of slots F2 and F3 is changed from Figure 3C The L=1 shown in FIG. 1 is changed to L=2.

[0104] The atomic operation lock in the first metadata is used to ensure that there is no conflict when multiple threads perform the same file sub-operation on the same slot during the expansion process. For example, when the bit corresponding to the lock of the slot is "1", it is used to indicate that there is currently a thread performing an operation on it, and when the bit corresponding to the lock of the slot is "0", it indicates that no thread is performing an operation on it. This lock can be used in conjunction with HTM, that is, when HTM is enabled, if multiple threads fail to perform expansion operations at the same time, then the function of the atomic operation lock can be enabled.

[0105] For example, taking 64-bit data as an example, Figure 4A As shown in FIG. 1 , in slot F0 in the first-level directory, among the 64 bits of metadata F0_1, bits 52 to 63 are used to store the local depth, and bit 51 is used to store the atomic operation lock.

[0106] The first data stores a version number and a pointer to a specific segment in the second-level directory, which are used to ensure consistency and index the segment in the second-level directory. Figure 4A As shown in FIG. 1 , in the slot F0 in the first-level directory, among the 64 bits of data F0_2, the 56th to 63rd bits are used to store the version number, and the 0th to 55th bits are used to store a pointer to a specific segment in the second-level directory.

[0107] For the slots in the second-level directory, the second metadata stores fingerprints, file name length, overflow information, and overflow positions. The fingerprint is used to compare with some feature segments in the file index to determine whether the record in the slot is the record corresponding to the file index. The overflow information is an overflow record, which is used to indicate that there are slots associated with it in other buckets in the segment, which means that the slots in other buckets in the segment can be found through the information of this bucket. The overflow position records the specific slot positions of other buckets in this segment where the records corresponding to the file index information are stored. For example, Figure 4A It is shown in FIG. 1 that in the slot S0 in the second-level directory, among the 64 bits of the metadata S0_1, the 52nd to 63rd bits are used for fingerprints, the 44th to 51st bits store the file name length, the 32nd to 43rd bits are used to store overflow information, and the 28th to 31st bits are used to store overflow positions. It can be understood that when an overflow occurs, specific overflow information and overflow position contents are present in the second metadata, otherwise, there is no specific overflow information and overflow position contents on specific bits in the second metadata.

[0108] The second data includes a version and a pointer to the file index information (i.e., the address of the file index information). Figure 4A It is shown in the figure that in the slot S0 in the second-level directory, among the 64 bits of data S0_2, the 56th to 63rd bits are used to store the version, and the 0th to 55th bits are used to store a pointer to specific file index information, that is, the specific address of the currently stored file index information.

[0109] It can be understood that since the segments in the second-level directory are in a chain structure, a slot will be set in the segment to store pointers to the relationship between the segments. For example, the slot stores a pointer to the next segment, or stores a segment end marker, indicating that the current segment is the last segment.

[0110] It is understandable that when the directory index structure has not been established, the file system needs to apply for space for the two-layer directory index structure, so as to establish the first-layer directory and the second-layer directory, and initialize the first-layer directory and the second-layer directory. It is understandable that during initialization, each slot in the first-layer directory corresponds to each segment in the second-layer directory one by one, that is, the local depth of each slot in the first-layer directory is equal to the global depth. Among them, the number of slots in the first-layer directory and the number of segments in the second-layer directory can be set during initialization. Therefore, when the segment in the second-layer directory needs to be increased for the first time, the first-layer directory expansion operation must be performed first. After the first-layer directory is expanded, there will be multiple slots in the first-layer directory corresponding to the same segment. At this time, the global depth of each slot in the first layer is increased by 1. Then, the local depth of each slot will be less than the global depth, that is, at least 2 slots will be associated with the same segment, so that the segment can be expanded in the second-layer directory later.

[0111] Assume that at initialization, the number of each slot in the first-level directory and each segment in the second-level directory is 2. For example, Figure 4C As shown in (a), slot A0 and slot A1, the local depth of each slot = global depth, which is 1. After the first-level directory is expanded by doubling the number of slots in the first-level directory, the number of slots in the first-level directory is 4, and every 2 slots are associated with 1 identical segment. At this point, the local depth of each slot is still 1, but the global depth is 2. For example, Figure 4C As shown in (b), the slots in the first-level directory increase from slot A0 and slot A1 to slot F0, slot F1, slot F2, and slot F3. Among them, the records of slot F0 and slot F1 are the same as Figure 4C (a) The records in slot A0 are the same as those in slots F2 and F3. Figure 4C The records in slot A1 in (a) are the same. Since the global depth of each slot plus 1 is 2, that is, the local depth 1 of each slot is less than the global depth 2, the segment can be expanded in the second-level directory later.

[0112] It is understandable that each slot in the first-level directory will have a slot identifier. For example, the slot identifier can be represented by a binary representation of multiple bits, where the number of bits F of the slot identifier is equal to the value of the global depth. When the first-level directory is expanded, the number of slots changes, and the number of bits used to represent the slot identifier of each slot changes. For example, Figure 4C The slots A0 and A1 in (a) correspond to slot identifiers 0 and 1 respectively. After the first-level directory is expanded, Figure 4C In (b), slot F0, slot F1, slot F2, and slot F3 are represented by 2 bits, 00, 01, 10, and 11, respectively.

[0113] The following is combined with Figure 5 The following is a diagram of the specific process of the file system finding the file index information address (i.e., pointer) based on the file index in a two-layer directory index structure where each segment in the second-layer directory is divided into multiple buckets. The specific process is as follows:

[0114] S501, searching for a corresponding slot in the first-level directory according to a file index, thereby obtaining information on a specific segment associated with the second-level directory according to the corresponding slot.

[0115] It is understandable that when the directory index structure has not yet been established, it is necessary to apply for space in the memory (eg, DRAM) and the persistent memory (eg, NVM) to establish the first-level directory and the second-level directory.

[0116] It can be understood that the corresponding slot in the first-level directory stores the address pointing to the associated segment in the second-level directory.

[0117] In some embodiments, a file index is obtained, and a corresponding slot is found based on a slot index identifier in the file index that corresponds to a slot identifier in the first-level directory, and a specific segment address pointing to the second-level directory is obtained based on the found slot.

[0118] For example, the file name represented by the hash value is 64-bit binary data. Assume that the slot index identifier is data with the first 2 bits being 00, and the 2 bits of the slot index identifier corresponding to the slot identifier in the first-level directory are 00. Figure 3C In the two-layer directory structure shown, since slot F0 corresponds to slot ID 00, slot F0 is found at this time, and the specific segment address pointing to the second-layer directory is obtained from slot F0. For example, Figure 4A In the data F0_2 shown in FIG. 1 , the 0th bit to the lower 55th bits correspond to a specific segment address.

[0119] S502, according to the file index, searching for the corresponding file index information address in each slot of the bucket corresponding to the segment of the found second-level directory.

[0120] It can be understood that in order to reduce the number of indexes in a segment, each segment is divided into multiple buckets of the same size.

[0121] In some embodiments, the file index includes a corresponding bucket index identifier. After searching the corresponding segment address from the first-level directory, the corresponding bucket in the corresponding segment can be indexed according to the corresponding bucket index identifier in the file index. By traversing, the specific identification identifier in the file index is compared with the specific identification information corresponding to the specific slot. For example, the identification information includes information such as fingerprint and file name length.

[0122] It can be understood that if the identification information in a certain slot is successfully compared with the identification identifier in the file index, the pointer to the specific file index information in the slot is used as the file index information address corresponding to the file index; if the identification information of no slot in the current bucket is successfully compared, the specific overflow information in the slot including the overflow information and the overflow position (that is, there is an overflow) in the current bucket can be used as the identification information to be compared with the identification identifier of the file index again; if they are the same, the overflow information is successfully compared, then the specific slots of other buckets of the current segment stored in the overflow position are searched, and the pointers to the specific file index information in the slots of other buckets are used as the file index information address corresponding to the file index; if they are different, the overflow information comparison fails, and the search is considered to have failed.

[0123] For example, Figure 3C In the data F0_2 shown in , the specific segment address is the address pointing to segment D0. At this time, the corresponding bucket index identifier in the file index is assumed to be 00, and the bucket identifier corresponding to the first bucket T0 in segment D0 is 00. At this time, search in bucket T0.

[0124] Compare the bits corresponding to the specific identification mark in the file index with the specific identification information in the slot. Specifically, it can include comparing the bits in the specific identification mark in the file index that correspond to the fingerprint in the slot with the fingerprint in the specific slot. In the case of a successful fingerprint comparison, the bits in the specific identification mark in the file index that correspond to the length of the file name in the slot are compared with the bits corresponding to the length of the file name in the specific slot. If the fingerprint and file name length are compared successfully, the slot is considered to have been found to be the corresponding slot. Otherwise, the comparison is not considered to be successful. For example, if the specific identification mark in the file index is compared with the specific identification mark in the file index in order, the specific identification mark in the file index is compared with the specific identification mark in the slot. Figure 4A The data from the 52nd to the 63rd bit of the metadata in the slot of each bucket to which the fingerprint is assigned is compared to obtain the fingerprint matching result. Then, if the fingerprint matching is successful, the specific identification mark is continued to be compared with the Figure 4A The data from the 44th to the 51st bits in the metadata in the slot shown are compared. If the comparison is successful, it is considered that the pointer pointing to the specific file index information in the slot is the corresponding pointer, that is, the file index information address is obtained.

[0125] If in Figure 3C If no fingerprint or file name length corresponding to the specific identification mark is matched in each slot of bucket T0 in the file index, the specific overflow information in the slot with overflow in bucket T0 is compared with the specific identification mark in the file index. Figure 4A The overflow information from bit 32 to bit 43 in the metadata S0_1 shown in is compared with the identification mark.

[0126] Assuming that the overflow information in slot S0 matches the identification mark, according to the overflow position in slot S0, (assuming the overflow position is as follows Figure 3C The slot S1 of the bucket T1 shown in the figure is found, and the slot S1 of the bucket T1 can be compared with the specific identification mark in the file index again in the slot S1. If the comparison is successful, the pointer pointing to the specific file index information in the slot is used as the file index information address corresponding to the file index. It can be understood that the pointer pointing to the specific file index information in the slot S1 can be used as the file index information address corresponding to the file index without comparison.

[0127] Assuming that the overflow information in slot S0 does not match the identification mark, it is considered that the search has failed.

[0128] It can be understood that the execution order of the above steps S501 to S502 is only an example. In other embodiments, other execution orders may be adopted, and some steps may be split or combined, which is not limited here.

[0129] It is understandable that when the number of files increases, the file system needs to insert files. At this time, it is also necessary to add new file index information addresses, that is, add new slots in the two-layer directory structure to store the file index information addresses of the newly added files (that is, pointers to specific file index information).

[0130] The following is combined with Fig. 6A The present invention specifically introduces the situation in which each segment in the second-layer directory is divided into multiple buckets, and a schematic diagram of the specific process of the file system adding a file index information address (i.e., a pointer) according to the file index (taking the file name as the specific file index as an example). The example of storing the first-layer directory in DRAM and the second-layer directory in NVM is used for explanation.

[0131] The specific process is as follows:

[0132] S601, searching for a file with the same name in the first-level directory according to the file name.

[0133] It can be understood that when the index structure is a two-layer directory index structure, the above Figure 5 The specific process of searching the file index information address corresponding to the file name in the two-layer directory index structure to find out whether there is a file with the same name is specifically described. It can be understood that if the specific file index information address can be found, the specific file index information can be found according to the file index information address, and the file name in the file index information can be compared with the searched file name to determine whether there is a file with the same name.

[0134] S602, determine whether there is a file with the same name.

[0135] It can be understood that if there is a file with the same name, the process goes to S606, otherwise, the process goes to S603.

[0136] It is understandable that if a file with the same name is found, there is no need to insert the file into the file system, that is, there is no need to insert the corresponding file index information address into the 2-layer directory index structure, then enter S606, indicating that the insertion failed. If no file with the same name is found, then enter S603 and perform subsequent insertion operations.

[0137] For example, for file name 1, the file name represented by the hash value is 64-bit binary data. In addition, for file name 1, the corresponding slot is not included in the segment D0 corresponding to the slot F0 in the first-level directory according to file name 1, or, after finding a matching slot in the segment D0 corresponding to the slot F0 in the first-level directory according to file name 1, the specific file name in the file index information found according to the file index information address in the slot does not match the file name 1, so the corresponding file with the same name cannot be found, and then enter S603.

[0138] S603, determine whether it is necessary to add a segment in the second-level directory. If it is not necessary to add, go to S604; if it is necessary to add, go to S605.

[0139] It is understandable that the first-level directory and the second-level directory can be stored in DRAM and NVM respectively. When it is necessary to insert a corresponding record of a file corresponding to a file name in the index structure (including the file index information address and other additional information), it is necessary to apply for space in the current 2-level directory structure for storing the corresponding record.

[0140] It can be understood that in step S601, when searching for files with the same name, the file system has found the corresponding slot in the first-level directory based on the slot index identifier in the file index, and found the corresponding segment in the second-level directory based on the segment address in the slot in the first-level directory.

[0141] For the sake of convenience, the corresponding segment found in the second-level directory when searching for files with the same name is called a "search segment".

[0142] Since there is no slot record related to the file to be inserted in the segment, a record related to the file index information of the file to be inserted can be inserted into an empty slot in the current segment. However, since there may be no empty slot in the segment for storing specific related records, it is necessary to add an additional segment in the second-level directory to meet the usage.

[0143] In some embodiments, since there are empty slots in the search segment in the second-level directory of the current two-level directory structure that can be used to store records related to the file index information of the file to be inserted, the empty slots can be used to store records of the corresponding file. In this case, it is not necessary to add an additional segment, and the process proceeds to S604.

[0144] In other embodiments, since there are no free slots in the search segment of the second-level directory in the current two-level directory structure that can be used to store records related to the file index information of the file to be inserted, it is necessary to add a new segment to store the records of the corresponding file, and enter S605.

[0145] S604: Store the record corresponding to the file to be inserted in the slot of the corresponding segment, wherein the record corresponding to the file to be inserted includes the file index information address, fingerprint and other additional information.

[0146] In some embodiments, a pre-configured HTM may be started to insert a record into a slot of a corresponding segment. The record may include Figure 4A Information corresponding to the specific contents of slot S0 shown in the figure, etc.

[0147] S605, adding a segment in the second-level directory, and storing a record corresponding to the file to be inserted in a slot of the corresponding segment, wherein the record includes a file index information address, a fingerprint, and other additional information.

[0148] In some embodiments, the local depth and global depth corresponding to the slot in the first-level directory associated with the search segment in the current second-level directory are compared. If the two are equal, the first-level directory is expanded, that is, the number of slots in the first-level directory is increased, and then the segment in the second-level directory is expanded, that is, the segment in the second-level directory is increased accordingly. If the local depth is less than the global depth, only the segment in the second-level directory needs to be expanded. Then, the corresponding record is filled into the slot of the segment corresponding to the slot index identifier in the file name of the inserted file.

[0149] In some implementations, for the case where only a segment in the second-layer directory is added, that is, the currently searched segment is associated with multiple slots in the first-layer directory. The file system applies for a second-layer directory space in the NVM, and associates half of the slots associated with the searched segment in the first-layer directory with the newly added segment in the second-layer directory. For example, if the currently searched segment corresponds to 4 slots in the first-layer directory, at this time, the newly added segment will be associated with 2 of the 4 slots, and the local depth of each slot is +1. Since the original search segment is associated with multiple slots in the first-layer directory, different slots in the segment will actually correspond to different slots in the first-layer directory. When a new segment is added, the slot record corresponding to the slot in the first-layer directory associated with the newly added segment in the original search segment can be migrated to the new segment, and the slot record in the original segment can be deleted. At this time, the record corresponding to the file to be inserted can be stored in the segment associated with the slot in the first-layer directory corresponding to the slot index identifier obtained during the original search.

[0150] For example, the above Figure 3C and Figure 4B The relevant description has been given as an example and will not be repeated here.

[0151] Understandably, for the migration process, the following is combined Figure 6B , so as to convert the above Figure 3C The records in the middle section D2 are increasing as Figure 4B After segment D3 in segment D2 is moved, the corresponding slot records in segment D2 and segment D3 are recorded in the corresponding specific slots. Figure 6B (a) shows the Figure 3C The specific slot record corresponding to the middle segment D2. Figure 6B (b) shows the migration of the slot contents in segment D2 to segment D3. Figure 3C The specific slot records corresponding to the middle segments D2 and D3. It can be understood that Figure 6B (a) Segment D2 is associated with slots F2 and F3 in the first-level directory, and the slot identifiers of slots F2 and F3 are 10 and 11 respectively. The slot records in segment D2 include a slot record corresponding to slot F2 (i.e., slot identifier 10) and a slot record corresponding to slot F3 (i.e., slot identifier 11). For example, Figure 6B As shown in (a), the "slash" slot in segment D2 corresponds to slot F0 (i.e. slot number 10) in the first-level directory, and the "vertical" slot in segment D2 corresponds to slot F1 (i.e. slot number 11) in the first-level directory, where the "snowflake" slot (such as SD0 shown in the figure) is used to store pointers to subsequent segments. When segment D3 is added, since the added segment D3 is associated with slot F3, for example, Figure 6BAs shown in (b), at this time, segment D2 will migrate the slot record corresponding to slot F3 (i.e., slot identifier 11) to the slot corresponding to segment D3, and delete the corresponding content of slot D2. Figure 6B As shown in (b), only the "slash" slot remains in segment D2, and the "vertical line" slot record is stored in segment D3, among which the "snowflake" slot SD1 is used to store the segment end mark, indicating that the current segment is the last segment.

[0152] Assume that when searching for a file with the same name according to the file name, the slot F2 (corresponding to the slot identifier 10) is found in the first-level directory according to the slot index identifier of the file name. At this time, the record corresponding to the file to be inserted is stored in the following manner: Figure 6B (b) In the vacant slot of segment D2 associated with slot F2 shown.

[0153] In other embodiments, for the case where not only the segments in the second-layer directory need to be increased, but also the slots in the first-layer directory need to be increased. Specifically, a space twice the original capacity is applied for in the DRAM where the first-layer directory is located. It can be understood that it is assumed that the slots in the original first-layer directory are numbered in sequence starting from 0. That is, slot F0 is at 0, slot F1 is at 1..., slot Fi is at i, and the global depth is increased by 1, that is, the slot identifier in the new first-layer directory is represented by the bit corresponding to the new global depth value. The value at index i in the original first-layer directory (assuming that slot F0 in the original first-layer directory is at index 0) is filled into the new first-layer directory at indexes 2*i and 2*i+1. For example, for the slot content corresponding to 0 in the original first-layer directory, fill it into 0 and 1 in the new first-layer directory. It can be understood that at this time, the number of slots in the first-layer directory associated with a segment in the original second-layer directory will become twice the original. Furthermore, after the first-layer directory is expanded, the slot identifiers in the first-layer directory corresponding to each segment in the second-layer directory change, that is, the slot identifiers corresponding to the first-layer slots associated with the search segment also change.

[0154] It is understandable that at this time, the situation will be converted into a situation where there is no need to increase the slots in the first-level directory. Specifically, the storage space of the segment can be increased, that is, it is understandable that when the segment in the second-level directory is expanded, an application is made in the persistent memory (for example, NVM) to increase the space of a segment, and some records in the search segment in the original second-level directory are moved into the new segment. Among them, when some records in the search segment in the original second-level directory are moved into the new segment, due to the change in the global depth, it is necessary to obtain the slot index identifier of the bit corresponding to the new global depth value in the file name of the inserted file (for example, when the global depth is +1, a number of 1 bit will be selected in sequence on the basis of the bit selection corresponding to the original slot index identifier to obtain a new slot index identifier), and some records in the search segment in the original second-level directory are moved into the new segment according to the new slot index identifier, and then the records corresponding to the required inserted file are stored in the segment associated with the slot in the first-level directory corresponding to the new slot index identifier.

[0155] For example, Figure 6C As shown above Figure 3C By comparison, at this time, 8 slots are applied for in the memory where the new first-level directory is located, and slots F0', slot F1', slot F2', slot F3', slot F4', slot F5', slot F6', slot F7' are obtained, corresponding to 0, 1, ..., 7 respectively. Figure 3C Slot F0 in Figure 6C The contents of slots F0' and F1' in the corresponding slots are Figure 3C Slot F1 in the Figure 6C The contents of slots F2' and F3' in the corresponding slots, Figure 3C Slot F2 in the Figure 6C The contents of slots F4' and F5' in the corresponding slots are Figure 3C Slot F3 in the Figure 6C The content in slots F6' and F7' in the first-level directory corresponds to the content in slots F6' and F7'. The global depth is G=lg8=3. In addition, slots F0' and F1' in the first-level directory are associated with segment D0, slots F2' and F3' in the first-level directory are associated with segment D1, and slots F4', F5', F6' and F7' in the first-level directory are associated with segment D2. In addition, the slot identifiers corresponding to the 8 slots in the first-level directory are 000, 001, 010, 011, 100, 101, 110 and 111 respectively.

[0156] For example, refer to Figure 6C as well as Fig.6D At this time, assuming that the file with the same name was not found in segment D0, there is no free slot in segment D0. Figure 6CAfter increasing the number of slots in the first-level directory, a new segment D0' is added corresponding to segment D0, and segment D0' is associated with slot F1'. Figure 6C The record corresponding to the slot identifier of the slot F1' corresponding to the file is migrated to segment D0', and the migrated slot record in D0 is deleted. For the record to be inserted, it is assumed that the new slot index identifier corresponding to the file name is 001. At this time, the record corresponding to the file to be inserted is stored in the vacant slot of segment D0' corresponding to slot F1'.

[0157] It is understandable that when the file system implements the expansion file sub-operation through multiple threads, the configured HTM can be started. If under HTM, multiple threads fail to execute after multiple conflicts, the atomic operation lock in the slot in the first-level directory can be enabled to prevent multiple threads from conflicting and failing to execute successfully. Figure 6C The expansion situation shown in the figure briefly introduces a situation in which the file system enables the HTM process to expand the first-level directory.

[0158] like Figure 6C The method of expanding the slots in the first-level directory shown in FIG. 1 is that after the file system applies for 8 slots in DRAM, the expansion is realized through 4 threads, and each thread corresponds to an HTM when executing. When each thread completes the related operations of expanding the first-level directory, the HTM corresponding to the thread ends. Specifically, Figure 6C As shown in the figure, each of thread 1, thread 2, thread 3, and thread 4 has a corresponding HTM. Thread 1 can be used to implement Figure 3C The content of the original slot F0 is copied to slot F0' and slot F1', thread 2 can be used to copy the content of the original slot F1 to slot F2' and slot F3', thread 3 can be used to copy the content of the original slot F2 to slot F4' and slot F5', thread 4 can be used to copy the content of the original slot F3 to slot F6' and slot F7', and the content in the slot is adaptively modified. At this time, the slot identifier of each slot is 3 bits, and the corresponding global depth is +1. Each thread will release the old first-level directory space in DRAM, and the HTM corresponding to each thread ends.

[0159] S606, Insertion failed.

[0160] It can be understood that the execution order of the above steps S601 to S606 is only an example. In other embodiments, other execution orders may be adopted, and some steps may be split or combined, which is not limited here.

[0161] It is understandable that when it is necessary to change or delete a file in the file system, it is also necessary to operate according to the specific operation method corresponding to the query file mentioned above. After finding the specific file according to the corresponding search method, the content of the file can be changed or deleted.

[0162] Fig. 7A According to some embodiments of the present application, an index system architecture is shown. The framework stores the first-level directory in DRAM and the second-level directory in NVM, and specifically describes the electronic device supporting the eADR environment as an example. It can be understood that since NVM is non-volatile, the data stored in NVM is persistent.

[0163] like Fig. 7A As shown in , the index system architecture includes a user application 701, a system kernel 702, and a file system 703. When the user application 701 detects a user operation corresponding to a file (e.g., insert, query, etc.), a system call is made to call the system kernel 702, and the system kernel 702 calls the file system 703, and the file system 703 performs a specific file operation (e.g., insert, query, etc.).

[0164] Specifically, the file system 703 includes an index module 7031 , a persistent memory 7032 , a memory 7033 , a persistence module 7034 , and an allocation module 7035 .

[0165] The index module 7031 is used to execute the file indexing process related to the file operation performed by the above-mentioned file system.

[0166] The persistent memory 7032 is a memory with a persistent function, which does not cause data loss after power failure, for example, NVM.

[0167] The memory 7033 is a memory with a simple storage function, for example, DRAM.

[0168] The allocation module 7035 is used to allocate storage space to the directory structure when constructing a two-layer directory structure, and to allocate storage space in the memory 7033 and the persistent memory 7032 respectively when the first-layer directory or the second-layer directory needs to be expanded when inserting a file.

[0169] The persistence module 7034 is used to control the process of placing data in the persistent memory 7032.

[0170] It can be understood that the index module 7031 can call the persistent memory 7032, the memory 7033, the persistence module 7034, and the allocation module 7035 during the execution of the file indexing process.

[0171] Among them, corresponding to the establishment of a two-layer directory structure when the file system is initialized, it can be: the allocation module 7035 will apply for persistent memory space (for example, apply for the use of NVM storage space) for the mounted root directory to place the second-layer directory. When the user application 701 initiates a system call to request a new file or a new directory, the system kernel 702 receives the call and calls the index module 7031 in the file system 703 for processing. For example, for the first file insertion operation, the allocation module 7035 will allocate memory space in the memory 7033 to place the first-layer directory, thereby establishing a two-layer directory structure. The index module 7031 in the file system 703 searches for the corresponding slot in the first-layer directory according to the slot identifier of the file name, and searches for the slot corresponding to the identification identifier in the file name in the segment associated with the slot found in the first-layer directory. If the required file cannot be found according to the identification identifier in the file name, and then it is determined that the associated segment in the second-layer directory is not full, the content corresponding to the file is filled into the second-layer directory. If the corresponding segment of the second-level directory is full, the first-level directory or the second-level directory is expanded according to the situation, and the information is filled in after the expansion.

[0172] It can be understood that the index system architecture shown above is only an example. In other embodiments, other modules may be included, and some modules may be split or merged, which is not limited here.

[0173] like Figure 7B An embodiment of the present application provides another indexing device, which includes a first acquisition module, a first determination module, and a second acquisition module.

[0174] A first acquisition module, the first acquisition module is used to acquire a file index, the first file index includes a slot index identifier in the file index and an identification identifier in the file index;

[0175] A first determination module, the first determination module is used to determine the corresponding slot in the slots in the first-level directory according to the slot index identifier in the file index, wherein in each segment of the second-level directory, there is a segment associated with the determined slot in the first-level directory (referred to as the associated segment), and each segment includes the same number of slots;

[0176] The second acquisition module is used to obtain the file corresponding to the file index based on the identification mark in the file index and each slot of the associated segment.

[0177] Figure 8 According to some embodiments of the present application, a schematic diagram of the test effect of the two-layer directory index structure in an actual application scenario is shown. Figure 8 As shown, it shows the test results of different file systems corresponding to different directory structures under 4 actual directory applications.

[0178] It is understandable that when corresponding to different threads, the number of file operations that each file system can support is different.

[0179] Specifically, the actual directory application scenarios are as follows:

[0180] a) MWCL corresponds to the application scenario of creating new files in different directories.

[0181] b) MWCM corresponds to the application scenario of creating a new file in the same directory.

[0182] c) MRDL corresponds to the application scenario of reading content in different directories.

[0183] d)MRDM corresponds to the application scenario of reading the contents in the same directory.

[0184] Among them, Ext4-dax is a traditional file system, the EulerFS file system is a currently more commonly used file system, and EulerFS-S is a file system based on the EulerFS file system, using the two-layer index directory structure of this application and combined with HTM.

[0185] Figure 8 (a) is the effect diagram of the corresponding MWCL application scenario. Figure 8 (b) is the effect diagram of the corresponding MWCM application scenario. Figure 8 (c) is the effect diagram of the corresponding MRDL application scenario. Figure 8 (d) is the effect diagram of the corresponding MRDM application scenario. The horizontal axis (threads) is the number of threads, and the vertical axis (M ops / sec) is the number of operations per second. From the figure, we can see that in these four application scenarios, when the file system executes the same number of threads, the number of operations supported by the EulerFS-S file system is the largest. Moreover, when the number of operations per second of each file system is the same, the number of threads supported by the EulerFS-S file system is the largest.

[0186] Table 1 below shows, in different application scenarios, a table showing the ratio of the number of operations per second (referred to as throughput in the table) that can be supported by the EulerFS-S file system using the two-layer directory structure of the present application and combined with HTM, compared with the other two EXT4-dax file systems and the EulerFS file system.

[0187] As can be seen from Table 1, in the MWCL application scenario, when the number of threads is 56, the throughput of EulerFS-S is about 2 Mops / sec, which is 8.0 times that of EXT4-dax and 7.15 times that of EulerFS under the same conditions. When the number of threads is 7, the throughput of EulerFS-S is about 1.43 Mops / sec, which is 5.11 times that of EXT4-dax and 7.15 times that of EulerFS under the same conditions.

[0188] In the MWCM application scenario, when the number of threads is 56, the throughput of EulerFS-S is about 0.15M ops / sec, which is 3.11 times that of EXT4-dax and 3.02 times that of EulerFS under the same conditions. When the number of threads is 7, the throughput of EulerFS-S is about 0.165M ops / sec, which is 1.75 times that of EXT4-dax and 5.53 times that of EulerFS under the same conditions.

[0189] In the MRDL application scenario, when the number of threads is 56, the throughput of EulerFS-S is about 501M ops / sec, which is 8.01 times that of EXT4-dax and 1.07 times that of EulerFS under the same conditions. When the number of threads is 7, the throughput of EulerFS-S is about 65Mops / sec, which is 1.03 times that of EXT4-dax and 1.03 times that of EulerFS under the same conditions.

[0190] In the MRDM application scenario, when the number of threads is 56, the throughput of EulerFS-S is about 501M ops / sec, which is 53.3 times that of EXT4-dax and 129.4 times that of EulerFS under the same conditions. When the number of threads is 7, the throughput of EulerFS-S is about 64M ops / sec, which is 7.9 times that of EXT4-dax and 8.2 times that of EulerFS under the same conditions.

[0191] It is understandable that the access performance is not good enough compared with the traditional file system. After applying the technology of this application, the concurrent access performance of the file system is improved and the throughput rate is significantly improved.

[0192] Table 1

[0193]

[0194] Fig. 9 According to an embodiment of the present application, a hardware structure diagram of an electronic device 100 is shown. The electronic device 100 is provided with a file system, which can cooperate with the file indexing method provided in the embodiment of the present application. Fig. 9 In the drawings, similar parts have the same reference numerals. Fig. 9As shown, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0195] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0196] The processor 110 may include one or more processing units, for example, a processing module or processing circuit including a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), a microprocessor (MCU), an artificial intelligence (AI) processor or a programmable logic device (FPGA). Different processing units may be independent devices or integrated into one or more processors. The processor 110 may support file system operation.

[0197] The memory can be used to store data, software programs and modules, and can be a volatile memory (volatile memory), such as a random-access memory (RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or a combination of the above types of memory, or it can also be a removable storage medium, such as a secure digital (SD) memory card.

[0198] The charging management module 140 may include a power source, a power management component, etc. The power source may be a battery. The power management component is used to manage the charging of the power source and the power supply of the power source to other modules. The charging management module is used to receive charging input from the charger; the power management module is used to connect the power source, the charging management module and the processor 110.

[0199] The mobile communication module 150 may include, but is not limited to, an antenna, a power amplifier, a filter, a low noise amplifier (LNA), etc. The mobile communication module 150 may provide a solution for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may receive electromagnetic waves by an antenna, and perform filtering, amplification, and other processing on the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 may also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be arranged in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be arranged in the same device as at least some of the modules of the processor 110.

[0200] The wireless communication module 160 may include an antenna, and transmit and receive electromagnetic waves via the antenna. The wireless communication module 160 may provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., applied to the electronic device 100. The electronic device 100 may communicate with the network and other devices through wireless communication technology.

[0201] In some embodiments, the mobile communication module 150 and the wireless communication module 160 of the electronic device 100 may also be located in the same module.

[0202] The camera 193 is used to capture still images or videos. The optical image generated by the lens is projected onto the photosensitive element. The photosensitive element converts the optical signal into an electrical signal, which is then passed to an image signal processor (ISP) to be converted into a digital image signal. The electronic device 100 can achieve a shooting function through the ISP, the camera 193, a video codec, a graphic processing unit (GPU), a display screen, and an application processor.

[0203] The display screen includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Mini LED, Micro LED, Micro OLED, quantum dot light-emitting diodes (QLED), etc.

[0204] The audio module 170 can convert digital audio information into analog audio signal output, or convert analog audio input into digital audio signal. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

[0205] The interface module includes an external memory interface, a universal serial bus (USB) interface, and a subscriber identification module (SIM) card interface. The external memory interface can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface to implement a data storage function. The universal serial bus interface is used for the electronic device 100 to communicate with other mobile phones. The subscriber identification module card interface is used to communicate with a SIM card installed in the electronic device 100, for example, to read a phone number stored in the SIM card, or to write a phone number into the SIM card.

[0206] In some embodiments, the electronic device 100 further includes buttons, motors, and indicators. The buttons may include volume buttons, power on / off buttons, etc. The motor is used to make the electronic device 100 vibrate, for example, when the user's electronic device 100 receives a new IM APP message, vibration is generated to prompt the user to check the message. The indicator may include a laser indicator, a radio frequency indicator, an LED indicator, etc.

[0207] It is understandable that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100 .

[0208] The various embodiments of the mechanism disclosed in the present application can be implemented in hardware, software, firmware or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device and at least one output device.

[0209] Program code can be applied to input instructions to perform the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0210] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.

[0211] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, including, but not limited to, floppy disks, optical disks, optical disks, read-only memories (CD-ROMs), magneto-optical disks, read-only memories (ROMs), random access memories (RAMs), erasable programmable read-only memories (EPROMs), electrically erasable programmable read-only memories (EEPROMs), magnetic or optical cards, flash memory, or a tangible machine-readable memory for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in electrical, optical, acoustic, or other forms of propagation signals. Therefore, machine-readable media include any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a machine (e.g., computer) readable form.

[0212] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.

[0213] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation method of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed by the present application. In addition, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed by the present application, which does not mean that there are no other units / modules in the above-mentioned device embodiments.

[0214] It should be noted that in the examples and description of this patent, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one" do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0215] Although the present application has been illustrated and described with reference to certain preferred embodiments thereof, it will be apparent to those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present application.

Claims

1. An indexing method, characterized in that: include: Obtain a first file index, wherein the first file index includes a first index part L1 and a second index part L2; According to the first index part L1, a first-level directory element S1n is determined from the m first-level directory elements in the first-level directory, wherein: Among the n secondary directory elements of the second-level directory, there is a secondary directory element S2m associated with the first-level directory element S1n, and the n secondary directory elements each include p index information spaces X1-Xp; Based on the second index part L2 and the p index information spaces X1-Xp of the secondary directory element S2m, the file corresponding to the first file index is obtained.

2. The method according to claim 1, characterized in that The p index information spaces X1-Xp constitute j bucket index spaces T1-Tj, and each of the bucket index spaces includes i index information spaces, where i*j=p; and the first file index also includes a third index part L3.

3. The method according to claim 2, characterized in that The obtaining of the file corresponding to the first file index based on the p index information spaces X1-Xp of the second index part L2 and the secondary directory element S2m comprises: According to the third index part L3, a first bucket index space Td corresponding to the third index part L3 is selected from the j bucket index spaces T1-Tj of the secondary directory element S2m; Based on the second index part L2 and the i index information spaces of the first bucket index space Td, the file corresponding to the first file index is obtained, wherein the i index information spaces of the first bucket index space Td belong to the p index information spaces X1-Xp of the secondary directory element S2m.

4. The method according to claim 3, characterized in that The obtaining the file corresponding to the first file index based on the i index information spaces of the second index part L2 and the first bucket index space Td includes: Selecting a first index information space Xc corresponding to the second index part L2 from the first bucket index space Td; Based on the selected first index information address Dt in the first index information space Xc, the file corresponding to the first file index is obtained.

5. The method according to claim 3, characterized in that: The obtaining the file corresponding to the first file index based on the i index information spaces of the second index part L2 and the first bucket index space Td includes: No index information space corresponding to the second index part L2 is found in the first bucket index space Td; In the secondary directory element S2m, the second index information space Xq corresponding to the second index part L2 is found in the second bucket index space Tv associated with the first bucket index space Td as the first index information space Xc.

6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: A second file index is obtained, where the second file index includes a fourth index part L4 and a fifth index part L5; According to the fourth index part L4, determining a first-level directory element S1p from the m first-level directory elements in the first-level directory; Based on the fifth index part L5, the file corresponding to the second file index cannot be obtained through the second directory element S2u associated with the first directory element S1p.

7. The method according to claim 6, characterized in that The process of failing to obtain a file corresponding to the second file index through the second directory element S2u associated with the first directory element S1p based on the fifth index part L5 includes: The second-level directory element S2u associated with the first-level directory element S1p does not include the index information space corresponding to the fifth index part L5; or, The second-level directory element S2u associated with the first-level directory element S1p includes a second index information space Xh corresponding to the fifth index part L5, and The file corresponding to the second index information address Ds in the second index information space Xh does not match the file corresponding to the second file index.

8. The method according to claim 6 or 7, characterized in that: The method further comprises: Among the p index information spaces X1-Xp corresponding to the secondary directory element S2u, there is at least one free index information space; The first relevant content of the file corresponding to the second file index is stored in the first free index information space Xk in the at least one free index information space, wherein the first relevant content is used to match the second file index and to find the file index information of the file corresponding to the second file index.

9. The method according to claim 6 or 7, characterized in that: Also includes: There is no free index information space in the p index information spaces X1-Xp corresponding to the second-level directory element S2u, and the second-level directory element S2u is associated with at least two of the m first-level directory elements in the first-level directory; A secondary directory element S2k is added to the second-level directory, and the secondary directory element S2k has an associated first-level directory element S1k in the first-level directory, wherein before the secondary directory element S2k is added to the second-level directory, the first-level directory element S1k is associated with the secondary directory element S2u, and the first-level directory element S1k is the same as or different from the first-level directory element S1p.

10. The method according to claim 9, characterized in that Among the p index information spaces X1-Xp of the secondary directory element S2u, f index information spaces Xf1-Xff correspond to the primary directory element S1k, and the method further includes: Migrate the contents of the f index information spaces Xf1-Xff to the f index information spaces Xf1-Xff in the secondary directory element S2k; Furthermore, corresponding to the first-level directory element S1k being the first-level directory element S1p, the first relevant content of the file corresponding to the second file index is stored in the free index information space in the second-level directory element associated with the first-level directory element S1p.

11. The method according to claim 6 or 7, characterized in that: The method further includes: there is no free index information space in the p index information spaces X1-Xp corresponding to the second-level directory element S2u, and the second-level directory element S2u is associated with only one first-level directory element S1p among the m first-level directory elements in the first-level directory; Increase the number of m first-level directory elements in the first-level directory to 2*m first-level directory elements, and associate the second-level directory element S2u with the two first-level directory elements S1t and S1o; A second-level directory element S2w is added to the second-level directory, and the second-level directory element S2w has an associated first-level directory element S1z in the first-level directory, wherein the first-level directory element S1z is any one of the first-level directory elements S1t and S1o.

12. The method according to claim 11, characterized in that Among the p index information spaces X1-Xp of the secondary directory element S2u, f index information spaces Xf1-Xff correspond to the primary directory element S1z, and the method further includes: Migrate the contents of the f index information spaces Xf1-Xff to the f index information spaces Xf1-Xff in the secondary directory element S2w; And, obtaining a sixth index part L6 in the second file index, wherein the sixth index part L6 includes the fourth index part L4, and the sixth index part L6 corresponds to a first-level directory element S1d in the first-level directory, wherein the first-level directory element S1d is any one of the first-level directory elements S1t and S1o; The first relevant content of the file corresponding to the second file index is stored in the free storage information space in the second-level directory element associated with the first-level directory element S1d.

13. An electronic device, characterized in that: include: one or more processors; One or more memories; the one or more memories store one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device executes the indexing method described in any one of claims 1 to 12.

14. A computer-readable storage medium, characterized in that: The storage medium stores instructions, which, when executed on a computer, cause the computer to execute the indexing method according to any one of claims 1 to 12.

15. A computer program product comprising instructions, characterized in that When the computer program product is executed on a computer, the computer is enabled to execute the indexing method according to any one of claims 1 to 12.