Code difference query method and device, equipment and storage medium
By using a code difference query method with multi-node parallel computing, the problems of slow query speed and low efficiency in existing technologies are solved, and efficient code difference query is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING QIHOOD TECHNOLOGY CO LTD
- Filing Date
- 2020-05-13
- Publication Date
- 2026-06-09
AI Technical Summary
Existing technologies are slow and inefficient when performing code difference queries, and their performance is affected by the limitations of the system's CPU cores when the computational load is too large.
A multi-node parallel computing approach is adopted. When a code difference query request is received, the request task information is read, the code path information is obtained, and the code file to be compared is located. The code difference results are obtained by comparing the code files using multiple processing nodes.
It greatly improves the speed of code difference calculation and query efficiency, optimizes the user's query experience, and reduces system resource consumption and query waiting time.
Smart Images

Figure CN113672281B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer software technology, and in particular to a method, apparatus, device, and storage medium for code difference querying. Background Technology
[0002] In code difference query systems, the initial solution was single-machine deployment and real-time calculation. The most obvious drawback of this solution in practical applications is that the code difference calculation is slow and time-consuming, and it is only calculated after each user submits a query request. Moreover, it cannot provide services to users if the machine crashes.
[0003] To optimize computation speed, the development and testing team improved the existing solution by using a multi-process + caching approach to handle code difference queries. This approach can improve computation performance to some extent, but it is still affected by the limitations of the system's CPU cores. When the amount of computation exceeds a certain threshold, the performance is still affected, resulting in low speed and efficiency of code difference queries.
[0004] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main objective of this invention is to provide a code difference query method, apparatus, device, and storage medium, aiming to solve the technical problems of low query speed and low efficiency in existing technologies when performing code difference queries.
[0006] To achieve the above objectives, the present invention provides a code difference query method, the method comprising the following steps:
[0007] Upon receiving a code difference query request, read the request task information carried in the code difference query request;
[0008] Obtain the code path information contained in the request task information, and find the code file to be compared corresponding to the code path information;
[0009] The code files to be compared are compared using multiple processing nodes to obtain code difference results.
[0010] Optionally, the step of obtaining the code path information contained in the request task information and finding the code file to be compared corresponding to the code path information includes:
[0011] Obtain the code path information contained in the requested task information;
[0012] The code path information is compared, and the corresponding code difference result is searched in a preset database based on the comparison result.
[0013] If the code difference result is not found in the preset database, the code file to be compared corresponding to the code path information is searched.
[0014] Optionally, after the step of comparing the code path information and searching a preset database for a corresponding code difference result based on the comparison result, the method further includes:
[0015] When the code difference result exists in the preset database, the code difference result is fed back to the user who initiated the code difference query request.
[0016] Optionally, before the step of reading the request task information carried in the code difference query request upon receiving the code difference query request, the method further includes:
[0017] Retrieve historical code information submitted by registered users;
[0018] Based on the historical code information, predict the code difference query needs of the registered users to obtain the code difference query requests to be executed.
[0019] Write the request task information corresponding to the code difference query request to be executed into a preset message queue;
[0020] The tasks in the preset message queue are processed, and the task processing results are saved to the preset database.
[0021] Optionally, the step of searching for the code file to be compared corresponding to the code path information when the code difference result does not exist in the preset database includes:
[0022] If the code difference result is not found in the preset database, the request task information is written to the preset message queue;
[0023] The request task information is read from the preset message queue through multiple processing nodes, and the corresponding code file to be compared is determined according to the code path information and the request task information.
[0024] Optionally, the step of predicting the code difference query needs of the registered user based on the historical code information and obtaining the code difference query request to be executed includes:
[0025] Based on the code compilation information and code testing information contained in the historical code information, obtain the historical code files that have undergone code changes;
[0026] Obtain the file feature information corresponding to the historical code file, and determine the target code file to be compared based on the file feature information;
[0027] Based on the target code file to be compared, the code difference query needs of the registered user are predicted, and the code difference query request to be executed is obtained.
[0028] Optionally, the step of reading the request task information carried in the code difference query request when receiving the code difference query request includes:
[0029] Upon receiving a code difference query request, the user identifier contained in the request message of the code difference query request is read;
[0030] Determine whether the user initiating the request has access rights based on the user identifier;
[0031] When the user initiating the request has access rights, the request task information carried in the code difference query request is read.
[0032] Furthermore, to achieve the above objectives, the present invention also proposes a code difference query device, the code difference query device comprising:
[0033] The request receiving module is used to read the request task information carried in the code difference query request when it receives the code difference query request;
[0034] The file search module is used to obtain the code path information contained in the request task information and search for the code file to be compared corresponding to the code path information;
[0035] The file comparison module is used to compare the code files to be compared through multiple processing nodes to obtain code difference results.
[0036] Furthermore, to achieve the above objectives, the present invention also proposes a code difference query device, the device comprising: a memory, a processor, and a code difference query program stored in the memory and executable on the processor, the code difference query program being configured to implement the steps of the code difference query method as described above.
[0037] In addition, to achieve the above objectives, the present invention also proposes a storage medium storing a code difference query program, which, when executed by a processor, implements the steps of the code difference query method as described above.
[0038] This invention, upon receiving a code difference query request, reads the request task information carried in the request; then, it obtains the code path information contained in the request task information, locates the corresponding code file to be compared, and then compares the code file to be compared through multiple processing nodes to obtain the code difference result. Because this invention uses multiple nodes to simultaneously calculate the code differences between code files, it can significantly improve the calculation speed of code differences and increase query efficiency compared to existing multi-process and caching methods. Attached Figure Description
[0039] Figure 1 This is a schematic diagram of the structure of the code difference query device for the hardware operating environment involved in the embodiments of the present invention;
[0040] Figure 2 This is a flowchart illustrating the first embodiment of the code difference query method of the present invention;
[0041] Figure 3 This is an architecture diagram of the distributed task processing system in the first embodiment of the code difference query method of the present invention;
[0042] Figure 4 This is a flowchart illustrating the second embodiment of the code difference query method of the present invention;
[0043] Figure 5 This is a flowchart illustrating the third embodiment of the code difference query method of the present invention;
[0044] Figure 6 This is a structural block diagram of the first embodiment of the code difference query device of the present invention.
[0045] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0046] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0047] Reference Figure 1 , Figure 1 This is a schematic diagram of the hardware operating environment code difference query device involved in the embodiment of the present invention.
[0048] like Figure 1As shown, the code difference query device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to implement communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0049] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the code difference query device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0050] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a data storage module, a network communication module, a user interface module, and a code difference query program.
[0051] exist Figure 1 In the code difference query device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the code difference query device of the present invention can be set in the code difference query device, and the code difference query device calls the code difference query program stored in the memory 1005 through the processor 1001 and executes the code difference query method provided in the embodiment of the present invention.
[0052] This invention provides a method for querying code differences, referring to... Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the code difference query method of the present invention.
[0053] In this embodiment, the code difference query method includes the following steps:
[0054] Step S10: Upon receiving a code difference query request, read the request task information carried in the code difference query request;
[0055] It should be noted that the execution entity of the method in this embodiment can be a distributed task processing system (hereinafter referred to as the system). See reference... Figure 3 , Figure 3 This is an architecture diagram of the distributed task processing system in the first embodiment of the code difference query method of the present invention.
[0056] like Figure 3 As shown, the distributed task processing system in this embodiment may include a central control unit 10, a message queue 20, processing nodes (301...30n), and a database 40. The central control unit 10 can interact with the front end. In actual operation, users can input corresponding code difference query requests through the interactive interface provided by the front end, and then the central control unit 10 will process the request.
[0057] Understandably, the message queue can be understood as a container for storing messages during message transmission. In this embodiment, the message queue 20 is used to store task information to be executed. The processing nodes (301...30n) are node servers in this distributed task processing system used to read task information from the message queue 20 and process the tasks. The database 40 may include a master database and a slave database, used to store the request processing results of various code difference query requests after they have been processed by the processing nodes (301...30n).
[0058] It should be understood that the requested task information may include task information containing different query requirements, such as querying a list of differing code files corresponding to differing code files, or querying the specific code differences corresponding to differing code files.
[0059] In the specific implementation, when the system receives a code difference query request input by the user, it first parses the request, and then reads the request task information carried in the request based on the parsed request message.
[0060] To enhance the security of code difference queries and ensure system information security, as one implementation method, the central control unit in this embodiment will also check whether the user has access permissions when receiving a code difference query request initiated by the user.
[0061] Specifically, when the system receives a code difference query request, it first reads the user identifier contained in the request message of the code difference query request; then it determines whether the user who initiated the request has access rights based on the user identifier; if the user has access rights, it executes the subsequent operations; if the user does not have access rights, it directly returns a permission activation prompt to guide the user to activate permissions according to the prompt.
[0062] It should be understood that, in order to reduce the complexity of access control, the system in this embodiment can use a user identifier to determine whether a user has access rights, which can further improve the overall query efficiency. In this embodiment, the user identifier can be the user's registration ID, account number, or other character data that can be used to represent the uniqueness of the user and is easy to control access.
[0063] Step S20: Obtain the code path information contained in the request task information, and find the code file to be compared corresponding to the code path information;
[0064] It should be understood that when processing a request to query code differences, it is necessary to first determine the code file to be compared. Therefore, in this embodiment, the path information where the code is stored is selected as the query condition to determine the code file to be compared, which can ensure the accuracy and efficiency of code file search.
[0065] Specifically, the system can first obtain the code path information contained in the request task information; then compare these code path information to determine which code files the user needs to view for differences; then search the preset database to see if the corresponding code difference results already exist; if they exist, there is no need to perform subsequent code comparison operations, and the search results can be directly fed back to the user.
[0066] In one implementation, the system can first obtain the code path information contained in the request task information, then compare the code path information, and search for the corresponding code difference result in the preset database (i.e., the database 40 mentioned above) according to the comparison result; if it does not exist, it continues to search for the code file to be compared corresponding to the code path information; if it exists, it feeds back the code difference result to the request initiating user corresponding to the code difference query request.
[0067] Furthermore, to ensure the orderliness and reliability of request processing and improve query efficiency, in this embodiment, the system can also write the request task information into a preset message queue when no code difference results exist in the preset database. Then, multiple processing nodes read the request task information from the preset message queue and determine the corresponding code file to be compared based on the code path information and the request task information.
[0068] This embodiment, by first searching the database for corresponding code difference results before obtaining the code files to be compared, effectively utilizes the user's historical query data, avoids unnecessary repetitive operations, improves the efficiency of code difference queries, and saves on the occupation of various system resources. Furthermore, since different versions of code files correspond to different storage paths, comparing code paths can more accurately and quickly identify which code files may have differences.
[0069] Step S30: The code files to be compared are compared through multiple processing nodes to obtain code difference results.
[0070] It should be noted that, in order to effectively improve the query speed of code differences, this embodiment uses multiple processing nodes to calculate code differences simultaneously to compare the code files to be compared, thereby quickly obtaining the code differences (results) between the code files, and then displaying the code differences to the user through the front end for viewing.
[0071] Furthermore, in this embodiment, when selecting a processing node for code comparison, the system can first obtain the current performance status information of the processing node, such as CPU utilization, memory utilization, and disk I / O. Then, based on this status information, it selects a processing node with good performance as an effective processing node to compare the code file, thereby further improving the query efficiency.
[0072] Of course, when selecting processing nodes based on the above performance status parameters, nodes that are currently idle can be given priority. If there are no idle processing nodes, multiple processing nodes can be selected for comparison of the code files based on the amount of tasks waiting to be processed on each processing node at the current moment, as well as the average task processing rate and performance status parameters over a recent period.
[0073] As one implementation method, in order to maximize the efficiency of code file comparison, when the system assigns the code files to be compared to different processing nodes, it can first obtain the file size of the code files to be compared, then predict the time taken for the code comparison process based on the file size, and then prioritize assigning the code files with longer processing times to processing nodes with good performance and less workload based on the prediction results, thereby greatly improving the efficiency of code difference query.
[0074] In practice, after obtaining the code file to be compared, the system can assign the code file to different processing nodes for comparison in the manner described above, thereby obtaining the code difference results, and then feeding the results back to the user.
[0075] In practical applications, different users initiate code difference query requests that target different objects, and the specific query operations performed by the system also differ for different types of request objects. This embodiment will illustrate this with two types of request objects: code file differences and a list of code difference files.
[0076] Specifically, the system can first read request task information from the preset message queue through multiple processing nodes, and then determine the request object corresponding to the code difference query request based on the request task information.
[0077] When the requested object is a code file difference, the system can classify the code files to be compared into code items to obtain a set of code items to be compared; calculate the specific differences between each code file in the set of code items through multiple processing nodes, and use the specific differences as the code difference result.
[0078] When the requested object is a list of code difference files, the corresponding code file to be compared is obtained according to the code path information. Then, the code file to be compared is compared through multiple processing nodes, and the target code file with differences is determined according to the comparison results. Finally, a corresponding list of code difference files is generated according to the target code file, and the list of code difference files is used as the code difference result.
[0079] This embodiment reads the request task information carried in the code difference query request upon receiving it; then, it obtains the code path information contained in the request task information, locates the code file to be compared corresponding to the code path information, and then compares the code file to be compared through multiple processing nodes to obtain the code difference result. Since this embodiment uses multiple nodes to simultaneously calculate the code differences between code files, it can greatly improve the calculation speed of code differences and increase query efficiency compared to existing multi-process and caching methods.
[0080] refer to Figure 4 , Figure 4 This is a flowchart illustrating the second embodiment of the code difference query method of the present invention.
[0081] Based on the first embodiment described above, in this embodiment, the distributed task processing system further includes: an artificial intelligence (AI) module. Figure 3 (Not shown in the image) This module is designed to predict in advance the code files (paths) that a user might need to compare. It can extract corresponding feature information from the user's submitted historical code compilation information and code testing information, and then predict the code difference query requests that the user may initiate later based on this feature information. It infers the query tasks that the user may publish and puts these tasks into a message queue in advance. This way, the processing nodes can process these tasks in the message queue in advance. When the user visits later, if there are already processing results, the results can be read and displayed directly, thereby greatly improving query efficiency and optimizing the user's query experience.
[0082] Accordingly, in this embodiment, before step S10, the method further includes:
[0083] Step S01: Obtain historical code information submitted by registered users;
[0084] It should be noted that the registered users can be those who have pre-registered an account in the distributed task processing system. Of course, the code difference query method provided in this embodiment is also applicable to unregistered users.
[0085] It should be understood that the historical code information includes, but is not limited to, code compilation information and code testing information. Code compilation information can be information related to the user's compilation operations on the code program, such as CRUD operations. Code testing information can be code testing information related to the code submission testing process, such as functional test information and stress test information.
[0086] In this step, this historical code information can be submitted by the user or extracted by the system based on the user's code operation records. This embodiment does not impose any restrictions on this.
[0087] Step S02: Based on the historical code information, predict the code difference query needs of the registered users to obtain the code difference query requests to be executed;
[0088] In its implementation, the system can predict the code difference query requests that registered users may submit in the future based on the aforementioned historical code information, thereby obtaining the code difference query requests to be executed.
[0089] In practical applications, if the prediction is made based on the user's historical code information, although the prediction accuracy can be high, the amount of prediction work involved is also huge, which will consume too much of the system's computing resources.
[0090] Therefore, as one implementation method, in this embodiment, the system can preferentially use the code compilation information and code testing information contained in the historical code information to predict requests.
[0091] Specifically, the system can obtain historical code files that have undergone code changes based on the code compilation and testing information contained in the historical code information, i.e., obtain historical code files that have been modified by the user; then obtain the file feature information corresponding to these historical code files, and determine the target code files to be compared based on these file feature information; finally, predict the code difference query needs of registered users based on the target code files to be compared, and obtain the code difference query request to be executed.
[0092] It should be noted that the file feature information may include the file's update frequency, update count, update content, the length / proportion of the updated content, and the code project to which the code file belongs. This embodiment does not impose specific limitations on the message dimensions involved in the file feature information.
[0093] In its implementation, the system can obtain the code path corresponding to the historical code file, and then select the associated code file from the historical code file according to the code path; then obtain the key code information corresponding to each associated code file, and then determine the target code file to be compared according to the key code information.
[0094] It should be understood that a complete code project may include many code files, and different versions of the same code file may have different storage paths. However, the prefixes or most of the path characters are basically the same, with differences possibly only in the last few characters of the path. Therefore, in this embodiment, the system can select the associated code file based on these identical characters in the code path. The key code information can be key information that can characterize the features or characteristics of the code file, such as certain specific functions or characters common to the file.
[0095] In practice, the system can process code difference query requests in advance once it predicts the requests to be executed.
[0096] Step S03: Write the request task information corresponding to the code difference query request to be executed into a preset message queue;
[0097] In practice, the system can write the request task information contained in the predicted code difference request to a preset message queue, and then different processing nodes can preprocess the request tasks in the current preset message queue.
[0098] Step S04: Process the tasks in the preset message queue and save the task processing results to the preset database.
[0099] It should be understood that, in order to enable the advance calculation of code differences, in this embodiment, the tasks corresponding to the code difference query requests to be executed in the preset message queue can be processed in advance through different processing nodes, and then the processing results can be saved in the preset database.
[0100] It should be noted that the preset database is the aforementioned database 40 in the distributed task processing system. In order to ensure that the task processing results of such pre-predicted calculations can be quickly queried, the system can save these task processing results to the slave database corresponding to the aforementioned database 40.
[0101] Considering that there may be some deviation in request prediction, in this embodiment the system can also judge the accuracy of request prediction based on the reading records of task processing results stored in the database. For task processing results that have not been read or queried for a long time in the database, periodic clearing can be used to reduce the storage pressure on the database.
[0102] Furthermore, since the system in this embodiment has a request prediction function, to avoid a situation where the request task information corresponding to the user's current code difference query request has been successfully predicted by the AI module and written into a preset message queue awaiting processing, but no processing result has been received, resulting in the code difference result not being found in the database temporarily, in this embodiment, when the system initially detects that there is no code difference result in the preset database, it will wait for a certain period of time and, during the waiting period, cyclically check whether the code difference result corresponding to the code difference query request already exists in the preset database. If it still does not exist, a normal code file search operation is performed, that is, the request task information is read from the preset message queue through multiple processing nodes, and the corresponding code file to be compared is determined according to the code path information and the request task information. This cyclical detection method in this embodiment can also ensure the efficiency of code difference query.
[0103] This embodiment obtains historical code information submitted by registered users; predicts the code difference query needs of registered users based on the historical code information to obtain code difference query requests to be executed; writes the request task information corresponding to the code difference query requests to be executed into a preset message queue; processes the tasks in the preset message queue and saves the task processing results to a preset database. This embodiment can accurately predict the code difference query requests that users may make in advance based on the user's historical code information, then process the query requests in advance and pre-store the processing results, so that when the user initiates the same query request, feedback can be immediately provided based on the pre-stored results, shortening the query waiting time and improving the user's query experience.
[0104] refer to Figure 5 , Figure 5 This is a flowchart illustrating the third embodiment of the code difference query method of the present invention.
[0105] Based on the above embodiments, a third embodiment of the code difference query method of the present invention is proposed.
[0106] In this embodiment, step S10 may specifically include the following steps:
[0107] Step S101: Upon receiving a code difference query request, read the user identifier contained in the request message of the code difference query request;
[0108] It should be understood that the user identifier mentioned in this embodiment may be the user's registration ID, account number, or other character data that can be used to represent the uniqueness of the user and is easy to control in terms of permissions.
[0109] When the system receives a code difference query request, it can parse the request and read the user identifier contained in the request message.
[0110] Step S102: Determine whether the user initiating the request has access rights based on the user identifier;
[0111] Considering that in practice, relying solely on user identifiers to determine whether a requesting user has access rights cannot guarantee the authenticity and security of user access, this embodiment's system will also combine the Internet Protocol address (IP address) of the requesting user with the permission verification.
[0112] Specifically, the system can first obtain the Internet Protocol address corresponding to the request initiating user and check whether the Internet Protocol address exists in a preset whitelist; if the Internet Protocol address exists in the preset whitelist, the system determines the target code resource that the request initiating user wants to query based on the request message; and determines whether the request initiating user has access rights based on the user identifier and the target code resource.
[0113] The preset whitelist can be a list of IP addresses corresponding to users with access permissions.
[0114] Furthermore, to manage the security of different code resources, a permission access list corresponding to each code resource can be pre-established in the system. This list stores the correspondence between code resources and user identifiers that have access permissions to those resources. When querying whether a user has access permissions to a specific code resource, the user identifier can be matched against this permission access list, and the system determines whether the user has the necessary permissions based on the matching result. Specifically, the system can obtain the permission access list corresponding to the target code resource; then, it can match the user identifier against the permission access list. If the match is successful, the system determines that the user initiating the request has the necessary permissions; if the match fails, the system determines that the user initiating the request does not have the necessary permissions.
[0115] Step S103: When the user initiating the request has access rights, read the request task information carried in the code difference query request.
[0116] In the specific implementation, when the system detects that the user initiating the request has the necessary access permissions, it can read the request task information carried in the code difference query request and then execute the subsequent code difference query operation.
[0117] Accordingly, when the user initiating the request does not have access rights, the system can send a pre-set permission activation prompt to the user initiating the request, so that the user initiating the request can activate access rights according to the permission activation prompt.
[0118] In this embodiment, upon receiving a code difference query request, the user identifier contained in the request message is read; the user identifier is used to determine whether the requesting user has access permissions; if the requesting user has access permissions, the request task information carried in the code difference query request is read; if the requesting user does not have access permissions, a pre-set permission activation prompt is sent to the requesting user, so that the requesting user can activate the access permissions according to the permission activation prompt. This embodiment effectively verifies user access permissions through the above method, preventing unauthorized users from accessing and querying code resources, thus ensuring the security of code information.
[0119] Furthermore, this embodiment of the invention also proposes a storage medium storing a code difference query program, which, when executed by a processor, implements the steps of the code difference query method described above.
[0120] Reference Figure 6 , Figure 6 This is a structural block diagram of the first embodiment of the code difference query device of the present invention.
[0121] like Figure 6 As shown, the code difference query device proposed in this embodiment of the invention includes:
[0122] The request receiving module 601 is used to read the request task information carried in the code difference query request when it receives the code difference query request;
[0123] The file search module 602 is used to obtain the code path information contained in the request task information and search for the code file to be compared corresponding to the code path information;
[0124] The file comparison module 603 is used to compare the code files to be compared through multiple processing nodes to obtain code difference results.
[0125] This embodiment reads the request task information carried in the code difference query request upon receiving it; then, it obtains the code path information contained in the request task information, locates the code file to be compared corresponding to the code path information, and then compares the code file to be compared through multiple processing nodes to obtain the code difference result. Since this embodiment uses multiple nodes to simultaneously calculate the code differences between code files, it can greatly improve the calculation speed of code differences and increase query efficiency compared to existing multi-process and caching methods.
[0126] Based on the first embodiment of the code difference query device of the present invention, a second embodiment of the code difference query device of the present invention is proposed.
[0127] In this embodiment, the file search module 602 is further configured to obtain code path information contained in the request task information; compare the code path information and search in a preset database for a corresponding code difference result based on the comparison result; and if the code difference result is not found in the preset database, search for the code file to be compared corresponding to the code path information.
[0128] As one implementation, the file search module 602 is also used to, when the code difference result exists in the preset database, feed back the code difference result to the request initiating user corresponding to the code difference query request.
[0129] In one implementation, the code difference query device further includes a request prediction module, which is used to obtain historical code information submitted by registered users; predict the code difference query needs of registered users based on the historical code information to obtain code difference query requests to be executed; write the request task information corresponding to the code difference query requests to be executed into a preset message queue; process the tasks in the preset message queue and save the task processing results to a preset database.
[0130] In one implementation, the request prediction module is further configured to obtain historical code files with code change operations based on the code compilation information and code testing information contained in the historical code information; obtain file feature information corresponding to the historical code files; determine the target code file to be compared based on the file feature information; and predict the code difference query needs of the registered user based on the target code file to be compared, thereby obtaining the code difference query request to be executed.
[0131] In one implementation, the request prediction module is further configured to obtain the code path corresponding to the historical code file, select associated code files from the historical code files according to the code path, obtain the key code information corresponding to each associated code file, and determine the target code file to be compared according to the key code information.
[0132] In one implementation, the file search module 602 is further configured to write the request task information into the preset message queue when the code difference result does not exist in the preset database; read the request task information from the preset message queue through multiple processing nodes, and determine the corresponding code file to be compared based on the code path information and the request task information.
[0133] As one implementation, the file search module 602 is further configured to cyclically detect whether the code difference result corresponding to the code difference query request has been stored in the preset database within a preset time period; if the code difference result has not been stored in the preset database, then the operation of reading request task information from the preset message queue through multiple processing nodes and determining the corresponding code file to be compared based on the code path information and the request task information is performed.
[0134] In one implementation, the file search module 602 is further configured to read request task information from the preset message queue through multiple processing nodes; determine the request object corresponding to the code difference query request based on the request task information; and when the request object is a code file difference, obtain the corresponding code file to be compared based on the code path information.
[0135] Accordingly, the file comparison module 603 is also used to classify the code files to be compared into code items to obtain a set of code items to be compared; calculate the specific differences between each code file in the set of code items through multiple processing nodes, and use the specific differences as the code difference results.
[0136] In one implementation, the file search module 602 is further configured to obtain the corresponding code file to be compared based on the code path information when the requested object is a list of code difference files;
[0137] Accordingly, the file comparison module 603 is further configured to compare the code files to be compared through multiple processing nodes, determine the target code files with differences based on the comparison results, generate a corresponding list of code difference files based on the target code files, and use the list of code difference files as the code difference results.
[0138] In one implementation, the request receiving module 601 is further configured to, upon receiving a code difference query request, read the user identifier contained in the request message of the code difference query request; determine whether the request initiating user has access rights based on the user identifier; and, if the request initiating user has access rights, read the request task information carried in the code difference query request.
[0139] In one implementation, the request receiving module 601 is further configured to obtain the Internet Protocol address corresponding to the request initiating user and detect whether the Internet Protocol address exists in a preset whitelist; when the Internet Protocol address exists in the preset whitelist, determine the target code resource to be queried by the request initiating user based on the request message; and determine whether the request initiating user has access rights based on the user identifier and the target code resource.
[0140] In one implementation, the request receiving module 601 is further configured to obtain an access permission list corresponding to the target code resource; match the user identifier according to the access permission list; if the match is successful, it is determined that the user initiating the request has access permission; if the match fails, it is determined that the user initiating the request does not have the access permission.
[0141] In one implementation, the request receiving module 601 is further configured to send a pre-set permission activation prompt to the request initiating user when the request initiating user does not have access rights, so that the request initiating user can activate the access rights according to the permission activation prompt.
[0142] Other embodiments or specific implementations of the code difference query device of the present invention can be referred to the above-described method embodiments, and will not be repeated here.
[0143] This invention provides a code difference query method, which further includes the following steps:
[0144] Upon receiving a code difference query request, read the request task information carried in the code difference query request;
[0145] Obtain the code path information contained in the request task information, and find the code file to be compared corresponding to the code path information;
[0146] The code files to be compared are compared using multiple processing nodes to obtain code difference results.
[0147] Optionally, the step of obtaining the code path information contained in the request task information and finding the code file to be compared corresponding to the code path information includes:
[0148] Obtain the code path information contained in the requested task information;
[0149] The code path information is compared, and the corresponding code difference result is searched in a preset database based on the comparison result.
[0150] If the code difference result is not found in the preset database, the code file to be compared corresponding to the code path information is searched.
[0151] Optionally, after the step of comparing the code path information and searching a preset database for a corresponding code difference result based on the comparison result, the method further includes:
[0152] When the code difference result exists in the preset database, the code difference result is fed back to the user who initiated the code difference query request.
[0153] Optionally, before the step of reading the request task information carried in the code difference query request upon receiving the code difference query request, the method further includes:
[0154] Retrieve historical code information submitted by registered users;
[0155] Based on the historical code information, predict the code difference query needs of the registered users to obtain the code difference query requests to be executed.
[0156] Write the request task information corresponding to the code difference query request to be executed into a preset message queue;
[0157] The tasks in the preset message queue are processed, and the task processing results are saved to the preset database.
[0158] Optionally, the step of searching for the code file to be compared corresponding to the code path information when the code difference result does not exist in the preset database includes:
[0159] If the code difference result is not found in the preset database, the request task information is written to the preset message queue;
[0160] The request task information is read from the preset message queue through multiple processing nodes, and the corresponding code file to be compared is determined according to the code path information and the request task information.
[0161] Optionally, before the step of reading request task information from the preset message queue through multiple processing nodes, the method further includes:
[0162] Within a preset time period, the code difference results corresponding to the code difference query request are repeatedly checked to see if they have been stored in the preset database.
[0163] If the code difference results are not stored in the preset database, then the steps of reading request task information from the preset message queue through multiple processing nodes and determining the corresponding code file to be compared based on the code path information and the request task information are executed.
[0164] Optionally, the step of predicting the code difference query needs of the registered user based on the historical code information and obtaining the code difference query request to be executed includes:
[0165] Based on the code compilation information and code testing information contained in the historical code information, obtain the historical code files that have undergone code changes;
[0166] Obtain the file feature information corresponding to the historical code file, and determine the target code file to be compared based on the file feature information;
[0167] Based on the target code file to be compared, the code difference query needs of the registered user are predicted, and the code difference query request to be executed is obtained.
[0168] Optionally, the step of obtaining file feature information corresponding to the historical code file and determining the target code file to be compared based on the file feature information includes:
[0169] Obtain the code path corresponding to the historical code file, and select an associated code file from the historical code file according to the code path;
[0170] Obtain the key code information corresponding to each associated code file, and determine the target code file to be compared based on the key code information.
[0171] Optionally, the step of reading request task information from the preset message queue through multiple processing nodes and determining the corresponding code file to be compared based on the code path information and the request task information includes:
[0172] Request task information is read from the preset message queue through multiple processing nodes;
[0173] The request object corresponding to the code difference query request is determined based on the requested task information;
[0174] When the requested object is a code file difference, the corresponding code file to be compared is obtained based on the code path information.
[0175] Optionally, the step of comparing the code files to be compared through multiple processing nodes to obtain code difference results includes:
[0176] The code files to be compared are classified into code items to obtain a set of code items to be compared.
[0177] The specific differences between each code file in the code project set are calculated by multiple processing nodes, and the specific differences are used as the code difference results.
[0178] Optionally, after the step of determining the request object corresponding to the code difference query request based on the request task information, the method further includes:
[0179] When the requested object is a list of code difference files, the corresponding code file to be compared is obtained based on the code path information.
[0180] Optionally, the step of comparing the code files to be compared through multiple processing nodes to obtain code difference results includes:
[0181] The code files to be compared are compared through multiple processing nodes, and the target code files with differences are determined based on the comparison results.
[0182] A list of corresponding code diff files is generated based on the target code file, and the list of code diff files is used as the code diff result.
[0183] Optionally, the step of reading the request task information carried in the code difference query request when receiving the code difference query request includes:
[0184] Upon receiving a code difference query request, the user identifier contained in the request message of the code difference query request is read;
[0185] Determine whether the user initiating the request has access rights based on the user identifier;
[0186] When the user initiating the request has access rights, the request task information carried in the code difference query request is read.
[0187] Optionally, the step of determining whether the requesting user has access rights based on the user identifier includes:
[0188] Obtain the Internet Protocol address corresponding to the user who initiated the request, and check whether the Internet Protocol address exists in a preset whitelist;
[0189] When the Internet Protocol address exists in the preset whitelist, the target code resource that the requesting user wants to query is determined according to the request message;
[0190] Based on the user identifier and the target code resource, it is determined whether the user initiating the request has access rights.
[0191] Optionally, the step of determining whether the user initiating the request has access rights based on the user identifier and the target code resource includes:
[0192] Obtain the access permission list corresponding to the target code resource;
[0193] The user identifier is matched against the access permission list. If a match is found, it is determined that the user who initiated the request has the access permission.
[0194] If the match fails, it is determined that the user who initiated the request does not have the required access rights.
[0195] Optionally, after the step of determining whether the requesting user has access rights based on the user identifier, the method further includes:
[0196] When the user initiating the request does not have access rights, a pre-set permission activation prompt will be sent to the user initiating the request, so that the user initiating the request can activate the access rights according to the permission activation prompt.
[0197] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0198] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0199] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory / random access memory, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0200] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A code difference query method, characterized in that, The code difference query method includes: Upon receiving a code difference query request, read the request task information carried in the code difference query request; Obtain the code path information contained in the request task information, and find the code file to be compared corresponding to the code path information; The code files to be compared are compared through multiple processing nodes to obtain code difference results; Before the step of reading the request task information carried in the code difference query request upon receiving it, the method further includes: Obtain historical code information submitted by registered users, wherein the historical code information includes at least one of the following: code compilation information and code testing information; Based on the historical code information, predict the code difference query needs of the registered users to obtain the code difference query requests to be executed. Write the request task information corresponding to the code difference query request to be executed into a preset message queue; The tasks in the preset message queue are processed, and the task processing results are saved to the preset database.
2. The code difference query method as described in claim 1, characterized in that, The step of obtaining the code path information contained in the request task information and finding the code file to be compared corresponding to the code path information includes: Obtain the code path information contained in the requested task information; The code path information is compared, and the corresponding code difference result is searched in a preset database based on the comparison result. If the code difference result is not found in the preset database, the code file to be compared corresponding to the code path information is searched.
3. The code difference query method as described in claim 2, characterized in that, After the steps of comparing the code path information and searching a preset database for corresponding code difference results based on the comparison results, the method further includes: When the code difference result exists in the preset database, the code difference result is fed back to the user who initiated the code difference query request.
4. The code difference query method as described in claim 2, characterized in that, The step of searching for the code file to be compared corresponding to the code path information when the code difference result is not found in the preset database includes: If the code difference result is not found in the preset database, the request task information is written to the preset message queue; The request task information is read from the preset message queue through multiple processing nodes, and the corresponding code file to be compared is determined according to the code path information and the request task information.
5. The code difference query method as described in claim 4, characterized in that, Before the step of reading request task information from the preset message queue through multiple processing nodes, the method further includes: Within a preset time period, the code difference results corresponding to the code difference query request are repeatedly checked to see if they have been stored in the preset database. If the code difference results are not stored in the preset database, then the steps of reading request task information from the preset message queue through multiple processing nodes and determining the corresponding code file to be compared based on the code path information and the request task information are executed.
6. The code difference query method as described in claim 1, characterized in that, The step of predicting the code difference query needs of the registered user based on the historical code information and obtaining the code difference query request to be executed includes: Based on the code compilation information and code testing information contained in the historical code information, obtain the historical code files that have undergone code changes; Obtain the file feature information corresponding to the historical code file, and determine the target code file to be compared based on the file feature information; Based on the target code file to be compared, the code difference query needs of the registered user are predicted, and the code difference query request to be executed is obtained.
7. The code difference query method as described in claim 6, characterized in that, The step of obtaining file feature information corresponding to the historical code file and determining the target code file to be compared based on the file feature information includes: Obtain the code path corresponding to the historical code file, and select an associated code file from the historical code file according to the code path; Obtain the key code information corresponding to each associated code file, and determine the target code file to be compared based on the key code information.
8. The code difference query method as described in claim 5, characterized in that, The step of reading request task information from the preset message queue through multiple processing nodes and determining the corresponding code file to be compared based on the code path information and the request task information includes: Request task information is read from the preset message queue through multiple processing nodes; The request object corresponding to the code difference query request is determined based on the requested task information; When the requested object is a code file difference, the corresponding code file to be compared is obtained based on the code path information.
9. The code difference query method as described in claim 1, characterized in that, The step of comparing the code files to be compared through multiple processing nodes to obtain code difference results includes: The code files to be compared are classified into code items to obtain a set of code items to be compared. The specific differences between each code file in the code project set are calculated by multiple processing nodes, and the specific differences are used as the code difference results.
10. The code difference query method as described in claim 8, characterized in that, After the step of determining the request object corresponding to the code difference query request based on the request task information, the method further includes: When the requested object is a list of code difference files, the corresponding code file to be compared is obtained based on the code path information.
11. The code difference query method as described in claim 9, characterized in that, The step of comparing the code files to be compared through multiple processing nodes to obtain code difference results includes: The code files to be compared are compared through multiple processing nodes, and the target code files with differences are determined based on the comparison results. A list of corresponding code diff files is generated based on the target code file, and the list of code diff files is used as the code diff result.
12. The code difference query method according to any one of claims 1 to 5, characterized in that, The step of reading the request task information carried in the code difference query request when a code difference query request is received includes: Upon receiving a code difference query request, the user identifier contained in the request message of the code difference query request is read; Determine whether the user initiating the request has access rights based on the user identifier; When the user initiating the request has access rights, the request task information carried in the code difference query request is read.
13. The code difference query method as described in claim 12, characterized in that, The step of determining whether the requesting user has access rights based on the user identifier includes: Obtain the Internet Protocol address corresponding to the user who initiated the request, and check whether the Internet Protocol address exists in a preset whitelist; When the Internet Protocol address exists in the preset whitelist, the target code resource that the requesting user wants to query is determined according to the request message; Based on the user identifier and the target code resource, it is determined whether the user initiating the request has access rights.
14. The code difference query method as described in claim 13, characterized in that, The step of determining whether the user initiating the request has access rights based on the user identifier and the target code resource includes: Obtain the access permission list corresponding to the target code resource; The user identifier is matched against the access permission list. If a match is found, it is determined that the user who initiated the request has the access permission. If the match fails, it is determined that the user who initiated the request does not have the required access rights.
15. The code difference query method as described in claim 12, characterized in that, After the step of determining whether the requesting user has access rights based on the user identifier, the method further includes: When the user initiating the request does not have access rights, a pre-set permission activation prompt will be sent to the user initiating the request, so that the user initiating the request can activate the access rights according to the permission activation prompt.
16. A code difference query device, characterized in that, The code difference query device includes: The request receiving module is used to read the request task information carried in the code difference query request when it receives the code difference query request; The file search module is used to obtain the code path information contained in the request task information and search for the code file to be compared corresponding to the code path information; The file comparison module is used to compare the code files to be compared through multiple processing nodes to obtain code difference results; The request receiving module is also used to obtain historical code information submitted by registered users, and the historical code information includes at least one of the following: code compilation information and code testing information; Based on the historical code information, predict the code difference query needs of the registered users to obtain the code difference query requests to be executed. Write the request task information corresponding to the code difference query request to be executed into a preset message queue; The tasks in the preset message queue are processed, and the task processing results are saved to the preset database.
17. A code difference query device, characterized in that, The device includes: a memory, a processor, and a code difference query program stored in the memory and executable on the processor, the code difference query program being configured to implement the steps of the code difference query method as described in any one of claims 1 to 15.
18. A storage medium, characterized in that, The storage medium stores a code difference query program, which, when executed by a processor, implements the steps of the code difference query method as described in any one of claims 1 to 15.