A file management method and device
By combining adjacency lists and path enumeration in file management, a file adjacency list containing file storage paths is constructed, which solves the problems of low query efficiency and complex path maintenance in existing technologies, and achieves efficient file management and improved user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- E-SURFING DIGITAL LIFE TECH CO LTD
- Filing Date
- 2023-10-09
- Publication Date
- 2026-06-19
AI Technical Summary
Existing tree-structured storage models suffer from low query efficiency, complex path enumeration maintenance, and frequent updates in file management, which negatively impacts user experience, especially in cloud storage applications.
A file adjacency table is constructed by combining adjacency lists and path enumeration. The adjacency table includes file ID, file name, parent file ID, and file storage path. File query and management operations are performed through this table, reducing the maintenance cost of path enumeration.
It improves file query efficiency, reduces the maintenance cost of path enumeration, and enhances user experience.
Smart Images

Figure CN117370279B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data management, and more particularly to a file management method and apparatus. Background Technology
[0002] Common tree-structured storage models in existing technologies include adjacency lists, path enumerations, nested sets, and closure tables; however, each type has its own drawbacks. For example, adjacency lists store the parent node of each node, which is convenient to use, but when there are too many node levels, querying becomes difficult. While path enumerations can intuitively display the path relationships between ancestors and descendants in the structure, they cannot ensure reference integrity, making data storage redundant and relationship maintenance complex.
[0003] For example, in cloud storage applications that use adjacency lists, a common scenario is needing to query a list of files or folders based on file paths. When a user inputs a complete path on the front end, the application needs to find the corresponding folder based on that path and return the complete path of each file or folder. Understandably, the adjacency list only stores the mapping between the file and its parent file (i.e., the parent file ID). To perform a complete path query, recursive queries are required, which is extremely inefficient.
[0004] While path enumeration storage designs excel at handling such scenarios, they suffer from high storage overhead and complex path maintenance. Furthermore, path enumeration involves file operations (renaming, copying, moving, etc.), requiring batch updates of file paths, resulting in frequent updates and a large number of update records. For cloud storage applications, approximately 90% of business requests are file queries, so query efficiency directly impacts user experience. Existing file management methods cannot meet user needs.
[0005] In order to overcome the above-mentioned defects in the existing technology, there is an urgent need in the field for a file management method and apparatus that can improve file query efficiency by using a combination of adjacency list and path enumeration, while reducing the maintenance cost of path enumeration. Summary of the Invention
[0006] The following provides a brief overview of one or more aspects to offer a basic understanding of them. This overview is not an exhaustive summary of all conceived aspects, nor is it intended to identify key or decisive elements of all aspects, nor to define the scope of any or all aspects. Its sole purpose is to present some concepts of one or more aspects in a simplified form to prepare for the more detailed descriptions that follow.
[0007] To overcome the aforementioned deficiencies in the existing technology, the present invention provides a file management method, comprising: constructing a file adjacency table, wherein the fields in the file adjacency table include file ID, file name, parent file ID, and whether the file type is a folder; for folder-type files, the fields in the file adjacency table also include file storage path, wherein the file storage path does not include the file name of the folder; and performing file management operations based on the file adjacency table.
[0008] Optionally, the file management operation based on the file adjacency list includes: performing a file query operation based on the file adjacency list. The file query operation includes querying a list of subfiles of the file based on the complete file path passed from the front end, and querying the complete file path of the file based on the file ID. The complete file path consists of the file storage path and the file name.
[0009] In one embodiment, preferably, the process of querying the list of subfiles of a file based on the complete file path passed from the front end may include: matching the file storage path field and the file name field in the file adjacency table based on the complete file path of the file, while the file type is a folder, to find the file in the file adjacency table; and using the file ID field of the found file as the parent file ID, and then searching again to match the parent file ID field in the file adjacency table to obtain the list of subfiles of the file.
[0010] In one embodiment, preferably, querying the complete file path of a file based on a file ID may include: matching the file ID field in the file adjacency table to find the file; and in response to the found file being a folder type, combining the file storage path field and the file name field of the file in the file adjacency table to form the complete file path of the file.
[0011] In one embodiment, preferably, the query for the complete file path of a file based on its file ID may further include: in response to the found file being a file type, using the parent file ID field of the file in the file's adjacency table as a new query condition to search the file's adjacency table again; and combining the found parent file's storage path field with its file ID field to obtain the complete file path of the parent file, and then combining the complete file path of the parent file with the file name of the file to obtain the complete file path of the file.
[0012] In one embodiment, preferably, the file management operation based on the file adjacency list may include: updating the file storage path field in the file adjacency list after performing a specific file management operation, which includes copying, moving, and renaming the file.
[0013] In one embodiment, preferably, updating the file storage path field in the file adjacency table after performing a specific file management operation may include: responding to the file object performing the specific file management operation being a non-folder type, or performing a renaming operation for a folder type that does not have subfolders, or performing the specific file management operation within the same file directory, without needing to update the file storage path field; and responding to performing a copy or move operation for a folder type that does not have subfolders, updating the current file storage path field of the folder.
[0014] In one embodiment, preferably, updating the file storage path field in the file adjacency table after performing a specific file management operation may include: in response to the file object performing the specific file management operation being a folder type with subfolders, searching and traversing the list of subfiles of the file, and updating the file storage path field of the subfolders of the file in the file adjacency table.
[0015] Another aspect of the present invention provides a file management apparatus, comprising: a memory; and a processor coupled to the memory, the processor being configured to perform the file management method as described in any of the preceding descriptions.
[0016] The present invention also provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the file management method as described in any of the above. Attached Figure Description
[0017] The above-described features and advantages of the present invention will be better understood after reading the following detailed description of embodiments of the present disclosure in conjunction with the accompanying drawings. In the drawings, components are not necessarily drawn to scale, and components having similar related properties or features may have the same or similar reference numerals.
[0018] Figure 1 This is a flowchart illustrating a document management method according to one aspect of the present invention;
[0019] Figure 2 This is a flowchart illustrating a method for querying a subfolder of a file based on its complete file path, according to an embodiment of the present invention.
[0020] Figure 3 This is a flowchart illustrating a method for querying the complete file path of a file based on a file ID, according to an embodiment of the present invention.
[0021] Figure 4 This is a schematic flowchart illustrating a file path update method according to an embodiment of the present invention; and
[0022] Figure 5This is a schematic diagram of the device structure of a document management apparatus according to another aspect of the present invention. Detailed Implementation
[0023] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Although the description of the present invention is presented in conjunction with preferred embodiments, this does not mean that the features of the invention are limited to these embodiments. On the contrary, the purpose of describing the invention in conjunction with embodiments is to cover other options or modifications that may be derived based on the claims of the present invention. To provide a thorough understanding of the invention, many specific details will be included in the following description. The invention may also be implemented without using these details. Furthermore, to avoid confusion or obscuring the focus of the invention, some specific details will be omitted in the description.
[0024] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0025] Furthermore, the terms "upper," "lower," "left," "right," "top," "bottom," "horizontal," and "vertical" used in the following description should be understood as the orientations shown in the relevant paragraphs and accompanying drawings. These relative terms are for illustrative purposes only and do not imply that the described apparatus must be manufactured or operated in a specific orientation, and therefore should not be construed as limiting the invention.
[0026] It is understood that although terms such as "first," "second," and "third" may be used herein to describe various components, regions, layers, and / or parts, these components, regions, layers, and / or parts should not be limited by these terms, and these terms are only used to distinguish different components, regions, layers, and / or parts. Therefore, the first components, regions, layers, and / or parts discussed below may be referred to as second components, regions, layers, and / or parts without departing from some embodiments of the present invention.
[0027] To overcome the aforementioned deficiencies in the existing technology, the present invention provides a file management method and apparatus that improves file query efficiency by combining an adjacency list with path enumeration, thereby reducing the maintenance cost of path enumeration.
[0028] Figure 1This is a schematic diagram illustrating a document management method according to one aspect of the present invention.
[0029] Please refer to Figure 1 The file management method 100 provided by the present invention includes:
[0030] Step 101: Construct a file adjacency table. The fields in this adjacency table include file ID, file name, parent file ID, and whether the file type is a folder. For folder-type files, the adjacency table also includes the file storage path, which does not include the folder's filename.
[0031] Step 102: Perform file management operations based on the file's adjacency list.
[0032] Table 1 is a file adjacency table illustrated according to an embodiment of the present invention.
[0033] Table 1. Examples of file adjacency representation
[0034]
[0035] As shown in Table 1, the file adjacency table in the file management method provided by the present invention mainly includes fields such as file ID, file name, whether it is a folder, file path, file size, and parent file ID, where the parent file refers to the parent file of the file.
[0036] As can be seen, compared with the adjacency list in the prior art, the adjacency list in this invention adds a file storage path field for folder-type files, and the file storage path does not include the file name of the current file.
[0037] In a preferred embodiment, the file management method provided by the present invention, which performs file management operations based on a file adjacency list, may include: performing a file query operation based on the file adjacency list. The file query operation includes querying a list of subfiles of the file based on the complete file path passed in from the front end, and querying the complete file path of the file based on the file ID. The complete file path consists of the file storage path and the file name.
[0038] Preferably, the process of querying the list of subfiles of a file based on the complete file path passed from the front end can further include: matching the file storage path field and the file name field in the file adjacency table based on the complete file path of the file, while the file type is a folder, to find the file in the file adjacency table; and using the file ID field of the found file as the parent file ID, and searching again to match the parent file ID field in the file adjacency table to obtain the list of subfiles of the file.
[0039] It can be seen that when using the file adjacency table provided by this invention for file management, only two queries are needed when querying the list of subfiles (including the complete path of each subfile) using the full path. The process is described in detail below.
[0040] Taking the file adjacency table in Table 1 as an example, let's say we need to query the list of subfiles based on the full path a( / All Files / My Pictures / Travel / 2023 / January / ). Understandably, since only folders can contain subfile lists, this full path must be a folder.
[0041] In this embodiment, the first file query is performed: The file adjacency table 1 is queried, and the query condition is "file path field + file name field = the complete path to be queried 'a', and it is a folder". This yields the file ID1 (i.e., file ID = 5) corresponding to the current folder. The database query expression and results are as follows:
[0042] SQL: select * from file_table where file_path + file_name = ' / all_files / my_pictures / travel / 2023 / January / ' and is_folder = 'is';
[0043]
[0044] Next, a second query is performed: using the file ID1 obtained in the first query as the parent file ID to query the database (i.e., parent file ID = 5), the query condition is "parent file ID = 5", which yields a list of child files (i.e., the corresponding file IDs are 6, 9, and 12). The database query expression and results are as follows:
[0045] SQL: select * from file_table where parent_file_ID = 5;
[0046]
[0047]
[0048] Figure 2 This is a flowchart illustrating a method for querying subfolders of a file based on its complete file path, according to an embodiment of the present invention. (Refer to the reference.) Figure 2 This allows for a better understanding of the steps involved in querying a list of subfiles using the full path in the file management method provided by this invention.
[0049] like Figure 2As shown, when searching for a list of subfiles using a full path, the process first retrieves a list of files or folders and the full path of each file based on the full path ( / All Files / My Pictures / Travel / 2023 / January / ). Next, the full path is split into two parts: the last part is used as the filename (January), and the remaining part is used as the file path ( / All Files / My Pictures / Travel / 2023 / ). This retrieves the current folder information (file ID 5). Then, the file ID from the previous step is used as the parent file ID to search the file table, yielding a list of 1 subfiles or folders (file IDs include 6, 9, and 12). The file paths of the subfiles are then padded with the full path (file ID 12). File paths already existing in subfolders do not need to be padded. After the traversal is complete, the file list search results are returned.
[0050] As can be seen, in the file management method provided by this invention, no matter how deep the file hierarchy is, querying the list of subfiles (including the complete path of each subfile) using the full path only requires two queries to obtain the result, which greatly improves the query efficiency.
[0051] The file query operation also includes querying the complete file path of the file based on the file ID. In one embodiment, querying the complete file path of the file based on the file ID may include: matching the file ID field in the file adjacency table to find the file; and in response to the found file being a folder type, combining the file storage path field and the file name field of the file in the file adjacency table to form the complete file path of the file.
[0052] Furthermore, preferably, the process of querying the complete file path of a file based on its file ID may further include: in response to the found file being a file type, using the parent file ID field of the file in the file's adjacency table as a new query condition to search the file's adjacency table again; and combining the found parent file's storage path field with its file ID field to obtain the complete file path of the parent file, and then combining the complete file path of the parent file with the file name of the file to obtain the complete file path of the file.
[0053] The following explanation will continue using Table 1 as an example.
[0054] First, if the file type you need to query is a folder (e.g., file ID = 9), the database will be queried only once when querying the full file path:
[0055] The database is queried based on the file ID (file ID = 9). The query condition is "file ID = 9". If the query result is a folder, the file path field and file name field are concatenated to obtain the complete path ( / All Files / My Pictures / Travel / 2023 / January / 10th / ). The database query expression and results are as follows:
[0056] SQL: select * from file_table where fileID = 9;
[0057]
[0058] In another scenario, if the file to be queried is a file (e.g., file ID = 12), querying the full file path only requires two database queries, as detailed below.
[0059] First query: Query the database based on file ID1 (file ID=12), with the query condition "file ID=12". If the query result is a file, then retrieve the parent file ID2 (parent file ID=5) and the current file name 3 (1.txt). The database query expression and results are as follows:
[0060] SQL: select * from file_table where fileID = 12;
[0061] File ID File Name It is a folder File storage path File size Parent file ID 12 1.txt no 5 5
[0062] The second query: Using the parent file ID2 obtained in the first query as the file ID, the database is queried (i.e., file ID = 5). The query condition is "file ID = 5". The file path field and file name field of the query result are concatenated to obtain the complete path of the parent file ( / all files / my pictures / travel / 2023 / January / ). Then, the complete path of the parent file is concatenated with the file name 3 from the first query to obtain the complete path of file ID1 ( / all files / my pictures / travel / 2023 / January / 1.txt). The database query expression and results are as follows:
[0063] SQL: select * from file_table where fileID = 5;
[0064]
[0065] You can refer to the following: Figure 3 . Figure 3 This is a flowchart illustrating a method for querying the complete file path of a file based on a file ID, according to an embodiment of the present invention.
[0066] like Figure 3As shown, firstly, the file information 1 is obtained by querying the file table based on the file ID; then, it is determined whether the current file is a folder. If it is a folder, the file path is directly obtained from the file information 1 and returned; if it is a file, the parent file ID of the file information 1 is used to query the file table to obtain the parent folder information 2. The file path and file name are obtained from the parent folder information 2 to get the complete path, and finally the query result is returned.
[0067] Combination Figure 3 Analysis shows that, regardless of the depth of the file hierarchy, the file management method provided by this invention requires at most two database queries when querying the complete file path using the file ID. Specifically, two queries are required for file types, while only one query is required for folder types. Therefore, the file management method provided by this invention requires at most two database queries when querying the complete file path using the file ID, which greatly improves query speed and file management efficiency.
[0068] In addition, in a preferred embodiment of the present invention, the file management operation based on the file adjacency list may further include: updating the file storage path field in the file adjacency list after performing a specific file management operation, wherein the specific file management operation includes copying, moving and renaming the file.
[0069] Further, preferably, updating the storage file path field in the adjacency table of the file after performing a specific file management operation may include: responding to the file object performing the specific file management operation being a non-folder type, or performing a renaming operation for a folder type that does not have subfolders, or performing the specific file management operation within the same file directory, without needing to update the file storage path field; and responding to performing a copy or move operation for a folder type that does not have subfolders, updating the current file storage path field of the folder.
[0070] Furthermore, updating the file storage path field in the file adjacency table after performing a specific file management operation may also include: in response to the file object performing the specific file management operation being a folder type with subfolders, searching and traversing the list of subfiles of that file, and updating the file storage path field of the subfolders of that file in the file adjacency table. (See reference...) Figure 4 .
[0071] Figure 4 This is a schematic flowchart illustrating a method for updating file paths according to an embodiment of the present invention.
[0072] Understandably, file path updates are triggered when a user initiates file operations, such as copying, moving, or renaming files, while file path updates are not triggered when files are added, deleted, or modified. Figure 4The file operations mentioned in the illustrated embodiments mainly refer to file copying, moving, and renaming operations.
[0073] like Figure 4 As shown, in the file management method provided by this invention, when updating the file path, it is first determined whether the current file is a folder. If it is a file, there is no need to update the file path field for renaming, copying, or moving the file.
[0074] Next, a fuzzy search of the file adjacency table is performed based on the current file path and file name to determine if the current folder contains subfolders. If the current folder does not contain subfolders, the renaming operation of the current folder does not require updating the file path. For copying and moving operations of the folder, only the file storage path field of the current folder needs to be updated.
[0075] Additionally, if the current folder contains subfolders, for folder renaming and moving operations, all subfolders need to be searched and their file paths updated. The process iterates through the subfolders, updating the file storage path field each time, before ending.
[0076] Continue to refer to Figure 4 For copying folders with subfolders, it is necessary to further determine whether the copy is made to the same directory. If the copy is made to the same directory, there is no need to maintain the file path; otherwise, all subfolders need to be searched and updated.
[0077] As can be seen from the above file path update process, the file management method provided by the present invention only saves the complete path of the folder, and the complete path does not include the current folder name. Therefore, the path information only needs to be maintained when the folder is renamed / copied / moved. File operations do not require path maintenance, which greatly reduces the path maintenance cost and improves the efficiency of file management.
[0078] In summary, the file management method provided by this invention overcomes the problems of existing file management methods where the more levels of the entire path, the lower the query and location efficiency and the longer the time consumption. By adopting a combination of adjacency list and path enumeration, the maintenance cost of path enumeration is reduced, the efficiency of file query and management is improved, and the user experience is enhanced.
[0079] Although the methods described above are illustrated and depicted as a series of actions for the sake of simplicity, it should be understood and appreciated that these methods are not limited by the order of the actions, as some actions may occur in a different order and / or concurrently with other actions from the illustrations and descriptions herein or not illustrated and described herein but which may be understood by those skilled in the art, according to one or more embodiments.
[0080] Figure 5This is a schematic diagram of the device structure of a document management apparatus according to another aspect of the present invention.
[0081] According to another aspect of the present invention, an embodiment of a file management device 500 is also provided herein.
[0082] like Figure 5 As shown, the file management device 500 provided in this embodiment may include a memory 501 and a processor 502 coupled to the memory 501. The processor 502 may be configured to implement any of the above-described file management methods.
[0083] According to another aspect of the invention, an embodiment of a computer storage medium is also provided herein.
[0084] The computer storage medium contains a computer program. When this computer program is executed by the processor, it can implement the steps of any of the above-mentioned file management methods.
[0085] Those skilled in the art will further appreciate that the various illustrative logic blocks, modules, circuits, and algorithm steps described in conjunction with the embodiments disclosed herein can be implemented as electronic hardware, computer software, or a combination of both. To clearly illustrate this interchangeability between hardware and software, the various illustrative components, blocks, modules, circuits, and steps are described above in a generalized manner in terms of their functionality. Whether such functionality is implemented as hardware or software depends on the specific application and the design constraints imposed on the overall system. Those skilled in the art may implement the described functionality in different ways for each specific application, but such implementation decisions should not be construed as departing from the scope of the invention.
[0086] The processor described herein can be implemented using electronic hardware, computer software, or any combination thereof. Whether such a processor is implemented as hardware or software will depend on the specific application and the overall design constraints imposed on the system. As an example, the processor, any part of the processor, or any combination of processors presented in this disclosure can be implemented using a microprocessor, microcontroller, digital signal processor (DSP), field-programmable gate array (FPGA), programmable logic device (PLD), state machine, gated logic, discrete hardware circuitry, and other suitable processing components configured to perform the various functions described throughout this disclosure. The functionality of the processor, any part of the processor, or any combination of processors presented in this disclosure can be implemented using software executed by a microprocessor, microcontroller, DSP, or other suitable platform.
[0087] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of both. The software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor such that the processor can read and write information to / from the storage medium. In an alternative, the storage medium may be integrated into the processor. The processor and storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In an alternative, the processor and storage medium may reside as discrete components in the user terminal.
[0088] The prior description of this disclosure is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to this disclosure will be apparent to those skilled in the art, and the general principles defined herein may be applied to other variations without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not intended to be limited to the examples and designs described herein, but should be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A file management method, comprising: Construct a file adjacency table. The fields in the file adjacency table include file ID, file name, parent file ID, and whether the file type is a folder. For folder-type files, the fields in the file adjacency table also include the file storage path, and the file storage path does not include the file name of the folder. as well as File management operations are performed based on the file adjacency list; The file management operation based on the file adjacency list includes: A file query operation is performed based on the file adjacency list. The file query operation includes querying a list of subfiles of a file based on the complete file path passed in from the front end; the complete file path is the complete file path of the folder. The step of querying the list of sub-files of a file based on the complete file path passed from the front end includes: Based on the complete file path of the file, match the file storage path field and the file name field in the file adjacency table; given that the file type is a folder, search for the file in the file adjacency table; and The file ID field of the found file is used as the parent file ID. The parent file ID field that matches the file adjacency table is searched again to obtain the list of subfiles of the file. The complete file path of the file is retrieved based on the file ID. The complete file path consists of the file storage path and the file name. The step of performing file management operations based on the file adjacency list further includes: After performing a specific file management operation, update the file storage path field in the file adjacency table.
2. The file management method as described in claim 1, characterized in that, The step of querying the complete file path of a file based on its file ID includes: The file is located by matching the file ID field in the file adjacency table with the file ID; and In response to the fact that the found file is a folder type, the file storage path field and file name field of the file in the file adjacency table are combined to form the complete file path of the file.
3. The file management method as described in claim 2, characterized in that, The method of querying the complete file path of a file based on its file ID also includes: In response to the found file being a file type, the parent file ID field of that file in the file adjacency table is used as a new query condition to search the file adjacency table again; and The file storage path field of the parent file is combined with the file ID field to obtain the complete file path of the parent file. Then, the complete file path of the parent file is combined with the file name of the file to obtain the complete file path of the file.
4. The file management method as described in claim 1, characterized in that, The step of performing file management operations based on the file adjacency list further includes: The specific file management operations include copying, moving, and renaming files.
5. The file management method as described in claim 4, characterized in that, The step of updating the file storage path field in the file adjacency table after performing a specific file management operation includes: In response to a file object performing a specific file management operation being a non-folder type, or a folder type without subfolders, or the specific file management operation being performed within the same file directory, there is no need to update the file storage path field; and In response to performing a copy or move operation for a folder type that does not have subfolders, update the file storage path field for that folder.
6. The file management method as described in claim 5, characterized in that, The step of updating the file storage path field in the file adjacency table after performing a specific file management operation also includes: If the file object performing a specific file management operation is a folder type with subfolders, then the list of subfiles of that file is searched and traversed, and the file storage path field of the subfolders of that file is updated in the file adjacency table.
7. A document management device, comprising: Memory; as well as A processor coupled to the memory, the processor being configured to perform the file management method as described in any one of claims 1 to 6.
8. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the file management method as described in any one of claims 1 to 6.