Disclosure of Invention
In order to solve the problems in the prior art, embodiments of the present invention provide a method and an apparatus for querying target data, a computer device, and a storage medium, so as to overcome the problems in the prior art that when an application project depends on too many processes, a search range is too large, omission occurs easily, is repeated, a search precision is not high, and manual operations are relied on, which results in high cost and high error rate.
In order to solve one or more technical problems, the invention adopts the technical scheme that:
in a first aspect, a method for querying target data is provided, the method including the following steps:
compiling the application project to obtain a target file generated in the compiling process of the application project;
analyzing the target file, searching in an analysis result according to a query condition, and acquiring target data meeting the query condition;
and outputting the target data for query.
Further, the analyzing the target file, searching in an analysis result according to a query condition, and acquiring target data meeting the query condition includes:
and calling a pre-generated plug-in to analyze the target file, configuring a query condition in the plug-in, and searching in the analysis result by the plug-in according to the query condition to acquire target data meeting the query condition.
Further, the target data includes code file content, the analyzing the target file, and searching in an analysis result according to a query condition, and the obtaining of the target data meeting the query condition includes:
and analyzing the target file, searching in the byte code file in the analysis result according to the query condition, and acquiring the target data meeting the query condition.
Further, the target data includes resource file content, the analyzing the target file, and searching in the analysis result according to the query condition, and the obtaining the target data meeting the query condition includes:
and analyzing the target file, searching in a compiling directory in an analysis result according to the query condition, and acquiring target data meeting the query condition.
Further, the target data includes an engineering file, the analyzing the target file, and searching in an analysis result according to a query condition, and the obtaining of the target data meeting the query condition includes:
and analyzing the target file, searching in a local directory depending on engineering in an analysis result according to the query condition, and acquiring target data meeting the query condition.
In a second aspect, an apparatus for querying target data is provided, the apparatus including:
the engineering compiling module is used for compiling the application engineering and acquiring a target file generated in the compiling process of the application engineering;
the analysis query module is used for analyzing the target file, searching in an analysis result according to a query condition and acquiring target data meeting the query condition;
and the result output module is used for outputting the target data for query.
Further, the file parsing module is specifically configured to invoke a pre-generated plug-in to parse the target file;
the device further comprises:
the condition configuration module is used for configuring query conditions in the plug-in;
the data query module is specifically used for the plug-in to search in the analysis result according to the query condition to acquire the target data meeting the query condition.
Further, the data query module includes:
and the first query unit is used for searching in the byte code file in the analysis result according to the query condition to acquire the target data meeting the query condition.
Further, the data query module further includes:
and the second query unit is used for searching in the compiling directory in the analysis result according to the query condition to acquire the target data meeting the query condition.
Further, the data query module further includes:
and the third query unit is used for searching in the local directory depending on the project in the analysis result according to the query condition to acquire the target data meeting the query condition.
In a third aspect, a computer device is provided, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the computer program, the following steps are implemented:
compiling the application project to obtain a target file generated in the compiling process of the application project;
analyzing the target file, searching in an analysis result according to a query condition, and acquiring target data meeting the query condition;
and outputting the target data for query.
In a fourth aspect, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of:
compiling the application project to obtain a target file generated in the compiling process of the application project;
analyzing the target file, searching in an analysis result according to a query condition, and acquiring target data meeting the query condition;
and outputting the target data for query.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
1. according to the target data query method, the target data query device, the computer equipment and the storage medium, the application project is compiled, the target file generated by the application project in the compiling process is obtained, the target file is analyzed, the target data meeting the query condition is obtained by searching in the analysis result according to the query condition, the target data is output for query, the compiled file is searched to replace the application project source file, the search range is reduced, the search efficiency is improved, and the problems of search omission, repetition and the like are avoided;
2. according to the target data query method, the target data query device, the computer equipment and the storage medium, the target file is analyzed by calling the pre-generated plug-in, the query condition is configured in the plug-in, the plug-in searches the analysis result according to the query condition to obtain the target data meeting the query condition, the type limitation of the query condition is increased, and the queried target data are more accurate;
3. according to the target data query method and device, the computer equipment and the storage medium provided by the embodiment of the invention, the target data is output for query, the whole process is automatically operated, the labor cost is reduced, the error rate is reduced, and the search is quicker and more convenient.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 is a flowchart illustrating a query method of target data according to an exemplary embodiment, and referring to fig. 1, the method includes the following steps:
s1: compiling the application project to obtain a target file generated in the compiling process of the application project.
Specifically, for example, in an Android project, target data needs to be searched in an Android application project source file in the traditional method, the source file generally includes the Android application project and all project-dependent files thereof, when the Android application project depends on a lot, the amount of data to be searched is large, the time consumed by query is long, and problems such as search omission and repetition are prone to occur. In order to solve the above problem, in the embodiment of the present invention, a compressed file (i.e., a target file) obtained by compiling an Android application project is searched for instead of searching for an Android application project source file, so as to narrow a search range. Therefore, when there is a query requirement for target data, the application project to be searched needs to be compiled first, and all files generated in the compiling process of the application project are used as target files. It should be noted that, in the embodiment of the present invention, the target data includes data such as a file and a character, which is not limited herein.
S2: and analyzing the target file, searching in an analysis result according to the query condition, and acquiring target data meeting the query condition.
Specifically, after the target file is obtained, the target file is firstly analyzed to obtain an analysis result, wherein the target file comprises a target compressed file in an application engineering compiling link. Then, searching is carried out in the analysis result according to the query condition, and the target data meeting the query condition is matched from the analysis result.
S3: and outputting the target data for query.
Specifically, also taking an Android project as an example, after target data is traditionally searched in an Android application project and is searched by an Android studio or other file searching tools, generally, a search result is manually counted, and then a statistical result is generated in the form of Excel or other documents. In order to solve the problem, in the embodiment of the present invention, after the target data is acquired, the target data is automatically summarized, and the summarized target data is output for query. When the target data is output, the target data can be output in a log output window in a form of a group log, and can also be directly output to a text file, wherein the output is not listed, and a developer can set the target data according to actual requirements.
As a preferred implementation manner, in the embodiment of the present invention, the parsing the target file, and searching in the parsing result according to the query condition, and acquiring the target data meeting the query condition includes:
and calling a pre-generated plug-in to analyze the target file, configuring a query condition in the plug-in, and searching in the analysis result by the plug-in according to the query condition to acquire target data meeting the query condition.
Specifically, in the embodiment of the present invention, the target data may be searched in the application engineering by a plug-in mode. Similarly, the application project can be compiled through a plug-in to generate a target file. During specific implementation, a plug-in can be generated in advance according to actual requirements, and the plug-in is called to analyze the target file to obtain an analysis result. It should be noted that, in the embodiment of the present invention, the plug-in is not specifically limited, and the developer may perform configuration according to actual requirements, for example, an android graph plug-in may be generated based on the graph, which is not listed here.
In addition, in the method for searching the target file or the character in the application project in the prior art, the query conditions have the problems of single limit condition (usually adopting a character searching mode), more noise points and the like, and in order to solve the problems, the embodiment of the invention also has the advantage that the query conditions can be configured. For example, the plug-in may configure a query condition by itself, and then search in the parsing result according to the received query condition through the plug-in to obtain the target data that conforms to the query condition. It should be noted that, in the embodiment of the present invention, the query condition may be a condition defined by multiple dimensions, such as a file type, a character type, a function type, and the like, so that the search result is more accurate.
As a preferred implementation manner, in an embodiment of the present invention, the target data includes code file content, the analyzing the target file, and searching in an analysis result according to a query condition, and acquiring the target data meeting the query condition includes:
and analyzing the target file, searching in the byte code file in the analysis result according to the query condition, and acquiring the target data meeting the query condition.
Specifically, when the target data to be searched is the content of the code file, the target file is analyzed, after the analysis result is obtained, the byte code file in the analysis result is searched according to the query condition, and the target data meeting the query condition is obtained.
As a preferred implementation manner, in an embodiment of the present invention, the target data includes resource file content, the analyzing the target file, and searching in an analysis result according to a query condition, and acquiring the target data meeting the query condition includes:
and analyzing the target file, searching in a compiling directory in an analysis result according to the query condition, and acquiring target data meeting the query condition.
Specifically, when the target data to be searched is the content of the resource file, the target file is analyzed, and after the analysis result is obtained, the target data meeting the query condition is obtained by searching in a compiling directory (such as res, assets, and the like) in the analysis result according to the query condition.
As a preferred implementation manner, in an embodiment of the present invention, the target data includes an engineering file, the parsing the target file, and searching in a parsing result according to a query condition, and acquiring the target data that meets the query condition includes:
and analyzing the target file, searching in a local directory depending on engineering in an analysis result according to the query condition, and acquiring target data meeting the query condition.
Specifically, when the target data to be searched is a project file, the target file is analyzed, after an analysis result is obtained, the target data meeting the query condition is obtained by searching in a local directory depending on the project in the analysis result according to the query condition.
Fig. 2 is a schematic structural diagram illustrating a query apparatus for target data according to an exemplary embodiment, and referring to fig. 2, the query apparatus includes:
the engineering compiling module is used for compiling the application engineering and acquiring a target file generated in the compiling process of the application engineering;
the file analysis module is used for analyzing the target file to generate an analysis result;
the data query module is used for searching in the analysis result according to the query condition to acquire target data meeting the query condition;
and the result output module is used for outputting the target data for query.
As a preferred embodiment, in the embodiment of the present invention, the file parsing module is specifically configured to invoke a pre-generated plug-in to parse the target file;
the device further comprises:
the condition configuration module is used for configuring query conditions in the plug-in;
the data query module is specifically used for the plug-in to search in the analysis result according to the query condition to acquire target data meeting the query condition.
As a preferred implementation manner, in an embodiment of the present invention, the data query module includes:
and the first query unit is used for searching byte code files in the analysis result according to the query conditions to acquire the target data meeting the query conditions.
As a preferred implementation manner, in an embodiment of the present invention, the data query module further includes:
and the second query unit is used for searching in the compiling directory in the analysis result according to the query condition to acquire the target data meeting the query condition.
As a preferred implementation manner, in an embodiment of the present invention, the data query module further includes:
and the third query unit is used for searching in the local directory depending on the project in the analysis result according to the query condition to acquire the target data meeting the query condition.
Fig. 3 is a schematic diagram illustrating an internal configuration of a computer device according to an exemplary embodiment, which includes a processor, a memory, and a network interface connected through a system bus, as shown in fig. 3. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operating system and the computer program to run on the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of optimization of an execution plan.
Those skilled in the art will appreciate that the configuration shown in fig. 3 is a block diagram of only a portion of the configuration associated with aspects of the present invention and is not intended to limit the computing devices to which aspects of the present invention may be applied, and that a particular computing device may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
As a preferred implementation manner, in an embodiment of the present invention, the computer device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the following steps when executing the computer program:
compiling the application project to obtain a target file generated in the compiling process of the application project;
analyzing the target file, searching in an analysis result according to a query condition, and acquiring target data meeting the query condition;
and outputting the target data for query.
As a preferred implementation manner, in the embodiment of the present invention, when the processor executes the computer program, the following steps are further implemented:
and calling a pre-generated plug-in to analyze the target file, configuring a query condition in the plug-in, and searching in the analysis result by the plug-in according to the query condition to acquire target data meeting the query condition.
As a preferred implementation manner, in the embodiment of the present invention, when the processor executes the computer program, the following steps are further implemented:
and analyzing the target file, searching in the byte code file in the analysis result according to the query condition, and acquiring the target data meeting the query condition.
As a preferred implementation manner, in the embodiment of the present invention, when the processor executes the computer program, the following steps are further implemented:
and analyzing the target file, searching in a compiling directory in an analysis result according to the query condition, and acquiring target data meeting the query condition.
As a preferred implementation manner, in the embodiment of the present invention, when the processor executes the computer program, the following steps are further implemented:
and analyzing the target file, searching in a local directory depending on engineering in an analysis result according to a query condition, and acquiring target data meeting the query condition.
In an embodiment of the present invention, a computer-readable storage medium is further provided, on which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the following steps:
compiling the application project to obtain a target file generated in the compiling process of the application project;
analyzing the target file, searching in an analysis result according to a query condition, and acquiring target data meeting the query condition;
and outputting the target data for query.
As a preferred implementation manner, in the embodiment of the present invention, when executed by a processor, the computer program further implements the following steps:
and calling a pre-generated plug-in to analyze the target file, configuring a query condition in the plug-in, and searching in the analysis result by the plug-in according to the query condition to acquire target data meeting the query condition.
As a preferred implementation manner, in the embodiment of the present invention, when executed by the processor, the computer program further implements the following steps:
and analyzing the target file, searching in the byte code file in the analysis result according to the query condition, and acquiring the target data meeting the query condition.
As a preferred implementation manner, in the embodiment of the present invention, when executed by the processor, the computer program further implements the following steps:
and analyzing the target file, searching in a compiling directory in an analysis result according to the query condition, and acquiring target data meeting the query condition.
As a preferred implementation manner, in the embodiment of the present invention, when executed by the processor, the computer program further implements the following steps:
and analyzing the target file, searching in a local directory depending on engineering in an analysis result according to the query condition, and acquiring target data meeting the query condition.
In summary, the technical solution provided by the embodiment of the present invention has the following beneficial effects:
it should be noted that: the query device of target data provided in the foregoing embodiment is only illustrated by dividing the functional modules when triggering a data query service, and in practical applications, the function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the target data query device and the target data query method provided in the above embodiments belong to the same concept, that is, the device is based on the target data query method, and the specific implementation process thereof is detailed in the method embodiments, and is not described herein again.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and should not be taken as limiting the scope of the present invention, which is intended to cover any modifications, equivalents, improvements, etc. within the spirit and scope of the present invention.