A file search method and device, computer equipment and a storage medium

By establishing an index table and generating query key information, the path information of dependent files can be directly obtained, which solves the problem of time-consuming determination of file dependency lists in existing technologies and improves the efficiency of distributed compilation.

CN114185852BActive Publication Date: 2026-06-23DOUYIN VISION CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DOUYIN VISION CO LTD
Filing Date
2021-12-10
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

In existing technologies, the process of determining the file dependency list corresponding to the compilation commands in the compilation request is time-consuming, resulting in low efficiency of distributed compilation.

Method used

By creating an index table that stores key information such as file identifiers and search directories, as well as path information, query key information for dependent files is generated, and the target path information is matched in the index table to directly obtain the dependent files, thus avoiding the process of searching for file locations sequentially in the search directory.

Benefits of technology

It improves the efficiency of file searching, saves a lot of search time, and enhances the overall efficiency of distributed compilation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114185852B_ABST
    Figure CN114185852B_ABST
Patent Text Reader

Abstract

The present disclosure provides a file search method and device, computer equipment and a storage medium, wherein the method comprises: obtaining at least one compilation command for a to-be-compiled file in a target project; for each compilation command, obtaining an entry file from a file location of the entry file carried in the compilation command, and obtaining preprocessing instructions of each dependent file having a dependency relationship with the entry file from the entry file; for each dependent file, generating query key information corresponding to the dependent file based on a search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent file; determining whether there is target path information matching the query key information in a pre-established index table corresponding to the target project, and obtaining the dependent file according to a file path indicated by the target path information in a case where it is determined that there is target path information matching the query key information in the index table. The present disclosure can improve the file search efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more specifically, to a file search method, apparatus, computer device, and storage medium. Background Technology

[0002] Distributed compilation is typically accomplished by a master server and multiple compilation servers that act as worker nodes. Specifically, after receiving a compilation request for the target project, the master server needs to parse the compilation request, determine the various compilation commands and the file dependency list corresponding to each compilation command, and then send the file dependency list and compilation commands to different compilation servers to compile the various files corresponding to the target project.

[0003] However, in existing technologies, the process of determining the file dependency list corresponding to the compilation commands in the compilation request is time-consuming and inefficient, resulting in low overall efficiency of distributed compilation. Summary of the Invention

[0004] This disclosure provides at least one file search method, apparatus, computer device, and storage medium.

[0005] In a first aspect, embodiments of this disclosure provide a file search method, including:

[0006] Obtain at least one compilation command for the file to be compiled in the target project. For each compilation command, obtain the entry file from the file location of the entry file carried in the compilation command, and obtain the preprocessing instructions of each dependent file that has a dependency relationship with the entry file from the entry file.

[0007] For each dependent file, based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent file, query key information corresponding to the dependent file is generated;

[0008] Determine whether there is target path information matching the query key information in the pre-established index table corresponding to the target project. If it is determined that there is target path information matching the query key information in the index table, obtain the dependent file according to the file path indicated by the target path information.

[0009] In one possible implementation, the method further includes:

[0010] If no target path information matching the query key information is found in the pre-established index table, the target file path of the dependent file is searched in each of the directories in the search directory according to the directory order of each directory, and the dependent file is obtained at the file storage location indicated by the target file path.

[0011] The target file path is used as the target path information corresponding to the query key information, and the query key information and the target path information are stored in the index table.

[0012] In one possible implementation, after obtaining the dependency file, the method further includes:

[0013] The obtained dependency file is used as the new entry file, and the step of obtaining the preprocessing instructions of each dependency file that has a dependency relationship with the entry file is returned until the dependency files corresponding to the entry file carried in the compilation command are obtained.

[0014] Based on the entry file and its corresponding dependent files carried in the compilation command, a compilation dependency list corresponding to the compilation command is generated, and the compilation dependency list and the compilation command are sent to the compilation server, so that the compilation server can compile each file in the compilation dependency list based on the compilation command to obtain the compilation product.

[0015] In one possible implementation, generating query key information corresponding to the dependent file based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent file includes:

[0016] The preprocessing instructions and the search directory are compressed using a hash algorithm, and the compressed preprocessing instructions and the search directory are used as the query key information corresponding to the dependent file.

[0017] In one possible implementation, generating query key information corresponding to the dependent file based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent file includes:

[0018] In the case where the search directory includes multiple directories, a target directory whose content can be modified is identified among the multiple directories;

[0019] Obtain the file content of each file included in the target directory, and based on the file content of each file included in the target directory, the preprocessing instructions, and each directory in the search directory other than the target directory, generate the query key information corresponding to the dependent file.

[0020] In one possible implementation, sending the compilation dependency list and the compilation command to the compilation server includes:

[0021] After obtaining the compilation dependency list corresponding to each compilation command in at least one compilation command for the files to be compiled in the target project, each compilation command and its corresponding compilation dependency list are sent to different compilation servers.

[0022] In one possible implementation, obtaining at least one compilation command for the file to be compiled in the target project includes:

[0023] In response to a compilation request for a target project, determine the files to be compiled for the target project and the number of such files;

[0024] Based on each file to be compiled and the number of files to be compiled, at least one compilation command is generated for each file to be compiled in the target project.

[0025] Secondly, embodiments of this disclosure also provide a file search device, comprising:

[0026] The acquisition module is used to acquire at least one compilation command for the file to be compiled in the target project. For each compilation command, the module acquires the entry file from the file location of the entry file carried in the compilation command, and acquires the preprocessing instructions of each dependent file that has a dependency relationship with the entry file from the entry file.

[0027] The generation module is used to generate query key information for each dependent file based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent file.

[0028] The judgment module is used to determine whether there is target path information matching the query key information in the pre-established index table corresponding to the target project, and if it is determined that there is target path information matching the query key information in the index table, the dependent file is obtained according to the file path indicated by the target path information.

[0029] In one possible implementation, the judgment module is further configured to, when there is no target path information matching the query key information in the pre-established index table, sequentially search for the target file path of the dependent file in each of the directories in the search directory according to the directory order of each directory, and obtain the dependent file at the file storage location indicated by the target file path;

[0030] The target file path is used as the target path information corresponding to the query key information, and the query key information and the target path information are stored in the index table.

[0031] In one possible implementation, the device further includes:

[0032] The parsing module is used to, after obtaining the dependency file, use the obtained dependency file as a new entry file and return the step of obtaining the preprocessing instructions of each dependency file that has a dependency relationship with the entry file from the entry file, until the dependency files corresponding to the entry file carried in the compilation command are obtained.

[0033] Based on the entry file and its corresponding dependent files carried in the compilation command, a compilation dependency list corresponding to the compilation command is generated, and the compilation dependency list and the compilation command are sent to the compilation server, so that the compilation server can compile each file in the compilation dependency list based on the compilation command to obtain the compilation product.

[0034] In one possible implementation, the generation module is used to compress the preprocessing instructions and the search directory using a hash algorithm, and use the compressed preprocessing instructions and the search directory as the query key information corresponding to the dependent file.

[0035] In one possible implementation, the generation module is configured to determine a target directory whose content can be modified among the multiple directories when the search directory includes multiple directories;

[0036] Obtain the file content of each file included in the target directory, and based on the file content of each file included in the target directory, the preprocessing instructions, and each directory in the search directory other than the target directory, generate the query key information corresponding to the dependent file.

[0037] In one possible implementation, the parsing module is configured to, after obtaining the compilation dependency list corresponding to each compilation command in at least one compilation command for the file to be compiled in the target project, send each compilation command and its corresponding compilation dependency list to different compilation servers.

[0038] In one possible implementation, the acquisition module is configured to determine, in response to a compilation request for the target project, the files to be compiled corresponding to the target project and the number of files to be compiled.

[0039] Based on each file to be compiled and the number of files to be compiled, at least one compilation command is generated for each file to be compiled in the target project.

[0040] Thirdly, an optional implementation of this disclosure also provides a computer device, a processor, and a memory, wherein the memory stores machine-readable instructions executable by the processor, and the processor is configured to execute the machine-readable instructions stored in the memory. When the machine-readable instructions are executed by the processor, the steps of the first aspect above, or any possible implementation of the first aspect, are performed.

[0041] Fourthly, an optional implementation of this disclosure also provides a computer-readable storage medium storing a computer program that, when run, performs the steps of the first aspect or any possible implementation of the first aspect.

[0042] For a description of the effects of the aforementioned file search device, computer equipment, and computer-readable storage medium, please refer to the description of the file search method above; it will not be repeated here.

[0043] The file search method, apparatus, computer device, and storage medium provided in this disclosure generate query key information corresponding to dependent files based on the retrieval directory corresponding to the entry file and preprocessing instructions for dependent files corresponding to the entry file. By filtering target path information matching the query key information from a pre-established index table, dependent files can be directly retrieved from the file path indicated by the target path information once the target path information is determined. Compared to existing technologies that require sequentially searching file locations according to the retrieval directory when determining the path information corresponding to each file, wasting significant time and reducing file search efficiency, this disclosure, by establishing an index table storing key information that characterizes file identifiers and retrieval directories, as well as path information matching the key information, allows the determination of the target path information corresponding to the query key information after determining the query key information of the dependent file. This eliminates the need for sequentially searching file locations according to the retrieval directory, thus saving considerable search time and effectively improving file search efficiency.

[0044] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0045] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.

[0046] Figure 1 A flowchart of a file search method provided by an embodiment of this disclosure is shown;

[0047] Figure 2 A schematic diagram of a key-value pair provided in an embodiment of this disclosure is shown;

[0048] Figure 3 This illustration shows a flowchart of an embodiment of the present disclosure for obtaining the various files corresponding to a compilation command;

[0049] Figure 4 A schematic diagram of a file search device provided in an embodiment of this disclosure is shown;

[0050] Figure 5 A schematic diagram of a computer device structure provided in an embodiment of this disclosure is shown. Detailed Implementation

[0051] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown herein can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.

[0052] Furthermore, the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein.

[0053] In this article, "multiple or several" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0054] Research has revealed that existing distributed compilation processes, for any given compilation command, require sequentially parsing the search directory corresponding to the compilation command to determine the path information of each dependent file corresponding to the entry file in order to identify each dependent file. However, since the search directory typically contains a large amount of complex path information, and the number of dependent files corresponding to the entry file is usually relatively large, this method of sequentially parsing the search directory corresponding to the compilation command to determine the path information of each dependent file consumes a significant amount of search time, greatly reducing the efficiency of file search.

[0055] Based on the above research, this disclosure provides a file search method, apparatus, computer device, and storage medium. By establishing an index table that stores key information that can characterize file identifiers and search directories, as well as path information that matches the key information, after determining the query key information corresponding to the dependent file, it is only necessary to match the key information to determine the target path information corresponding to the query key information. It is not necessary to search the file location sequentially according to the search directory, thereby saving a lot of search time and effectively improving the efficiency of file search.

[0056] The shortcomings of the above solutions are the result of the inventor's practical experience and careful research. Therefore, the discovery process of the above problems and the solutions proposed in this disclosure below should be considered as the inventor's contribution to this disclosure.

[0057] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0058] It should be noted that the specific terms mentioned in the embodiments of this disclosure include:

[0059] C language: is a procedural, abstract, general-purpose programming language that is widely used in low-level development;

[0060] C++ is an inheritance of the C language. It can perform procedural programming like C, object-based programming with abstract data types, and object-oriented programming with inheritance and polymorphism.

[0061] Objective-C is an object-oriented programming language that extends C.

[0062] The hash algorithm transforms an input of arbitrary length into a fixed-length output, known as the hash value. Simply put, it's an algorithm that compresses a message of arbitrary length into a message digest of a fixed length.

[0063] MD5 Message-Digest Algorithm: MD5 is a widely used cryptographic hash function that produces a 128-bit (16-byte) hash value to ensure the integrity and consistency of transmitted information.

[0064] SHA256 algorithm: A mainstream hash algorithm that produces a 256-bit hash value, called a message digest, for any message length. This digest is essentially a 32-byte array, usually represented by a 64-bit hexadecimal string, where 1 byte = 8 bits and a hexadecimal character is 4 bits long.

[0065] To facilitate understanding of this embodiment, a file search method disclosed in this disclosure will first be described in detail. The file search method provided in this disclosure is generally executed by a computer device with certain computing power. In some possible implementations, the file search method can be implemented by the processor calling computer-readable instructions stored in the memory.

[0066] The following describes the file search method provided in this disclosure embodiment, taking a computer device as the execution subject as an example.

[0067] like Figure 1 The flowchart shown is a file search method provided in an embodiment of this disclosure, which may include the following steps:

[0068] S101: Obtain at least one compilation command for the file to be compiled in the target project. For each compilation command, obtain the entry file from the file location of the entry file carried in the compilation command, and obtain the preprocessing instructions of each dependent file that has a dependency relationship with the entry file from the entry file.

[0069] Here, the target project can specifically be a code compilation project, for example, a project that compiles the code corresponding to a certain application. The target project can include at least one file to be compiled, each of which can be a code file corresponding to a specific function. Multiple files to be compiled can correspond to a functional module of the target project, with each module providing relatively complete and rich functionality. Each file to be compiled can also include other files to be compiled that it depends on, referred to as its dependency files. Each other file to be compiled can also include other files it depends on. The number of dependency files corresponding to each file to be compiled can be determined based on actual development needs and is not limited here. In specific implementation, the target project can be a project based on one of the three programming languages: C++, C, or Objective-C. Each file to be compiled in the target project is a file based on any of these programming languages.

[0070] A compilation command is a command used to compile a file. It may include the file identifier and location of the entry file to be compiled, as well as the search directories for dependent files that have dependencies on the entry file. One file to be compiled can correspond to at least one compilation command; for example, one file to be compiled can correspond to a compilation command that compiles the entire file. Alternatively, multiple files to be compiled can correspond to one compilation command. For instance, if compiling multiple files according to a certain project result and order can result in more powerful and comprehensive functionality, the compilation command can be a command targeting these multiple files. For example, the compilation command could be "clang-c hello.mI Foo-I Bar-I Baz", where "hello.m" represents the file identifier of the entry file, and "-IFoo-I Bar-I Baz" represents the three search directories corresponding to the entry file. This compilation command indicates that the file with the file identifier "hello.m" will be compiled, and the dependent files for that file can be obtained from the search directory "-I Foo-I Bar-IBaz". Both the file identifier and the search directories can be referred to as compilation parameters.

[0071] The entry file can be the target file to be compiled for each compilation command. The entry file may include multiple dependent files, which are determined by parsing the entry file and using the resulting preprocessing directives. Preprocessing directives are instructions for processing the dependent files corresponding to that command, including file identifiers. For example, a preprocessing directive like "#include "xxx.h"" indicates instructions to preprocess the dependent file with the file identifier "xxx.h". The search directory can include multiple subdirectories, each of which can correspond to multiple new subdirectories or multiple files. The search directory can be predefined by the user, representing the directories where the dependent files corresponding to the entry file may appear. In practice, the search directory can be identified using specific characters, such as -I + parameter or -F + parameter. As shown in the compilation command example above, -I Foo-I Bar-I Baz indicates that the three search directories are Foo, Bar, and Baz, respectively. The file identifier can be a filename; as shown in the compilation command example above, the file identifier "hello.m" indicates a file named hello.m.

[0072] In practice, after obtaining the various files to be compiled corresponding to the target project, in response to the user's compilation operation on the compilation software for the target project, at least one compilation command can be generated for each of the files to be compiled in at least some of the files to be compiled corresponding to the target project, based on the project structure and configuration corresponding to the target project.

[0073] Alternatively, you can directly obtain at least one compilation command for the file to be compiled in the target project. The compilation command can be generated in advance based on the file to be compiled in the target project using compilation software, compiler, server, etc.

[0074] After obtaining at least one compilation command for the files to be compiled in the target project, a pre-deployed fake compiler can be used to process the compilation commands. Specifically, for each of the at least one compilation command, the pre-deployed fake compiler can perform command parsing to determine the file location of the entry file carried in the compilation command, as well as the search directory corresponding to the entry file. As shown in the example compilation command above, processing the compilation command using the fake compiler can be represented as: "fake_clang-chello.mI Foo-I Bar-I Baz", where "fake clang" represents the fake compiler.

[0075] Furthermore, the entry file can be obtained at its file location, and preprocessing instructions for each dependent file that has a dependency relationship with the entry file can be obtained from the entry file.

[0076] For example, the content of the obtained entry file can be analyzed to obtain the preprocessing instructions included in the entry file. That is, the "#include + "file identifier" statement can be obtained from the entry file. The file corresponding to the file identifier in the statement is the dependent file that has a dependency relationship with the entry file, and the statement is the preprocessing instruction for the dependent file.

[0077] The entry file may include one or more preprocessing directives, each of which may correspond to a different dependent file. Based on the analysis of the entry file, each dependent file that has a dependency relationship with the entry file can be identified.

[0078] S102: For each dependent file, based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent file, generate the query key information corresponding to the dependent file. The query key information is used to represent the file identifier and the search directory.

[0079] The query key information is used to represent the preprocessing instructions and the search directory. The search directory corresponding to the entry file is the same as the search directory corresponding to the compilation command.

[0080] In practice, for each identified dependency file, the preprocessing directives of that dependency file and the search directory corresponding to the entry file can be merged according to a preset merging rule to obtain the query key information corresponding to the dependency file. For example, if the merging rule is that the preprocessing directive comes before the search directory, and the preprocessing directive is "#include "111.h" and the search directory is "-I aI bI c", then the obtained query key information can be "#include "111.h I aI b-Ic". In practical applications, the information included in the compilation command is relatively complex, and the parameters representing the search directory are also very complex. Here, only a simple example is given; for instance, in practical applications, the search directory can correspond to several lines of code and may include several subdirectories.

[0081] Alternatively, the file identifier in the preprocessing directives of the dependent files and the search directory corresponding to the compilation command can be merged to obtain the query key information corresponding to the dependent files.

[0082] In one embodiment, after obtaining the preprocessing instructions and the search directory, a hash algorithm can be used to compress the preprocessing instructions and the search directory, and the compressed preprocessing instructions and the search directory can be used as the query key information corresponding to the dependent files. In this way, the query key information can represent both the search directory and the preprocessing commands corresponding to the dependent files.

[0083] Alternatively, other encryption and compression algorithms, such as MD5 message digest algorithm and SHA-256 algorithm, can be used to compress and encrypt the preprocessing instructions and search directory, and the encrypted and compressed preprocessing instructions and search directory can be used as the query key information corresponding to the dependent files.

[0084] S103: Determine whether there is target path information matching the query key information in the pre-established index table corresponding to the target project, and if it is determined that there is target path information matching the query key information in the index table, obtain the dependent files according to the file path indicated by the target path information.

[0085] The pre-established index table mentioned above can include multiple pre-determined key information and path information matching those keys. The key information can represent a preprocessing directive and its corresponding search directory, while the path information is the storage path of the file matching the file identifier included in the preprocessing directive. In practice, the index table can be continuously determined or completed based on the compilation results of previously parsed compilation commands.

[0086] In practice, after obtaining the query key information corresponding to the dependent files, a query can be performed in a pre-built index table to check if there is target path information matching the query key information. Specifically, the index table can be checked to see if there is key information consistent with the query key information. If so, the path information corresponding to that key information can be used as the target path information matching the query key information. Here, since the target path information corresponding to the same file must be the same when the file identifier and the search directory are the same, and the key information obtained after compressing the search directory and the preprocessing command including the file identifier using the same algorithm must be the same; therefore, if there is key information consistent with the query key information in the index table, it means that the search directory and preprocessing command corresponding to the two key information are the same, and the path information corresponding to the two key information is also the same; using the path information corresponding to the key information consistent with the query key information as the target path information matching the query key information means that the dependent file corresponding to the query key information can be obtained at the file path indicated by the target path information.

[0087] Furthermore, if it is determined that there is target path information in the index table that matches the query key information, the dependent files can be obtained according to the file path indicated by the target path information.

[0088] In this way, by establishing an index table that stores key information that can represent file identifiers and search directories, as well as path information that matches the key information, after determining the query key information corresponding to the dependent file, it is only necessary to match the key information to determine the target path information corresponding to the query key information. It is not necessary to search for file locations sequentially according to the search directory, thereby saving a lot of search time and effectively improving the efficiency of file search.

[0089] In one embodiment, regarding S103, if it is determined that there is no target path information matching the above query key information in the pre-established index table, the file storage location can also be searched according to the search directory corresponding to the compilation command. Specifically, the number of directories (i.e., the above subdirectories) included in the search directory corresponding to the compilation command, and the directory order corresponding to each directory, can be determined first. For example, if the search directory corresponding to the compilation command is "-I Foo-I Bar-I Baz", then the directory order corresponding to the three subdirectories Foo, Bar, and Baz is as follows: first search in the Foo directory; if no result is found in the Foo directory, search in the Bar directory; and if no result is found in the Bar directory, search in the Baz directory.

[0090] Next, following the directory order of each directory in the defined search catalog, the dependent files are searched sequentially in each directory until the target file path corresponding to the dependent file is determined. The target file path indicates the file storage location of the dependent file. Once the target file path is determined, the dependent file can be directly retrieved from the file storage location indicated by the target file path. When searching for the target file path of a dependent file, the search can begin in the directory corresponding to the entry file's location. If the file is not found in that directory, the search continues sequentially in each directory of the search catalog, searching for the target file path of the dependent file.

[0091] In one implementation, the search directory for the dependent files corresponding to the entry file can also be a directory pre-specified by the user that is different from the search directory corresponding to the entry file. In this case, after receiving the preprocessing instructions for the dependent files, it is also necessary to obtain the search directory pre-specified by the user and generate the query key information corresponding to the dependent file based on the search directory and the preprocessing instructions.

[0092] In addition, the file storage location indicated by the target file path may also store multiple different files. In this case, the file whose file identifier is the same as the file identifier of the dependent file can be found among the multiple files stored at the file storage location. This file is the dependent file.

[0093] After determining the target file path corresponding to the dependent files, this target file path can be used as the target path information corresponding to the query key information. This target path information and the query key information are then stored as a new key-value pair in the index table, where the key is the query key information and the value is the target path information. For example... Figure 2 The diagram shown is a schematic representation of a key-value pair provided in an embodiment of this disclosure. Thus, if a subsequently generated new query key matches the query key in this key-value pair, the value in the key-value pair can be directly used to retrieve the file corresponding to the new query key.

[0094] In one embodiment, if the entry file has dependent files, after obtaining the dependent files, each dependent file corresponding to the entry file can be obtained by following these steps:

[0095] Step 1: Use the obtained dependency file as the new entry file, and return to the step of obtaining the preprocessing instructions of each dependency file that has a dependency relationship with the entry file from the entry file, until the dependency files corresponding to the entry file carried in the compilation command are obtained.

[0096] In this step, after obtaining the dependency file, the obtained dependency file can be used as a new entry file. Then, return to the step of S101 above, which involves obtaining the preprocessing instructions of each dependency file that has a dependency relationship with the entry file from the entry file, to determine whether there is a new dependency file that has a dependency relationship with the entry file. If there is, then S102 above can be executed to generate the query key information corresponding to the new dependency file based on the preprocessing instructions corresponding to the new dependency file and the search directory corresponding to the entry file, and return to the step of S103 above, which involves determining whether there is target path information in the index table that matches the query key information, until the new dependency file is obtained.

[0097] Then, the new dependency file can be used as the new entry file, and the above S101, S102 and S103 can be executed again. After several loops, the dependency files corresponding to the entry file carried in the compilation command, as well as the dependency relationships between the entry file and its corresponding dependency files, can be obtained.

[0098] If it is determined that there are no new dependent files that have a dependency relationship with the entry file, then it can be determined that all the dependent files corresponding to the entry file have been obtained.

[0099] Step 2: Based on the entry file and its corresponding dependency files carried in the compilation command, generate a compilation dependency list corresponding to the compilation command, and send the compilation dependency list and compilation command to the compilation server so that the compilation server can compile each file in the compilation dependency list based on the compilation command to obtain the compilation product.

[0100] Here, the compilation dependency list includes the entry file and its corresponding file location, the dependency files corresponding to the entry file, and the target path information for each dependency file.

[0101] In practice, the compilation dependency list corresponding to the compilation command can be generated according to the entry file and its corresponding file location, the dependency files corresponding to the entry file, and the target path information of each dependency file.

[0102] Next, the compilation dependency list and compilation commands can be sent to the compilation server. The compilation server, based on the compilation commands and the dependencies in the dependency list, compiles each file in the dependency list to obtain the compilation output. The compilation server is the worker node; different compilation servers are different worker nodes. The step of determining the dependency file list is completed by the master server.

[0103] In one embodiment, regarding the step of sending the compilation dependency list and compilation commands to the compilation server, after obtaining the compilation dependency list corresponding to each compilation command in at least one compilation command for the files to be compiled in the target project, each compilation command and its corresponding compilation dependency list can be sent to different compilation servers. Here, the step of determining the compilation dependency list corresponding to each compilation command can be completed synchronously by the master server. Using different compilation servers to compile the files corresponding to the compilation dependency lists can ensure the efficiency of distributed compilation.

[0104] After each compilation server receives the compilation artifacts, it can send the artifacts back to the main server. The main server can then process the artifacts, for example, by merging them according to the project structure of the target project, to obtain the final compilation artifacts corresponding to the target project.

[0105] In one embodiment, generating query key information for dependent files based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent files in S102 can also be implemented according to the following steps:

[0106] S102-1: In cases where the search catalog includes multiple directories, identify the target directory whose contents can be modified within the multiple directories.

[0107] Here, the target directory is the search directory, which includes multiple directories whose contents can be modified.

[0108] In cases where the search directory includes multiple directories, there may be target directories whose content is modifiable. The modifiable content in a target directory can include the file content of each file within that directory, the subdirectories it contains, the number of subdirectories, and so on.

[0109] In practice, when the search directory includes multiple directories, the target directories whose content can be modified can be identified first.

[0110] S102-2: Obtain the file content of each file included in the target directory, and based on the file content of each file included in the target directory, preprocessing instructions, and each directory in the search directory other than the target directory, generate the query key information corresponding to the dependent files.

[0111] In this step, for each identified target directory, the file content of each file included in that target directory can be obtained. Then, a hash algorithm can be used to compress the file content of each file included in each target directory, the preprocessing instructions corresponding to the dependent files, and the directories in the search directory other than the target directories, to obtain the query key information corresponding to the dependent files.

[0112] In addition, when searching for the path information of dependent files, if the search directory corresponding to the dependent file also includes target directories whose content can be modified, the query key information corresponding to the dependent file can be determined according to S102-1 and S102-2 above, which will not be elaborated here.

[0113] In one implementation, the search directory corresponding to the compilation command may include an "hmap" file. The "hmap" file stores information about the mapping between file identifiers and path information. In some cases, this mapping may not be complete. For example, a project might contain three files: "Ah", "Bh", and "Ch", but the "hmap" file might only store the mappings for "Ah" and "Bh", omitting the mapping for "Ch". Furthermore, the information stored in the "hmap" file may be dynamically updated.

[0114] Based on the aforementioned characteristics of "hmap" files, even for the same file, it may be possible to find the file based on the "hmap" file in a previous search, but in a subsequent search, due to updates to the content of the "hmap" file, it may be impossible to find the file based on the "hmap" file.

[0115] Therefore, when the target path information of a certain dependency file is related to the "hmap" file, the steps to generate the query key information corresponding to the dependency file can be as follows: obtain the file content of the "hmap" file, and then generate the query key information corresponding to the dependency file based on the file content of the "hmap" file, the search directory corresponding to the compilation command, and the preprocessing directives corresponding to the dependency file.

[0116] In this way, by generating query key information based on the content of the "hmap" file and storing it in the index table, it can be guaranteed that when querying the target path information of a certain dependent file using the index table, if the query key information is matched, it means that the content of the "hmap" file in the search directory represented by the query key information corresponding to the dependent file is the same as the content of the "hmap" file in the search directory represented by the key information pre-stored in the index table. Therefore, the target path information can definitely be determined based on the "hmap" file.

[0117] In one embodiment, the step of obtaining at least one compilation command for the file to be compiled in the target project in S101 can be implemented according to the following steps:

[0118] S101-1: In response to a compilation request for the target project, determine the files to be compiled and the number of files to be compiled for the target project.

[0119] Here, a compilation request can be a request initiated by the user to compile the target project.

[0120] In practice, in response to a user's compilation request for the target project, the number of files to be compiled for the target project and the details of each file to be compiled can be determined.

[0121] S101-2: Based on each file to be compiled and the number of files to be compiled, generate at least one compilation command for each file to be compiled in the target project.

[0122] Here, the number of files to be compiled can be used as the number of compilation commands to be generated; that is, one file to be compiled can correspond to one compilation command. Then, based on each file to be compiled, a compilation command corresponding to each file can be generated. Each compilation command may include only the file identifier of the file to be compiled, i.e., the file identifier of the entry file, or it may include the file location of the entry file, but not the file content of the file to be compiled.

[0123] Alternatively, based on the project structure and configuration of the target project, the number of compilation commands to be generated can be determined, as well as the number of files to be compiled corresponding to each compilation command, and one file to be compiled can also correspond to multiple compilation commands. Then, based on the files to be compiled corresponding to the target project, at least one compilation command can be generated for each file to be compiled in the target project.

[0124] like Figure 3 The flowchart shown is a method for obtaining various files corresponding to compilation commands according to an embodiment of this disclosure, which may include the following steps:

[0125] S301: Obtain at least one compilation command for the file to be compiled in the target project. For each compilation command, obtain the entry file from the file location of the entry file carried in the compilation command, and obtain the preprocessing instructions of each dependent file that has a dependency relationship with the entry file from the entry file.

[0126] S302: For each dependency file, generate query key information corresponding to the dependency file based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependency file.

[0127] S303: Determine whether there is target path information in the pre-established index table corresponding to the target project that matches the query key information.

[0128] If yes, execute S304; if no, execute S305.

[0129] S304: Obtain the dependent files according to the file paths indicated by the target path information.

[0130] S305: Following the directory order of each directory in the search catalog, sequentially search for the target file path of the dependent file in each directory, and retrieve the dependent file at the file storage location indicated by the target file path; use the target file path as the target path information corresponding to the query key information, and store the query key information and the target path information in the index table.

[0131] Here, there is no execution order between steps S304 and S305; they are selected as one of the two execution steps.

[0132] S306: Use the obtained dependency file as the new entry file, and return to execute the steps of obtaining the preprocessing instructions of each dependency file that has a dependency relationship with the entry file from the entry file, until the dependency files corresponding to the entry file carried in the compilation command are obtained.

[0133] S307: Based on the entry file carried in the compilation command and the various dependent files corresponding to that entry file, generate a compilation dependency list corresponding to the compilation command, and send the compilation dependency list and the compilation command to the compilation server.

[0134] The specific implementation steps of S301 to S307 above can be referred to the above embodiments, and will not be repeated here.

[0135] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.

[0136] Based on the same inventive concept, this disclosure also provides a file search device corresponding to the file search method. Since the principle of the device in this disclosure for solving the problem is similar to the file search method described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0137] like Figure 4 The diagram shown is a schematic representation of a file search device provided in an embodiment of this disclosure, comprising:

[0138] The acquisition module 401 is used to acquire at least one compilation command for the file to be compiled in the target project, and for each compilation command, to acquire the entry file from the file location of the entry file carried in the compilation command, and to acquire the preprocessing instructions of each dependent file that has a dependency relationship with the entry file from the entry file.

[0139] The generation module 402 is used to generate query key information corresponding to each dependent file based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent file.

[0140] The judgment module 403 is used to determine whether there is target path information matching the query key information in the pre-established index table corresponding to the target project, and if it is determined that there is target path information matching the query key information in the index table, the dependent file is obtained according to the file path indicated by the target path information.

[0141] In one possible implementation, the judgment module 403 is further configured to, when there is no target path information matching the query key information in the pre-established index table, sequentially search for the target file path of the dependent file in each of the directories in the search directory according to the directory order of each directory, and obtain the dependent file at the file storage location indicated by the target file path;

[0142] The target file path is used as the target path information corresponding to the query key information, and the query key information and the target path information are stored in the index table.

[0143] In one possible implementation, the device further includes:

[0144] The parsing module 404 is used to, after obtaining the dependency file, use the obtained dependency file as a new entry file and return the step of obtaining the preprocessing instructions of each dependency file that has a dependency relationship with the entry file from the entry file, until the dependency files corresponding to the entry file carried in the compilation command are obtained.

[0145] Based on the entry file and its corresponding dependent files carried in the compilation command, a compilation dependency list corresponding to the compilation command is generated, and the compilation dependency list and the compilation command are sent to the compilation server, so that the compilation server can compile each file in the compilation dependency list based on the compilation command to obtain the compilation product.

[0146] In one possible implementation, the generation module 402 is used to compress the preprocessing instruction and the search directory using a hash algorithm, and use the compressed preprocessing instruction and the search directory as the query key information corresponding to the dependent file.

[0147] In one possible implementation, the generation module 402 is configured to determine a target directory whose content can be modified among the multiple directories when the search directory includes multiple directories;

[0148] Obtain the file content of each file included in the target directory, and based on the file content of each file included in the target directory, the preprocessing instructions, and each directory in the search directory other than the target directory, generate the query key information corresponding to the dependent file.

[0149] In one possible implementation, the parsing module 404 is configured to, after obtaining the compilation dependency list corresponding to each compilation command in at least one compilation command for the file to be compiled in the target project, send each compilation command and its corresponding compilation dependency list to different compilation servers.

[0150] In one possible implementation, the acquisition module 401 is used to determine the files to be compiled and the number of files to be compiled corresponding to the target project in response to a compilation request in the target project;

[0151] Based on each file to be compiled and the number of files to be compiled, at least one compilation command is generated for each file to be compiled in the target project.

[0152] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.

[0153] This disclosure also provides a computer device, such as... Figure 5 The diagram shown is a schematic representation of a computer device structure provided in an embodiment of this disclosure, including:

[0154] The processor 51 and memory 52; the memory 52 stores machine-readable instructions executable by the processor 51. The processor 51 executes the machine-readable instructions stored in the memory 52. ​​When the machine-readable instructions are executed by the processor 51, the processor 51 performs the following steps: S101: Obtain at least one compilation command for the file to be compiled in the target project. For each compilation command, obtain the entry file from the file location of the entry file carried in the compilation command, and obtain the preprocessing instructions for each dependent file that has a dependency relationship with the entry file from the entry file; S102: For each dependent file, generate query key information corresponding to the dependent file based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent file; S103: Determine whether there is target path information matching the query key information in the pre-established index table corresponding to the target project, and if it is determined that there is target path information matching the query key information in the index table, obtain the dependent file according to the file path indicated by the target path information.

[0155] The aforementioned memory 52 includes a main memory 521 and an external memory 522; the main memory 521, also known as internal memory, is used to temporarily store the computational data in the processor 51, as well as the data exchanged with external memory 522 such as a hard disk. The processor 51 exchanges data with the external memory 522 through the main memory 521.

[0156] The specific execution process of the above instructions can be referred to the steps of the file search method described in the embodiments of this disclosure, and will not be repeated here.

[0157] This disclosure also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the file search method described in the above-described method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.

[0158] The computer program product of the file search method provided in this disclosure includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the steps of the file search method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.

[0159] The computer program product can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0160] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0161] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

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

[0163] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0164] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.

Claims

1. A file search method, characterized in that, include: Obtain at least one compilation command for the file to be compiled in the target project. For each compilation command, obtain the entry file from the file location of the entry file carried in the compilation command, and obtain the preprocessing instructions of each dependent file that has a dependency relationship with the entry file from the entry file. For each dependent file, based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent file, query key information corresponding to the dependent file is generated; Determine whether a target path matching the query key exists in a pre-established index table corresponding to the target project. If a target path matching the query key exists in the index table, retrieve the dependent file according to the file path indicated by the target path information. The search directory is a pre-defined directory in which each dependent file corresponding to the entry file appears; The preprocessing instructions include the file identifier of the corresponding dependent file; the step of generating query key information corresponding to the dependent file based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent file includes: In the case where the search directory includes multiple directories, a target directory whose content can be modified is identified among the multiple directories; Obtain the file content of each file included in the target directory, and generate the query key information corresponding to the dependent file based on the file content of each file included in the target directory, the preprocessing instructions, and each directory in the search directory other than the target directory; The index table includes multiple predetermined key information and path information matching the key information; the key information represents a preprocessing instruction and a search directory corresponding to the preprocessing instruction.

2. The method according to claim 1, characterized in that, The method further includes: If no target path information matching the query key information is found in the pre-established index table, the target file path of the dependent file is searched in each of the directories in the search directory according to the directory order of each directory, and the dependent file is obtained at the file storage location indicated by the target file path. The target file path is used as the target path information corresponding to the query key information, and the query key information and the target path information are stored in the index table.

3. The method according to claim 2, characterized in that, After obtaining the dependency files, the following is also included: The obtained dependency file is used as the new entry file, and the step of obtaining the preprocessing instructions of each dependency file that has a dependency relationship with the entry file is returned until the dependency files corresponding to the entry file carried in the compilation command are obtained. Based on the entry file and its corresponding dependency files carried in the compilation command, a compilation dependency list corresponding to the compilation command is generated, and the compilation dependency list and the compilation command are sent to the compilation server. This enables the compilation server to compile each file in the compilation dependency list based on the compilation command to obtain the compilation output.

4. The method according to claim 1, characterized in that, The step of generating query key information corresponding to the dependent files based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent files includes: The preprocessing instructions and the search directory are compressed using a hash algorithm, and the compressed preprocessing instructions and the search directory are used as the query key information corresponding to the dependent file.

5. The method according to claim 3, characterized in that, Sending the compilation dependency list and the compilation command to the compilation server includes: After obtaining the compilation dependency list corresponding to each compilation command in at least one compilation command for the files to be compiled in the target project, each compilation command and its corresponding compilation dependency list are sent to different compilation servers.

6. The method according to claim 1, characterized in that, The step of obtaining at least one compilation command for the file to be compiled in the target project includes: In response to a compilation request for a target project, determine the files to be compiled for the target project and the number of such files; Based on each file to be compiled and the number of files to be compiled, at least one compilation command is generated for each file to be compiled in the target project.

7. A file search device, characterized in that, include: The acquisition module is used to acquire at least one compilation command for the file to be compiled in the target project. For each compilation command, the module acquires the entry file from the file location of the entry file carried in the compilation command, and acquires the preprocessing instructions of each dependent file that has a dependency relationship with the entry file from the entry file. The generation module is used to generate query key information for each dependent file based on the search directory corresponding to the entry file and the preprocessing instructions corresponding to the dependent file. The judgment module is used to determine whether there is target path information matching the query key information in a pre-established index table corresponding to the target project, and if it is determined that there is target path information matching the query key information in the index table, the dependent file is obtained according to the file path indicated by the target path information. The search directory is a pre-defined directory in which each dependent file corresponding to the entry file appears; The preprocessing instructions include the file identifiers of the corresponding dependent files; the generation module is specifically used for: In the case where the search directory includes multiple directories, a target directory whose content can be modified is identified among the multiple directories; Obtain the file content of each file included in the target directory, and generate the query key information corresponding to the dependent file based on the file content of each file included in the target directory, the preprocessing instructions, and each directory in the search directory other than the target directory; The index table includes multiple predetermined key information and path information matching the key information; the key information represents a preprocessing instruction and a search directory corresponding to the preprocessing instruction.

8. A computer device, characterized in that, include: A processor and a memory, the memory storing machine-readable instructions executable by the processor, the processor executing the machine-readable instructions stored in the memory, wherein when the machine-readable instructions are executed by the processor, the processor performs the steps of the file search method as described in any one of claims 1 to 6.

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