File processing and searching method and device, computer device and storage medium

By generating a target package file and finding the target file based on the package information, the problems of slow file reading speed and high memory consumption in the existing technology are solved, achieving faster file reading and more stable device operation.

CN114780494BActive Publication Date: 2026-01-23DOUYIN VISION CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210377423.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-11
Publication Date
2026-01-23
Estimated Expiration
2042-04-11

AI Technical Summary

Technical Problem

Existing file packaging technologies suffer from slow file reading speeds and high memory consumption, which negatively impacts device stability.

Method used

By obtaining the directory to be processed, the folders and subfiles at each level are traversed in hierarchical order to generate the target package file, and the target file is found based on the packaging information, thus omitting the decompression process.

Benefits of technology

It improves file reading speed, reduces memory usage, and makes the device run more stably.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114780494B_ABST
    Figure CN114780494B_ABST
Patent Text Reader

Abstract

The present disclosure provides a file processing method and device, a computer device and a storage medium, and the method comprises: obtaining a to-be-processed directory, wherein the to-be-processed directory comprises at least one hierarchical folder, and each hierarchical folder comprises at least one sub-file; based on the hierarchical order of the folders in the to-be-processed directory, traversing each hierarchical folder and the sub-files in the folder to obtain packing information of each hierarchical folder, wherein the packing information is used to indicate the file attribute information and the file location information of each sub-file in the hierarchical folder, and the file location information is used to indicate the location of the sub-file in a target packing file to be generated; and generating the target packing file based on the packing information of each hierarchical folder.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of computers, and in particular, to a file processing method and device, a file searching method and device, a computer device, and a storage medium. BACKGROUND

[0002] In the existing file packaging technology, a compression software is usually selected to package files into a compressed package. When a user needs to use the files in the compressed package, the compressed package needs to be decompressed to obtain the data in the compressed package. Therefore, the file reading speed of the existing file packaging technology is slow. Moreover, when data in the compressed package is updated, the compressed package cannot be deleted, which will occupy a large amount of memory space, thereby affecting the stable operation of the device. SUMMARY

[0003] Embodiments of the present disclosure at least provide a file processing method and device, a file searching method and device, a computer device, and a storage medium.

[0004] In a first aspect, the embodiments of the present disclosure provide a file processing method, comprising:

[0005] obtaining a to-be-processed directory, wherein the to-be-processed directory comprises at least one level of folders, and each level of folder comprises at least one sub-file;

[0006] traversing each level of folder and the sub-file in the folder based on a level order of the folder in the to-be-processed directory to obtain packaging information of each level of folder, wherein the packaging information is used to indicate file attribute information and file position information of each sub-file in the level of folder, and the file position information is used to indicate a position of the sub-file in a target packaging file to be generated;

[0007] generating the target packaging file based on the packaging information of each level of folder.

[0008] In an optional implementation, the traversing each level of folder and the sub-file in the folder based on the level order of the folder in the to-be-processed directory to obtain the packaging information of each level of folder comprises:

[0009] determining first packaging sub-information of each level of folder based on the level order;

[0010] determining second packaging sub-information of each sub-file in each level of folder;

[0011] determining the packaging information of the folder based on the first packaging sub-information and the second packaging sub-information.

[0012] In an alternative implementation, the second packing sub-information of each sub-file contained in each folder at each level is determined by:

[0013] determining the file type of each sub-file in each folder at each level, and determining a file packing mode matching the file type;

[0014] determining the second packing sub-information of the sub-file based on the file packing mode.

[0015] In an alternative implementation, the first packing sub-information contains at least one of the following: type identification of the folder, folder name, number of sub-files contained in the folder, file name hash value of each sub-file in the folder, and file location information of each sub-file in the folder.

[0016] In an alternative implementation, when the file type of the sub-file is a folder, the second packing sub-information contains at least one of the following: type identification of the sub-file, sub-file name, number of sub-files contained in the sub-file, file name hash value of each sub-file in the sub-file, and file location information of each sub-file in the sub-file; when the file type of the sub-file is a document file, the second packing sub-information contains at least one of the following: type identification of the sub-file, sub-file name, sub-file length, sub-file content, and file location information of the sub-file.

[0017] In an alternative implementation, the second packing sub-information of each sub-file contained in each folder at each level is determined by:

[0018] determining the file name hash value of each sub-file;

[0019] sorting each sub-file in the folder based on the file name hash value to obtain a sub-file sorting result;

[0020] determining the second packing sub-information of each sub-file contained in the folder based on the sub-file sorting result.

[0021] In a second aspect, the embodiments of the present disclosure further provide a file searching method, comprising:

[0022] obtaining a file searching request and a target searching file corresponding to the file searching request, wherein the file searching request carries a file searching path, and the target searching file is a target packing file obtained based on the file processing method in any one of the first aspect;

[0023] determining the file location information of each sub-file contained in each sub-path in the target searching file according to the path level order of each sub-path in the file searching path.

[0024] determining a target file indicated by the file search request in the target search file based on the file position information found.

[0025] In an optional implementation, the determining of the file position information of each sub-file contained in each sub-path in the target search file according to the path level order of each sub-path in the file search path comprises:

[0026] splitting the file search path according to the path level order to obtain at least one sub-path;

[0027] sequentially searching for a hash value corresponding to each sub-path in the target search file;

[0028] in a case where the corresponding hash value is found in the target search file, searching for file position information corresponding to the sub-path in the target search file, and determining the found file position information as the file position information of the sub-file contained in the sub-path in the target search file.

[0029] In a third aspect, the embodiments of the present disclosure further provide a file processing apparatus, comprising:

[0030] a first obtaining unit configured to obtain a to-be-processed directory, wherein the to-be-processed directory contains at least one level of folder, and each level of folder contains at least one sub-file;

[0031] a traversing unit configured to traverse each level of folder and the sub-file in the folder based on a level order of the folder in the to-be-processed directory, to obtain packing information of each level of folder, wherein the packing information is used to indicate file attribute information and file position information of each sub-file contained in the level of folder, and the file position information is used to indicate a position of the sub-file in a target packing file to be generated;

[0032] a generating unit configured to generate the target packing file based on the packing information of each level of folder.

[0033] In a fourth aspect, the embodiments of the present disclosure further provide a file search apparatus, comprising:

[0034] a second obtaining unit configured to obtain a file search request and a target search file corresponding to the file search request, wherein the file search request carries a file search path, and the target search file is a target packing file obtained based on the file processing method in the first aspect;

[0035] The first determining unit is configured to determine file position information of a sub-file contained in each sub-path in the target search file according to a path level order of each sub-path in the file search path;

[0036] The second determining unit is configured to determine a target file searched according to the file search request in the target search file based on the found file position information.

[0037] In a fifth aspect, the embodiments of the present disclosure further provide a computer device, including a processor, a memory and a bus, the memory stores machine readable instructions executable by the processor, when the computer device is running, the processor and the memory communicate through the bus, and the machine readable instructions are executed by the processor to perform the steps in any possible implementation manner of the first aspect to the second aspect.

[0038] In a sixth aspect, the embodiments of the present disclosure further provide a computer readable storage medium, the computer readable storage medium stores a computer program, and the computer program is executed by the processor to perform the steps in any possible implementation manner of the first aspect to the second aspect.

[0039] The file processing method and device, the computer device and the storage medium provided by the embodiments of the present disclosure. In the embodiments of the present disclosure, firstly, a to-be-processed directory can be acquired, and each level of folder and sub-file is traversed based on a level order of the folder in the to-be-processed directory to obtain packing information of each level of folder, and a target packing file is generated based on the packing information, so that a user searches a target file in the target packing file based on a file search request containing a path level order, thereby improving the speed of file packing on the one hand, and omitting the decompression process when searching the target file on the other hand, reducing the occupation of memory space, and enabling the device to run more stably.

[0040] In order to make the above objectives, features and advantages of the present disclosure more apparent, clear and easy to understand, the following will specifically describe the preferred embodiments in conjunction with the accompanying drawings, and the specific description is as follows. BRIEF DESCRIPTION OF DRAWINGS

[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following will briefly introduce the drawings needed to be used in the embodiments, the drawings herein are incorporated into the description and form a part of the description, the drawings show the embodiments consistent with the present disclosure, and are used to illustrate the technical solutions of the present disclosure together with the description. It should be understood that the following drawings only show some embodiments of the present disclosure, and therefore should not be regarded as a limitation on the scope, and for those skilled in the art, other related drawings can also be obtained without paying creative labor on the basis of the drawings.

[0042] Figure 1 A flow chart of a file processing method is shown;

[0043] Figure 2 A flow chart of a file searching method is shown;

[0044] Figure 3 A schematic diagram of a file processing apparatus is shown;

[0045] Figure 4 A schematic diagram of a file searching apparatus is shown;

[0046] Figure 5 A schematic diagram of a computer device is shown;

[0047] Figure 6 A schematic diagram of another computer device is shown. DETAILED DESCRIPTION

[0048] In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure clearer, the following will be combined with the accompanying drawings for the embodiments of the present disclosure to clearly and completely describe the technical solutions of the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments. The components of the embodiments of the present disclosure described and shown in the accompanying drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed present disclosure, but only represents selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present disclosure.

[0049] It should be noted that: similar reference numerals and letters represent similar items in the following drawings, therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.

[0050] The term “and / or” in this document is only used to describe an association relationship, which means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone. In addition, the term “at least one” in this document means any one of multiple or any combination of at least two of multiple, for example, including at least one of A, B and C can mean including any one or more elements selected from the set consisting of A, B and C.

[0051] It is found through research that in the existing file packaging technology, a compression software is usually selected to package files into a compressed package. When a user needs to use the files in the compressed package, the compressed package needs to be decompressed to obtain the data in the compressed package. Therefore, the file reading speed of the existing file packaging technology is slow. Moreover, when data in the compressed package is updated, the compressed package cannot be deleted, which will occupy a large amount of memory space, thereby affecting the stable operation of the device.

[0052] Based on the above research, the present disclosure provides a file processing method, a file searching method, an apparatus, a computer device and a storage medium. In the embodiment of the present disclosure, firstly, a to-be-processed directory can be obtained, and each level of folder and sub-file is traversed based on the hierarchical order of the folder in the to-be-processed directory to obtain packaging information of each level of folder, and a target packaging file is generated based on the packaging information, so that in the process of searching for a target file, the file position information of the target file in the target packaging file can be searched based on the packaging information, thereby on the one hand, the multiple levels of folders can be merged through file packaging to improve the file reading speed, and on the other hand, the decompression process is omitted when searching for the target file, the occupation of the memory space is reduced, and the device can operate more stably.

[0053] In order to facilitate the understanding of the present embodiment, firstly, a file processing method disclosed by the present embodiment is introduced in detail, and the execution subject of the file processing method provided by the present embodiment is generally a computer device with certain computing capability. In some possible implementation manners, the file processing method can be realized by calling the computer readable instructions stored in the memory by the processor.

[0054] Referring to Figure 1 The method provided by the present embodiment includes steps S101-S105, wherein:

[0055] S101: obtaining a to-be-processed directory, wherein the to-be-processed directory contains at least one level of folder, and each level of folder contains at least one sub-file.

[0056] In the embodiments of the present disclosure, in the process of updating the application program contained in the terminal device, a large number of update files are generated, especially in the process of incremental update, a large number of small-size update resource packages (with a capacity of several KB to several tens of KB) are generated. Due to the influence of the memory reading mechanism, the reading speed of the system when reading these small-size update resource packages is often slower than that of large-size update resource packages (here, the large size is a resource package with a capacity of GB level). Therefore, in the embodiments of the present disclosure, the files of the multiple update resources corresponding to the application program need to be packaged to improve the reading speed of the files. Here, the incremental update is different from the full update. In the process of incremental update, only the places that need to be changed are updated, and the places that do not need to be updated or have been updated will not be repeatedly updated, for example, only the bug in the application program is repaired, and the repaired part of the update content is downloaded to the application program.

[0057] In the implementation, the to-be-processed directory can be acquired first, for example, the to-be-processed directory can be the update resource directory of the application program, the update resource directory can contain at least one hierarchical folder, each hierarchical folder contains at least one sub-file, wherein the at least one hierarchical folder can correspond to the update resource of each function in the application program, and the folder can contain the incremental update sub-file corresponding to each function in the application program.

[0058] For example, the to-be-processed directory is the update resource directory of the application program A, the update resource directory corresponds to all update resources a of the application program A, and contains the folder a1 corresponding to the function a1, and the folder contains the incremental update sub-file a1.txt of the function a1. Then, the to-be-processed directory can be represented as a / a1 / a1.txt. Here, “ / ” is a hierarchical identifier, which is used to distinguish the files at different levels under the to-be-processed directory.

[0059] S103: based on the hierarchical order of the folders in the to-be-processed directory, each hierarchical folder and the sub-file in the folder are traversed to obtain the packaging information of each hierarchical folder, wherein the packaging information is used to indicate the file attribute information and the file position information of each sub-file contained in the hierarchical folder, and the file position information is used to indicate the position of the sub-file in the target packaging file to be generated.

[0060] In the embodiments of the present disclosure, first, each hierarchical folder and the sub-file contained in the folder can be traversed based on the hierarchical order of the folders in the to-be-processed directory. Here, in the process of traversal, the file attribute information and the file position information of each hierarchical folder and the sub-file contained in the folder can be acquired, and then the packaging information of each hierarchical folder is obtained based on the file attribute information and the file position information.

[0061] Here, the file attribute information can be used to indicate the type, file name, file content, and other attributes of the folder or the sub-file. The file position information can be used to indicate the hierarchical position of the folder or the sub-file in the to-be-processed file, for example, the file position information can be used to indicate the upper-level folder containing a certain sub-file and the lower-level sub-file contained by the sub-file. It should be understood that the hierarchical position of the folder or the sub-file in the to-be-processed file can be the position of the folder or the sub-file in the target packaging file to be generated.

[0062] For example, taking folder a in the to-be-processed directory as an example, the folder a contains sub-file b1 and sub-file b2, the sub-file b1 contains sub-file c, the sub-file c contains sub-file 1.txt, and in addition, the sub-file b2 contains sub-file 2.txt, then the hierarchical order of the folder a can be a / {b1 / c / 1.txt}, {b2 / 2.txt}. Therefore, when traversing the folder a and the sub-files contained therein, the traversal can be performed based on the hierarchical order of the folder a.

[0063] Specifically, in the process of traversing based on the hierarchical order a / {b1 / c / 1.txt}, the folder a can be traversed first, and then the sub-file b1, the sub-file c, and the sub-file 1.txt are traversed respectively. Then, the sub-file b2 and the sub-file 2.txt can be traversed based on the hierarchical order {b2 / 2.txt} respectively, so as to complete the traversal of the folder a and the sub-files contained in the folder a.

[0064] S105: generating the target packaging file based on the packaging information of each hierarchical folder.

[0065] In the embodiments of the present disclosure, after the packaging information of each hierarchical folder is determined, the folders of each hierarchy can be packaged according to the determined packaging information, so as to generate the target packaging file.

[0066] Here, the packaging process can be a merging and compressing process, that is, different hierarchical folders are merged to obtain a merging result, and the merging result is compressed to obtain the target packaging file, where the target packaging file can be a compressed file. Compared with the uncompressed folder, the target packaging file in the form of a compressed file greatly reduces the occupation of memory space.

[0067] It can be known from the above description that, in the embodiment of the present disclosure, firstly, the to-be-processed directory can be acquired, and each hierarchical folder and the sub-files in the folder are traversed based on the hierarchical order of the folders in the to-be-processed directory to obtain the packaging information of each hierarchical folder, and the target packaging file is generated based on the packaging information, so that the multiple hierarchical folders are merged through file packaging, and the file reading speed is improved.

[0068] In an optional implementation, the step S103 of traversing each hierarchical folder and the sub-files in the folder based on the hierarchical order of the folders in the to-be-processed directory to obtain the packaging information of each hierarchical folder includes the following process:

[0069] S1031: determining the first packaging sub-information of each hierarchical folder based on the hierarchical order;

[0070] S1032: determining the second packaging sub-information of each sub-file contained in each hierarchical folder;

[0071] S1033: determining the packaging information of the folder based on the first packaging sub-information and the second packaging sub-information.

[0072] In the embodiment of the present disclosure, since the file attribute information and the file location information of each hierarchical folder and the sub-files contained in the folder are different, the packaging information of each hierarchical folder and the sub-files contained in the folder needs to be acquired respectively, so as to obtain the first packaging sub-information of each hierarchical folder and the second packaging sub-information of each sub-file contained in each hierarchical folder.

[0073] For example, the application program contains function A, the function A contains sub-functions B1 and B2, the update resource folder corresponding to the function A is a, the update resource folder corresponding to the sub-function B1 is b1, and the update resource folder corresponding to the sub-function B2 is b2.

[0074] Then, the folder a contains the sub-file b1 and the sub-file b2, in the process of determining the packaging information of the hierarchical folder corresponding to the folder a, firstly, the first packaging sub-information corresponding to the folder a is determined, and then the second packaging sub-information corresponding to the sub-file b1 and the sub-file b2 contained in the folder a is determined respectively.

[0075] In the embodiments of the present disclosure, in the process of determining the packing information of each hierarchical folder, the first packing sub-information of each hierarchical folder can be determined first, and the second packing sub-information of each sub-file contained in each hierarchical folder can be determined, so that the packing information of the folder is determined based on the first packing sub-information and the second packing sub-information, thereby providing a technical basis for generating a target packing file based on the packing information of each folder.

[0076] In an optional implementation, the step S1032 of determining the second packing sub-information of each sub-file contained in each hierarchical folder includes the following process:

[0077] (1) Determine the file type of each sub-file in each hierarchical folder, and determine the file packing mode matched with the file type.

[0078] (2) Determine the second packing sub-information of the sub-file based on the file packing mode.

[0079] In the embodiments of the present disclosure, since the file packing modes corresponding to different file types are different, the file type of each sub-file in each hierarchical folder needs to be determined, wherein the file type can be divided into folders and document files according to different contents contained in each sub-file.

[0080] Here, the sub-file of the file type of the folder can further contain a sub-file of a lower level, for example, the sub-file b can further contain the sub-file c. The sub-file of the file type of the document file can contain various formats of document files, for example,.txt format of document file.

[0081] After determining the file type corresponding to each sub-file of the folder, the second packing sub-information of the sub-file of the file type can be determined based on the file packing mode corresponding to different file types, wherein the second packing sub-information is used to pack the sub-file based on the file packing mode, thereby generating a target packing file.

[0082] In the embodiments of the present disclosure, since the file types of the sub-files contained in each hierarchical folder can be different, different file packing modes can be set for different types of sub-files, and the second packing sub-information of the sub-file can be obtained based on the file packing mode, thereby being applicable to packing of sub-files of different file types, and improving the accuracy of the generated target packing file.

[0083] In an optional implementation, the first packing sub-information includes at least one of the following: a type identifier of the folder, a folder name, a number of sub-files contained in the folder, a file name hash value of each sub-file in the folder, and file location information of each sub-file in the folder.

[0084] In the embodiments of the present disclosure, the type identifier of the folder can be an identifier of a file type of the folder, for example, the type identifier of the folder can be 0x2; the folder name can be a file name of the folder; the file name hash value of each sub-file in the folder can be a value obtained by calculating a hash function on the file name of the folder, which can also be referred to as a Hash value; and the file location information of each sub-file in the folder can be represented by an offset of the sub-file in the folder, where the offset can be used to represent a difference between an actual storage address of the sub-file in a storage unit and an actual storage address of the folder containing the sub-file in the storage unit, for example, the actual storage location of the folder in the storage unit is the 100th byte position, and the offset of the sub-file in the folder is 50, so the actual storage location of the sub-file in the storage unit can be the 150th byte position.

[0085] For example, the folder is a, and the folder contains a sub-file b1 and a sub-file b2, so the type identifier of the folder a can be 0x2; the folder name can be a; the number of sub-files contained in the folder can be 2; the file name hash value of each sub-file in the folder can be a file name hash value Hash(b1) of the sub-file b1 and a file name hash value Hash(b2) of the sub-file b2; and the file location information of each sub-file in the folder can be an offset (b1) of the sub-file b1 in the folder a and an offset (b2) of the sub-file b2 in the folder a.

[0086] Therefore, the first packing sub-information of the folder a can be recorded as: 0x2 | a | 2 | Hash(b1) Hash(b2) | offset(b1) offset(b2).

[0087] In the embodiments of the present disclosure, the first packing sub-information includes at least one of the following: a type identifier of the folder, a folder name, a number of sub-files contained in the folder, a file name hash value of each sub-file in the folder, and file location information of each sub-file in the folder, thereby providing a technical basis for packing the folder based on the first packing information.

[0088] In an optional embodiment, in the case that the file type of the sub-file is a folder, the second packing sub-information contains at least one of the following: type identification of the sub-file, name of the sub-file, number of sub-files contained in the sub-file, file name hash value of each sub-file in the sub-file, file location information of each sub-file in the sub-file; in the case that the file type of the sub-file is a document file, the second packing sub-information contains at least one of the following: type identification of the sub-file, name of the sub-file, length of the sub-file, content of the sub-file, file location information of the sub-file.

[0089] In the embodiments of the present disclosure, in the case that the file type of the sub-file is a folder, the second sub-information contains at least one of the following: type identification of the sub-file, name of the sub-file, number of sub-files contained in the sub-file, file name hash value of each sub-file in the sub-file, file location information of each sub-file in the sub-file, wherein the type identification of the sub-file can be 0x2.

[0090] Here, the sub-file of the file type of folder can further contain sub-files of a lower level, thus the file types of the sub-file b1, the sub-file b2 and the sub-file c of the folder a are all folders. Then, taking the sub-file b1 as an example, the type identification of the sub-file b1 is 0x2, the sub-file name is b1, the number of sub-files contained in the file is 1, the file name hash value of each sub-file in the sub-file is the file name hash value Hash(c) of the sub-file c, and the file location information of each sub-file in the sub-file is the offset (c) of the sub-file c relative to the sub-file b1. Therefore, the second packing sub-information of the sub-file b1 can be recorded as: 0x2 | b1 | 1 | Hash(c) | offset(c).

[0091] Then, by analogy, the second packing sub-information of the sub-file b2 can be recorded as: 0x2 | b2 | 1 | Hash(2.txt) | offset(2.txt); and the second packing sub-information of the sub-file c can be recorded as: 0x2 | c | 1 | Hash(1.txt) | offset(1.txt).

[0092] In the embodiments of the present disclosure, the first packing sub-information of the folder can be determined, thereby providing a technical basis for packing the folder based on the first packing sub-information.

[0093] In an optional embodiment, in the case that the file type of the sub-file is a document file, the second packing sub-information contains at least one of the following: type identification of the sub-file, name of the sub-file, length of the sub-file, content of the sub-file, file location information of the sub-file, wherein the type identification of the sub-file can be 0x1.

[0094] Here, the sub-file of the file type of document file can contain various formats of document file, so the file type of the sub-file 1.txt in the sub-file c and the sub-file 2.txt in the sub-file b2 is document file. Then, taking the sub-file 1.txt as an example, the type identifier of the sub-file 1.txt is 0x1, the sub-file name is 1.txt, the sub-file length is d(1.txt), the sub-file content is content(1.txt), and the file position information of the sub-file is the offset of the sub-file 1.txt relative to the sub-file c (offset(1.txt)). Therefore, the second packing sub-information of the sub-file 1.txt can be recorded as: 0x1 | 1.txt | d(1.txt) | content(1.txt) | offset(1.txt).

[0095] Then, by analogy, the second packing sub-information of the sub-file 2.txt can be recorded as: 0x1 | 2.txt | d(2.txt) | content(2.txt) | offset(2.txt).

[0096] In the embodiments of the present disclosure, the second packing sub-information of the sub-file of the file type of folder and document file can be determined respectively, thereby providing a technical basis for packing the sub-file based on the second packing sub-information.

[0097] In an optional implementation, the step S1032 of determining the second packing sub-information of each sub-file contained in each hierarchical folder further includes the following processes:

[0098] (1) determining the file name hash value of each sub-file;

[0099] (2) sorting each sub-file in the folder based on the file name hash value to obtain a sub-file sorting result;

[0100] (3) determining the second packing sub-information of each sub-file contained in the folder based on the sub-file sorting result.

[0101] In the embodiments of the present disclosure, the file name of each sub-file can be calculated by a hash function to obtain the file name hash value of each sub-file, and then each sub-file in the folder can be sorted based on the file name hash value to obtain a sub-file sorting result. Then, the file position information of each sub-file can be determined based on the sub-file sorting result, and the second packing sub-information of each sub-file can be determined based on the file position information.

[0102] In the embodiments of the present disclosure, after the sub-files in the folder are sorted based on the file name hash value to obtain a sub-file sorting result, each sub-file in the target packaging file generated based on the sub-file sorting result is also sorted according to the sub-file sorting result, and will not be disordered due to packaging, so that when searching for a target file in the target packaging file, the target file can be searched based on the sub-file sorting result, without decompressing the target packaging file, thereby improving the searching efficiency and saving storage space.

[0103] Referring to Figure 2 FIG. 2 shows a flowchart of a file searching method according to an embodiment of the present disclosure, and the method includes steps S201-S205, wherein:

[0104] S201: Obtain a file searching request and obtain a target searching file corresponding to the file searching request, wherein the file searching request carries a file searching path, and the target searching file is a target packaging file obtained based on the above file processing method.

[0105] In the embodiments of the present disclosure, the target file in the target searching file can be obtained through a file searching request. Here, the file searching request of the target file can be generated based on the file searching path of the target file, and the file searching path can be used to indicate the hierarchical order of the target file in the target searching file.

[0106] Here, taking the above 1.txt as an example, the file searching path corresponding to the target file can be a / b1 / c / 1.txt.

[0107] S203: Determine the file position information of each sub-file contained in each sub-path in the target searching file according to the path hierarchical order of each sub-path in the file searching path.

[0108] In the embodiments of the present disclosure, first, the packaging information of each sub-file contained in each sub-path can be determined based on the path hierarchical order of each sub-path in the above file searching path, and the file position information of the corresponding sub-file in the target searching file can be determined based on the packaging information, so as to determine the file position information of the target file.

[0109] For example, taking the file searching path a / b1 / c / 1.txt corresponding to the above target file 1.txt as an example, first, the packaging information of the folder a can be determined, and the file position information of the sub-file b1 can be determined based on the packaging information of the folder a, then the position information of the sub-file c can be determined based on the packaging information of the sub-file b1, and finally the position information of 1.txt can be determined based on the packaging information of the sub-file c.

[0110] S205: determining the target file indicated by the file search request in the target search file based on the found file location information.

[0111] In the embodiments of the present disclosure, after the file location information of the target file is determined, the target file can be searched in the target search file based on the file location information. Specifically, the file location information can be an offset (1.txt) contained in the packaging information of the target file, and the actual storage address of the target file in the storage unit can be determined based on the offset (1.txt).

[0112] As described above, in the embodiments of the present disclosure, the file location information of the target file in the target search file can be searched based on the packaging information of the target file, the process of decompressing the target search file is omitted, the occupation of the memory space is reduced, and the device can operate more stably.

[0113] In an optional implementation, the step S203 of determining the file location information of each sub-file contained in each sub-path in the target search file according to the path level order of each sub-path in the file search path specifically includes the following process:

[0114] S2031: splitting the file search path according to the path level order to obtain at least one sub-path.

[0115] In the embodiments of the present disclosure, in the process of splitting the file search path according to the path level order, the file search path can be split based on the level identifier contained in the file search path to obtain at least one sub-path. Here, the level identifier can be “ / ” as described above.

[0116] In implementation, taking the file search path a / b1 / c / 1.txt as an example, after the file search path is split based on the level identifier “ / ”, the sub-path of the folder a, the sub-path of the sub-file b1, the sub-path of the sub-file c and the sub-path of the sub-file 1.txt can be obtained respectively.

[0117] S2032: sequentially searching the hash value corresponding to each sub-path in the target search file.

[0118] S2033: in the case that the corresponding hash value is found in the target search file, searching the file location information corresponding to the sub-path in the target search file, and determining the found file location information as the file location information of the sub-file contained in the sub-path in the target search file.

[0119] In the embodiments of the present disclosure, the hash value of the next level sub-path corresponding to each sub-path can be sequentially searched according to the above path level order, and the file location information of the sub-file corresponding to the next level sub-path can be determined if the hash value of the next level sub-path is found.

[0120] In the implementation, taking the file query path a / b1 / c / 1.txt as an example, the packing information of the folder a is obtained first, and the hash value Hash(b1) of the sub-file b1 is searched in the packing information. If the hash value Hash(b1) is found, the file location information of the sub-file b1, i.e., the offset (b1), can be determined.

[0121] Next, the packing information of the sub-file b1 can be obtained, and the hash value Hash(c) of the sub-file c can be searched in the packing information. If the hash value Hash(c) is found, the file location information of the sub-file c, i.e., the offset (c), can be determined. Similarly, the file location information of the target file 1.txt, i.e., the offset (1.txt), can be determined based on the packing information of the sub-file c.

[0122] It should be noted that in the process of sequentially searching the hash value corresponding to each sub-path, a binary search method can be used. For example, the folder a corresponds to two sub-files, i.e., the sub-file b1 and the sub-file b2, the file query path corresponding to the sub-file b1 can be b1 / c / 1.txt, and the file query path corresponding to the sub-file b2 can be b2 / 2.txt. Then, the hash value Hash(c) of the sub-file c can be searched in the packing information of the sub-file b1 and the sub-file b2, respectively. As known from the above implementation, the hash value Hash(c) of the sub-file c can be found in the packing information of the sub-file b1, and the result output by the binary search for the sub-file b1 can be 1. Next, the file location information of the sub-file c can be searched in the packing information of the sub-file b1. Conversely, the result output by the binary search for the sub-file b2 can be 0.

[0123] In the embodiments of the present disclosure, the file query path can be divided into at least one sub-path according to the path level order, the hash value corresponding to each sub-path can be sequentially searched, and the file location information corresponding to the sub-path can be searched in the target file if the hash value is found, thereby improving the accuracy of searching the file location information and the response speed of the device.

[0124] To sum up, in the embodiment of the present disclosure, firstly, the to-be-processed directory can be acquired, and each hierarchical folder and sub-file is traversed based on the hierarchical order of the folders in the to-be-processed directory to obtain the packaging information of each hierarchical folder, and the target packaging file is generated based on the packaging information, so that in the process of searching for the target file, the file location information of the target file in the target packaging file can be searched based on the packaging information, thereby on the one hand, the multiple hierarchical folders can be merged through file packaging to improve the file reading speed, and on the other hand, the decompression process is omitted when searching for the target file, the memory space occupation is reduced, and the device can run more stably.

[0125] Those skilled in the art can understand that in the above method of the specific implementation, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process, and the specific execution order of each step should be determined by its function and possible internal logic.

[0126] Based on the same inventive concept, the present disclosure also provides a file processing device and a file searching device corresponding to the file processing method. Since the principles of the devices in the embodiments of the present disclosure for solving problems are similar to the above-mentioned file processing method, the implementation of the device can be referred to the implementation of the method, and the repeated parts will not be described again.

[0127] Reference Figure 3 Fig. 1 is a schematic diagram of a file processing device provided by an embodiment of the present disclosure. The device comprises a first acquisition unit 31, a traversal unit 32, and a generation unit 33.

[0128] The first acquisition unit 31 is configured to acquire a to-be-processed directory, wherein the to-be-processed directory comprises at least one hierarchical folder, and each hierarchical folder comprises at least one sub-file.

[0129] The traversal unit 32 is configured to traverse each hierarchical folder and the sub-file in the folder based on the hierarchical order of the folders in the to-be-processed directory to obtain the packaging information of each hierarchical folder, wherein the packaging information is used to indicate the file attribute information and the file location information of each sub-file in the hierarchical folder, and the file location information is used to indicate the position of the sub-file in the target packaging file to be generated.

[0130] The generation unit 33 is configured to generate the target packaging file based on the packaging information of each hierarchical folder.

[0131] In the embodiments of the present disclosure, firstly, a to-be-processed directory can be acquired, and each hierarchical folder and each sub-file in the to-be-processed directory is traversed based on a hierarchical order of the folders, to obtain packing information of each hierarchical folder, and a target packing file is generated based on the packing information, so that the folders of multiple hierarchies are merged through file packing, and the speed of file reading is improved.

[0132] In a possible implementation, the traversing unit 32 is further configured to:

[0133] determine first packing sub-information of each hierarchical folder based on the hierarchical order;

[0134] determine second packing sub-information of each sub-file in each hierarchical folder;

[0135] determine the packing information of the folder based on the first packing sub-information and the second packing sub-information.

[0136] In a possible implementation, the traversing unit 32 is further configured to:

[0137] determine a file type of each sub-file in each hierarchical folder, and determine a file packing mode matched with the file type;

[0138] determine the second packing sub-information of the sub-file based on the file packing mode.

[0139] In a possible implementation, the first packing sub-information includes at least one of the following: a type identifier of the folder, a folder name, a number of sub-files included in the folder, a file name hash value of each sub-file in the folder, and file location information of each sub-file in the folder.

[0140] In a possible implementation, in a case where the file type of the sub-file is a folder, the second packing sub-information includes at least one of the following: a type identifier of the sub-file, a sub-file name, a number of sub-files included in the sub-file, a file name hash value of each sub-file in the sub-file, and file location information of each sub-file in the sub-file; in a case where the file type of the sub-file is a document file, the second packing sub-information includes at least one of the following: a type identifier of the sub-file, a sub-file name, a sub-file length, sub-file content, and file location information of the sub-file.

[0141] In a possible implementation, the traversing unit 32 is further configured to:

[0142] determine a file name hash value of each sub-file;

[0143] sort each sub-file in the folder based on the file name hash value, to obtain a sub-file sorting result.

[0144] determine a second packing sub-information of each sub-file contained in the folder based on the sub-file sorting result.

[0145] Referring to Figure 4 As shown in a schematic diagram of a file searching device provided by an embodiment of the present disclosure, the device comprises a second acquisition unit 41, a first determination unit 42, and a second determination unit 43, wherein,

[0146] The second acquisition unit 41 is configured to acquire a file searching request and acquire a target searching file corresponding to the file searching request, wherein the file searching request carries a file searching path, and the target searching file is a target packing file obtained based on an implementation of the above file processing method.

[0147] The first determination unit 42 is configured to determine file position information of a sub-file contained in each sub-path in the target searching file according to a path level order of each sub-path in the file searching path.

[0148] The second determination unit 43 is configured to determine a target file indicated by the file searching request in the target searching file based on the file position information found.

[0149] In a possible implementation, the first determination unit 42 is further configured to:

[0150] divide the file searching path according to the path level order to obtain at least one sub-path;

[0151] find a hash value corresponding to each sub-path in the target searching file in sequence;

[0152] in a case where the corresponding hash value is found in the target searching file, find file position information corresponding to the sub-path in the target searching file, and determine the found file position information as file position information of a sub-file contained in the sub-path in the target searching file.

[0153] The processing flow of each unit in the device and the interaction flow between the units can refer to the related description in the above method embodiments, and will not be described in detail here.

[0154] Corresponding to the file processing method in Figure 1 , the present disclosure further provides a computer device 500, as shown in Figure 5 a structural schematic diagram of the computer device 500 provided by an embodiment of the present disclosure, which comprises:

[0155] The processor 51, the memory 52, and the bus 53; the memory 52 is used for storing execution instructions, including the memory 521 and the external memory 522; the memory 521 here is also called the internal memory, used for temporarily storing operation data in the processor 51 and data exchanged with the external memory 522 such as a hard disk, the processor 51 exchanges data with the external memory 522 through the memory 521, when the computer equipment 500 runs, the processor 51 and the memory 52 communicate through the bus 53, so that the processor 51 executes the following instructions:

[0156] Obtain a to-be-processed directory, wherein the to-be-processed directory comprises at least one hierarchical folder, and each hierarchical folder comprises at least one sub-file;

[0157] Based on the hierarchical order of the folders in the to-be-processed directory, traverse each hierarchical folder and the sub-files in the folder to obtain packing information of each hierarchical folder, wherein the packing information is used to indicate file attribute information and file location information of each sub-file included in the hierarchical folder, and the file location information is used to indicate the location of the sub-file in a target packing file to be generated;

[0158] Based on the packing information of each hierarchical folder, generate the target packing file.

[0159] Corresponding to the file searching method in Figure 2 , the embodiment of the present disclosure further provides another computer equipment 600, as shown in Figure 6 , a structural schematic diagram of the computer equipment 600 provided by the embodiment of the present disclosure, comprising:

[0160] The processor 61, the memory 62, and the bus 63; the memory 62 is used for storing execution instructions, including the memory 621 and the external memory 622; the memory 621 here is also called the internal memory, used for temporarily storing operation data in the processor 61 and data exchanged with the external memory 622 such as a hard disk, the processor 61 exchanges data with the external memory 622 through the memory 621, when the computer equipment 600 runs, the processor 61 and the memory 62 communicate through the bus 63, so that the processor 61 executes the following instructions:

[0161] Obtain a file searching request and a target searching file corresponding to the file searching request, wherein the file searching request carries a file searching path, and the target searching file is a target packing file obtained based on the implementation manner of the above file processing method;

[0162] According to a path level order of each sub-path in the file search path, file position information of each sub-file contained in each sub-path in the target search file is determined;

[0163] According to the file position information found, a target file searched by the file search request is determined in the target search file.

[0164] The embodiment of the present disclosure further provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is run by a processor, the steps of the file processing and file searching method described in the method embodiment are executed. The storage medium can be a volatile or non-volatile computer readable storage medium.

[0165] The embodiment of the present disclosure further provides a computer program product, and the computer program product carries a program code. The instructions included in the program code can be used to execute the steps of the file processing and file searching method described in the method embodiment. For details, refer to the method embodiment, and details are not described herein.

[0166] The computer program product can be specifically implemented by means of hardware, software or a combination thereof. In an optional embodiment, the computer program product is specifically embodied as a computer storage medium. In another optional embodiment, the computer program product is specifically embodied as a software product, such as a software development kit (SDK) and the like.

[0167] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the foregoing method embodiment, and details are not described herein. In several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented by other ways. The device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units or components shown or discussed can be indirect coupling or communication connection through some communication interface, device or unit, and can be electrical, mechanical or other forms.

[0168] The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, i.e. may be located in one place, or may be distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.

[0169] In addition, each functional unit in various embodiments of the present disclosure can be integrated into one processing unit, or each unit can exist physically, or two or more units can be integrated into one unit.

[0170] If the functions are realized in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer readable storage medium executable by a processor. Based on this understanding, the technical solutions of the present disclosure essentially or the part of the prior art or the part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for making a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in various embodiments of the present disclosure. The foregoing storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, and various program code storage media.

[0171] Finally, it should be noted that: the above-described embodiments are only specific embodiments of the present disclosure, used to illustrate the technical solutions of the present disclosure, and not to limit it, the protection scope of the present disclosure is not limited to this, although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand: any person skilled in the art in the technical range disclosed by the present disclosure, it can still modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part of the technical features; and these modifications, changes or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and all should be covered in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.

Claims

1. A file search method, characterized in that, include: Obtain a file search request and obtain the target file corresponding to the file search request, wherein the file search request carries a file search path; According to the path hierarchy order of each sub-path in the file search path, determine the packaging information of the sub-files contained in each sub-path, and determine the file position information of the corresponding sub-file in the target search file based on the packaging information, wherein the file position information is the offset contained in the packaging information of the target search file; Based on the found file location information, the target file indicated by the file search request is determined in the target search file. The target search file is a target packaged file obtained based on a file processing method, which includes: Obtain the directory to be processed, wherein the directory to be processed contains at least one level of folders, and each level of folder contains at least one sub-file; Based on the hierarchical order of the folders in the directory to be processed, the folders at each level and the sub-files in each folder are traversed to obtain the packaging information of each level of folder. The packaging information is used to indicate the file attribute information and file position information of each sub-file contained in the folder at that level. The file position information is used to indicate the position of the sub-file in the target package file to be generated and is represented by the offset of the sub-file in the folder. Based on the packaging information, the folders at each level are merged according to the packaging information to generate the target package file.

2. The method according to claim 1, characterized in that, The process involves traversing the folders at each level and their subfiles within the directory to be processed, based on the hierarchical order of the folders, to obtain the packaging information for each level of folders, including: The first package sub-information of the folder at each level is determined based on the hierarchical order; Determine the second packaged sub-information of each sub-file contained in each folder at each level; The packaging information of the folder is determined based on the first and second packaging information.

3. The method according to claim 2, characterized in that, The step of determining the second packaged sub-information of each sub-file contained in each level of folder includes: Determine the file type of each sub-file in each level of folder, and determine the file packaging pattern that matches the file type; The second packaging sub-information of the sub-file is determined based on the file packaging mode.

4. The method according to claim 2, characterized in that, The first packaged sub-information includes: folder type identifier, folder name, number of sub-files contained in the folder, file name hash value of each sub-file in the folder, and file location information of each sub-file in the folder.

5. The method according to claim 2, characterized in that, When the file type of the sub-file is a folder, the second packaging sub-information includes: the sub-file type identifier, the sub-file name, the number of sub-files contained in the sub-file, the file name hash value of each sub-file in the sub-file, and the file location information of each sub-file in the sub-file; when the file type of the sub-file is a document file, the second packaging sub-information includes: the sub-file type identifier, the sub-file name, the sub-file length, the sub-file content, and the file location information of the sub-file.

6. The method according to claim 2, characterized in that, The step of determining the second packaged sub-information of each sub-file contained in each level of folder includes: Determine the filename hash value for each of the sub-files; The sub-files in the folder are sorted based on the file name hash value to obtain the sub-file sorting result; Based on the sorting results of the sub-files, determine the second packaged sub-information of each sub-file contained in the folder.

7. The method according to claim 1, characterized in that, The step of determining the file location information of the sub-files contained in each sub-path in the target search file according to the path hierarchy order of each sub-path in the file search path includes: The file search path is divided according to the path hierarchy to obtain at least one sub-path; The hash value corresponding to each sub-path is sequentially searched in the packaging information; If the corresponding hash value is found in the packaging information, the file location information corresponding to the sub-path is found in the packaging information, and the found file location information is determined as the file location information of the sub-file contained in the sub-path in the target search file.

8. A file search device, characterized in that, include: The second acquisition unit is used to acquire a file search request and acquire a target search file corresponding to the file search request, wherein the file search request carries a file search path; The first determining unit is configured to determine the packaging information of the sub-files contained in each sub-path according to the path hierarchy order of each sub-path in the file search path, and determine the file position information of the corresponding sub-file in the target search file based on the packaging information, wherein the file position information is the offset contained in the packaging information of the target search file. The second determining unit is used to determine, based on the found file location information, the target file indicated by the file search request in the target search file. The target search file is a target packaged file obtained based on a file processing device, which includes: The first acquisition unit is used to acquire a directory to be processed, wherein the directory to be processed contains at least one level of folders, and each level of folder contains at least one sub-file; The traversal unit is used to traverse the folders at each level and the sub-files in each folder based on the hierarchical order of the folders in the directory to be processed, and to obtain the packaging information of each level of folder. The packaging information is used to indicate the file attribute information and file position information of each sub-file contained in the folder at that level. The file position information is used to indicate the position of the sub-file in the target package file to be generated and is represented by the offset of the sub-file in the folder. The generation unit is used to merge folders at each level according to the packaging information to generate the target packaged file.

9. A computer device, characterized in that, include: The computer device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the computer device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, they perform the steps of the file search method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the file search method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Small file storage method, query method and device

    CN105069048A

  • Bookshelf backup and synchronization method, terminal and computer storage medium

    CN112685228A

  • Metadata searching method, device and equipment and computer readable storage medium

    CN113010476A