CN113806595B - Code search system generation method, code search method and search server - Google Patents

Code search system generation method, code search method and search server Download PDF

Info

Publication number
CN113806595B
CN113806595B CN202110932999.3A CN202110932999A CN113806595B CN 113806595 B CN113806595 B CN 113806595B CN 202110932999 A CN202110932999 A CN 202110932999A CN 113806595 B CN113806595 B CN 113806595B
Authority
CN
China
Prior art keywords
code
branch
search
target
search server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110932999.3A
Other languages
Chinese (zh)
Other versions
CN113806595A (en
Inventor
于亮
张大欣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202110932999.3A priority Critical patent/CN113806595B/en
Publication of CN113806595A publication Critical patent/CN113806595A/en
Application granted granted Critical
Publication of CN113806595B publication Critical patent/CN113806595B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9017Indexing; Data structures therefor; Storage structures using directory or table look-up
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9027Trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/9032Query formulation

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application provides a code search system generation method, a code search method and a search server, relates to the field of data retrieval, and improves the utilization rate of storage resources of the search server. The method comprises the following steps: and generating a branch directory of the target branch according to the relative path of the code bin of the target branch and the directory tree information. And when the code files are not stored, downloading the code bins to which all the code files of the first branch belong from the code server and reading all the code files. When the code files are stored, reading a first code file in the code files of the second branch from the local, reading a second code file except the first code file from the code server, and downloading the code bin to which the second code file belongs. And generating a branch index of the branch according to the branch directory of the branch, all the code files and the storage addresses thereof. And generating a code search system according to all branch directories, all branch indexes and all code bins.

Description

Code search system generation method, code search method and search server
Technical Field
The present application relates to the field of data retrieval, and in particular, to a code search system generation method, a code search method, and a search server.
Background
In developing some large websites or some operating systems (e.g. android) TM System), the code volume of these large websites or operating systems is very large because the number of functions that need to be implemented is very large. Taking the android system as an example, the android system itself includes a plurality of modules (e.g., a starting module, a home page module, a message pushing module, etc.), and the amount of code corresponding to each module may be large. Google for easy management and recall TM And dividing all code files of the android system into different code bins according to different modules for developers to use. For convenience of development and release, a branch is actually established for a code file with certain requirements/characteristics, each branch corresponds to a plurality of code bins, and a subsequent user can conveniently modify or supplement the code file in different code bins on the branch during development.
The existing code search system can provide the function of searching and viewing the target code file by a developer. In the existing code search system, it is necessary to download the branch code file corresponding to each branch in all the code bins for each branch, and then establish a branch index corresponding to each branch. The branch index for each branch may be associated to all code files for that branch for subsequent searches. After the branch index is established, the generation of search system can search the code file corresponding to the search requirement by using the branch index according to the search requirement of the user and provide the code file for the user to view. Because different branches may correspond to the same code file, the existing code search system can locally download multiple sets of repeated code files, which causes great waste to local storage resources and reduces the utilization rate of the storage resources.
Disclosure of Invention
The application provides a code search system generation method, a code search method and a search server, which can avoid the code search system from downloading multiple sets of repeated code files in the search server and improve the utilization rate of storage resources of the search server.
In a first aspect, the present application provides a code search system generation method, which may be applied to a search server. In the method, a search server first obtains feature information and directory tree information of a code bin of at least one target branch in target code from a code server. Wherein the characteristic information includes: name, relative path, latest submission point and download address; the latest submission point of the target code bin of the target branch is the latest one of all submission points of the target branch submitting the code file in the target code bin; the target code bin is any one of all code bins of the target branch; the directory tree information at least comprises characteristic parameters of code files in a code bin to which the directory tree information belongs; the characteristic parameter is used for indicating a code file to which the characteristic parameter belongs. Then, the search server generates a branch directory of the target branch according to the relative path of the code bin of the target branch and the directory tree information; the branch directory includes at least the relative path of the code bin included by the target branch and the characteristic parameters of the code files in the code bin corresponding to the target branch.
Under the condition that any code file of the target code is not stored in the search server, the search server downloads the code bins to which all the code files of the first branch belong from the code server according to the names and the downloading addresses of the code bins of the first branch, and reads all the code files corresponding to the branch directories of the first branch; the first branch is any one of the at least one target branch. Then, the search server generates a branch index of the first branch according to all code files of the first branch, the branch directory of the first branch, and the storage addresses of all code files of the first branch. The branch index is at least used for indicating the position of any code file corresponding to the branch to which the branch index belongs in the branch directory corresponding to the branch index.
Under the condition that the code bins to which all the code files of the established branches belong are stored in the search server, the search server sequentially reads all first code files in the code files corresponding to the branch directory of the second branch from the local; the established branch is a target branch which is generated with a branch index; the second branch is any one of the at least one target branch except the established branch; the first code file is the code file in the code bin to which all code files of the created branch belong. Then, the search server reads all the second code files from the code server according to the characteristic parameters of all the second code files except the first code file in the code files corresponding to the branch directory of the second branch, the names of the code bins to which all the second code files belong, the latest submission points of the code bins to which all the second code files belong and the download addresses of the code bins to which all the second code files belong, and downloads the code bins to which all the second code files belong. Then, the search server generates a branch index of the second branch according to the branch directory of the second branch, all code files of the second branch, and storage addresses of all code files of the second branch. And finally, the search server generates a code search system according to the branch directory of the at least one target branch, the branch index of the at least one target branch and all the code bins which are downloaded by the search server and correspond to the at least one target branch.
Based on the above embodiments, according to the code search system generation method provided in the embodiments of the present application, after obtaining the feature information (including the name, the sex pair path, the latest proposed point, and the download address) and the directory tree information of the code bins of the multiple target branches of the target code, the search server may generate the branch directory of the target branches according to the relative path of the code bins of the target branches and the directory tree information. Then, when a branch index is first established for a first branch (any target branch), a code bin to which all code files of the first branch belong can be downloaded from the code server according to the name and the download address of the code bin of the first branch, and all code files corresponding to the branch directory of the first branch are read. Then, the search server may generate a branch index of the first branch according to the branch directory of the first branch, all code files of the first branch, and a storage address thereof. The branch index is at least used for indicating the position of any code file corresponding to the branch to which the branch index belongs in the branch directory.
In the case that the branch index of some target branches is established, and the code bins corresponding to some branches (for example, the code bins to which all the code files of the first branch belong) exist in the search server, the search server may locally read all the first code files in the code files corresponding to the branch directories of the second branch for which the branch index is currently required to be established. Then, the search server may read all the second code files from the code server and download all the code bins to which the second code files belong, according to the feature parameters of all the second code files except the first code file in the code files corresponding to the branch directory of the second branch, the names of the code bins to which all the second code files belong, the latest submission points of the code bins to which all the second code files belong, and the download addresses of the code bins to which all the second code files belong. And further generating a branch index of the second branch according to the branch directory of the second branch, all the code files of the second branch and the storage addresses thereof. And finally, generating a code searching system according to the branch directory of the at least one target branch, the branch index of the at least one target branch and all the downloaded code bins.
It can be seen that, according to the technical solution provided in the embodiment of the present application, in the process of constructing a branch index in a code search system, after some code bins are downloaded in the process of establishing a branch index for a certain target branch, it is not necessary to download the code bins again in the subsequent process of establishing other branch indexes, so that the search server can download each code bin once, and then the branch index can be generated according to a branch directory, read results (i.e., all code files of the target branch) and storage addresses of the code files. And because the branch index can be used for indicating the position of any code file corresponding to the branch to which the branch index belongs in the branch directory, in the process that a subsequent user uses the code search system, the branch directory and the branch index can be determined according to the search requirement, then the corresponding position of the required code file in the branch directory (namely the position of the name of the code file) is determined according to the branch index, and then the corresponding code file can be obtained from the code bin by using the association of the branch directory and each code file in the code, so that the search process is completed. In summary, compared with the prior art, the embodiment of the application does not need to download all the corresponding code bins for each branch, and the utilization rate of the storage resources of the search server is greatly improved.
In a possible design of the first aspect, the obtaining, by the search server, feature information and directory tree information of a code bin of at least one target branch in the target code from the code server includes: the search server acquires a manifest file of at least one branch and directory tree information of a code bin of at least one branch from the code server; the search server analyzes the manifest file of the at least one target branch to obtain the characteristic information of the code bin of the at least one target branch.
In this way, since the manifest file exists in the code bin of the android system during storage, and the file includes the feature information of the code bin, based on the above scheme, the feature information of the code bin of the target branch can be smoothly acquired.
In a possible design manner of the first aspect, the downloading, by the search server, the code bin to which all the code files of the first branch belong from the code server according to the name and the download address of the code bin of the first branch, and reading all the code files corresponding to the branch directory of the first branch includes:
the search server sequentially reads each code file corresponding to the branch directory of the first branch from the local; the first branch is one of the at least one branch; under the condition that the search server cannot read the target code file from the local memory, the search server reads the target code file from the code server according to the characteristic parameters of the target code file, the name of the code bin to which the target code file belongs, the latest extraction point of the code bin to which the target code file belongs and the download address of the code bin to which the target code file belongs, and downloads the code bin to which the target code file belongs to the local memory; the target code file is any one of all code files corresponding to the branch directory of the first branch.
Based on the scheme, the search server can read all code files corresponding to the first branch at the fastest speed so as to conveniently take the reading result as a basis for establishing the branch index. And simultaneously, all the code bins corresponding to the first branch can be downloaded without repetition. So that a code search system can be subsequently established to provide data support.
In a possible design manner of the first aspect, the reading, by the search server, all the second code files from the code server and downloading the code bins to which all the second code files belong according to the characteristic parameters of all the second code files except the first code file in the code files corresponding to the branch directory of the second branch, the names of the code bins to which all the second code files belong, the latest submission points of the code bins to which all the second code files belong, and the download addresses of the code bins to which all the second code files belong includes:
the search server reads all the second code files from the local in sequence; under the condition that the search server cannot read the fourth code file from the local memory, the search server reads the fourth code file from the code server according to the characteristic parameters of the fourth code file, the name of the code bin to which the fourth code file belongs, the latest submission point of the code bin to which the fourth code file belongs and the download address of the code bin to which the fourth code file belongs, and downloads the code bin to which the fourth code file belongs; the fourth code file is any one of all the second code files.
Based on the scheme, the search server can quickly read from the code server and download the corresponding code bin when reading the second code file which is not in the code bin downloaded for the first branch in the second branch directory. So that a branch index and code search system for the second branch may be subsequently built to provide data support. Furthermore, because in the above solution, the search server only downloads the code bins except the code bin downloaded for the first branch, the defect that the same code file is repeatedly downloaded due to the existence of repetition in the code files corresponding to the first branch and the second branch in the prior art is also avoided.
In a possible design manner of the first aspect, the method further includes: and the search server acquires all code bins corresponding to the target branch from the code server every preset time length, and updates all code bins corresponding to the target branch stored by the search server by using all newly acquired code bins corresponding to the target branch.
Based on the scheme, the content of the code bin stored locally by the search server can be synchronized with the same code bin in the code server in time, and the accuracy of a user in searching the code is guaranteed.
In one possible design of the first aspect, after generating the code search system, the method further includes:
the search server responds to a search instruction from the development client, and searches a third code file matched with the keyword from local by using the keyword carried by the search instruction according to the branch index and the branch directory of the branch corresponding to the branch mark carried by the search instruction; the search server sends the third code file to the development client.
Based on the scheme, the search server can smoothly find the code file required by the user by using the branch index and the branch directory generated in the embodiment.
In a possible design manner of the first aspect, the searching server, in response to a search instruction from the development client, according to a branch index and a branch directory of a branch corresponding to a branch marker carried by the search instruction, and using a keyword carried by the search instruction, locally searches for a third code file corresponding to the keyword, including: the search server responds to a search instruction from the development client, and determines a target position of a third code file matched with a keyword carried by the search instruction in a branch directory according to a branch index of a branch corresponding to a branch mark carried by the search instruction; the search server searches the third code file from the local using the branching directory and the target location.
Based on the above scheme, when searching for the corresponding code file according to the search instruction, the search server determines the corresponding position of the code file in the branch directory through the branch index, and then obtains the code file according to the branch directory. The branch directory is generated according to directory tree information and relative paths of a plurality of code bins corresponding to branches, so that all code files in the code bins related to the branches are associated in the branch directory of a certain branch and all code bins locally stored by the search server, and the search server can utilize the branch directory to smoothly acquire the code files when knowing the corresponding positions of the code files needing to be searched by developers in the branch directory. Furthermore, even when the search server receives a plurality of search instructions for different branches at the same time, because each branch has a corresponding branch directory to acquire the code file from the code bin, the working space of a certain code bin is not frequently switched due to the difference of the branches corresponding to the search instructions, and the search efficiency is reduced.
In a possible design manner of the first aspect, the searching server, in response to a search instruction from the development client, searches a third code file matching the keyword from a local location by using the keyword carried by the search instruction according to a branch index and a branch directory of a branch corresponding to a branch marker carried by the search instruction, including: the search server responds to a search instruction from the development client, and under the condition that a branch corresponding to a branch mark carried by the search instruction is a second branch, if a third code file corresponding to a keyword carried by the search instruction is determined to be a code file in a second code bin according to a branch index of the second branch and a branch directory of the second branch, the third code file is obtained from the second code bin; the second code bin is any one of the code bins to which all the code files of the established branch belong.
Based on the above scheme, the code search system generated by the technical scheme provided by the embodiment of the application can enable the search server to smoothly acquire a certain code file when searching the code file, regardless of which branch index was downloaded before in the code bin to which the code file belongs.
In a second aspect, the present application provides a code search method applied to a search server, in which a code search system generated by the code search system generation method provided in the first aspect is arranged. The code searching method comprises the following steps: the search server responds to a search instruction from the development client, and searches a third code file corresponding to a keyword from local by using the keyword carried by the search instruction according to a branch index and a branch directory of a branch corresponding to a branch mark carried by the search instruction; the search server sends the third code file to the development client.
Based on the scheme, the search server can smoothly find the code file required by the user by using the branch index and the branch directory generated in the embodiment.
In a possible design manner of the second aspect, the searching server, in response to a search instruction from the development client, according to a branch index and a branch directory of a branch corresponding to a branch marker carried by the search instruction, and using a keyword carried by the search instruction, locally searches for a third code file matching the keyword, including:
the search server responds to a search instruction from the development client, and determines a target position of a third code file matched with a keyword carried by the search instruction in a branch directory according to a branch index of a branch corresponding to a branch mark carried by the search instruction; the search server searches the third code file from the local using the branching directory and the target location.
Based on the above scheme, when searching for the corresponding code file according to the search instruction, the search server determines the corresponding position of the code file in the branch directory through the branch index, and then obtains the code file according to the branch directory. The branch directory is generated according to directory tree information and relative paths of a plurality of code bins corresponding to branches, so that all code files in the code bins related to the branches are associated in the branch directory of a certain branch and all code bins locally stored by the search server, and the search server can utilize the branch directory to smoothly acquire the code files when knowing the corresponding positions of the code files needing to be searched by developers in the branch directory. Furthermore, even when the search server receives a plurality of search instructions for different branches at the same time, because each branch has a corresponding branch directory to acquire the code file from the code bin, the working space of a certain code bin is not frequently switched due to the difference of the branches corresponding to the search instructions, and the search efficiency is reduced.
In a third aspect, the present application provides a search server comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to cause the search server to perform the steps of:
the search server acquires the characteristic information and directory tree information of a code bin of at least one target branch in the target code from the code server; the characteristic information includes: name, relative path, latest submission point and download address; the latest submission point of the target code bin of the target branch is the latest one of all submission points of the target branch submitting the code file in the target code bin; the target code bin is any one of all code bins of the target branch; the directory tree information at least comprises characteristic parameters of code files in a code bin to which the directory tree information belongs; the characteristic parameter is used for indicating a code file to which the characteristic parameter belongs;
the search server generates a branch directory of the target branch according to the relative path of the code bin of the target branch and the directory tree information; the branch directory at least comprises a relative path of a code bin included by the target branch and characteristic parameters of a code file in the code bin corresponding to the target branch;
under the condition that any code file of the target code is not stored in the search server, the search server downloads the code bins to which all the code files of the first branch belong from the code server according to the names and the downloading addresses of the code bins of the first branch, and reads all the code files corresponding to the branch directories of the first branch; the first branch is any one of at least one target branch;
the search server generates a branch index of the first branch according to all the code files of the first branch, the branch directory of the first branch and the storage addresses of all the code files of the first branch; the branch index is at least used for indicating the position of any code file corresponding to the branch to which the branch index belongs in a branch directory corresponding to the branch index;
under the condition that the code bins to which all the code files of the established branches belong are stored in the search server, the search server sequentially reads all first code files in the code files corresponding to the branch directory of the second branch from the local; the established branch is a target branch which is generated with a branch index; the second branch is any one of the at least one target branch except the established branch; the first code file is a code file in a code bin to which all the code files of the established branch belong;
the search server reads all the second code files from the code server according to the characteristic parameters of all the second code files except the first code file in the code files corresponding to the branch directory of the second branch, the names of the code bins to which all the second code files belong, the latest submission points of the code bins to which all the second code files belong and the download addresses of the code bins to which all the second code files belong, and downloads the code bins to which all the second code files belong;
the search server generates a branch index of the second branch according to the branch directory of the second branch, all the code files of the second branch and the storage addresses of all the code files of the second branch;
and the search server generates a code search system according to the branch directory of the at least one target branch, the branch index of the at least one target branch and all the code bins which are downloaded by the search server and correspond to the at least one target branch.
In a possible design of the third aspect, the processor is configured to execute the instructions, so that the search server specifically performs the following steps: the search server acquires a manifest file of at least one branch and directory tree information of a code bin of at least one branch from the code server; the search server analyzes the manifest file of the at least one target branch to obtain the characteristic information of the code bin of the at least one target branch.
In one possible design of the third aspect, the processor is configured to execute the instructions, so that the search server specifically performs the following steps: the search server sequentially reads each code file corresponding to the branch directory of the first branch from the local; the first branch is one of the at least one branch; under the condition that the search server cannot read the target code file from the local, the search server reads the target code file from the code server according to the characteristic parameters of the target code file, the name of the code bin to which the target code file belongs, the latest extraction point of the code bin to which the target code file belongs and the download address of the code bin to which the target code file belongs, and downloads the code bin to which the target code file belongs to the local memory; the target code file is any one of all code files corresponding to the branch directory of the first branch.
In a possible design of the third aspect, the processor is configured to execute the instructions, so that the search server specifically performs the following steps: the search server reads all the second code files from the local in sequence; under the condition that the search server cannot read the fourth code file from the local memory, the search server reads the fourth code file from the code server according to the characteristic parameters of the fourth code file, the name of the code bin to which the fourth code file belongs, the latest submission point of the code bin to which the fourth code file belongs and the download address of the code bin to which the fourth code file belongs, and downloads the code bin to which the fourth code file belongs; the fourth code file is any one of all the second code files.
In one possible design of the third aspect, the processor is configured to execute the instructions, so that the search server further performs the following steps: and the search server acquires all code bins corresponding to the target branch from the code server every preset time length, and updates all code bins corresponding to the target branch stored by the search server by using all newly acquired code bins corresponding to the target branch.
In one possible design of the third aspect, the processor is configured to execute the instructions, so that the search server further performs the following steps after generating the code search system: the search server responds to a search instruction from the development client, and searches a third code file matched with the keyword from local by using the keyword carried by the search instruction according to the branch index and the branch directory of the branch corresponding to the branch mark carried by the search instruction; the search server sends the third code file to the development client.
In a possible design of the third aspect, the processor is configured to execute the instructions, so that the search server specifically performs the following steps: the search server responds to a search instruction from the development client, and determines a target position of a third code file matched with a keyword carried by the search instruction in a branch directory according to a branch index of a branch corresponding to a branch mark carried by the search instruction; the search server searches the third code file from the local using the branching directory and the target location.
In a possible design of the third aspect, the processor is configured to execute the instructions, so that the search server specifically performs the following steps:
the search server responds to a search instruction from the development client, and under the condition that a branch corresponding to a branch mark carried by the search instruction is a second branch, if a third code file corresponding to a keyword carried by the search instruction is determined to be a code file in a second code bin according to a branch index of the second branch and a branch directory of the second branch, the third code file is obtained from the second code bin; the second code bin is any one of the code bins to which all the code files of the established branch belong.
In a fourth aspect, the present application provides a search server, in which a code search system generated by the code search system generation method provided in the first aspect is provided. The search server includes: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to cause the search server to perform the steps of: the search server responds to a search instruction from the development client, and searches a third code file corresponding to a keyword from local by using the keyword carried by the search instruction according to a branch index and a branch directory of a branch corresponding to a branch mark carried by the search instruction; the search server sends the third code file to the development client.
In one possible design of the fourth aspect, the processor is configured to execute the instructions, so that the search server specifically performs the following steps: the search server responds to a search instruction from the development client, and determines a target position of a third code file matched with a keyword carried by the search instruction in a branch directory according to a branch index of a branch corresponding to a branch mark carried by the search instruction; the search server searches the third code file from the local using the branching directory and the target location.
In a fifth aspect, the present application provides a computer-readable storage medium comprising computer instructions which, when run on a search server, cause the search server to perform a code search system generation method as provided by the first aspect and any one of its possible designs, or a code search method as provided by the second aspect and any one of its possible designs.
In a sixth aspect, the present application provides a computer program product, which, when run on a search server, causes the search server to execute a code search system generation method as provided by the first aspect and any one of its possible designs, or a code search method as provided by the second aspect and any one of its possible designs.
It can be understood that, for the beneficial effects that can be achieved by the search server according to the third aspect and any one of the possible design manners provided above, reference may be made to the beneficial effects of the first aspect and any one of the possible design manners thereof, and details are not described here again. The beneficial effects that can be achieved by the search server according to the fourth aspect and any one of the possible design manners thereof can refer to the beneficial effects of the second aspect and any one of the possible design manners thereof, and are not described herein again. The computer storage medium provided in the fifth aspect and the advantageous effects achieved by the computer program product provided in the sixth aspect may refer to the advantageous effects of the first aspect and any one of the possible design manners thereof, and the advantageous effects of the second aspect and any one of the possible design manners thereof, which are not described herein again.
Drawings
Fig. 1 is a schematic structural diagram of a code search system according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of a development client according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a search server according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a code search scheme provided in the prior art;
FIG. 5 is a schematic diagram illustrating a different branch submission process for a code bin according to an embodiment of the present disclosure;
FIG. 6 is a schematic diagram of a login interface of a code search service according to an embodiment of the present application;
fig. 7 is a schematic view of a code search scenario provided in an embodiment of the present application;
FIG. 8 is a schematic diagram of a bifurcation searching interface provided in an embodiment of the present application;
FIG. 9 is a schematic diagram illustrating a code searching method according to an embodiment of the present application;
FIG. 10 is a diagram illustrating a branch directory according to an embodiment of the present application;
FIG. 11 is a schematic diagram illustrating a principle of generating a branch directory according to an embodiment of the present disclosure;
FIG. 12 is a schematic diagram illustrating a principle of generating a branch index according to an embodiment of the present disclosure;
fig. 13 is a schematic flowchart of a code searching method according to an embodiment of the present application;
FIG. 14 is a flowchart illustrating another code searching method according to an embodiment of the present application;
FIG. 15 is a schematic diagram of a code search process provided in an embodiment of the present application;
FIG. 16 is a flowchart illustrating a further code searching method according to an embodiment of the present application;
fig. 17 is a schematic structural diagram of another search server according to an embodiment of the present application.
Detailed Description
In the following, the terms "first", "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present embodiment, "a plurality" means two or more unless otherwise specified.
First, related art terms referred to in the present application are introduced:
the user space file system (FUSE) is a software interface oriented to Unix-like computer operating systems (equivalent to linux computer operating systems), which enables an unprivileged user to create his own file system without editing kernel code. FUSE may be used to create a file system, such as a file system composed of a directory tree of branches in the present application.
Indexing: in a relational database, an index is a single, physical storage structure that orders one or more columns of values in a database table, which is a collection of one or more columns of values in a table and a corresponding list of logical pointers to data pages in the table that physically identify the values. The index is equivalent to the directory of the book, and the required content can be quickly found according to the page number in the directory. In the present application, the branch index of a branch is generated according to all code files and storage addresses of the branch and the branch directory of the branch, and can reflect the corresponding positions of the code files corresponding to different keywords in the branch directory of the branch (i.e. the positions of the names of the codes in the branch directory).
Repo: repo is a script written by google with Python script for calling git, and is mainly a software warehouse for downloading and managing Android projects. That is, Repo is used to manage individual git repositories (i.e., code bins as referred to in this application), which can simplify git usage in android development.
Git: git is an open-source, distributed version control system for expeditiously and efficiently processing any item, small or large. Git is different from common version control tool code version control software (CVS), time machine (SVN) and the like, and adopts a distributed version library mode without being supported by server-side software. All code bins in the embodiment of the present application are git managed code bins, i.e., git bins.
git bin (i.e. code bin in this application): the git bin is used to manage code files submitted by developers for at least one branch. A submission point of the code file for each branch at each submission time of the developer is set, and the code file corresponding to each submission point of each branch is all the code files of the developer at the submission point for the branch (i.e., all the code files submitted at the submission point and all the submission points before the submission point). The working space of the git bin is a code file corresponding to one commit point (generally, the latest commit point, i.e., the latest commit point in this application) of one branch, that is, the git bin can only outwardly display the code file corresponding to one commit point of one branch at the same time. If the code files corresponding to other commit points of other branches need to be displayed, specific function switching is needed. The concrete example of git bin can refer to the corresponding related expression of the following fig. 5. The commit points of the different branches differ.
Gerrit: gerrit is a git-based web code review tool. Gerrit aims to provide a lightweight framework for reviewing each submission before the code is binned. Gerrit records the code modifications for each submission, but only if they are reviewed and received can they be incorporated as part of the project.
Gitiles is a simple Git warehouse browser based on Jgit.
Manifest: the first step of the android project engineering is to acquire all source code information through repo and finally successfully download the fetch to the local, and the git management is performed through manifest. Taking an android branch in the application as an example, a manifest file (i.e., manifest. xml file) of the android branch may include feature information (name, relative path, commit point/version number, download address) of all code bins corresponding to the android branch.
Binary large object: namely, binary large object, abbreviated as BLOB, is a container that can store binary files. In computers, BLOBs are often the type of field in a database used to store a binary file.
For large websites or some operating systems, the amount of code is very large. For convenience of management, manufacturers of these large websites or operating systems divide the corresponding codes into different code bins according to different functions, so as to be used by developers. The code files in each code bin are developed by developers according to certain user requirements, and part or all of the code files in different code bins correspond to the same user requirements. In order to facilitate development, a branch is actually established for a code file corresponding to the same requirement, and a subsequent user can conveniently modify or supplement the code file belonging to the branch in different code bins on the branch during development. For a code bin, different developers may modify or supplement the content of the code bin at different branches, so that the content of the code file with the same name in the code bin has different contents at different branches, and in order to embody this and facilitate the call of the developers, the code bin (i.e. git bin) is generated and managed by adopting git technology at present.
In order to facilitate a developer to quickly find a target code to be checked in all codes of a large website or some operating systems, a code search scheme is designed at present for the developer to search, download and check the target code in a large amount of codes. In the conventional code search scheme, a branch index corresponding to each branch is generated after all code bins corresponding to the branch are downloaded corresponding to each branch. And then the generation of search system can search the code file corresponding to the search requirement by utilizing the branch index according to the search requirement of the user and provide the code file for the user to view.
Referring to fig. 1, a schematic diagram of an architecture of a code search system is shown, in which an existing code search scheme can be applied. The system may include a development client 01, a search server 02, and a code server 03. Development clients 01-1 and 01-2 are shown in fig. 1 as examples of development client 01, and may be more or less in practice, and the present application is not limited thereto. The development client 01 and the search server 02 communicate with each other in a wired or wireless communication manner, and the search server 02 and the code server 03 communicate with each other in a wired or wireless communication manner.
The development client 01 is mainly used for a developer to log in a search service or a search application in the search server 02 to perform code search. The search server 02 is mainly configured to obtain a plurality of branched code files from the code server 03, and generate a branch index for each branch, so that when a search request sent by the development client 01 is received, a corresponding code file is searched according to the branch index and returned to the development client 01.
In this application, the development client 01 may be a device that can be used by a user to search and view a code, such as a mobile phone, a tablet computer, an ultra-mobile personal computer (UMPC), a netbook, a desktop computer, a notebook computer, a mini-notebook computer, an ultrabook, a Personal Digital Assistant (PDA), and the like. The specific form of the development client is not particularly limited in the present application.
Illustratively, referring to fig. 2, the development client 01 may include a processor 11, a memory 12, a display 13, a Wi-Fi device 14, a bluetooth device 15, an audio circuit 16, a microphone 16A, a speaker 16B, a power system 17, a peripheral interface 18, a sensor module 19, and the like. These components may communicate over one or more communication buses or signal lines (not shown in fig. 2). Those skilled in the art will appreciate that the hardware configuration shown in fig. 2 does not constitute a limitation of the development client 01, and that the development client 01 may include more or less components than those shown, or combine certain components, or a different arrangement of components.
The processor 11 is a control center of the development client 01, connects various parts of the development client 01 by using various interfaces and lines, and executes various functions of the development client 01 and processes data by running or executing an application program stored in the memory 12 and calling data and instructions stored in the memory 12. In some embodiments, processor 11 may include one or more processing units; processor 11 may also integrate an application processor and a modem processor; the application processor mainly processes an operating system, a user interface, application programs and the like, and the modem processor mainly processes wireless communication. It will be appreciated that the modem processor described above may not be integrated into the processor 11.
In some other embodiments of the present application, the processor 11 may further include an AI chip. The learning and processing capabilities of the AI chip include image understanding capabilities, natural language understanding capabilities, voice recognition capabilities, and the like. The AI chip may enable the development client 01 to have better performance, longer endurance, and better security and privacy. For example, if the development client 01 processes data through the cloud, the result is returned after the data is uploaded, and the efficiency is very low under the prior art. If the local end of the development client 01 has strong AI learning capability, the development client 01 does not need to upload data to the cloud end and directly processes the data at the local end, so that the processing efficiency can be improved, and the safety and the privacy of the data can be improved.
The memory 12 stores application programs and data, and the processor 11 executes various functions and data processing of the development client 01 by running the application programs and data stored in the memory 12. The memory 12 mainly includes a program storage area and a data storage area. Wherein, the storage program area can store an operating system, application programs required by at least one function (such as a sound playing function, an image playing function, etc.); the storage data area may store data (such as audio data, video data, and the like) created when the development client 01 is used. Further, the memory 12 may include high speed random access memory, and may also include non-volatile memory, such as a magnetic disk storage device, a flash memory device, or other non-volatile solid state storage device. The memory 12 may store various operating systems, such as those developed by apple Inc
Figure BDA0003211752320000111
Operating System, developed by Microsoft corporation
Figure BDA0003211752320000112
An operating system, etc.
The display screen 13 is used to display images, videos, and the like. The display screen may be a touch screen. In some embodiments, the development client 01 may include 1 or N display screens 13, N being a positive integer greater than 1. The development client 01 realizes a display function through the GPU, the display screen 194, the application processor, and the like. The GPU is a microprocessor for image processing, connected to the display 13 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 11 may include one or more GPUs that execute program instructions to generate or alter display information.
And the Wi-Fi device 14 is used for providing the network access conforming to Wi-Fi related standard protocols for the development client 01. The development client 01 can access to a Wi-Fi access point through the Wi-Fi device 14, thereby helping a user to send and receive e-mails, browse webpages, access streaming media and the like, and providing wireless broadband internet access for the user. The development client 01 may also establish a Wi-Fi connection with a terminal device connected to the Wi-Fi access point through a Wi-Fi device and the Wi-Fi access point, for mutual data transmission. In other embodiments, the Wi-Fi apparatus 14 can also act as a Wi-Fi wireless access point and can provide Wi-Fi network access to other electronic devices.
And the bluetooth device 15 is configured to implement data exchange between the development client 01 and other short-distance electronic devices (e.g., a terminal, a smart watch, etc.). The bluetooth device in the embodiment of the present application may be an integrated circuit or a bluetooth chip.
Audio circuitry 16, speaker 16B, microphone 16A may provide an audio interface between the user and development client 01. The audio circuit 16 may transmit the electrical signal obtained by converting the received audio data to the speaker 16B, and the electrical signal is converted into a sound signal by the speaker 16B and output; on the other hand, the microphone 16A converts the collected sound signal into an electric signal, converts the electric signal into audio data after being received by the audio circuit 16, and transmits the audio data to the terminal through the internet or a Wi-Fi network or bluetooth, or outputs the audio data to the memory 12 for further processing.
The power supply system 17 is used to charge the respective components of the development client 01. The power system 17 may include a battery and a power management module, and the battery may be logically connected to the processor 11 through a power management chip, so as to implement functions of managing charging, discharging, and power consumption management through the power system 17.
Peripheral interface 18 provides various interfaces for external input/output devices (e.g., keyboard, mouse, external display, external memory, SIM card, etc.). For example, the mouse is connected with the universal serial bus interface, so that the aim of receiving the relevant operation implemented by the user through the mouse is fulfilled. For another example, the storage capability of the extended development client 01 is implemented by connecting an external storage interface with an external storage, such as a Micro SD card. Peripheral interface 110 may be used to couple the aforementioned external input/output peripherals to processor 11 and memory 12.
The sensor module 19 may include at least one sensor. Such as light sensors, motion sensors, and other sensors. In particular, the light sensor may comprise an ambient light sensor. Wherein, the ambient light sensor can adjust the brightness of the display 13 according to the brightness of the ambient light. As one type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in various directions (generally three axes), detect the magnitude and direction of gravity when stationary, and can be used for applications of recognizing the posture of a personal computer (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), and the like. Of course, the sensor module may also include any other feasible sensors according to actual needs.
Although not shown in fig. 2, the development client 01 may further include a camera, for example, a front camera and a rear camera, where the front camera may be used to capture face feature information, and the processor 11 may perform face recognition on the face feature information, so as to perform subsequent processing. The development client 01 may further include a flash, a micro projection device, a Near Field Communication (NFC) device, and the like, which are not described in detail herein.
In this application, the search server 02 may be one server, a server cluster formed by combining a plurality of servers, or a cloud computing service center, which is determined specifically according to the actual situation, and this application is not limited specifically. In the existing code searching scheme, android is searched by developers TM Some codes of the system are taken as examples, and the search server 02 is mainly used for downloading code files of all branches from the code server 03 and establishing corresponding indexes for the subsequent development client 01 to use when requesting the code files from the search server.
In an implementation manner, referring to fig. 3, when the search server 02 is a server, the search server 02 may include a memory 21 and a processor 22; memory 21 is used to store computer-executable instructions that are executable by processor 22. The processor 22 and the memory 21 are connected by a bus 23.
In particular implementations, processor 22(22-1 and 22-2) may include one or more CPUs, such as CPU0 and CPU1 shown in FIG. 3, for example, as one embodiment. And as an example, the search server 02 may include a plurality of processors 22, such as processor 22-1 and processor 22-2 shown in fig. 3. Each of the processors 22 may be a Single-core processor (Single-CPU) or a Multi-core processor (Multi-CPU). Processor 22 may refer herein to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).
The Memory 21 may be a Read-Only Memory 21 (ROM) or other type of static storage device that may store static information and instructions, may be a cache Memory, may be a Random Access Memory (RAM) or other type of dynamic storage device that may store information and instructions, may be an electrically erasable programmable Read-Only Memory (EEPROM), a compact disk Read-Only Memory (CD-ROM) or other optical disk storage, optical disk storage (including compact disk, laser disk, optical disk, digital versatile disk, blu-ray disk, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that may be used to carry or store desired program code in the form of instructions or data structures and that may be accessed by a computer, but is not limited thereto. The memory 21 may be self-contained and coupled to the processor 22 via a bus 23. The memory 21 may also be integrated with the processor 22.
In a specific implementation, the memory 21 is used for storing data (code files obtained from a code server) in the present application and computer-executable instructions corresponding to software programs for executing the present application. The processor 22 may implement various functions of the search server 02 by running or executing software programs stored in the memory 21 and calling up data stored in the memory 21.
Optionally, as shown in fig. 3, the search server 02 further includes: the communication interface 24 is any device, such as a transceiver, for communicating with other devices or communication networks, such as a control system, a Radio Access Network (RAN), a Wireless Local Area Network (WLAN), and the like. The communication interface 24 may include a receiving unit implementing a receiving function and a transmitting unit implementing a transmitting function.
The bus 23 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an extended ISA (enhanced industry standard architecture) bus, or the like. The bus 23 may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 3, but this does not mean only one bus or one type of bus.
In this application, the code server 03 may be one server, a server cluster formed by combining a plurality of servers, or a cloud computing service center, which is determined specifically according to the actual situation, and this application is not limited specifically. In the application, the code server 02 is mainly used for storing all code files that a developer needs to search by using a git technology, and sending the corresponding code files to the search server 02 for storage when receiving a download instruction or an acquisition instruction of the search server 02. The specific results of the code server 03 can refer to the structure of the search server 02, and are not described in detail herein.
In addition, if the storage capacity of the development client 01 is strong enough or the development client 01 needs to search and view a small number of code files, the search server 02 may not be present in practice, and all functions of the search server 02 may be integrated on the development client.
Fig. 4 is a schematic diagram of a conventional code search scheme. First, the search server 02 downloads a code file for each branch from the code server 03. For example, referring to fig. 4, taking the code server 03 as an example that three code bins are stored in total, for branch 1, the search server 02 needs to download a code file corresponding to branch 1 from each code bin (specifically, including a branch 1 portion of code bin 1, a branch 1 portion of code bin 2, and a branch 1 portion of code bin 3). For branch 2, the search server needs to download the code file corresponding to branch 2 from each code bin (specifically including code bin 1 branch 2 portion, code bin 2 branch 2 portion, and code bin 3 branch 2 portion). For branch m, the search server needs to download the part of branch m corresponding to each code bin (specifically, the part of branch m of code bin 1, the part of branch m of code bin 2, and the part of branch m of code bin 3). In fig. 4, a part of the code file in which all branches exist in each code bin is shown as an example, and in practice, the part of the code file in which only part of branches exist in one code bin may be used. For example, there may be only a branch 1 and branch 2 code file in code bin 1, i.e., code bin 1 includes a branch 1 portion of code bin 1 and a branch 2 portion of code bin 1.
Note that, here, the code bin x branch y portion refers to: and after the branch y submits the code for the latest time, the code file corresponding to the branch y in the code bin x. Where, code bin x may be the aforementioned code bin 1 or 2 or 3, and branch y may be branch 1 or 2 or 3.
For example, FIG. 5 is a diagram illustrating the commit process for different branches of a code bin. C0, C1, C2, C3, and C4 shown in FIG. 5 are used to indicate the commit point (i.e., the time at which the code was committed) of the branch commit code. Therein, branch 1, branch 2, and branch 3, all commit code starting at C0. The code file of branch 1 in the code bin is the code file of branch 1 in the code bin after the codes are submitted at three submission points of C0, C1 and C2 in sequence. In other words, the code file for branch 1 in the code bin is the code file for branch 1 in the code bin after the code was committed at the C2 commit point.
The code file of branch 2 in the code bin is the code file of branch 2 in the code bin after codes are submitted at four submission points of C0, C1, C2 and C4 in sequence. In other words, the code file for branch 1 in the code bin is the code file for branch 2 in the code bin after the code was committed at the C4 commit point.
The code file of branch 3 in the code bin is the code file of branch 3 in the code bin after codes are submitted at four submission points of C0, C1, C2 and C3 in sequence. In other words, the code file for branch 1 in the code bin is the code file for branch 3 in the code bin after the code was committed at the C3 commit point.
The latest commit point corresponding to branch 1 is C2, the latest commit point corresponding to branch 2 is C4, and the latest commit point corresponding to branch 3 is C3.
Then, the search server 02 may generate a branch index of the branch according to the code files of the different branches and the storage addresses thereof. For example, branch index 1 is generated for branch 1, branch index 2 is generated for branch 2, and branch index m is generated for branch m. In this way, the search service/application set in the search server is set up to be completed.
Thereafter, the developer may log in the code search application/service in the search server through the development client 01. For example, the code search application/service may be registered on the registration interface after the web address of the website corresponding to the search server is browsed and input. The development client can then acquire a corresponding code file display from the search server 02 in response to a developer's selection operation of a branch index (any one of branch index 1, branch index 2, and branch index m …) of a certain branch.
For example, taking the code searching method as an example for searching the code of the android system, the login interface on the development client 01 is shown in fig. 6. After a developer inputs a legal account number and a password, the development client can log in code search application/service. After the login is successful, as shown in fig. 7, the development client 01 may display a search interface 71 provided by the search server 02. Specifically, the search interface 71 may include branch selection controls (i.e., underlined branch names shown in fig. 7) such as hxx x.x, MX9XXX x.x, MXX5 x.x, mxx6xxxx.x, mxxx7xxx.x, and sxxxx.x, input boxes (full search), definition (definition), symbol (symbol), file path (file path), history (history), type (type), and the like) corresponding to different search modes, and a list of items for all branches. The item list includes the number, branch name and download address of each branch.
Thereafter, as shown in fig. 7, the development client 01 may request the directory tree of a branch MX9XXX x.x from the search server 02 in response to a click operation of a selection control of the branch (e.g., MX9XXX x.x) by a developer. Then, the development client 01 receives and displays the directory tree of MX9XXX x.x branches transmitted from the search server 02. The specific display interface is shown with reference to fig. 8, wherein the interface includes the name, date (corresponding to the time of the latest submission point of the branch MX9XXX x.x), and size of each code bin included in the branch MX9XXX x.x. The name of each code bin can be simultaneously used as an index control for triggering by a user.
There may be one or more code files in a code bin for a branch. In the case that there is only one code file in the code bin, a type of control corresponding to the code file can be directly displayed. Such as "android.bp", "bootstrap.bash", "build.sh" and the like shown in fig. 8. In the case of multiple code files in a code bin, a class two control may be displayed corresponding to the code bin. Such as "Art/", "binary/", "bionic/", "cts/", "system/" etc., as shown in FIG. 8.
Referring to fig. 8, the first type of control and the second type of control can be distinguished according to icons next to the controls, for example, icons next to the first type of control "android.bp", "bootstrap.bash", "build.sh" and the like are consistent to be an icon 1, icons next to the second type of controls "Art/", "binary/", "bipolar/", "cts/", "system/" and the like are consistent to be an icon 2, and the icon 1 is different from the icon 2.
The development client 01 may request a code file corresponding to a type of control (e.g., "android. bp" in fig. 8) from the search server 02 in response to a trigger operation (e.g., click, double click, long press, etc.) of the type of control by a developer. After receiving a request of the search server for requesting a code file of a certain type of control, the search server 02 may search for a corresponding code file according to a name (e.g., android. bp) of a code bin corresponding to the type of control and a branch index of a branch (e.g., MX9XXX x.x) corresponding to the type of control, and send the searched code file to the development client 01. The development client 01 may display the code file after receiving the code file transmitted by the search server.
The development client 01 may also request the search server 02 for one type of control (i.e., name) of all code files of the code bin of the second type of control and display (how to display specifically, which may be determined according to practical considerations and is not limited specifically herein) in response to a trigger operation (e.g., click, double click, long press, etc.) of the second type of control (e.g., "Art/" in fig. 8) by the developer. Then, the development client 01 may respond to the triggering operation of the user on the first type of control corresponding to the second type of control, and request the search server 02 for the content of the corresponding code file to be displayed (for specific implementation, refer to the related expression that the developer triggers the first type of control).
In order to facilitate the search of the required code file by the developer, as shown in fig. 8, the display interface of the development client 01 receiving and displaying the branch index of the MX9XXX x.x branch sent by the search server 02 may further include a search box 81 and a search control 82. When a user needs to search a certain code file, the user can click the search control 82 after entering a keyword in the search box 81. Thereafter, the development client 01 may request a code file related to the keyword in the search box 81 from the search server 02 in response to the user clicking the search control 82, and display the code file after receiving the code file transmitted by the search server 02.
In addition, because the code file required by the user may not be in the branch corresponding to the content currently displayed by the development client, in order to facilitate the search of the user, as shown in fig. 8, the development client 01 receives and displays the display interface of the branch index of MX9XXX x.x sent by the search server 02, and may further include a selection control 83, and an attachment of the selection control may have a descriptive word similar to "only in this directory". Illustratively, as shown in fig. 8, the initial state of the selection control 83 is a blank box, and when the user triggers the selection of the selection control 83, the selection control 83 changes to a box with a number in the middle. The development client may respond to the trigger selection for the selection control 83 and then request only the code files in the MX9XXX x.x branch that match the user selection (keyword or trigger operation of an index control for a certain code file) from the search server 02.
Based on the foregoing solution, in the existing code searching solution, for each branch, all the code files thereof need to be downloaded. Since the code files corresponding to different branches are repeated to some extent, storage resources of a search server bearing search services are wasted greatly, and the utilization rate is low.
In order to solve this problem, based on the code search system shown in fig. 1, the embodiment of the present application provides a code search method, the principle of which is shown in fig. 9. Search server 02 may download all code bins (e.g., code bin 1, code bin 2, and code bin 3) of the target code (e.g., code of android system) that needs to be searched from code server 03. Here, downloading a code bin specifically means downloading all code files in the code bin at the current time.
In practice, a code bin is managed by git, and the working space of the code bin corresponds to the code file of only one commit point (generally, the latest commit point) of one branch (i.e., the code file of only one commit point of one branch can be shown at one time), and if the code file of the latest commit point of another branch needs to be shown, the commit point (or version number) needs to be switched. Moreover, if there are two branch indexes for different branches to fetch data exposure from the code bin, the code bin will not be able to expose different directory trees to developers for viewing and use at the same time. The method for establishing the full-text index by directly using all code files in the code bin is the simplest index establishing method. However, for a code bin, if two developers need to search code files belonging to two different branches in the code bin, and the two branches have code files with the same name but slightly different contents, then because two code files with the same file name cannot exist in the same directory, the search server cannot show the code file directory for the two developers, and the whole code searching process cannot be smoothly performed. Thus, if an index is built directly using all code files in a code bin, a normal data search cannot be completed.
Therefore, the search server 02 may further construct a branch directory corresponding to each branch by using a Fuse technology, where each branch directory is associated with a code file corresponding to the branch, the code file corresponding to the branch is located in at least one code bin, and each branch directory is associated with at least one code bin. Since the branch directory is virtually derived by using real files in the code bin and is associated with the code file of the branch to which the branch directory belongs, the branch directory can be used as a directory which is sent to a development client by a subsequent search server 02 for being viewed by a user. Furthermore, when the subsequent search server 02 needs to obtain the code file at the same time, the corresponding code file can be quickly obtained from the code bin by means of the branch directory.
For example, the branch directory of the target branch may be specifically as shown in fig. 10. If a code bin includes a plurality of code files (e.g., code bin 1 and code bin 2) corresponding to the target branch, besides that a path of the code bin may exist in the branch directory to refer to the code bin, a subdirectory may also exist for showing the code files in the code bin (e.g., the subdirectory of the code bin 2 includes the name of the code file 2.1 and the name of the code file 2.2). If a code bin has only one code file corresponding to the target branch (e.g., code bin 3 and code bin 4), the path in the branch directory where the code bin is useful may refer to the unique file in the code bin.
As an example, a specific principle of generating the branch directory of the target branch by the search server 02 is shown in fig. 11. The method specifically comprises the steps of S101-S104.
S101, the search server 02 acquires a mailest file of a target branch.
S102, the search server 02 obtains the directory tree information of the code bin of the target branch.
Wherein the directory tree information of the code bin is used to express or show which code files are in the code bin.
Specifically, in steps S101 and S102, the search server 02 may download the mailest file of the target branch by using Gerrit and Gitiles in the code server 03, and obtain the directory tree information of the code bin corresponding to the target branch. Where the search server 02 needs to download the mailest file of the target branch using repo.
S103, the search server 02 analyzes the manifest file of the target branch to obtain the characteristic information of the code bin corresponding to the target branch.
Wherein, the characteristic information may include: name, relative path, latest commit point (or version number) and download address (or clone address). Where the relative path specifies for code server 03 the path of the code bin as it is downloaded, e.g.,/code bin a. The latest commit point of the target code bin of the target branch is the latest one of all commit points of the target branch committing the code file in the target code bin, and the target code bin is any one of all code bins of the target branch. Taking the code bin corresponding to fig. 5 as the code bin, and taking the time at which the current time is the latest commit point in fig. 5 as an example, if the target branch is branch 2, the latest commit point in the code bin corresponding to fig. 5 is C4 (specifically, the time corresponding to C4 may be used).
S104, the search server 02 generates a branch directory of the target branch according to the path of the code bin corresponding to the target branch and the directory tree information of the target branch by using FUSE.
Thereafter, the search server 02 may generate a corresponding branch index according to the branch directory of each branch and its corresponding code file. Such as branch index 1-branch index n in fig. 9. After receiving the search instruction of the development client 01, the search server 02 may determine, by using the branch index and the search information (e.g., the branch flag and the keyword) in the search instruction, a branch directory to which the code file corresponding to the search instruction belongs and a location of the code file corresponding to the search instruction in the branch directory. Then, the search server 02 can smoothly obtain the code file corresponding to the search instruction from the local storage according to the branch directory.
It can be seen that, because the branch directory is virtually derived from the real code file, the branch directory can be associated to the real code file, and the branch index generated according to the branch directory and the code file is a branch directory corresponding to the determinable search information, in the code search method, the existence of the branch directory can enable the appropriate branch index to be generated only by downloading all the code files (without repeated code files) of each code bin once, and the subsequent code search process is completed.
Illustratively, the specific principle of generating a branch directory of a certain branch by the search service tool is shown in fig. 12. Specifically, S111-S113 are included.
S111, the search server 02 sequentially reads each code file in the branch directory of the target branch by using the index generator.
For example, in the embodiment of the present application, the index generator may be a Lucence. The index generator may be configured in a search server.
Specifically, if the target code file does not exist in the local storage, the search server cannot read the target code file by using the index generator, and S112 is executed. The target code file is any one of all code files corresponding to the branch directory of the target branch.
In the case where the object code file exists in the local storage, the search server normally reads the object code file from the local storage.
S112, the search server 02 may obtain the target code file from the code server 03 for the index generator to read according to the characteristic parameters such as the name of the target code file, and the name, the extraction point, and the download address of the code bin to which the target code file belongs.
S113, the search server downloads/clones the code bin to which the target code file belongs to the local memory.
For example, the code bin to which the target code file belongs is taken as the code bin a in fig. 12 as an example. In addition, taking the code bin as the git technology generation as an example, the search server 02 may download/clone the code bin to the local storage using the git clone function, and further, in the code search scheme, generally, the searcher (i.e. the developer) is not allowed to modify the code, so the git clone function may be a git clone-barrel specifically.
Illustratively, as shown in fig. 12, the code files in the code bins may be stored in the local memory in a BLOB manner.
Further, to ensure that the code bin stored in the local memory (e.g., code bin a) is updated in time, after the code bin is downloaded by the search server, a specific function (e.g., git fetch origin function) may be used to periodically clone the latest code bin a into the local memory to replace the original code bin a.
After the search server 02 reads all the code files in the branch directory of the target branch by using the index generator, the index generator may be used to generate the branch index of the target branch according to the read result (i.e., all the code files in the branch directory of the target branch) and the storage addresses of all the code files of the target branch. The specific branch index generation manner may be any feasible manner, and the present application is not particularly limited.
Thereafter, the developer may log in to the code search application/service in the search server through the development client. For example, the code search application/service may be registered on the registration interface after the web address of the website corresponding to the search server is browsed and input. The development client may then transmit a search instruction requesting a code file corresponding to a selection operation or a keyword to the search server in response to the selection operation of the user on a branch index (any one of branch index 1, branch index 2, … branch index n) of a certain branch or the keyword input by the user. The search server can find the corresponding code file and send the code file to the development client according to the search instruction by combining the corresponding branch index and the branch directory, so that the development client displays the code file.
Based on the above principle, referring to fig. 13, an embodiment of the present application provides a code searching method, which may be applied to the code searching system shown in fig. 1. As shown in fig. 13, the method may include S121-S129:
s121, the search server 02 obtains the feature information and the directory tree information of the code bin of at least one target branch in the target code from the code server 03.
The target code is a set of codes (for example, all codes of the android system) targeted by the code search method provided by the application. In practice, in order to better provide the code search service, the search server may obtain the feature information and directory tree information of the code bin corresponding to all branches of the target code. The directory tree information at least comprises characteristic parameters of code files in a code bin to which the directory tree information belongs; the characteristic parameter is used for indicating a code file to which the characteristic parameter belongs. For example, the characteristic parameter may be a name or an id of the code file.
The characteristic information may include: name, relative path, latest commit point (or version number) and download address (or clone address). Where the relative path specifies for code server 03 the path of the code bin as it is downloaded, e.g.,/code bin a. The latest commit point is the commit point of the target branch corresponding to the code bin, taking the code bin as the code bin corresponding to fig. 5, and taking the current time as the latest time in fig. 5 as an example, if the target branch is branch 2, the latest commit point of the code bin corresponding to fig. 5 is C4 (specifically, the time corresponding to C4 may be used).
In an implementation manner, taking a code search method for searching for a code of an android system as an example, referring to fig. 14, the step S121 may specifically include steps S121A and S121B:
S121A, the search server 02 obtains the manifest file of at least one target branch and the directory tree information of the code bin corresponding to the target branch from the code server 03.
In an implementation manner, the search server 02 may specifically download the manifest file of the target branch by using Repo.
S121B, the search server 02 parses the maincast file of the target branch to obtain the feature information of the code bin corresponding to the target branch.
Based on this, because a manifest file exists in the code bin of the android system during storage, and the file contains the characteristic information of the code bin, based on the scheme, the characteristic information of the code bin of the target branch can be smoothly acquired.
S122, the search server 02 generates a branch directory of the target branch according to the path of the code bin corresponding to the target branch and the directory tree information.
The branch directory at least comprises the relative path of the code bin included by the target branch and the characteristic parameters of the code file in the code bin corresponding to the target branch. The characteristic parameter is used to indicate the code file, for example, the characteristic parameter may be the name or id of the code file.
In an implementation manner, the search server 02 may generate the branch directory of the target branch by using the user space file system according to the path and directory tree information of the code bin corresponding to the target branch.
Exemplarily, since the actual user space file system (FUSE) is a module in the linux system, it can be used only in the linux system. In the embodiment of the present application, for convenience of use, the user space file system (FUSE) in the search server 02 is implemented using a higher-level computer language (e.g., go language). In practice, a FUSE implemented using the go language may be referred to as a go FUSE interface.
For example, the branch directory of the target branch may be specifically as shown in fig. 10. For specific description, reference may be made to the related description of fig. 10 in the foregoing embodiments, and details are not repeated here.
S123, the search server 02 reads each code file in the branch directory of the target branch locally and sequentially.
In an implementation manner, the reading is specifically to generate a branch index according to the reading result, so the search server 02 may locally read each code file in the branch directory of the target branch in turn by using the index generator.
In the case where the search server 02 cannot read the object code file in the local, S124 and S125 may be executed. In a case where the search server 02 reads all the code files in the branch directory of the target branch, S126 may be executed.
And S124, the search server 02 reads the target code file from the code server 03 according to the characteristic parameters of the target code file, the name of the code bin to which the target code file belongs, the latest submission point and the download address.
In an implementation manner, S124 may specifically be that the search server 02 obtains the target code file from the code server 03 for the index generator to read, according to the characteristic parameters of the target code file and the name, the latest submission point, and the download address of the code bin to which the target code file belongs.
Wherein the target code file is any code file in the branch directory of the target branch. The characteristic parameter may be data capable of indicating the object code file, such as the name of the object code file.
When the search server 02 can locally read a code file in the branch directory of the target branch, the code file is read from the local storage.
And S125, searching the name, the extraction point and the download address of the code bin to which the target code file belongs by the server 02, and downloading the code bin to which the target code file belongs from the code server 03.
For how to download specifically, reference may be made to the related description of the example shown in fig. 12 in the foregoing embodiment, and details are not described here again. The downloaded code bins may be placed in local memory of the search server 02, for similar reasons.
In addition, because the branch directory of the target branch includes the path of each code bin, and the search server downloads each code bin corresponding to the target branch according to the path thereof when downloading the code bins corresponding to the target branch, after the local downloading of all the code bins corresponding to the target branch is completed, the corresponding actual code file can be subsequently obtained according to the branch directory of the target branch.
S126, the search server 02 generates a branch index of the target branch according to the read storage addresses of all code files of the target branch, the branch directory of the target branch and all code files in the branch directory of the target branch.
The branch index is at least used for indicating the position of any code file corresponding to the branch to which the branch index belongs in the branch directory corresponding to the branch index.
In order to more clearly illustrate the technical solutions provided in the embodiments of the present application, the following embodiments are provided to improve the utilization efficiency of the storage resources of the search server when generating the branch index in the code search system (i.e., the above-mentioned steps S123 to S126). The embodiment may specifically include T1-T5:
t1, when the search server 02 does not store any code file of the target code, the search server 02 downloads the code bin to which all the code files of the first branch belong from the code server 03 based on the name and the download address of the code bin of the first branch, and reads all the code files corresponding to the branch directory of the first branch.
Wherein the first branch is any one of the at least one target branch. Alternatively, the search server 02 reads the code file using an index generator.
In an implementation manner, the search server 02 in T1 downloads, from the code server 03, the code bin to which all the code files of the first branch belong according to the name and the download address of the code bin of the first branch, and reads all the code files corresponding to the branch directory of the first branch, which may specifically be: the code server 02 sequentially reads each code file corresponding to the branch directory of the first branch from the local; the first branch is one of the at least one branch; under the condition that the code server 02 cannot read a target code file from the local, the code server 02 reads the target code file from the code server according to the characteristic parameters of the target code file, the name of a code bin to which the target code file belongs, the latest submission point of the code bin to which the target code file belongs and the download address of the code bin to which the target code file belongs, and downloads the code bin to which the target code file belongs to the local memory; the target code file is any one of all code files corresponding to the branch directory of the first branch.
It can be understood that the specific implementation of part of the steps in T1 is a specific case of S123-S125 described above, that is, a case when the search server establishes the branch index of the first branch (i.e., the first branch in this application).
T2, the search server 02 generates a branch index of the first branch from all the code files of the first branch, the branch directory of the first branch, and the storage addresses of all the code files of the first branch.
The branch index is at least used for indicating the position of any code file corresponding to the branch to which the branch index belongs in the branch directory corresponding to the branch index.
It is understood that the step T2 is a specific case of the aforementioned step S126, namely, a case when the search server establishes the branch index of the first branch (i.e., the first branch in the present application).
T3, when the search server 02 stores the code bins to which all the code files of the established branches belong, the search server 02 sequentially reads all the first code files in the code files corresponding to the branch directory of the second branch from the local area.
The established branch is a target branch which is generated with a branch index; the second branch is any one of the at least one target branch except the established branch; the first code file is the code file in the code bin to which all code files of the created branch belong.
It is understood that the step T3 is a specific case of the foregoing step S123, namely, a case when the search server establishes the branch index of the first branch (i.e., the first branch in this application).
T4, the search server 02 reads all the second code files from the code server 03 according to the feature parameters of all the second code files except the first code file in the code files corresponding to the branch directory of the second branch, the names of the code bins to which all the second code files belong, the latest intersection points of the code bins to which all the second code files belong, and the download addresses of the code bins to which all the second code files belong.
In an implementation manner, T4 may be specifically: the search server 02 reads all the second code files from the local in turn; under the condition that the search server cannot read the fourth code file from the local memory, the search server reads the fourth code file from the code server according to the characteristic parameters of the fourth code file, the name of the code bin to which the fourth code file belongs, the latest submission point of the code bin to which the fourth code file belongs and the download address of the code bin to which the fourth code file belongs, and downloads the code bin to which the fourth code file belongs; the fourth code file is any one of all the second code files.
It is understood that the implementation manner of the aforementioned T4 step is a specific case of the aforementioned combination of S123-S125, that is, a case when the search server establishes a branch index of a non-first branch (i.e., a target branch other than the first branch in the present application). In addition, here, the search server reads the second code file, specifically, may read by using an index generator. And T5, the search server generates a branch index of the second branch according to the branch directory of the second branch, all the code files of the second branch and the storage addresses of all the code files of the second branch.
It is understood that the step T2 is a specific case of the aforementioned step S126, namely, a case when the search server establishes a branch index of a non-first branch (i.e., a target branch other than the first branch in the present application).
Based on the above technical solutions corresponding to T1-T5, it can be seen that, in the process of constructing a branch index in a code search system, after some code bins are downloaded in the process of establishing a branch index for a certain target branch, it is not necessary to download the code bins again in the subsequent process of establishing other branch indexes, so that the technical solution provided by the embodiment of the present application only enables the search server to download each code bin once, and then the branch index can be generated according to the branch directory, the read results (i.e., all code files of the target branch) and the storage addresses of the code files. And further improve the utilization rate of the storage resources of the search server.
S127, the search server generates a code search system according to the branch directory of the at least one target branch, the branch index of the at least one target branch and all the code bins downloaded by the search server and corresponding to the at least one target branch.
It should be noted that the foregoing steps S121 to S127 are schematic flow charts of a code search system generation method provided in the embodiment of the present application.
S128, the search server 02 responds to the search instruction from the development client 01-1, and searches a third code file matched with the keyword from the local by using the keyword carried by the search instruction according to the branch index and the branch directory of the branch corresponding to the branch mark carried by the search instruction.
Wherein the search instruction is for requesting a code file corresponding to the branch marker and the keyword.
Based on the branch index and the branch directory of the target branch established in the embodiment of the present application, the process of the developer entering the search interface of a certain branch through the code search service of the login search server 02 is similar to the related expressions in fig. 6, fig. 7, and fig. 8. Taking the interface shown in fig. 8 as an example, the name, date (corresponding to the time of the latest submission point of the MX9XXX x.x branch) and size of each code bin included in the MX9XXX x.x branch are shown, and can be considered as the branch list in the embodiment of the present application. The difference is that in fig. 8, for the convenience of the user to know more information, the latest date and size of the branch MX9XXX x.x corresponding to different code bins are also shown.
In one implementation scenario, taking the search interface shown in fig. 8 as an example, the development client 01-1 may generate and send a search instruction to the search server in response to a user's trigger operation on an index control in any one of the code bins. For example, the android.bp is taken as an example, because only one code file exists in the code bin of the android.bp in fig. 8, the branch marker carried by the search instruction at this time may be "MX 9XXX x.x", and the keyword may be "android.bp".
In another implementation scenario, taking the search interface shown in fig. 8 as an example, the development client 01-1 may also generate and send a search instruction to the search server in response to the user's input in the search box 81 and click operation on the search control 82. If the user triggers the selection control element 83 at this time, so that the selection control element 83 becomes a box with a matching number in the middle, the branch mark carried in the search instruction at this time may be "MX 9XXX x.x", and the keyword may be the content input by the user. If the user triggers the optional control element 83 at this time, so that the optional control element 83 becomes a box with a matching number in the middle, the branch marks carried in the search instruction at this time may be all branches (HISI 4.0, MX9XXX x.x, MTK5G 5.0, MTK 67564.0, MTK 67684.0, and SPRD 4.0, etc.) shown in fig. 7, and the keywords may be the contents input by the user.
Taking the total of three code bins as an example, the specific process implemented by the step S107 can be referred to as shown in fig. 15. After receiving the search instruction of the development client 01-1, the processing module of the search server 02 determines the corresponding branch index and branch directory (e.g., branch directory of branch index 2 and branch 2) according to the branch flag carried therein. The specific processing module may obtain the search instruction of the development client 01-1 through a communication module of the search server, and the processing module may be specifically a CPU of the search server.
Then, the search server 02 may determine, by using the branch index, a target location of the code file corresponding to the search instruction (specifically, a location of the name of the code file in the branch directory) in the branch directory according to the keyword in the search instruction. Then, the search server can obtain the code files corresponding to the branch marks and the keywords from all the code bins according to the association between the branch directories and the code bins by using the target positions determined by the branch directories and the branch indexes. The processing module may then return the code file obtained from the code bin by the branch directory to the development client 01-1.
In an implementation manner, S127 may be: in response to a search instruction from the development client, in the case that a branch corresponding to a branch mark carried by the search instruction is a second branch, if it is determined that a third code file corresponding to a keyword carried by the search instruction is a code file in the second code bin according to a branch index of the second branch and a branch directory of the second branch, the search server 02 obtains the third code file from the second code bin; the second code bin is any one of the code bins to which all the code files of the established branch belong.
Based on the above scheme, it can be seen that the code search system generated by the technical scheme provided in the embodiment of the present application can enable the search server to smoothly acquire a code file when searching the code file, regardless of which branch index was downloaded before when the code bin to which the code file belongs was established.
S129, the search server 02 sends the third code file to the development client 01-1.
Based on the technical solution provided by the embodiment of the present application, in the process of constructing a branch index in a code search system, after some code bins are downloaded in the process of establishing a branch index for a certain target branch, it is not necessary to download the code bins again in the subsequent process of establishing other branch indexes, so that the technical solution provided by the embodiment of the present application only enables the search server to download each code bin once, and then the branch index can be generated according to the branch directory, the read results (i.e., all code files of the target branch) and the storage addresses of the code files. And because the branch index can be used for indicating the position of any code file corresponding to the branch to which the branch index belongs in the branch directory, in the process that a subsequent user uses the code search system, the branch directory and the branch index can be determined according to the search requirement, then the corresponding position of the required code file in the branch directory (namely the position of the name of the code file) is determined according to the branch index, and then the corresponding code file can be obtained from the code bin by using the association of the branch directory and each code file in the code, so that the search process is completed. In summary, compared with the prior art, the embodiment of the application does not need to download all the corresponding code bins for each branch, and the utilization rate of the storage resources of the search server is greatly improved.
In some embodiments, in order to ensure that the code bins downloaded in the search server are timely synchronized with the same code bin content in the code server, referring to fig. 16 in conjunction with fig. 13, after S125 (specifically, after the search server downloads any one of the code bins), the code search method further includes S125A:
S125A, the search server 02 obtains all the code bins corresponding to the target branch from the code server 03 every preset time period, and updates all the code bins of the target branch in the local memory with all the code bins of the newly obtained target branch.
In this way, the contents of the code bins stored in the local memory of the search server can be synchronized in time with the same code bins in the code server, ensuring the accuracy of the user in searching for the code.
It is understood that the above-mentioned device (search server) and the like contain hardware structures and/or software modules for performing the respective functions in order to realize the above-mentioned functions. Those of skill in the art will readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the embodiments of the present application.
In the embodiment of the present application, the search server may be divided into function modules according to the method example, for example, each function module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. It should be noted that, the division of the modules in the embodiment of the present invention is schematic, and is only a logic function division, and there may be another division manner in actual implementation.
In the case of adopting a method of dividing each functional module corresponding to each function, as shown in fig. 17, an embodiment of the present application provides a search server 16, including: an acquisition module 161 and a processing module 162.
The obtaining module 161 is specifically configured to execute S121 (including S121A and S121B) in the foregoing embodiment. The processing module 162 is specifically configured to execute the operations S123-S128, S125A, and T1-T5 in the foregoing embodiments. Of course, in the implementation, the obtaining module 161 and the processing module 162 may also be composed of a plurality of sub-modules capable of implementing different functions or executing different steps, which is not specifically limited in this application.
With respect to the search server in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment of the code search method in the foregoing embodiment, and is not specifically set forth herein. The related advantages can also refer to the related advantages of the code searching method, and are not described herein again.
An embodiment of the present application further provides a search server, where the search server includes: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to cause the search server to perform the steps of:
the search server acquires feature information and directory tree information of a code bin of at least one target branch in the target code from the code server; the characteristic information includes: name, relative path, latest submission point and download address; the latest submission point of the target code bin of the target branch is the latest one of all submission points of the target branch submitting the code file in the target code bin; the target code bin is any one of all code bins of the target branch; the directory tree information at least comprises characteristic parameters of code files in a code bin to which the directory tree information belongs; the characteristic parameter is used for indicating a code file to which the characteristic parameter belongs;
the search server generates a branch directory of the target branch according to the relative path of the code bin of the target branch and the directory tree information; the branch directory at least comprises a relative path of a code bin included by the target branch and characteristic parameters of a code file in the code bin corresponding to the target branch;
under the condition that any code file of the target code is not stored in the search server, the search server downloads the code bins to which all the code files of the first branch belong from the code server according to the names and the downloading addresses of the code bins of the first branch, and reads all the code files corresponding to the branch directories of the first branch; the first branch is any one of at least one target branch;
the search server generates a branch index of the first branch according to all the code files of the first branch, the branch directory of the first branch and the storage addresses of all the code files of the first branch; the branch index is at least used for indicating the position of any code file corresponding to the branch to which the branch index belongs in a branch directory corresponding to the branch index;
under the condition that the code bins to which all the code files of the established branches belong are stored in the search server, the search server sequentially reads all first code files in the code files corresponding to the branch directory of the second branch from the local; the established branch is a target branch which is generated with a branch index; the second branch is any one of the at least one target branch except the established branch; the first code file is a code file in a code bin to which all the code files of the established branch belong;
the search server reads all the second code files from the code server according to the characteristic parameters of all the second code files except the first code file in the code files corresponding to the branch directory of the second branch, the names of the code bins to which all the second code files belong, the latest submission points of the code bins to which all the second code files belong and the download addresses of the code bins to which all the second code files belong, and downloads the code bins to which all the second code files belong;
the search server generates a branch index of the second branch according to the branch directory of the second branch, all the code files of the second branch and the storage addresses of all the code files of the second branch;
and the search server generates a code search system according to the branch directory of the at least one target branch, the branch index of the at least one target branch and all the code bins which are downloaded by the search server and correspond to the at least one target branch.
Optionally, the processor is configured to execute the instructions, so that the search server specifically performs the following steps: the search server acquires a manifest file of at least one branch and directory tree information of a code bin of at least one branch from the code server; the search server analyzes the manifest file of the at least one target branch to obtain the characteristic information of the code bin of the at least one target branch.
Optionally, the processor is configured to execute the instructions, so that the search server specifically performs the following steps: the search server sequentially reads each code file corresponding to the branch directory of the first branch from the local; the first branch is one of the at least one branch; under the condition that the search server cannot read the target code file from the local memory, the search server reads the target code file from the code server according to the characteristic parameters of the target code file, the name of the code bin to which the target code file belongs, the latest extraction point of the code bin to which the target code file belongs and the download address of the code bin to which the target code file belongs, and downloads the code bin to which the target code file belongs to the local memory; the target code file is any one of all code files corresponding to the branch directory of the first branch.
Optionally, the processor is configured to execute the instructions, so that the search server specifically performs the following steps: the search server reads all the second code files from the local in sequence; under the condition that the search server cannot read the fourth code file from the local memory, the search server reads the fourth code file from the code server according to the characteristic parameters of the fourth code file, the name of the code bin to which the fourth code file belongs, the latest submission point of the code bin to which the fourth code file belongs and the download address of the code bin to which the fourth code file belongs, and downloads the code bin to which the fourth code file belongs; the fourth code file is any one of all the second code files.
Optionally, the processor is configured to execute the instructions, so that the search server further performs the following steps: and the search server acquires all code bins corresponding to the target branch from the code server every preset time length, and updates all code bins corresponding to the target branch stored by the search server by using all newly acquired code bins corresponding to the target branch.
Optionally, the processor is configured to execute the instructions, so that the search server further performs the following steps after generating the code search system: the search server responds to a search instruction from the development client, and searches a third code file matched with the keyword from local by using the keyword carried by the search instruction according to the branch index and the branch directory of the branch corresponding to the branch mark carried by the search instruction; the search server sends the third code file to the development client.
Optionally, the processor is configured to execute the instructions, so that the search server specifically performs the following steps: the search server responds to a search instruction from the development client, and determines a target position of a third code file matched with a keyword carried by the search instruction in a branch directory according to a branch index of a branch corresponding to a branch mark carried by the search instruction; the search server searches the third code file from the local using the branching directory and the target location.
Optionally, the processor is configured to execute the instructions, so that the search server specifically performs the following steps:
the search server responds to a search instruction from the development client, and under the condition that a branch corresponding to a branch mark carried by the search instruction is a second branch, if a third code file corresponding to a keyword carried by the search instruction is determined to be a code file in a second code bin according to a branch index of the second branch and a branch directory of the second branch, the third code file is obtained from the second code bin; the second code bin is any one of the code bins to which all the code files of the established branch belong.
The embodiment of the application also provides another search server, and the search server is provided with the code search system generated in the code search method provided in the embodiment. The search server includes: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to cause the search server to perform the steps of: the search server responds to a search instruction from the development client, and searches a third code file corresponding to a keyword from local by using the keyword carried by the search instruction according to a branch index and a branch directory of a branch corresponding to a branch mark carried by the search instruction; the search server sends the third code file to the development client.
Optionally, the processor is configured to execute the instructions, so that the search server specifically performs the following steps: the search server responds to a search instruction from the development client, and determines a target position of a third code file matched with a keyword carried by the search instruction in a branch directory according to a branch index of a branch corresponding to a branch mark carried by the search instruction; the search server searches the third code file from the local using the branching directory and the target location.
Embodiments of the present application further provide a computer-readable storage medium, which includes computer instructions, when the computer instructions are executed on a search server, cause the search server to execute the code search method or the code search system generation method provided in the foregoing embodiments.
Embodiments of the present application further provide a computer program product, which, when running on a search server, causes the search server to execute the code search method or the code search system generation method provided in the foregoing embodiments.
Through the description of the above embodiments, it is clear to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical functional division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another device, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may be one physical unit or a plurality of physical units, that is, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially or partially contributed to by the prior art, or all or part of the technical solutions may be embodied in the form of a software product, where the software product is stored in a storage medium and includes several instructions to enable a device (which may be a single chip, a chip, or the like) or a processor (processor) to execute all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only an embodiment of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present disclosure should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (21)

1. A code search system generation method applied to a search server is characterized by comprising the following steps:
the search server acquires feature information and directory tree information of a code bin of at least one target branch in the target code from the code server; the characteristic information includes: name, relative path, latest submission point and download address; the latest submission point of the target code bin of the target branch is the latest one of all submission points of the target branch submitting the code file in the target code bin; the target code bin is any one of all code bins of the target branch; the directory tree information at least comprises characteristic parameters of code files in a code bin to which the directory tree information belongs; the characteristic parameter is used for indicating a code file to which the characteristic parameter belongs;
the search server generates a branch directory of the target branch according to the relative path of the code bin of the target branch and directory tree information; the branch directory at least comprises a relative path of a code bin included by the target branch and characteristic parameters of a code file in the code bin corresponding to the target branch;
under the condition that any code file of the target code is not stored in the search server, the search server downloads the code bins to which all the code files of the first branch belong from the code server according to the name and the download address of the code bin of the first branch, and reads all the code files corresponding to the branch directory of the first branch; the first branch is any one of the at least one target branch;
the search server generates a branch index of the first branch according to all the code files of the first branch, the branch directory of the first branch and the storage addresses of all the code files of the first branch; the branch index is at least used for indicating the position of any code file corresponding to the branch to which the branch index belongs in the branch directory corresponding to the branch index;
under the condition that the search server stores the code bins to which all the code files of the established branches belong, the search server sequentially reads all first code files in the code files corresponding to the branch directories of the second branch from the local; the established branch is a target branch which is generated with a branch index; the second branch is any one of the at least one target branch except the established branch; the first code file is a code file in a code bin to which all code files of the established branch belong;
the search server reads all the second code files from the code server according to the characteristic parameters of all the second code files except the first code file in the code files corresponding to the branch directory of the second branch, the names of the code bins to which all the second code files belong, the latest intersection points of the code bins to which all the second code files belong and the download addresses of the code bins to which all the second code files belong, and downloads the code bins to which all the second code files belong;
the search server generates a branch index of the second branch according to the branch directory of the second branch, all the code files of the second branch and the storage addresses of all the code files of the second branch;
and the search server generates the code search system according to the branch directory of the at least one target branch, the branch index of the at least one target branch and all the code bins downloaded by the search server and corresponding to the at least one target branch.
2. The method of claim 1, wherein the search server obtaining feature information and directory tree information for a code bin of at least one target branch in the target code from a code server, comprises:
the search server acquires the manifest file of the at least one target branch and the directory tree information of the code bin of the at least one target branch from the code server;
and the search server analyzes the manifest file of the at least one target branch to acquire the characteristic information of the code bin of the at least one target branch.
3. The method according to claim 1 or 2, wherein the searching server downloads, from the code server, the code bins to which all the code files of the first branch belong according to the name and the download address of the code bin of the first branch, and reads all the code files corresponding to the branch directory of the first branch, including:
the search server sequentially reads each code file corresponding to the branch directory of the first branch from the local; the first branch is any one of the at least one target branch;
under the condition that the search server cannot read a target code file from a local memory, the search server reads the target code file from the code server according to the characteristic parameters of the target code file, the name of a code bin to which the target code file belongs, the latest submission point of the code bin to which the target code file belongs and the download address of the code bin to which the target code file belongs, and downloads the code bin to which the target code file belongs to the local memory; the target code file is any one of all code files corresponding to the branch directory of the first branch.
4. The method according to claim 1 or 2, wherein the searching server reads all the second code files from the code server according to the characteristic parameters of all the second code files except the first code file in the code files corresponding to the branch directory of the second branch, the names of the code bins to which all the second code files belong, the latest intersection points of the code bins to which all the second code files belong, and the download addresses of the code bins to which all the second code files belong, and downloads the code bins to which all the second code files belong, including:
the search server reads all the second code files from the local in sequence;
under the condition that the search server cannot read a fourth code file from a local memory, the search server reads the fourth code file from the code server according to the characteristic parameters of the fourth code file, the name of a code bin to which the fourth code file belongs, the latest submission point of the code bin to which the fourth code file belongs and the download address of the code bin to which the fourth code file belongs, and downloads the code bin to which the fourth code file belongs; the fourth code file is any one of all the second code files.
5. The method according to claim 1 or 2, characterized in that the method further comprises: and the search server acquires all code bins corresponding to the target branch from a code server every preset time length, and updates all code bins corresponding to the target branch stored by the search server by using all newly acquired code bins corresponding to the target branch.
6. The method of claim 1 or 2, wherein after the generating the code search system, the method further comprises:
the search server responds to a search instruction from a development client, and according to a branch index and a branch directory of a branch corresponding to a branch mark carried by the search instruction, a third code file matched with a keyword is locally searched by using the keyword carried by the search instruction;
and the search server sends the third code file to the development client.
7. The method according to claim 6, wherein the search server responds to a search instruction from the development client, and searches a third code file corresponding to a keyword from a local place by using the keyword carried by the search instruction according to a branch index and a branch directory of a branch corresponding to a branch marker carried by the search instruction, and comprises:
the search server responds to a search instruction from a development client, and determines a target position of a third code file matched with a keyword carried by the search instruction in the branch directory according to a branch index of a branch corresponding to a branch mark carried by the search instruction;
the search server searches the third code file locally using the branching directory and the target location.
8. The method according to claim 6, wherein the search server responds to a search instruction from a development client, and according to a branch index and a branch directory of a branch corresponding to a branch marker carried by the search instruction, searches a third code file matching the keyword from a local by using the keyword carried by the search instruction, and comprises:
the search server responds to a search instruction from a development client, and under the condition that a branch corresponding to a branch mark carried by the search instruction is the second branch, if a third code file corresponding to a keyword carried by the search instruction is determined to be a code file in a second code bin according to a branch index of the second branch and a branch directory of the second branch, the third code file is obtained from the second code bin; the second code bin is any one of the code bins to which all the code files of the established branch belong.
9. A code search method applied to a search server in which a code search system generated by the code search system generation method according to any one of claims 1 to 8 is provided; the code searching method comprises the following steps:
the search server responds to a search instruction from a development client, and according to a branch index and a branch directory of a branch corresponding to a branch mark carried by the search instruction, a third code file corresponding to a keyword is searched from local by using the keyword carried by the search instruction;
and the search server sends the third code file to the development client.
10. The method according to claim 9, wherein the search server responds to a search instruction from a development client, and according to a branch index and a branch directory of a branch corresponding to a branch marker carried by the search instruction, searches a third code file matching the keyword from a local by using the keyword carried by the search instruction, and comprises:
the search server responds to a search instruction from a development client, and determines a target position of a third code file matched with a keyword carried by the search instruction in the branch directory according to a branch index of a branch corresponding to a branch mark carried by the search instruction;
the search server searches the third code file from the local using the branching directory and the target location.
11. A search server, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to cause the search server to perform the steps of:
the search server acquires feature information and directory tree information of a code bin of at least one target branch in the target code from the code server; the characteristic information includes: name, relative path, latest submission point and download address; the latest submission point of the target code bin of the target branch is the latest one of all submission points of the target branch submitting the code file in the target code bin; the target code bin is any one of all code bins of the target branch; the directory tree information at least comprises characteristic parameters of code files in a code bin to which the directory tree information belongs; the characteristic parameter is used for indicating a code file to which the characteristic parameter belongs;
the search server generates a branch directory of the target branch according to the relative path of the code bin of the target branch and directory tree information; the branch directory at least comprises a relative path of a code bin included by the target branch and characteristic parameters of a code file in the code bin corresponding to the target branch;
under the condition that any code file of the target code is not stored in the search server, the search server downloads the code bins to which all the code files of the first branch belong from the code server according to the name and the download address of the code bin of the first branch, and reads all the code files corresponding to the branch directory of the first branch; the first branch is any one of the at least one target branch;
the search server generates a branch index of the first branch according to all the code files of the first branch, the branch directory of the first branch and the storage addresses of all the code files of the first branch; the branch index is at least used for indicating the position of any code file corresponding to the branch to which the branch index belongs in the branch directory corresponding to the branch index;
under the condition that the search server stores the code bins to which all the code files of the established branches belong, the search server sequentially reads all the first code files in the code files corresponding to the branch directory of the second branch from the local; the established branch is a target branch which is generated with a branch index; the second branch is any one of the at least one target branch except the established branch; the first code file is a code file in a code bin to which all code files of the established branch belong;
the search server reads all the second code files from the code server according to the characteristic parameters of all the second code files except the first code file in the code files corresponding to the branch directory of the second branch, the names of the code bins to which all the second code files belong, the latest intersection points of the code bins to which all the second code files belong and the download addresses of the code bins to which all the second code files belong, and downloads the code bins to which all the second code files belong;
the search server generates a branch index of the second branch according to the branch directory of the second branch, all the code files of the second branch and the storage addresses of all the code files of the second branch;
and the search server generates a code search system according to the branch directory of the at least one target branch, the branch index of the at least one target branch and all the code bins downloaded by the search server and corresponding to the at least one target branch.
12. The search server of claim 11, wherein the processor is configured to execute the instructions to cause the search server to perform the steps of:
the search server acquires the manifest file of the at least one target branch and the directory tree information of the code bin of the at least one target branch from the code server;
and the search server analyzes the manifest file of the at least one target branch to acquire the characteristic information of the code bin of the at least one target branch.
13. The search server according to claim 11 or 12, wherein the processor is configured to execute the instructions such that the search server performs in particular the steps of:
the search server sequentially reads each code file corresponding to the branch directory of the first branch from the local; the first branch is any one of the at least one target branch;
under the condition that the search server cannot read a target code file from a local memory, the search server reads the target code file from the code server according to the characteristic parameters of the target code file, the name of a code bin to which the target code file belongs, the latest submission point of the code bin to which the target code file belongs and the download address of the code bin to which the target code file belongs, and downloads the code bin to which the target code file belongs to the local memory; the target code file is any one of all code files corresponding to the branch directory of the first branch.
14. The search server according to claim 11 or 12, wherein the processor is configured to execute the instructions such that the search server performs in particular the steps of:
the search server reads all the second code files from the local in sequence;
under the condition that the search server cannot read a fourth code file from a local memory, the search server reads the fourth code file from the code server according to the characteristic parameters of the fourth code file, the name of a code bin to which the fourth code file belongs, the latest submission point of the code bin to which the fourth code file belongs and the download address of the code bin to which the fourth code file belongs, and downloads the code bin to which the fourth code file belongs; the fourth code file is any one of all the second code files.
15. The search server of claim 11 or 12, wherein the processor is configured to execute the instructions to cause the search server to further perform the steps of:
and the search server acquires all code bins corresponding to the target branch from a code server every preset time length, and updates all code bins corresponding to the target branch stored by the search server by using all newly acquired code bins corresponding to the target branch.
16. The search server of claim 11 or 12, wherein the processor is configured to execute the instructions to cause the search server to, after generating the code search system, further perform the steps of:
the search server responds to a search instruction from a development client, and according to a branch index and a branch directory of a branch corresponding to a branch mark carried by the search instruction, a third code file matched with a keyword is locally searched by using the keyword carried by the search instruction;
and the search server sends the third code file to the development client.
17. The search server of claim 16, wherein the processor is configured to execute the instructions to cause the search server to perform the steps of:
the search server responds to a search instruction from a development client, and determines a target position of a third code file matched with a keyword carried by the search instruction in the branch directory according to a branch index of a branch corresponding to a branch mark carried by the search instruction;
the search server searches the third code file locally using the branching directory and the target location.
18. The search server of claim 16, wherein the processor is configured to execute the instructions to cause the search server to perform the steps of:
the search server responds to a search instruction from a development client, and under the condition that a branch corresponding to a branch mark carried by the search instruction is the second branch, if a third code file corresponding to a keyword carried by the search instruction is determined to be a code file in a second code bin according to a branch index of the second branch and a branch directory of the second branch, the third code file is obtained from the second code bin; the second code bin is any one of the code bins to which all the code files of the established branch belong.
19. A search server, characterized in that a code search system generated by the code search system generation method according to any one of claims 1 to 8 is provided in the search server; the search server includes:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to cause the search server to perform the steps of:
the search server responds to a search instruction from a development client, and searches a third code file corresponding to a keyword from local by using the keyword carried by the search instruction according to a branch index and a branch directory of a branch corresponding to a branch mark carried by the search instruction;
and the search server sends the third code file to the development client.
20. The search server of claim 19, wherein the processor is configured to execute the instructions to cause the search server to perform the steps of:
the search server responds to a search instruction from a development client, and determines a target position of a third code file matched with a keyword carried by the search instruction in the branch directory according to a branch index of a branch corresponding to a branch mark carried by the search instruction;
the search server searches the third code file locally using the branching directory and the target location.
21. A computer-readable storage medium comprising computer instructions which, when run on a search server, cause the search server to perform the code search system generation method of any one of claims 1-8 or the code search method of claim 9 or 10.
CN202110932999.3A 2021-08-13 2021-08-13 Code search system generation method, code search method and search server Active CN113806595B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110932999.3A CN113806595B (en) 2021-08-13 2021-08-13 Code search system generation method, code search method and search server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110932999.3A CN113806595B (en) 2021-08-13 2021-08-13 Code search system generation method, code search method and search server

Publications (2)

Publication Number Publication Date
CN113806595A CN113806595A (en) 2021-12-17
CN113806595B true CN113806595B (en) 2022-08-12

Family

ID=78942937

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110932999.3A Active CN113806595B (en) 2021-08-13 2021-08-13 Code search system generation method, code search method and search server

Country Status (1)

Country Link
CN (1) CN113806595B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7613693B1 (en) * 2006-11-30 2009-11-03 Google Inc. Preferential ranking of code search results
US7761439B1 (en) * 2004-06-30 2010-07-20 Google Inc. Systems and methods for performing a directory search
CN108563444A (en) * 2018-03-22 2018-09-21 福州瑞芯微电子股份有限公司 A kind of Android system firmware source code restoring method and storage medium
CN110688140A (en) * 2019-10-11 2020-01-14 上海创功通讯技术有限公司 Code management method and terminal
CN111125744A (en) * 2018-10-31 2020-05-08 上海哔哩哔哩科技有限公司 Code branch merging method, system, computer device and readable storage medium
CN111352649A (en) * 2018-12-24 2020-06-30 北京嘀嘀无限科技发展有限公司 Code processing method, device, server and readable storage medium
CN112416327A (en) * 2020-11-23 2021-02-26 平安普惠企业管理有限公司 Project construction method and device, computer equipment and storage medium
CN112947907A (en) * 2020-03-23 2021-06-11 深圳市明源云科技有限公司 Method for creating code branch

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101231636B (en) * 2007-01-25 2013-09-25 北京搜狗科技发展有限公司 Convenient information search method, system and an input method system

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7761439B1 (en) * 2004-06-30 2010-07-20 Google Inc. Systems and methods for performing a directory search
US7613693B1 (en) * 2006-11-30 2009-11-03 Google Inc. Preferential ranking of code search results
CN108563444A (en) * 2018-03-22 2018-09-21 福州瑞芯微电子股份有限公司 A kind of Android system firmware source code restoring method and storage medium
CN111125744A (en) * 2018-10-31 2020-05-08 上海哔哩哔哩科技有限公司 Code branch merging method, system, computer device and readable storage medium
CN111352649A (en) * 2018-12-24 2020-06-30 北京嘀嘀无限科技发展有限公司 Code processing method, device, server and readable storage medium
CN110688140A (en) * 2019-10-11 2020-01-14 上海创功通讯技术有限公司 Code management method and terminal
CN112947907A (en) * 2020-03-23 2021-06-11 深圳市明源云科技有限公司 Method for creating code branch
CN112416327A (en) * 2020-11-23 2021-02-26 平安普惠企业管理有限公司 Project construction method and device, computer equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于SQL Server的FTP搜索引擎系统的设计;汪剑 等;《软件导刊》;20080630(第06期);第93-95页 *

Also Published As

Publication number Publication date
CN113806595A (en) 2021-12-17

Similar Documents

Publication Publication Date Title
US10713034B2 (en) Updating web resources
CN109976667A (en) A kind of mirror image management method, apparatus and system
EP2504763A1 (en) Apparatus and method for loading and updating codes of cluster-based java application system
CN111125269B (en) Data management method, blood relationship display method and related device
CN105659209B (en) The cloud service of trustship on a client device
US11809429B2 (en) Method for processing model parameters, and apparatus
CN110515631B (en) Method for generating application installation data packet, server and computer storage medium
CN113626512A (en) Data processing method, device, equipment and readable storage medium
CN104205071A (en) Information processing system, information processing method, communications terminal, server, control method therefor, and control program
CN115203194A (en) Metadata information generation method, related device, equipment and storage medium
CN113806595B (en) Code search system generation method, code search method and search server
CN113157722B (en) Data processing method, device, server, system and storage medium
CN111784376B (en) Method and device for processing information
CN112698879A (en) Method and device for loading source file
CN112860840A (en) Search processing method, device, equipment and storage medium
CN110489469B (en) Data transmission method, device, computer equipment and storage medium
CN115390912B (en) Resource discovery method, device, computer equipment and storage medium
CN112883009B (en) Method and device for processing data
US12015686B2 (en) Intelligent media feed
US12067073B2 (en) URL exchange
CN114625788A (en) Method and device for querying component, storage medium and electronic equipment
KR101387859B1 (en) System for Providing Utilization Trend Information of Application
CN112597198A (en) User data query method and device, server and storage medium
CN117493594A (en) Query method and device for game resources, electronic equipment and storage medium
CN116980464A (en) Page processing method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant