CN112181489B - Code migration method, device, computer equipment and storage medium - Google Patents

Code migration method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN112181489B
CN112181489B CN202011041497.3A CN202011041497A CN112181489B CN 112181489 B CN112181489 B CN 112181489B CN 202011041497 A CN202011041497 A CN 202011041497A CN 112181489 B CN112181489 B CN 112181489B
Authority
CN
China
Prior art keywords
frame
matched
target
character
converted
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011041497.3A
Other languages
Chinese (zh)
Other versions
CN112181489A (en
Inventor
李广翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN202011041497.3A priority Critical patent/CN112181489B/en
Publication of CN112181489A publication Critical patent/CN112181489A/en
Application granted granted Critical
Publication of CN112181489B publication Critical patent/CN112181489B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/76Adapting program code to run in a different environment; Porting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The present invention relates to the field of data processing technologies, and in particular, to a code migration method, apparatus, device, and storage medium. The code migration method comprises the steps of obtaining source files and target conversion frame information; determining frame information to be converted corresponding to the source file according to the character string to be matched; acquiring a configuration file corresponding to the frame type; determining a target mapping relation from the mapping relations according to the frame information to be converted and the target conversion frame information; matching the character strings to be matched in a matching mode corresponding to the character types to obtain character strings to be converted, wherein the character strings to be converted are matched with the character strings of the source frame; and converting the character string to be converted into the target frame character string according to the target mapping relation to obtain a target file of the source file under the target conversion frame. The method can effectively solve the problems of low efficiency and low universality of the current code migration.

Description

Code migration method, device, computer equipment and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a code migration method, a code migration device, a computer device, and a storage medium.
Background
With the continuous development of internet technology, the scale of the system is also continuously increased, the system is also continuously changed to a modularized direction, and many framework technologies are introduced into the system as 'functional blocks'.
However, the development of the system is continuously changed to low coupling, so that the system is easy to generate a 'technical gap'. When a certain function module of the system is switched and upgraded or the service function of the system is migrated, the code logic is required to be migrated, and the code logic under the prior art frame cannot adapt to the rule of the new technical frame due to the difference of different technical frames, so that the prior code logic is required to be converted to adapt to the new technical frame. At present, the conversion of the code logic is generally carried out by manually analyzing and judging the difference between the technical frames, then the switching of the code logic is carried out manually, the efficiency is low, and the scheme under the new technical frame is easy to generate artificial errors to cause certain defects, so that a great deal of labor cost is consumed for repairing work in the follow-up process.
Disclosure of Invention
The embodiment of the invention provides a code migration method, a code migration device, computer equipment and a storage medium, which are used for solving the problems of low efficiency and low universality of the existing code migration.
A method of code migration, comprising:
acquiring source file and target conversion frame information; wherein the target conversion frame information corresponds to a frame type; the source file comprises a plurality of character strings to be matched;
determining frame information to be converted corresponding to the source file according to the character string to be matched;
acquiring a configuration file corresponding to the frame type; the configuration file is used for describing the mapping relation between the plurality of source frame information and the target frame information;
determining a target mapping relation from the mapping relations according to the frame information to be converted and the target conversion frame information; the target mapping relationship is used for indicating a mapping relationship between source frame information matched with the frame information to be converted and target frame information matched with the target conversion frame information; the source frame information comprises a source frame character string; the target frame information comprises a target frame character string;
matching the character strings to be matched in a matching mode corresponding to the character types to obtain character strings to be converted, wherein the character strings to be converted are matched with the character strings of the source frame;
and converting the character string to be converted into the target frame character string according to the target mapping relation to obtain a target file of the source file under the target conversion frame.
A code migration apparatus comprising:
the source file acquisition module is used for acquiring source files and target conversion frame information; wherein the target conversion frame information corresponds to a frame type; the source file comprises a plurality of character strings to be matched;
the frame information to be converted determining module is used for determining frame information to be converted corresponding to the source file according to the character strings to be matched;
the configuration file acquisition module is used for acquiring the configuration file corresponding to the frame type; the configuration file is used for describing the mapping relation between the plurality of source frame information and the target frame information;
the target mapping relation determining module is used for determining a target mapping relation from the plurality of mapping relations according to the frame information to be converted and the target conversion frame information; the target mapping relationship is used for indicating a mapping relationship between source frame information matched with the frame information to be converted and target frame information matched with the target conversion frame information; the source frame information comprises a source frame character string; the target frame information comprises a target frame character string;
the character matching module is used for matching the character strings to be matched by adopting a matching mode corresponding to the character types to obtain character strings to be converted, which are matched with the character strings of the source frame;
And the frame conversion module is used for converting the character string to be converted into the target frame character string according to the target mapping relation to obtain a target file of the source file under the target conversion frame.
A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the code migration method described above when the computer program is executed.
A computer storage medium storing a computer program which, when executed by a processor, implements the steps of the code migration method described above.
According to the code migration method, the code migration device, the computer equipment and the storage medium, the source file and the target conversion frame information are acquired, so that the frame information to be converted corresponding to the source file is determined according to the character strings to be matched in the source file, manual selection by a user is not needed, the requirement on the mastering degree of the source file is low, and the universality is higher. And then, acquiring a configuration file corresponding to the frame type, wherein the configuration file stores mapping relations among a plurality of technical frames of different frame versions of different frame types so as to realize comprehensive system code maintenance of various frame technologies and frame versions. And then, determining a target mapping relation from a plurality of mapping relations according to the frame information to be converted and the target frame information, so as to match the character strings to be matched in a matching mode corresponding to the character types, obtain the character strings to be converted matched with the character strings of the source frame, and match the character strings to be converted in different matching modes aiming at different character types, thereby having high universality. And finally, converting the character string to be converted into a target frame character string according to the target mapping relation to obtain a target file of the source file under the target conversion frame, so as to realize automatic conversion of code migration, improve the system code migration efficiency, reduce human errors in the migration process, facilitate unified management and reduce the cost of a later maintenance system.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the description of the embodiments of the present invention will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of an application environment of a code migration method according to an embodiment of the present invention;
FIG. 2 is a flow chart of a code migration method according to an embodiment of the present invention;
FIG. 3 is a flowchart showing step S202 in FIG. 2;
FIG. 4 is a flowchart showing step S204 in FIG. 2;
FIG. 5 is a flowchart showing step S205 in FIG. 2;
FIG. 6 is a flowchart showing step S501 in FIG. 5;
FIG. 7 is a diagram of an exemplary dictionary tree in one embodiment of the present invention;
FIG. 8 is a flow chart of a code migration method in an embodiment of the present invention;
FIG. 9 is a diagram of a code migration apparatus according to an embodiment of the present invention;
FIG. 10 is a schematic diagram of a computer device in accordance with an embodiment of the invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The code migration method is applicable in an application environment such as that of fig. 1, in which a computer device communicates with a server through a network. The computer devices may be, but are not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices. The server may be implemented as a stand-alone server.
In one embodiment, as shown in fig. 2, a code migration method is provided, and the method is applied to the server in fig. 1, and the method includes the following steps:
s201: acquiring source file and target conversion frame information; the target conversion frame information corresponds to a frame type; the source file includes a plurality of character strings to be matched.
Specifically, the method can be applied to a system code migration tool, and is used for converting a source file from a current technical framework to a migration tool of the same or different technical frameworks of a required framework version, the difference between the technical framework required to be migrated and the technical framework to be converted is not required to be analyzed offline by a developer, and code migration is performed manually according to the difference, so that the code migration efficiency can be effectively improved, and the labor cost can be reduced.
Among the frame types include, but are not limited to, database frames (e.g., SQLserver, mySQL, oracle), front-end technology frames (e.g., VUE, JS), and back-end technology frames (e.g., C, java, python). Wherein the target conversion frame information includes a target conversion frame and a conversion frame version. The target conversion framework is a new technical framework which is designated by a user and needs to be migrated. The conversion frame version is the frame version of the target conversion frame. The character string to be matched corresponds to a plurality of words in the source file.
Specifically, the user can select a target conversion frame and a corresponding conversion frame version to be converted according to actual needs in a display interface of the system code migration tool, and upload a source file to be converted at the same time, so that the server obtains the source file and conversion frame information.
S202: and determining the frame information to be converted corresponding to the source file according to the character string to be matched.
The frame information to be converted comprises frames to be converted and corresponding frame versions to be converted. The frame to be converted is the technical frame corresponding to the source file. The frame version to be converted is the frame version corresponding to the frame to be converted.
Specifically, the source file is scanned to match keywords with a predefined version specific character string, and if the keywords are matched, a technical framework and a framework version corresponding to the version specific character string are used as the framework information to be converted corresponding to the source file. The version specific character string is a specific keyword which is newly added or changed in different versions by different predefined technical frameworks. In this embodiment, by automatically detecting the frame information to be converted corresponding to the source file, the user does not need to manually select, and the requirement on the mastering degree of the source file is low and the universality is higher.
S203: acquiring a configuration file corresponding to the frame type; the configuration file is used for describing mapping relations between the plurality of source frame information and the target frame information.
The configuration file is a pre-created description file for storing active frame information and target frame information, and is used for describing the mapping relationship between source frame character strings corresponding to a plurality of source frames under a source frame version and target frame character strings corresponding to a target conversion frame under a conversion frame version. The source framework is the technical framework to be migrated. The target framework is a new technical framework requiring migration. The source frame information includes a source frame, a source frame version, and a source frame string. The source framework string is used for indicating keywords to be converted of the source framework under a certain source framework version. The target frame information includes a target frame, a target frame version, and a target frame string. The target frame string is used to indicate the target keywords that the target frame needs under the target frame version.
In this embodiment, the character strings in the source file are automatically converted by calling the configuration file, so that the main logic of the code is not affected, and the coupling between the service logic and the frame technology can be effectively reduced.
Illustratively, the configuration file may be a database framework type configuration file as shown in the following table:
s204: determining a target mapping relation from a plurality of mapping relations according to the frame information to be converted and the target conversion frame information; the target mapping relationship is used for indicating the mapping relationship between the source frame information matched with the frame information to be converted and the target frame information matched with the target conversion frame information; the source frame information includes a source frame string; the target frame information includes a target frame string.
Specifically, since a plurality of mapping relationships are stored in the configuration file, it is necessary to determine a target mapping relationship from the plurality of mapping relationships according to the frame information to be converted and the target conversion frame information selected by the user. For example, if the source frame corresponding to the source file is an ibatis frame, the source frame version is 1.10.3, the target conversion frame is mybatis, and the frame version is 4.11.5, the source frame in the source frame information stored in the configuration file is ibatis, and the frame version is 1.10.3; the target frame information is mybatis frame, and the mapping relation of the conversion frame version 4.11.5 is used as a target mapping relation.
S205: and matching the character strings to be matched in a matching mode corresponding to the character types to obtain character strings to be converted, which are matched with the character strings of the source frame.
Wherein the character types include, but are not limited to, keyword types and method types. Specifically, the matching modes corresponding to different character types are different, so that the character strings to be matched are matched in a targeted manner, and the applicability is higher. It can be understood that, since the character type includes a keyword type or a method type, when matching is performed by using the same keyword matching algorithm, only a code including the keyword "try" and the method is matched for the keyword of the method type, for example try.
S206: and converting the character string to be converted into a target frame character string according to the target mapping relation to obtain a target file of the source file under the target conversion frame.
Specifically, according to the description of the target mapping relationship, a plurality of groups of corresponding relationships between the source frame strings and the target frame strings, for example (< sql map >, < configuration >), (< sql map >, < mapper >) can be obtained, and according to the corresponding relationships, the to-be-converted strings matched with the source frame strings in the source file are converted into corresponding target frame strings, so as to obtain the target file of the source file under the target conversion frame.
In this embodiment, the source file and the target conversion frame information are obtained so as to determine the frame information to be converted corresponding to the source file according to the character strings to be matched in the source file, so that manual selection of a user is not required, the requirement on the mastering degree of the source file is low, and the universality is higher. And then, acquiring a configuration file corresponding to the frame type, wherein the configuration file stores mapping relations among a plurality of technical frames of different frame versions of different frame types so as to realize comprehensive system code maintenance of various frame technologies and frame versions. And then, determining a target mapping relation from a plurality of mapping relations according to the frame information to be converted and the target frame information, so as to match the character strings to be matched in a matching mode corresponding to the character types, obtain the character strings to be converted matched with the character strings of the source frame, and match the character strings to be converted in different matching modes aiming at different character types, thereby having high universality. And finally, converting the character string to be converted into a target frame character string according to the target mapping relation to obtain a target file of the source file under the target conversion frame, so as to realize automatic conversion of code migration, improve the system code migration efficiency, reduce human errors in the migration process, facilitate unified management and reduce the cost of a later maintenance system.
In an embodiment, as shown in fig. 3, in step 202, to-be-converted frame information corresponding to a source file is determined according to a to-be-matched character string, which specifically includes the following steps:
s301: keyword matching is carried out on the character strings to be matched according to the version specific character strings; the version specific character string is a specific keyword corresponding to a predefined technical framework under different versions.
Keyword matching includes, but is not limited to, using KMP algorithm, multimode string matching algorithm (Aho-coralick). Specifically, taking the multi-mode matching algorithm as an example, a plurality of character strings to be matched can be input into the multi-mode character string matching algorithm in full or batch mode for processing to determine whether the character strings to be matched with the version specific character strings exist in the source file.
It should be understood that the dictionary tree required in the multimodal string matching algorithm is constructed by a plurality of version specific strings predefined in this embodiment, and then string matching is performed according to the concepts of the success table and the failure table in the multimodal matching algorithm, so that it can be determined that keywords matched with the version specific strings exist in the source file.
S302: and if the source file has the character string to be matched with the version specific character string, taking the frame version and the technical frame corresponding to the version specific character string as frame information to be converted corresponding to the source file.
Specifically, if a keyword matched with the version specific character string exists in the source file, the frame version and the technical frame corresponding to the version specific character string are used as frame information to be converted corresponding to the source file, and if no character string matched with the version specific character string exists in the source file, prompt information can be generated to prompt a user to select the frame version of the source frame.
It can be understood that if the source file does not have a character string to be matched with the version specific character string, and possibly, the mapping relationship corresponding to the source frame does not exist in the configuration file, a prompt message may be generated to prompt the user to add the mapping relationship to the configuration file.
For example, if the keyword of the sqlMap tag in the v1 version of the ibatis framework is < sql-map >, and the keyword of the sqlMap tag in the v2 version is < sqlMap >, the < sql-map > may be used as a version specific character string of the ibatis framework in the v1 version, and if the keyword (i.e., < sql-map >) matched with the version specific character string exists in the source file, the framework version and the technical framework corresponding to the version specific character string may be used as the frame information to be converted corresponding to the source file, i.e., the source frame of the source file is the ibatis framework, and the source frame version is the v1 version.
In one embodiment, as shown in fig. 4, in step S204, a target mapping relationship is determined from a plurality of mapping relationships according to the frame information to be converted and the target conversion frame information, and the method specifically includes the following steps:
s401: and matching a plurality of mapping relations according to the frame information to be converted, and determining candidate mapping relations corresponding to the frame information to be converted.
Specifically, the mapping relationships in the configuration file are matched through the source frame and the frame version in the frame information to be converted, namely, the mapping relationship matched with the frame information to be converted is contained in the mapping relationships as a candidate mapping relationship. For example, if the configuration file includes mappings of SQLserver (source framework) -source framework version 2005-Oracle (target framework) -target framework version 10.2.0.1, SQLserver (source framework) -source framework version 2005-MySQL (target framework) -target framework version 5.6.23, and SQLserver (source framework) -framework version 2008-Oracle (target framework) -target framework version 10.2.0.1, if the source framework in the frame information to be converted is SQLserver (source framework) -source framework version 2005-Oracle (target framework) -target framework version 10.2.0.1, and SQLserver (source framework) -frame version 2005-MySQL (target framework) -target framework version 5.6.23, the two mappings are taken as candidate mappings.
S402: and matching the candidate mapping relation according to the target conversion frame information, and determining the target mapping relation.
Specifically, if the target transformation frame information is: the target frame is MySQL and the target frame version is 5.6.23, and then the candidate mapping relationship matched with the transformation frame information is taken as the target mapping relationship, that is, the SQLserver (source frame) -frame version is 2005-MySQL (target frame) -target frame version is 5.6.23 as described in the above example.
In one embodiment, as shown in fig. 5, in step S205, a matching method corresponding to a character type is adopted to match a character string to be matched, so as to obtain a character string to be converted matched with a character string of a source frame, and the method specifically includes the following steps:
s501: and if the character type is the keyword type, matching the character strings to be matched in a keyword matching mode to obtain character strings to be converted, which are matched with the character strings of the source frame.
The keyword types refer to tag fields of which the character strings to be matched are technical frameworks, such as < sql map >, < sql map >. Specifically, a keyword matching algorithm, such as KMP algorithm and multimode string matching algorithm (Aho-coralick), can be used for matching the keyword matching mode. The following description will be given of a keyword matching method using a multimodal string matching algorithm as an example.
S502: and if the character type is the method type, matching the character strings to be matched by adopting the regular expression to obtain the character strings to be converted, which are matched with the character strings of the source frame.
The method type refers to that the character string to be matched is a field representing the method, for example, try. Specifically, for a string to be matched for such character types, matching may be performed by constructing a regular expression, for example, for matching a string to be matched of try. In the embodiment, by adopting different matching modes for different character types to match, the universality of code migration can be effectively ensured, and the implementation of tools is realized.
In one embodiment, the source frame string includes a plurality of characters to be tested carrying sequence tags; as shown in fig. 6, in step S501, a keyword matching method is adopted to match a character string to be matched, so as to obtain a character string to be converted matched with a character string of a source frame, and the method specifically includes the following steps:
s601: constructing a dictionary tree corresponding to the source file according to the plurality of character strings to be matched; wherein the dictionary tree includes a plurality of node characters.
The node characters refer to characters stored in each child node in the dictionary tree. The dictionary tree, also called Trie tree, word search tree or prefix tree, is a multi-way tree structure for quick retrieval, e.g. the dictionary tree for english letters is a 26-way tree and the dictionary tree for numbers is a 10-way tree. Basic properties of Trie include:
(1) The root node does not contain characters, and each node contains only one character except the root node.
(2) From the root node to a certain node, the characters passing through the path are connected together to be the characters corresponding to the node.
(3) All children of each node contain different characters.
Specifically, the process of constructing the corresponding dictionary tree according to the character string to be matched is as follows: firstly initializing a root node (hereinafter referred to as root node) of a tree structure, then comparing whether each character in a word (i.e. character string to be matched) to be inserted is in a child node of a dictionary tree in sequence from the root node, if so, pointing a pointer to the child node, comparing the next character (i.e. second character of the character string to be matched), if not, creating a child node to store the current character, continuing judging the next character until all characters in the character string to be matched are judged to be finished and all characters are in the dictionary tree, and completing the construction of the dictionary tree.
S602: traversing the dictionary tree, and matching each character to be detected with the node character according to the sequence label to obtain a character string to be converted, wherein the character string to be converted is matched with the character string of the source frame.
Specifically, if the character to be detected with the source frame character string sequence label as the first position exists in the letter tree, the character is used as a current node, the successful pointer is pointed to the node character corresponding to the next node according to the path of the successful pointer in the letter tree, if the node character pointed by the pointer is matched with the character to be detected with the second sequence label in the frame character string, the character to be detected corresponding to the second sequence label is used as the current node, the steps of pointing the successful pointer to the node character corresponding to the next successful node according to the path of the successful pointer in the letter tree are continuously executed until the failed pointer is pointed to the root node, circulation is stopped, a target termination node is obtained, traversing is carried out according to the path of the successful pointer in the letter tree based on the root node and the termination node, and the character string to be converted is obtained.
For example, assuming that the source frame string is her, (the characters to be tested are "h", "e", r ") are illustrated by taking the letter tree of fig. 7 as an example (the dotted line part in the figure is the direction of the failure pointer; the solid line part is the path of the success pointer, the root is the root node, and the gray circle is the termination node), since the first character (i.e.," s ") exists in the letter tree, the character" h "is taken as the current node, and the success pointer is directed to the node character corresponding to the next node according to the path in the letter tree, i.e.," e ".
The server reads the character to be tested (i.e. "h") corresponding to the second sequence tag of the source frame character string, and matches the node character "h" pointed by the successful pointer at this time, as can be seen from fig. 7, the character to be tested "h" corresponding to the second sequence tag is matched with the node character "h", the character to be tested corresponding to the second sequence tag is taken as the current node, the step of pointing the successful pointer to the node character corresponding to the next node according to the path of the successful pointer in the letter tree is continuously executed, and the step of matching the node character "r" pointed by the pointer at this time with the character to be tested "r" corresponding to the third sequence tag in the read source frame character string is continuously executed, as can be seen from fig. 7, the character "r" to be matched with the node character "r", and the word obtained from the root node to the termination node is recorded as the character string to be converted, namely "her", the step of pointing the successful pointer to the node character corresponding to the next node in the letter tree is continuously executed, and the step of pointing the node character corresponding to the next node according to the successful pointer in the letter tree is continuously executed, and the step of pointing the node to the node character corresponding to the next node is ended, and the word is recorded as the word to be converted.
In the embodiment, the dictionary tree is constructed by the character strings to be matched, so that the data storage space can be effectively reduced; and then, performing character string matching by traversing the dictionary tree to obtain a character string to be converted, which is matched with the character string of the source frame, so that unnecessary character string comparison is reduced to the maximum extent, and the query efficiency is effectively ensured.
In one embodiment, as shown in fig. 8, after step 203, the code migration method further includes the following steps:
s701: and receiving a custom editing instruction input by the client, wherein the custom editing instruction comprises source frame information and corresponding target frame information.
The custom editing instruction is an instruction for triggering custom editing of the configuration file. The custom editing instruction includes, but is not limited to, adding, modifying or deleting configuration files.
Illustratively, the custom edit instruction is exemplified as a "new" operation. Specifically, the user can perform the custom editing interface through the custom editing module (such as a button form) in the interface, so as to edit according to the item to be edited displayed by the custom editing interface. The item to be edited comprises source frame information and corresponding target frame information, wherein the source frame information comprises a source frame, a source frame version and a source frame character string. The target frame information comprises a target frame, a target frame version and a target frame character string, and is used for carrying out custom editing or configuration on the information dimension so as to enable the server to acquire the source frame information and the corresponding target frame information.
S702: and responding to the custom editing instruction, and storing the source frame information and the corresponding target frame information in a configuration file in an associated manner so as to update the configuration file.
Specifically, the server responds to the custom editing instruction, and stores the source frame information and the target frame information in the configuration file in an associated mode so as to update the configuration file. It should be noted that, the corresponding relationship between the source frame information and the target frame information in the item to be edited is preset, and the user only needs to edit correspondingly without setting manually. In the embodiment, customization is realized by providing a custom editing interface for users and carrying out custom editing, and the method has the advantage of high expandability.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present invention.
In one embodiment, a code migration apparatus is provided, where the code migration apparatus corresponds to the code migration method in the above embodiment one by one. As shown in fig. 9, the code migration apparatus includes a source file acquisition module 10, a frame information to be converted determination module 20, a profile acquisition module 30, a target mapping relationship determination module 40, a character matching module 50, and a frame conversion module 60. The functional modules are described in detail as follows:
A source file obtaining module 10, configured to obtain source files and target conversion frame information; the target conversion frame information corresponds to a frame type; the source file includes a plurality of character strings to be matched.
And the frame information to be converted determining module 20 is configured to determine frame information to be converted corresponding to the source file according to the character string to be matched.
A configuration file obtaining module 30, configured to obtain a configuration file corresponding to the frame type; the configuration file is used for describing mapping relations between the plurality of source frame information and the target frame information.
A target mapping relationship determining module 40, configured to determine a target mapping relationship from a plurality of mapping relationships according to the frame information to be converted and the target conversion frame information; the target mapping relationship is used for indicating the mapping relationship between the source frame information matched with the frame information to be converted and the target frame information matched with the target conversion frame information; the source frame information includes a source frame string; the target frame information includes a target frame string.
The character matching module 50 is configured to match the character strings to be matched in a matching manner corresponding to the character types, so as to obtain character strings to be converted, which are matched with the character strings of the source frame.
The frame conversion module 60 is configured to convert the character string to be converted into a target frame character string according to the target mapping relationship, so as to obtain a target file of the source file under the target conversion frame.
Specifically, the frame information to be converted determining module includes a version specific character string matching unit and a frame information to be converted determining unit.
The version specific character string matching unit is used for matching keywords of character strings to be matched according to the version specific character string; the version specific character string is a specific keyword corresponding to a predefined technical framework under different versions.
And the frame information to be converted determining unit is used for taking the frame version and the technical frame corresponding to the version specific character string as the frame information to be converted corresponding to the source file if the character string to be matched with the version specific character string exists in the source file.
Specifically, the target mapping relation determining module includes a candidate mapping relation determining unit and a target mapping relation unit.
And the candidate mapping relation determining unit is used for matching a plurality of mapping relations according to the frame information to be converted and determining the candidate mapping relation corresponding to the frame information to be converted.
And the target mapping relation unit is used for determining that the candidate mapping relation is matched according to the target conversion frame information, and determining the target mapping relation.
Specifically, the character matching module comprises a keyword matching unit and a regular matching unit.
And the keyword matching unit is used for matching the character strings to be matched in a keyword matching mode if the character types are keyword types, so as to obtain character strings to be converted, which are matched with the character strings of the source frame.
And the regular matching unit is used for matching the character strings to be matched by adopting a regular expression if the character type is the method type, so as to obtain the character strings to be converted which are matched with the character strings of the source frame.
Specifically, the keyword matching unit includes a dictionary tree construction subunit and a traversal matching unit.
The dictionary tree construction subunit is used for constructing a dictionary tree corresponding to the source file according to the plurality of character strings to be matched; wherein the dictionary tree includes a plurality of node characters.
And the traversal matching unit is used for traversing the dictionary tree, matching the dictionary tree with the node characters according to the character sequence in the source frame character string, and obtaining a character string to be converted, which is matched with the source frame character string.
Specifically, the code migration apparatus further includes
The custom editing instruction acquisition module is used for receiving a custom editing instruction input by the client, wherein the custom editing instruction comprises source frame information and corresponding target frame information.
And the custom editing instruction response module is used for responding to the custom editing instruction, and storing the source frame information and the corresponding target frame information in the configuration file in an associated manner so as to update the configuration file.
The specific limitation of the code migration device can be referred to the limitation of the code migration method hereinabove, and will not be described herein. The various modules in the code migration apparatus described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 10. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a computer storage medium, an internal memory. The computer storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the computer storage media. The database of the computer device is used to store data, such as image recognition models, generated or obtained during execution of the code migration method. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a code migration method.
In one embodiment, a computer device is provided that includes a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing steps of the code migration method in the above embodiments when the computer program is executed, such as steps S201-S206 shown in fig. 2, or steps shown in fig. 3-8. Alternatively, the processor may implement the functions of each module/unit in this embodiment of the code migration apparatus when executing the computer program, for example, the functions of each module/unit shown in fig. 9, which are not described herein again for avoiding repetition.
In an embodiment, a computer storage medium is provided, where a computer program is stored, where the computer program when executed by a processor implements the steps of the code migration method in the foregoing embodiment, for example, steps S201 to S206 shown in fig. 2, or steps shown in fig. 3 to 8, which are not repeated herein. Alternatively, the computer program when executed by the processor implements the functions of each module/unit in the above embodiment of the code migration apparatus, for example, the functions of each module/unit shown in fig. 9, which are not described herein again for avoiding repetition.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the various embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions.
The above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention, and are intended to be included in the scope of the present invention.

Claims (8)

1. A method of code migration, comprising:
acquiring source file and target conversion frame information; wherein the target conversion frame information corresponds to a frame type; the source file comprises a plurality of character strings to be matched;
Determining frame information to be converted corresponding to the source file according to the character string to be matched;
acquiring a configuration file corresponding to the frame type; the configuration file is used for describing the mapping relation between the plurality of source frame information and the target frame information;
determining a target mapping relation from the mapping relations according to the frame information to be converted and the target conversion frame information; the target mapping relationship is used for indicating a mapping relationship between source frame information matched with the frame information to be converted and target frame information matched with the target conversion frame information; the source frame information comprises a source frame character string; the target frame information comprises a target frame character string;
matching the character strings to be matched in a matching mode corresponding to the character types to obtain character strings to be converted matched with the character strings of the source frame, wherein the matching mode comprises the following steps:
if the character type is a keyword type, matching the character string to be matched in a keyword matching mode to obtain a character string to be converted, wherein the character string to be converted is matched with the character string of the source frame;
if the character type is a method type, matching the character string to be matched by adopting a regular expression to obtain a character string to be converted, which is matched with the character string of the source frame;
The source frame character string comprises a plurality of characters to be tested carrying sequence labels;
the keyword matching method is adopted to match the character strings to be matched to obtain character strings to be converted matched with the source frame character strings, and the method comprises the following steps:
constructing a dictionary tree corresponding to the source file according to the plurality of character strings to be matched; wherein the dictionary tree includes a plurality of node characters;
traversing the dictionary tree, and matching each character to be detected with the node character according to the sequence label to obtain a character string to be converted, which is matched with the character string of the source frame;
and converting the character string to be converted into the target frame character string according to the target mapping relation to obtain a target file of the source file under the target conversion frame.
2. The code migration method of claim 1, wherein determining, according to the character string to be matched, frame information to be converted corresponding to the source file includes:
keyword matching is carried out on the character strings to be matched according to the version specific character strings; the version specific character strings are specific keywords corresponding to different versions of a predefined technical framework;
And if the source file has the character string to be matched with the version specific character string, taking the frame version and the technical frame corresponding to the version specific character string as frame information to be converted corresponding to the source file.
3. The code migration method of claim 1, wherein the determining a target mapping relationship from the plurality of mapping relationships according to the frame information to be converted and the target conversion frame information comprises:
according to the frame information to be converted, matching the plurality of mapping relations, and determining candidate mapping relations corresponding to the frame information to be converted;
and matching the candidate mapping relation according to the target conversion frame information, and determining the target mapping relation.
4. The code migration method of claim 1, wherein after the obtaining the configuration file corresponding to the frame type, the code migration method further comprises:
receiving a custom editing instruction input by a client, wherein the custom editing instruction comprises source frame information and corresponding target frame information;
and responding to the custom editing instruction, and storing the source frame information and the corresponding target frame information in the configuration file in an associated mode so as to update the configuration file.
5. A code migration apparatus, comprising:
the source file acquisition module is used for acquiring source files and target conversion frame information; wherein the target conversion frame information corresponds to a frame type; the source file comprises a plurality of character strings to be matched;
the frame information to be converted determining module is used for determining frame information to be converted corresponding to the source file according to the character strings to be matched;
the configuration file acquisition module is used for acquiring the configuration file corresponding to the frame type; the configuration file is used for describing the mapping relation between the plurality of source frame information and the target frame information;
the target mapping relation determining module is used for determining a target mapping relation from the plurality of mapping relations according to the frame information to be converted and the target conversion frame information; the target mapping relationship is used for indicating a mapping relationship between source frame information matched with the frame information to be converted and target frame information matched with the target conversion frame information; the source frame information comprises a source frame character string; the target frame information comprises a target frame character string;
The character matching module is used for matching the character strings to be matched by adopting a matching mode corresponding to the character types to obtain character strings to be converted matched with the source frame character strings, and comprises the following steps:
if the character type is a keyword type, matching the character string to be matched in a keyword matching mode to obtain a character string to be converted, wherein the character string to be converted is matched with the character string of the source frame;
if the character type is a method type, matching the character string to be matched by adopting a regular expression to obtain a character string to be converted, which is matched with the character string of the source frame;
the source frame character string comprises a plurality of characters to be tested carrying sequence labels;
the keyword matching method is adopted to match the character strings to be matched to obtain character strings to be converted matched with the source frame character strings, and the method comprises the following steps:
constructing a dictionary tree corresponding to the source file according to the plurality of character strings to be matched; wherein the dictionary tree includes a plurality of node characters;
traversing the dictionary tree, and matching each character to be detected with the node character according to the sequence label to obtain a character string to be converted, which is matched with the character string of the source frame;
And the frame conversion module is used for converting the character string to be converted into the target frame character string according to the target mapping relation to obtain a target file of the source file under the target conversion frame.
6. The code migration apparatus of claim 5, wherein the character matching module comprises:
the keyword matching unit is used for matching the character strings to be matched in a keyword matching mode if the character types are keyword types, so as to obtain character strings to be converted, which are matched with the character strings of the source frame;
and the regular matching unit is used for matching the character strings to be matched by adopting a regular expression if the character type is a method type, so as to obtain the character strings to be converted which are matched with the character strings of the source frame.
7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the code migration method of any one of claims 1 to 4 when the computer program is executed.
8. A computer storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the code migration method according to any one of claims 1 to 4.
CN202011041497.3A 2020-09-28 2020-09-28 Code migration method, device, computer equipment and storage medium Active CN112181489B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011041497.3A CN112181489B (en) 2020-09-28 2020-09-28 Code migration method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011041497.3A CN112181489B (en) 2020-09-28 2020-09-28 Code migration method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112181489A CN112181489A (en) 2021-01-05
CN112181489B true CN112181489B (en) 2023-07-25

Family

ID=73944570

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011041497.3A Active CN112181489B (en) 2020-09-28 2020-09-28 Code migration method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112181489B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220318049A1 (en) * 2021-03-30 2022-10-06 International Business Machines Corporation Program context migration
CN113377917A (en) * 2021-06-22 2021-09-10 云知声智能科技股份有限公司 Multi-mode matching method and device, electronic equipment and storage medium
CN113656055A (en) * 2021-08-20 2021-11-16 深圳壹账通智能科技有限公司 System architecture upgrading method and device, computer equipment and storage medium
CN114610385B (en) * 2022-03-16 2023-05-09 山东福生佳信科技股份有限公司 Running environment adaptation system and method
CN116009960B (en) * 2023-02-14 2024-01-23 花瓣云科技有限公司 Target micro-service migration method, system and electronic equipment
CN117270961B (en) * 2023-11-21 2024-04-12 武汉蜂鸟龙腾软件有限公司 Method for analyzing and loading MFC character resources in Linux environment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000029678A (en) * 1998-05-18 2000-01-28 Ntt Communication Ware Kk Program language conversion method, device therefor and recording medium
WO2013157008A2 (en) * 2012-04-18 2013-10-24 Gizmox Ltd. Code migration systems and methods and an online solutions store
CN109376142A (en) * 2018-09-03 2019-02-22 中国平安人寿保险股份有限公司 Data migration method and terminal device
CN111008037A (en) * 2019-12-17 2020-04-14 苏州浪潮智能科技有限公司 Code migration method, equipment and storage medium
CN111177113A (en) * 2019-12-06 2020-05-19 中国平安财产保险股份有限公司 Data migration method and device, computer equipment and storage medium
CN111367890A (en) * 2020-03-13 2020-07-03 深圳壹账通智能科技有限公司 Data migration method and device, computer equipment and readable storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7571175B2 (en) * 2005-09-23 2009-08-04 Sap Ag Transformation directives in datatype definitions
US8600925B2 (en) * 2011-06-23 2013-12-03 Microsoft Corporation Object-relational mapped database initialization
CN103631632B (en) * 2013-11-29 2017-08-04 华为技术有限公司 Implantation method and source-to-source compiler
US9886249B2 (en) * 2015-11-16 2018-02-06 Sap Se Universal transcompiling framework

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2000029678A (en) * 1998-05-18 2000-01-28 Ntt Communication Ware Kk Program language conversion method, device therefor and recording medium
WO2013157008A2 (en) * 2012-04-18 2013-10-24 Gizmox Ltd. Code migration systems and methods and an online solutions store
CN109376142A (en) * 2018-09-03 2019-02-22 中国平安人寿保险股份有限公司 Data migration method and terminal device
CN111177113A (en) * 2019-12-06 2020-05-19 中国平安财产保险股份有限公司 Data migration method and device, computer equipment and storage medium
CN111008037A (en) * 2019-12-17 2020-04-14 苏州浪潮智能科技有限公司 Code migration method, equipment and storage medium
CN111367890A (en) * 2020-03-13 2020-07-03 深圳壹账通智能科技有限公司 Data migration method and device, computer equipment and readable storage medium

Also Published As

Publication number Publication date
CN112181489A (en) 2021-01-05

Similar Documents

Publication Publication Date Title
CN112181489B (en) Code migration method, device, computer equipment and storage medium
CN110765763B (en) Error correction method and device for voice recognition text, computer equipment and storage medium
WO2020186786A1 (en) File processing method and apparatus, computer device and storage medium
CN111666401B (en) Document recommendation method, device, computer equipment and medium based on graph structure
CN111859986B (en) Semantic matching method, device, equipment and medium based on multi-task twin network
CN109814854B (en) Project framework generation method, device, computer equipment and storage medium
CN108108342B (en) Structured text generation method, search method and device
CN109635838A (en) Face samples pictures mask method, device, computer equipment and storage medium
CN111176996A (en) Test case generation method and device, computer equipment and storage medium
US9858330B2 (en) Content categorization system
CN110046637B (en) Training method, device and equipment for contract paragraph annotation model
CN111367595B (en) Data processing method, program running method, device and processing equipment
CN112286934A (en) Database table importing method, device, equipment and medium
CN110598210B (en) Entity recognition model training, entity recognition method, entity recognition device, entity recognition equipment and medium
CN110955608B (en) Test data processing method, device, computer equipment and storage medium
CN112528681A (en) Cross-language retrieval and model training method, device, equipment and storage medium
CN112580363A (en) Requirement document processing method and device, computer equipment and storage medium
CN112036161A (en) Requirement document processing method, device, equipment and storage medium
CN111984659B (en) Data updating method, device, computer equipment and storage medium
CN112307169B (en) Address data matching method and device, computer equipment and storage medium
CN111240790B (en) Multi-language adaptation method, device, client and storage medium for application
CN116861881A (en) Data processing method, device, equipment and medium
CN110222193A (en) Scan text modification method, device, computer equipment and storage medium
CN115345166A (en) Method, device, equipment and storage medium for identifying disease diagnosis name of medical text
CN115129598A (en) Risk detection method, device, system and medium for SQL (structured query language) statements

Legal Events

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