Data processing method and device, electronic equipment and storage medium

By generating abstract syntax trees to automatically merge code, the problem of inefficient code migration in the existing technology is solved, and an efficient and accurate code migration process is achieved.

CN119002902APending Publication Date: 2024-11-22SHENZHEN INTELLIFUSION TECHNOLOGIES CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410977876.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

In the prior art, code migration is inefficient, and it is necessary to manually analyze the code structure, dependencies and business logic of source and target projects, resulting in low migration efficiency and prone to human errors.

Method used

By generating an abstract syntax tree, the nodes to be migrated are merged into the target project, automated code merging is realized, human intervention is reduced, and migration efficiency is improved.

Benefits of technology

It greatly improves the efficiency of code data migration, reduces the possibility of human errors, and realizes an automated code merging process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119002902A_ABST
    Figure CN119002902A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data processing method which comprises the steps that first code data of a to-be-migrated node in a first project is acquired, second code data of a second project is acquired, the first project is a project of a first code environment, and the second project is a project of a second code environment; generating an abstract syntax tree of the second code environment based on the first code data and the second code data; and combining the to-be-migrated nodes into the second project based on the abstract syntax tree to obtain a target project. The abstract syntax tree of the second code environment is generated through the first code data of the to-be-migrated node and the second code data of the second project, and then the to-be-migrated node is merged into the second project through the abstract syntax tree to obtain the target project, so that automatic code merging is realized, the migration efficiency of the code data is greatly improved, and the user experience is improved. And the possibility of human errors is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing, and in particular to a data processing method, device, electronic equipment and storage medium. Background Art

[0002] During project development and maintenance, due to platform upgrades or the activation of new platforms, it is often necessary to migrate code data from one project to another project to achieve functional reuse or project integration. In the prior art, code migration usually involves manually analyzing the code structure, dependencies, and business logic of the source and target projects, and then manually copying the code or functional modules to be migrated to the target project, and making necessary modifications and debugging to ensure that the migrated code can run normally in the target project, which is inefficient. Summary of the invention

[0003] The embodiment of the present invention provides a data processing method, which aims to solve the problem of low efficiency of code data migration in the prior art. An abstract syntax tree of a second code environment is generated by first code data of a node to be migrated and second code data of a second project, and then the node to be migrated is merged into the second project through the abstract syntax tree to obtain a target project, thereby realizing automatic code merging, greatly improving the migration efficiency of code data, and reducing the possibility of human error.

[0004] In a first aspect, an embodiment of the present invention provides a data processing method, the method comprising the following steps:

[0005] Acquire first code data of a node to be migrated in a first project, and acquire second code data of a second project, wherein the first project is a project in a first code environment, and the second project is a project in a second code environment;

[0006] Based on the first code data and the second code data, generate an abstract syntax tree of the second code environment;

[0007] Based on the abstract syntax tree, the nodes to be migrated are merged into the second project at the code level to obtain code data of a target project, and the code data of the target project is used to deploy the target project in the second code environment.

[0008] Optionally, obtaining first code data of the node to be migrated in the first project includes:

[0009] Obtain a first dependency graph of the first project and a second dependency graph of the second project, the first dependency graph comprising a first node and a first connection edge, the first node corresponding one-to-one to a first functional module in the first project, the first connection edge corresponding one-to-one to a first calling relationship between two of the first functional modules in the first project, the second dependency graph comprising a second node and a second connection edge, the second node corresponding one-to-one to a second functional module in the second project, the second connection edge corresponding one-to-one to a second calling relationship between two of the second functional modules in the second project;

[0010] Determine the node to be migrated based on the first dependency graph and the second dependency graph, where the node to be migrated is the first node in the first dependency graph that is different from the first node in the second dependency graph;

[0011] In the first code environment, first code data of the node to be migrated is determined.

[0012] Optionally, the obtaining a first dependency graph of the first project and a second dependency graph of the second project includes:

[0013] Obtaining a first code document of the first project;

[0014] Performing natural language processing on the first code document to obtain the first functional module in the first project and a first calling relationship between two of the first functional modules;

[0015] Taking the first functional module as the first node and the first calling relationship between two first functional modules as the first connecting edge, performing graph convolution processing on the first node and the first connecting edge through a first graph convolution model to obtain a first dependency graph;

[0016] And, obtaining a second code document of the second project;

[0017] Performing natural language processing on the second code document to obtain the second function module in the second project and a second calling relationship between two second function modules;

[0018] The second functional module is used as the second node, and the second calling relationship between two second functional modules is used as the second connecting edge. The second node and the second connecting edge are processed by graph convolution through the first graph convolution model to obtain a second dependency graph.

[0019] Optionally, determining the node to be migrated based on the first dependency graph and the second dependency graph includes:

[0020] Determine a distinguishing node of the first dependency graph with respect to the second dependency graph, the distinguishing node being the first node in the first dependency graph;

[0021] Adding the distinguishing node to the second dependency graph to obtain a dependency graph to be processed;

[0022] Performing graph convolution processing on the dependency graph to be processed by a second graph convolution model, adding an attention parameter to the dependency graph to be processed, and obtaining a target dependency graph;

[0023] Perform code compatibility analysis based on the target dependency graph to obtain a code compatibility analysis result of the target dependency graph;

[0024] Based on the code compatibility analysis result, the node to be migrated is determined in the distinguishing nodes.

[0025] Optionally, generating an abstract syntax tree of the second code environment based on the first code data and the second code data includes:

[0026] Performing word embedding processing on the first code data and the second code data respectively to obtain word embedding vectors of the first code data and the second code data;

[0027] Based on the code rules of the second code environment and the word embedding vector, an abstract syntax tree of the second code environment is generated.

[0028] Optionally, after generating the abstract syntax tree of the second code environment based on the first code data and the second code data, the method further includes:

[0029] Perform code conflict detection on the abstract syntax tree through a large model;

[0030] If a code conflict is detected, obtaining conflict data of the code conflict;

[0031] Determining a solution strategy for the code conflict based on the conflict data;

[0032] According to the solution strategy, the abstract syntax tree is optimized to obtain an optimized abstract syntax tree.

[0033] Optionally, after merging the node to be migrated into the second project based on the abstract syntax tree to obtain a target project, the method further includes:

[0034] Generate test cases for the target project;

[0035] When the target project runs the test case, obtaining status data of each step in the code execution process of the target project;

[0036] Based on the status data, the code data of the target project is optimized.

[0037] Optionally, after merging the node to be migrated into the second project based on the abstract syntax tree to obtain a target project, the method further includes:

[0038] In the target business scenario, obtaining third code data of the target item;

[0039] Performing hotspot analysis processing on the third code data to obtain hotspot code segments in the third code data, wherein the hotspot code segments are code segments whose time consumption is greater than a preset time consumption threshold or whose number of calls is greater than a preset number threshold;

[0040] The hotspot code segment is optimized using a preset optimization strategy to obtain the optimized third code data.

[0041] In a second aspect, an embodiment of the present invention further provides a data processing device, the data processing device comprising:

[0042] An acquisition module, used to acquire first code data of a node to be migrated in a first project, and to acquire second code data of a second project, wherein the first project is a project in a first code environment, and the second project is a project in a second code environment;

[0043] A first processing module, configured to generate an abstract syntax tree of the second code environment based on the first code data and the second code data;

[0044] The second processing module is used to merge the node to be migrated into the second project based on the abstract syntax tree to obtain a target project.

[0045] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the data processing method provided in the embodiment of the present invention when executing the computer program.

[0046] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the data processing method provided in the embodiment of the invention are implemented.

[0047] In an embodiment of the present invention, the first code data of the node to be migrated in the first project is obtained, and the second code data of the second project is obtained, the first project is a project of the first code environment, and the second project is a project of the second code environment; based on the first code data and the second code data, an abstract syntax tree of the second code environment is generated; based on the abstract syntax tree, the node to be migrated is merged into the second project to obtain a target project. The abstract syntax tree of the second code environment is generated by the first code data of the node to be migrated and the second code data of the second project, and then the node to be migrated is merged into the second project through the abstract syntax tree to obtain the target project, which realizes automatic code merging, greatly improves the migration efficiency of code data, and reduces the possibility of human errors. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0049] Figure 1 is a flow chart of a data processing method provided by an embodiment of the present invention;

[0050] Figure 2 is a structural schematic diagram of a data processing device provided in an embodiment of the present invention;

[0051] Figure 3 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0053] like Figure 1 As shown, Figure 1 : is a flow chart of a data processing method provided by an embodiment of the present invention, the data processing method comprising the steps of:

[0054] 101. Obtain first code data of a node to be migrated in a first project, and obtain second code data of a second project.

[0055] In an embodiment of the present invention, the above-mentioned data processing method can be applied to a project management platform. The above-mentioned project management platform can be built based on a server or a distributed server. The above-mentioned project management platform is deployed with platform interfaces of different project platforms, code data processing applications, large models or large model calling interfaces and other functional applications that support project migration.

[0056] The above-mentioned project management platform communicates with different project platforms through the platform interface. Different project platforms correspond to different code environments. At least one project is deployed on the above-mentioned project platform. Each project runs through the underlying code to execute the corresponding function. When a user needs to migrate a project on a project platform to another project platform, the code data of the project to be migrated can be obtained from the project platform through the platform interface, and the code data can be processed by the code data processing application to obtain code data adapted to another project platform, and deployed on another project platform. When a user needs to merge a project on a project platform into another project platform, the code data of the project to be migrated can be obtained from the project platform through the platform interface, the code data of the project to be merged can be obtained from another project platform through the platform interface, the code data of the two projects can be processed by the code data processing application to obtain code data adapted to another project platform, and the code can be merged on another project platform to obtain the target project.

[0057] The first project is a project of the first code environment, that is, the first project is deployed on the first project platform, and the second project is a project of the second code environment, that is, the second project is deployed on the second project platform. The first code environment and the second code environment are different code environments, and the differences in code environments may include different code types, different versions, different syntaxes, dependent libraries, etc.

[0058] The node to be migrated may be a node existing in the first project but not in the second project, and may be determined by analyzing the functional modules of the first project and the second project. The node to be migrated may also be specified by the user in the first project.

[0059] After determining the node to be migrated, the project management platform obtains first code data of the node to be migrated in the first project through the platform interface, and obtains second code data of the second project through the platform interface.

[0060] 102. Generate an abstract syntax tree of a second code environment based on the first code data and the second code data.

[0061] In an embodiment of the present invention, after obtaining the first code data of the node to be migrated and the second code data of the second project, the first code data and the second code data can be processed by a large model to generate an abstract syntax tree of the second code environment.

[0062] The above-mentioned abstract syntax tree includes code nodes adapted to the second code environment, that is, the above-mentioned abstract syntax tree includes code nodes corresponding to the second project and code nodes corresponding to the nodes to be migrated, forming a framework of a project as a whole, on which corresponding code data can be automatically generated through a large model.

[0063] 103. Based on the abstract syntax tree, merge the nodes to be migrated into the second project at the code level to obtain code data of the target project.

[0064] In an embodiment of the present invention, after obtaining the abstract syntax tree, new code data corresponding to the nodes to be migrated can be generated based on the abstract syntax tree, and the new code data corresponding to the nodes to be migrated can be merged into the second code data in the second project to obtain the code data of the target project, and the target project can be deployed in the second code environment through the code data of the target project.

[0065] The new code data corresponding to the node to be migrated may also be sent to the second platform, and the second platform merges the new code data corresponding to the node to be migrated into the second code data of the second target to obtain the code data of the target project.

[0066] In an embodiment of the present invention, the first code data of the node to be migrated in the first project is obtained, and the second code data of the second project is obtained, the first project is a project of the first code environment, and the second project is a project of the second code environment; based on the first code data and the second code data, an abstract syntax tree of the second code environment is generated; based on the abstract syntax tree, the node to be migrated is merged into the second project to obtain a target project. The abstract syntax tree of the second code environment is generated by the first code data of the node to be migrated and the second code data of the second project, and then the node to be migrated is merged into the second project through the abstract syntax tree to obtain the target project, which realizes automatic code merging, greatly improves the migration efficiency of code data, and reduces the possibility of human errors.

[0067] It is understandable that in the specific implementation of this application, code data, document data, project data and other related data are involved. When the embodiments in this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data, as well as the training, deployment and calling of large models, must comply with relevant laws, regulations and standards of relevant countries and regions.

[0068] Optionally, in the step of obtaining the first code data of the node to be migrated in the first project, a first dependency graph of the first project and a second dependency graph of the second project can be obtained, the first dependency graph including a first node and a first connection edge, the first node corresponding one-to-one to the first functional module in the first project, the first connection edge corresponding one-to-one to the first calling relationship between the two first functional modules in the first project, the second dependency graph including a second node and a second connection edge, the second node corresponding one-to-one to the second functional module in the second project, the second connection edge corresponding one-to-one to the second calling relationship between the two second functional modules in the second project; based on the first dependency graph and the second dependency graph, determine the node to be migrated, the node to be migrated is the first node in the first dependency graph that is different from the second dependency graph; in the first code environment, determine the first code data of the node to be migrated.

[0069] In an embodiment of the present invention, the first dependency graph and the second dependency graph may be pre-set. For example, when a project is being developed, a dependency graph is generated as the project development progresses. When the project is completed, a dependency graph corresponding to the project is obtained.

[0070] In a possible embodiment, the first dependency graph can be obtained by performing dependency analysis on the code data of the first project, and the second dependency graph can be obtained by performing dependency analysis on the code data of the second project. The analysis can be performed manually or automatically through a large model. It is understandable that the code data of the second project used for dependency analysis can be the second code data.

[0071] After obtaining the first dependency graph and the second dependency graph, the first dependency graph and the second dependency graph may be compared, first nodes different from the second dependency graph may be determined in the first dependency graph, and these first nodes may be determined as nodes to be migrated.

[0072] Optionally, in the step of obtaining a first dependency graph of the first project and a second dependency graph of the second project, a first code document of the first project can be obtained; natural language processing is performed on the first code document to obtain a first functional module in the first project and a first calling relationship between two first functional modules; the first functional module is taken as a first node, and the first calling relationship between the two first functional modules is taken as a first connecting edge, and graph convolution processing is performed on the first node and the first connecting edge through a first graph convolution model to obtain a first dependency graph; and, a second code document of the second project is obtained; natural language processing is performed on the second code document to obtain a second functional module in the second project and a second calling relationship between the two second functional modules; the second functional module is taken as a second node, and the second calling relationship between the two second functional modules is taken as a second connecting edge, and graph convolution processing is performed on the second node and the second connecting edge through the first graph convolution model to obtain a second dependency graph.

[0073] In an embodiment of the present invention, the first code document includes code data and code comments, and the second code document also includes code data and code comments. The first code text and the second code text can be subjected to dependency analysis by a large model to obtain a first dependency graph and a second dependency graph.

[0074] In a possible embodiment, NLP models such as BERT that have been pre-trained and fine-tuned can be used to perform detailed analysis of code comments and code data. When BERT can be used to parse code documents, the attention mechanism inside BERT will play a key role. The attention mechanism dynamically assigns weights to different parts of the code document to highlight important information. When processing a comment statement, BERT will treat each character as an input vector, and then interact and process these vectors through a multi-layer Transformer structure to gradually extract key functional module information, which may include information such as classes and functions. At the same time, the multi-layer Transformer structure will understand the specific meaning of this information based on the context, such as determining the function of a functional module or its relationship with other parts through the surrounding descriptions. Each functional module can be used as a node, and the call relationship between two functional modules can be used as a connecting edge.

[0075] When using the graph convolution model (GCN model) to process the dependency graph, the features of the node can be updated through the convolution operation. For each node, the GCN model collects the features of its neighboring nodes and fuses and updates them through a specific convolution kernel. This process is iterated continuously, so that the features of the node gradually contain its local and global information in the dependency graph. For example, for a module node that is frequently called by other modules, its features will be strengthened after multiple convolutions, reflecting its importance in the entire project. When the GNN model trains and optimizes the dependency graph, the GNN model uses the back propagation algorithm to adjust the weights of nodes and edges. If a dependency is found to be omitted or misestimated in subsequent analysis, the GNN model adjusts the weights of the relevant nodes and edges through back propagation to improve the accuracy of the GNN model for the dependency. At the same time, the GNN model can introduce regularization terms to avoid overfitting and ensure that the GNN model can generalize to new code scenarios. Common regularization methods include L2 regularization, L1 regularization, and Dropout. For example, L2 regularization prevents overfitting by adding the square sum of weight parameters to the loss function, while Dropout prevents excessive dependence between neurons by randomly ignoring some neurons during training, thereby improving the generalization ability of the GNN model. Regularization technology can effectively reduce the error of the GNN model when dealing with different dependencies and improve the intelligence level and adaptability of the migration tool.

[0076] Optionally, in the step of determining the nodes to be migrated based on the first dependency graph and the second dependency graph, the distinguishing node of the first dependency graph for the second dependency graph can be determined, and the distinguishing node is the first node in the first dependency graph; the distinguishing node is added to the second dependency graph to obtain the dependency graph to be processed; the dependency graph to be processed is subjected to graph convolution processing by the second graph convolution model, and attention parameters are added to the dependency graph to be processed to obtain the target dependency graph; code compatibility analysis is performed based on the target dependency graph to obtain the code compatibility analysis results of the target dependency graph; based on the code compatibility analysis results, the nodes to be migrated are determined in the distinguishing nodes.

[0077] In the embodiment of the present invention, the above-mentioned code compatibility mainly includes code type, different versions, different syntax, dependent libraries, etc., and the above-mentioned dependency graph to be processed is a second dependency graph with added distinguishing nodes.

[0078] When the second graph convolution model (second GNN model) is used to perform compatibility analysis on the dependency graph to be processed, the second GNN model can use the graph attention mechanism to highlight the important nodes and connection edges in the dependency graph to be processed. For example, when a node is found to be closely connected with multiple key nodes (when the second GNN model is used to perform compatibility analysis on the dependency graph to be processed, the weight of the connection edge, the degree of the node, the centrality of the node, the clustering coefficient, and the frequent calls or dependencies of the node can be used to determine whether there is a close connection between the nodes. These quantitative standards help the model dynamically adjust the attention weight to ensure that important nodes receive appropriate attention in the compatibility analysis), the model will give a higher attention weight to emphasize its importance in the compatibility analysis, thereby obtaining the target dependency graph.

[0079] After obtaining the target dependency graph, source code data corresponding to each node in the target dependency graph may be obtained. The source code may include first code data for distinguishing the node and second code data for the second item.

[0080] The second GNN model can combine the attribute information of the node, such as the version of the module, the dependent library, etc., to more comprehensively evaluate the compatibility issues. Compatibility analysis can include static analysis and dynamic analysis. In static analysis, BERT is used to process the source code data character by character. BERT regards the code as a series of tokens and converts these tokens into vector representations through the embedding layer. Then, these vectors are processed through a multi-layer Transformer structure to capture the grammatical and semantic information in the code. For example, when processing a function call, BERT can identify information such as the function name and parameters, and understand its role and context in the code. In dynamic analysis, deep learning technology can be used. Taking the RNN model or LSTM model as an example, each code snippet can be processed in sequence according to the execution order of the code. When simulating the running environment, the RNN model or LSTM model predicts the next code state based on the historical code execution state and the current input. For example, when processing a loop structure, the RNN model or LSTM model remembers the previous iteration state and predicts the behavior of the next iteration based on the current loop condition, thereby effectively detecting runtime compatibility issues.

[0081] After obtaining the code compatibility analysis result, compatible nodes and incompatible nodes can be determined in the difference nodes, and the incompatible nodes can be determined as nodes to be migrated, while the compatible nodes can be directly merged into the second project without code conversion operation.

[0082] Optionally, in the step of generating an abstract syntax tree of the second code environment based on the first code data and the second code data, word embedding processing can be performed on the first code data and the second code data respectively to obtain word embedding vectors of the first code data and the second code data; based on the code rules and word embedding vectors of the second code environment, an abstract syntax tree of the second code environment is generated.

[0083] In the embodiment of the present invention, the first code data and the second code data may be processed based on the large model to generate an abstract syntax tree AST of the second code environment.

[0084] When the big model preprocesses the source code (the first code data and the second code data), the big model will use word embedding technology to represent the modules, functions, etc. in the code as vectors, namely word embedding vectors. The word embedding vector not only contains information at the character level, but also incorporates semantic information. For example, for modules with similar functions, their word embedding vectors will be relatively close in space, reflecting the similarity between them. When using the parser to build an abstract syntax tree, the parser will gradually build the structure of the tree according to the code rules of the second code environment. The big model scans the code line by line, identifies various syntax elements, such as variable declarations, statement blocks, etc., and organizes them into nodes and edges of the abstract syntax tree AST.

[0085] The parser can use some heuristic algorithms and rules to handle some complex grammatical situations and ensure the accuracy of AST. Complex grammatical situations include handling nested structures (such as multi-layer loops or conditional statements), resolving grammatical ambiguities (such as polysemy), correcting grammatical errors (such as missing semicolons or mismatched parentheses), parsing complex expressions (such as arithmetic expressions or logical expressions), and handling grammatical features of specific languages ​​(such as Python's indentation). The parser can formulate appropriate strategies based on the context, grammatical rules, and language features, such as recursive descent parsing, priority handling, error recovery mechanisms, and context-aware algorithms to handle these complex situations and ensure that the generated abstract syntax tree AST structure is correct and conforms to the language specification.

[0086] The Transformer model can be used to encode the abstract syntax tree AST, and the Transformer model will perform in-depth analysis of each node and edge in the abstract syntax tree AST. The Transformer model can consider information such as the type, attributes, and relationship of the node with other nodes, and integrate this information into the encoded word embedding vector. For example, for a node that includes a function, the Transformer model will not only encode its name and parameters, but also consider its position in the abstract syntax tree AST and the calling relationship with functions in other nodes.

[0087] When mapping based on the characteristics of the first code data and the target code data (code data of the second code environment), the Transformer model uses the learned knowledge and patterns to perform reasoning. The frequency and importance of certain features in the first code data can be used to determine how to convert in the target code. For example, if there are a large number of function calls of a specific type in the first code data, the Transformer model will adjust the way these function calls are called or replace them with code structures with similar functions according to the needs of the target code.

[0088] When using the decoder of the Transformer model to generate the abstract syntax tree AST of the target code, the decoder will gradually generate the structure of the abstract syntax tree AST based on the encoded information. According to the predictions and decisions of the Transformer model, nodes and edges are generated one by one to construct an abstract syntax tree AST that meets the target requirements. In this process, the Transformer model can use some generation strategies and constraints to ensure that the generated abstract syntax tree AST not only meets the characteristics of the target code, but also maintains the rationality and readability of the code. Finally, when optimizing the abstract syntax tree AST of the target code data, the Transformer model may simplify and adjust some redundant code structures or complex logic. It will improve the abstract syntax tree AST based on some code quality indicators and best practices to improve the performance and maintainability of the final generated target code.

[0089] Optionally, after the step of generating an abstract syntax tree of the second code environment based on the first code data and the second code data, the abstract syntax tree can also be subjected to code conflict detection through a large model; if a code conflict is detected, conflict data of the code conflict is obtained; based on the conflict data, a strategy for resolving the code conflict is determined; and according to the resolution strategy, the abstract syntax tree is optimized to obtain an optimized abstract syntax tree.

[0090] In an embodiment of the present invention, after generating the abstract syntax tree AST, the large model will use its powerful semantic understanding ability to carefully analyze each node in the abstract syntax tree AST. For variables, the large model can be used to trace their definition location, scope, and usage in different code blocks. For functions and classes, the large model can be used to analyze their parameters, return values, and interactions with other parts. A complex semantic network can be constructed through the large model to clearly show the relationship between the various elements in the code.

[0091] When performing pattern matching, the large model can compare the target code data corresponding to the abstract syntax tree AST with the pre-trained regular expression pattern library. It scans the code character by character, looking for fragments that match a specific pattern. For example, when a code segment that matches a specific variable declaration pattern is detected, the model will mark the location and extract relevant information, such as the variable name, type, etc.

[0092] When performing logic analysis, the big model will reason and judge like an experienced programmer. The big model can consider factors such as the execution order of the code and the possible results of conditional judgments to infer whether there may be a conflict. For example, when it is found that two functions use the same variable name but in different contexts, the model will determine that this may be a potential conflict point. When generating a conflict report, the big model will describe the specific circumstances of the conflict in great detail.

[0093] The above large model will not only output the location of the conflict, but also explain the type and cause of the conflict. For complex conflicts, the model may provide a step-by-step analysis process to help developers better understand the problem. For example, for naming conflicts, the model will clearly indicate which variables or functions have the same name and show their specific locations in the code. For providing automated renaming scripts or merging strategies, the large model will generate corresponding code adjustment suggestions based on the specific circumstances of the conflict. If it is a naming conflict, the model may generate a series of reasonable new names and provide corresponding code modification scripts. For more complex conflicts, the large model may propose some possible solutions, such as modifying the function interface or adjusting the code structure, and attach sample code to illustrate how to implement these strategies.

[0094] When developers review conflict reports, the big model can provide real-time assistance. For example, when a developer clicks on a specific conflict item in a conflict report, the big model can immediately display the relevant code snippet and highlight it so that the developer can see the problem more intuitively. When developers choose to adopt a solution, the big model can also provide corresponding verification and prompts to ensure the correctness and feasibility of the solution. The big model can also test the code again after the developer implements the solution to confirm that the conflict has been properly resolved.

[0095] It should be noted that the above-mentioned large model is an existing large model, and the embodiment of the present invention does not limit the specific parameters of the large model.

[0096] Optionally, after merging the nodes to be migrated into the second project at the code level based on the abstract syntax tree to obtain the code data of the target project, a test case for the target project can be generated; when the test case is run in the target project, the status data of each step in the code execution process in the target project is obtained; based on the status data, the code data of the target project is optimized.

[0097] In the embodiment of the present invention, after the node to be migrated is merged into the second project, a test case can be generated, and the large model can analyze the function call relationship, parameter transfer, and logical branching in the code in detail. For example, for a function with multiple conditional judgments, the model will generate corresponding test cases for different conditional combinations. The large model can construct test data covering various boundary conditions and typical values ​​according to the type and possible value range of the variables in the code.

[0098] When running test cases, the big model can use its built-in monitoring mechanism to closely monitor the state changes of each step in the code execution process. For example, the big model can track the entry and exit points of the function, record the value of each variable at different times, and the path of program execution. For codes involving network communication or database operations, the big model will simulate various network conditions and data scenarios for testing.

[0099] The big model can generate quality reports. The big model will use its powerful data analysis capabilities to carefully sort out and classify the collected test results. Through statistical analysis of a large amount of test data, potential patterns and trends can be discovered, thereby more accurately pointing out the problem. For example, if a function is found to frequently have errors under specific inputs, the big model will clearly point out the problem in the report and attach relevant test data and execution traces.

[0100] The big model can provide repair suggestions. Based on its in-depth understanding of the code structure and logic, combined with the existing knowledge of code best practices, the model will give specific and feasible improvement measures. For example, if a performance bottleneck is found in a piece of code, the big model may recommend a more efficient algorithm or data structure to optimize it. Or, if a security vulnerability is found, the big model will recommend a specific encryption or verification mechanism to solve the problem. Specific code snippet examples can also be provided to help developers better understand and implement repair solutions.

[0101] In one possible implementation, when the big model learns the logic and structure of the code, it can use its deep neural network to scan and parse the code line by line. For a function, the big model will identify the parameter type of the function, the possible value range, and the logical flow inside the function. For example, for a function with multiple conditional judgments, the model will carefully analyze the boundary conditions and possible combinations of each condition.

[0102] When generating unit test cases, the big model will intelligently construct input data based on the information it has learned. The big model may randomly generate some common test values, and also specifically design boundary values ​​and special cases that are prone to cause problems. For example, for a function that processes integers, the big model will not only generate some regular integers, but also deliberately generate the minimum integer, the maximum integer, and some values ​​that may cause overflow.

[0103] When combined with coverage analysis tools, the big model interacts closely with these tools. It receives coverage information from the tools to understand which parts of the code have been covered by tests and which have not. The big model then decides how to supplement the test cases based on this information. While automatically running the test cases, the model monitors the execution status of the code in real time.

[0104] Large models can obtain key data by inserting some monitoring points in the code, such as the changes in variable values ​​at different stages, the order in which functions are called, etc. If an abnormal situation is found during operation, such as an unexpected error or an unexpected result, the model will record it immediately.

[0105] When necessary test cases need to be supplemented, the big model will be designed specifically based on the previous analysis and monitoring results. The big model can generate test cases specifically for the uncovered code parts according to their characteristics to ensure that the previously missed functional points can be fully tested.

[0106] The large model can also dynamically adjust and supplement test cases based on code updates and changes to maintain continuous and effective testing of the code.

[0107] Optionally, after the step of merging the nodes to be migrated into the second project based on the abstract syntax tree to obtain the target project, the third code data of the target project can also be obtained in the target business scenario; hotspot analysis is performed on the third code data to obtain hotspot code segments in the third code data, where the hotspot code segments are code segments that take longer than a preset time threshold or are called more than a preset number of times threshold; the hotspot code segments are optimized using a preset optimization strategy to obtain optimized third code data.

[0108] In the embodiment of the present invention, the hot code segments can be identified and optimized by using a large model through frequency and performance analysis.

[0109] When using performance analysis tools for statistics, the big model can be deeply involved in the process of processing and understanding the data. The big model can carefully interpret the detailed information generated by the tool, such as the specific number of executions of each code segment, the time distribution, etc. For code segments that take a long time or are frequently called, the model will use its powerful pattern recognition ability to quickly locate the key hot spots.

[0110] When analyzing hot code segments, the big model uses its deep understanding of code logic and algorithms. The big model can match and compare hot code segments with known efficient algorithms and data structure patterns to find potential optimization points. For example, the model may find that the currently used data structure has performance bottlenecks in some cases, and then recommend changing it to a structure that is more suitable for the scenario, such as switching from a linked list to a hash table.

[0111] When generating detailed optimization suggestions, the big model will take into account a variety of factors. The big model can not only consider improvements in algorithms and data structures, but also give suggestions from aspects such as code parallelism and cache utilization. For example, for parts that can be executed in parallel, the model may recommend using multi-threading or multi-process to improve efficiency; for situations where there may be a large number of cache misses, the model will recommend reorganizing the data layout to improve the cache hit rate.

[0112] When automatically applying optimization suggestions, the big model will make code modifications in an intelligent way. It may first back up the original code, and then gradually modify and adjust it according to the suggestions.

[0113] During the modification process, the big model will monitor the syntactic correctness and logical consistency of the code in real time to ensure that no new problems are introduced.

[0114] For some complex optimizations, such as algorithm replacement, large models may be tested and verified step by step to ensure that the new algorithm can work properly in various scenarios and the performance is significantly improved.

[0115] In the process of continuously monitoring and optimizing hot code, the big model will continue to pay attention to how the code runs on the target platform.

[0116] The big model will re-run the performance analysis tool regularly to check whether the previous optimization has achieved the expected results and whether there are new hot spots in the code. If problems are found, the big model will adjust the optimization strategy in time, generate new optimization suggestions again and implement them, forming a continuous optimization cycle to ensure that the code always runs efficiently and continuously improve the performance of the entire system.

[0117] like Figure 2 As shown, an embodiment of the present invention provides a data processing device, the data processing device comprising:

[0118] A first acquisition module 201 is used to acquire first code data of a node to be migrated in a first project, and to acquire second code data of a second project, wherein the first project is a project in a first code environment, and the second project is a project in a second code environment;

[0119] A first processing module 202, configured to generate an abstract syntax tree of the second code environment based on the first code data and the second code data;

[0120] The second processing module 203 is used to merge the nodes to be migrated into the second project at the code level based on the abstract syntax tree to obtain code data of the target project, and the code data of the target project is used to deploy the target project in the second code environment.

[0121] Optionally, the first acquisition module 201 is also used to obtain a first dependency graph of the first project and a second dependency graph of the second project, the first dependency graph including a first node and a first connection edge, the first node corresponding one-to-one to a first functional module in the first project, the first connection edge corresponding one-to-one to a first calling relationship between two of the first functional modules in the first project, the second dependency graph including a second node and a second connection edge, the second node corresponding one-to-one to a second functional module in the second project, the second connection edge corresponding one-to-one to a second calling relationship between two of the second functional modules in the second project; based on the first dependency graph and the second dependency graph, determining the node to be migrated, the node to be migrated being the first node in the first dependency graph that is different from the second dependency graph; in the first code environment, determining the first code data of the node to be migrated.

[0122] Optionally, the first acquisition module 201 is also used to acquire the first code document of the first project; perform natural language processing on the first code document to obtain the first function module in the first project and the first calling relationship between the two first function modules; use the first function module as the first node, and the first calling relationship between the two first function modules as the first connecting edge, perform graph convolution processing on the first node and the first connecting edge through a first graph convolution model, and obtain a first dependency graph; and, acquire the second code document of the second project; perform natural language processing on the second code document to obtain the second function module in the second project and the second calling relationship between the two second function modules; use the second function module as the second node, and the second calling relationship between the two second function modules as the second connecting edge, perform graph convolution processing on the second node and the second connecting edge through a first graph convolution model, and obtain a second dependency graph.

[0123] Optionally, the first acquisition module 201 is also used to determine the distinguishing node of the first dependency graph for the second dependency graph, and the distinguishing node is the first node in the first dependency graph; add the distinguishing node to the second dependency graph to obtain a dependency graph to be processed; perform graph convolution processing on the dependency graph to be processed through a second graph convolution model, add attention parameters to the dependency graph to be processed, and obtain a target dependency graph; perform code compatibility analysis processing based on the target dependency graph to obtain a code compatibility analysis result of the target dependency graph; based on the code compatibility analysis result, determine the node to be migrated in the distinguishing node.

[0124] Optionally, the second processing module 203 is also used to perform word embedding processing on the first code data and the second code data respectively to obtain word embedding vectors of the first code data and the second code data; based on the code rules of the second code environment and the word embedding vectors, generate an abstract syntax tree of the second code environment.

[0125] Optionally, the device further comprises:

[0126] A detection module, used for performing code conflict detection on the abstract syntax tree through a large model;

[0127] A second acquisition module, configured to acquire conflict data of the code conflict if a code conflict is detected;

[0128] A third processing module, configured to determine a solution strategy for the code conflict based on the conflict data;

[0129] The fourth processing module is used to optimize the abstract syntax tree according to the solution strategy to obtain an optimized abstract syntax tree.

[0130] Optionally, the device further comprises:

[0131] A generation module, used to generate test cases for the target project;

[0132] A third acquisition module is used to acquire the status data of each step in the code execution process of the target project when the target project runs the test case;

[0133] The fifth processing module is used to optimize the code data of the target project based on the status data.

[0134] Optionally, the device further comprises:

[0135] A fourth acquisition module, used to acquire the third code data of the target project in the target business scenario;

[0136] A sixth processing module, configured to perform hot spot analysis on the third code data to obtain a hot spot code segment in the third code data, wherein the hot spot code segment is a code segment that takes a time greater than a preset time threshold or is called more than a preset number of times threshold;

[0137] The seventh processing module is used to optimize the hot code segment through a preset optimization strategy to obtain the optimized third code data.

[0138] like Figure 3 As shown, an embodiment of the present invention further provides an electronic device, including a processor, and the processor can execute any one of the above data processing methods.

[0139] Specifically, it includes a processor 301 and a memory 302, and a computer program for executing the data processing method which is stored in the memory 302 and can be run on the processor 301, wherein:

[0140] The processor 301 runs the computer program of the data processing method stored in the memory 302 to perform the following steps:

[0141] Acquire first code data of a node to be migrated in a first project, and acquire second code data of a second project, wherein the first project is a project in a first code environment, and the second project is a project in a second code environment;

[0142] Based on the first code data and the second code data, generate an abstract syntax tree of the second code environment;

[0143] Based on the abstract syntax tree, the nodes to be migrated are merged into the second project at the code level to obtain code data of a target project, and the code data of the target project is used to deploy the target project in the second code environment.

[0144] Optionally, the obtaining of first code data of the node to be migrated in the first project performed by the processor 301 includes:

[0145] Obtain a first dependency graph of the first project and a second dependency graph of the second project, the first dependency graph comprising a first node and a first connection edge, the first node corresponding one-to-one to a first functional module in the first project, the first connection edge corresponding one-to-one to a first calling relationship between two of the first functional modules in the first project, the second dependency graph comprising a second node and a second connection edge, the second node corresponding one-to-one to a second functional module in the second project, the second connection edge corresponding one-to-one to a second calling relationship between two of the second functional modules in the second project;

[0146] Determine the node to be migrated based on the first dependency graph and the second dependency graph, where the node to be migrated is at least one of the first nodes in the first dependency graph that is different from the second dependency graph;

[0147] In the first code environment, first code data of the node to be migrated is determined.

[0148] Optionally, the obtaining of the first dependency graph of the first project and the second dependency graph of the second project performed by the processor 301 includes:

[0149] Obtaining a first code document of the first project;

[0150] Performing natural language processing on the first code document to obtain the first functional module in the first project and a first calling relationship between two of the first functional modules;

[0151] Taking the first functional module as the first node and the first calling relationship between two first functional modules as the first connecting edge, performing graph convolution processing on the first node and the first connecting edge through a first graph convolution model to obtain a first dependency graph;

[0152] And, obtaining a second code document of the second project;

[0153] Performing natural language processing on the second code document to obtain the second function module in the second project and a second calling relationship between two second function modules;

[0154] The second functional module is used as the second node, and the second calling relationship between two second functional modules is used as the second connecting edge. The second node and the second connecting edge are processed by graph convolution through the first graph convolution model to obtain a second dependency graph.

[0155] Optionally, the determining the node to be migrated based on the first dependency graph and the second dependency graph performed by the processor 301 includes:

[0156] Determine a distinguishing node of the first dependency graph with respect to the second dependency graph, the distinguishing node being the first node in the first dependency graph;

[0157] Adding the distinguishing node to the second dependency graph to obtain a dependency graph to be processed;

[0158] Performing graph convolution processing on the dependency graph to be processed by a second graph convolution model, adding an attention parameter to the dependency graph to be processed, and obtaining a target dependency graph;

[0159] Perform code compatibility analysis based on the target dependency graph to obtain a code compatibility analysis result of the target dependency graph;

[0160] Based on the code compatibility analysis result, the node to be migrated is determined in the distinguishing nodes.

[0161] Optionally, the processor 301 generates an abstract syntax tree of the second code environment based on the first code data and the second code data, including:

[0162] Performing word embedding processing on the first code data and the second code data respectively to obtain word embedding vectors of the first code data and the second code data;

[0163] Based on the code rules of the second code environment and the word embedding vector, an abstract syntax tree of the second code environment is generated.

[0164] Optionally, after generating the abstract syntax tree of the second code environment based on the first code data and the second code data, the method executed by the processor 301 further includes:

[0165] Perform code conflict detection on the abstract syntax tree through a large model;

[0166] If a code conflict is detected, obtaining conflict data of the code conflict;

[0167] Determining a solution strategy for the code conflict based on the conflict data;

[0168] According to the solution strategy, the abstract syntax tree is optimized to obtain an optimized abstract syntax tree.

[0169] Optionally, after merging the node to be migrated into the second project at the code level based on the abstract syntax tree to obtain code data of the target project, the method executed by the processor 301 further includes:

[0170] Generate test cases for the target project;

[0171] When the target project runs the test case, obtaining status data of each step in the code execution process of the target project;

[0172] Based on the status data, the code data of the target project is optimized.

[0173] Optionally, after merging the node to be migrated into the second project at the code level based on the abstract syntax tree to obtain code data of the target project, the method executed by the processor 301 further includes:

[0174] In the target business scenario, obtaining third code data of the target item;

[0175] Performing hotspot analysis processing on the third code data to obtain hotspot code segments in the third code data, wherein the hotspot code segments are code segments whose time consumption is greater than a preset time consumption threshold or whose number of calls is greater than a preset number threshold;

[0176] The hotspot code segment is optimized using a preset optimization strategy to obtain the optimized third code data.

[0177] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the computer program implements the various processes of the data processing method or the application-side data processing method provided by the embodiment of the present invention, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0178] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0179] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.

Claims

1. A data processing method, characterized in that: The method comprises the following steps: Acquire first code data of a node to be migrated in a first project, and acquire second code data of a second project, wherein the first project is a project in a first code environment, and the second project is a project in a second code environment; Based on the first code data and the second code data, generate an abstract syntax tree of the second code environment; Based on the abstract syntax tree, the nodes to be migrated are merged into the second project at the code level to obtain code data of a target project, and the code data of the target project is used to deploy the target project in the second code environment.

2. The data processing method according to claim 1, characterized in that: The obtaining of first code data of the node to be migrated in the first project includes: Obtain a first dependency graph of the first project and a second dependency graph of the second project, the first dependency graph comprising a first node and a first connection edge, the first node corresponding one-to-one to a first functional module in the first project, the first connection edge corresponding one-to-one to a first calling relationship between two of the first functional modules in the first project, the second dependency graph comprising a second node and a second connection edge, the second node corresponding one-to-one to a second functional module in the second project, the second connection edge corresponding one-to-one to a second calling relationship between two of the second functional modules in the second project; Determine the node to be migrated based on the first dependency graph and the second dependency graph, where the node to be migrated is the first node in the first dependency graph that is different from the first node in the second dependency graph; In the first code environment, first code data of the node to be migrated is determined.

3. The data processing method according to claim 2, characterized in that: The obtaining of a first dependency graph of the first project and a second dependency graph of the second project includes: Obtaining a first code document of the first project; Performing natural language processing on the first code document to obtain the first functional module in the first project and a first calling relationship between two of the first functional modules; Taking the first functional module as the first node and the first calling relationship between two first functional modules as the first connecting edge, performing graph convolution processing on the first node and the first connecting edge through a first graph convolution model to obtain a first dependency graph; And, obtaining a second code document of the second project; Performing natural language processing on the second code document to obtain the second function module in the second project and a second calling relationship between two second function modules; The second functional module is used as the second node, and the second calling relationship between two second functional modules is used as the second connecting edge. The second node and the second connecting edge are processed by graph convolution through the first graph convolution model to obtain a second dependency graph.

4. The data processing method according to claim 2, characterized in that: The determining the node to be migrated based on the first dependency graph and the second dependency graph includes: Determine a distinguishing node of the first dependency graph with respect to the second dependency graph, the distinguishing node being the first node in the first dependency graph; Adding the distinguishing node to the second dependency graph to obtain a dependency graph to be processed; Performing graph convolution processing on the dependency graph to be processed by a second graph convolution model, adding an attention parameter to the dependency graph to be processed, and obtaining a target dependency graph; Perform code compatibility analysis based on the target dependency graph to obtain a code compatibility analysis result of the target dependency graph; Based on the code compatibility analysis result, the node to be migrated is determined in the distinguishing nodes.

5. The data processing method according to any one of claims 1 to 4, characterized in that: The step of generating an abstract syntax tree of the second code environment based on the first code data and the second code data includes: Performing word embedding processing on the first code data and the second code data respectively to obtain word embedding vectors of the first code data and the second code data; Based on the code rules of the second code environment and the word embedding vector, an abstract syntax tree of the second code environment is generated.

6. The data processing method according to any one of claims 1 to 5, characterized in that: After generating an abstract syntax tree of the second code environment based on the first code data and the second code data, the method further includes: Perform code conflict detection on the abstract syntax tree through a large model; If a code conflict is detected, obtaining conflict data of the code conflict; Determining a solution strategy for the code conflict based on the conflict data; According to the solution strategy, the abstract syntax tree is optimized to obtain an optimized abstract syntax tree.

7. The data processing method according to any one of claims 1 to 6, characterized in that: After merging the node to be migrated into the second project at the code level based on the abstract syntax tree to obtain code data of the target project, the method further includes: Generate test cases for the target project; When the target project runs the test case, obtaining status data of each step in the code execution process of the target project; Based on the status data, the code data of the target project is optimized.

8. The data processing method according to any one of claims 1 to 7, characterized in that: After merging the node to be migrated into the second project at the code level based on the abstract syntax tree to obtain code data of the target project, the method further includes: In the target business scenario, obtaining third code data of the target item; Performing hotspot analysis processing on the third code data to obtain hotspot code segments in the third code data, wherein the hotspot code segments are code segments whose time consumption is greater than a preset time consumption threshold or whose number of calls is greater than a preset number threshold; The hotspot code segment is optimized using a preset optimization strategy to obtain the optimized third code data.

9. A data processing device, characterized in that: The data processing device comprises: A first acquisition module is used to acquire first code data of a node to be migrated in a first project, and acquire second code data of a second project, wherein the first project is a project in a first code environment, and the second project is a project in a second code environment; A first processing module, configured to generate an abstract syntax tree of the second code environment based on the first code data and the second code data; The second processing module is used to merge the nodes to be migrated into the second project at the code level based on the abstract syntax tree to obtain code data of the target project, and the code data of the target project is used to deploy the target project in the second code environment.

10. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the data processing method according to any one of claims 1 to 8 when executing the computer program.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the data processing method according to any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Architecture code migration method and device, electronic equipment and storage medium

    CN121858159A