CN114924771A - Non-overlay code updating method, device, equipment and medium - Google Patents

Non-overlay code updating method, device, equipment and medium Download PDF

Info

Publication number
CN114924771A
CN114924771A CN202210686903.4A CN202210686903A CN114924771A CN 114924771 A CN114924771 A CN 114924771A CN 202210686903 A CN202210686903 A CN 202210686903A CN 114924771 A CN114924771 A CN 114924771A
Authority
CN
China
Prior art keywords
file
code
updated
source code
preset
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.)
Pending
Application number
CN202210686903.4A
Other languages
Chinese (zh)
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 Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202210686903.4A priority Critical patent/CN114924771A/en
Publication of CN114924771A publication Critical patent/CN114924771A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Abstract

The invention relates to the technical field of artificial intelligence, and provides a non-coverage code updating method, a non-coverage code updating device, non-coverage code updating equipment and a non-coverage code updating medium. The method comprises the steps of combining code data and a code model to generate a file to be updated; if the source code file is stored, acquiring a preset grammar model according to the type of the file to be updated; loading a file to be updated and a source code file by using a grammar model, respectively generating a first grammar tree and a second grammar tree, and analyzing and comparing the first grammar tree and the second grammar tree to determine content to be inserted; analyzing the file to be updated and the source code file respectively to obtain a first hash table and a second hash table, comparing the first hash table and the second hash table according to a preset hash function to determine an insertion position, and inserting the content to be inserted into the insertion position to generate a target file. The invention also relates to the technical field of block chains, and the insertion position and the content to be inserted can be stored in a node of a block chain.

Description

Non-overlay code updating method, device, equipment and medium
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a non-coverage code updating method, a non-coverage code updating device, non-coverage code updating equipment and a non-coverage code updating medium.
Background
After an application is released, the application needs to be updated in order to fix hidden errors, bugs, etc. or to release new functionality to improve the user experience.
After a code generator generates a new code, the existing updating method is to directly and comprehensively cover the old code before the new code, and simultaneously cover the code manually modified by a developer during maintenance, so that the problem of BUG (error, vulnerability and the like) is easy to occur; or after the new code is added to the old code, the new code is manually checked and merged, which easily causes the problems of code repeated compiling error and low working efficiency.
Disclosure of Invention
In view of the above, the present invention provides a method, an apparatus, a device and a medium for updating code without coverage, and aims to solve the technical problems in the prior art that the code update is easy to generate BUG and low in efficiency.
To achieve the above object, the present invention provides a non-overlay code updating method, comprising:
acquiring code data and a code template, and combining the code data and the code model to generate a file to be updated;
judging whether a preset engineering library stores a source code file corresponding to the file to be updated or not, and if the preset engineering library stores the source code file, acquiring a preset grammar model according to the type of the file to be updated;
loading the file to be updated and the source code file by using the grammar model, respectively generating a first grammar tree of the file to be updated and a second grammar tree of the source code file, analyzing and comparing the first grammar tree and the second grammar tree, and determining code blocks with differences in the file to be updated as content to be inserted;
analyzing the file to be updated and the source code file respectively to obtain a first hash table of the file to be updated and a second hash table of the source code file, comparing the first hash table with the second hash table according to a preset hash function, determining an insertion position of the content to be inserted in the source code file according to a comparison result, and inserting the content to be inserted into the insertion position to generate a target file.
Preferably, the obtaining the code data and the code template, and combining the code data and the code model to generate the file to be updated includes:
acquiring data table structure information and engineering configuration information of a generated code from a preset database as code data, and acquiring a code template of the type of the generated code;
and filling the data table structure information and the engineering configuration information into the code template according to the engine framework of the code template to generate the file to be updated.
Preferably, the step of filling the data table structure information and the engineering configuration information into the code template according to the engine framework of the code template to generate the file to be updated includes:
reading the preset mapping relation among the data table structure information, the engineering configuration information and the code template path according to the engine framework of the code template,
and filling the table name, the field type and the field attribute of the data table structure information and the engineering configuration information to a position corresponding to a code template according to the preset mapping relation, and generating the file to be updated.
Preferably, before the determining whether the preset engineering library stores the source code file corresponding to the file to be updated, the method includes:
reading directory information of the file to be updated in a preset database, and generating path information of the file to be updated;
and scanning the path information of all the project files in the preset project library according to the path information of the file to be updated.
Preferably, the loading the file to be updated and the source code file by using the grammar model to generate a first grammar tree of the file to be updated and a second grammar tree of the source code file respectively includes:
encoding characters of each code block of the file to be updated into bytes by using a port of the grammar model, creating a node of the bytes associated with the file to be updated, writing the node into an analysis module of the grammar model, and generating a first grammar tree of the file to be updated;
and encoding the characters of each code block of the source code file into bytes by using the port of the grammar model, creating a node of the bytes related to the source code file, writing the node into a parsing module of the grammar model, and generating a second grammar tree of the source code file.
Preferably, the analyzing and comparing the first syntax tree with the second syntax tree to determine the code blocks with differences in the file to be updated as the content to be inserted includes:
reading the element number and the node value of each node of the first syntax tree as an array and storing the array to a first linked list of the syntax model;
reading the element number and the node value of each node of the second syntax tree as an array and storing the array to a second linked list of the syntax model;
and performing difference calculation on each array of the first linked list and the second linked list according to a preset difference calculation formula, and determining code blocks with differences in the file to be updated as content to be inserted according to the obtained difference values.
Preferably, the comparing the first hash table with the second hash table according to a preset hash function, and determining an insertion position of the content to be inserted in the source code file according to a result obtained by the comparison, includes:
reading the number of data elements of the hash key of the first hash table, and reading the number of data elements of the hash value of the first hash table as an integer;
and judging whether the integer is stored in a second hash table according to a preset hash function, if the integer is not stored in the second hash table, inserting the integer into the second hash table, and determining the insertion position of the content to be inserted in the source code file according to the position of the integer inserted into the second hash table.
To achieve the above object, the present invention further provides a non-overlay update code device, including:
an acquisition module: the system comprises a code module, a code module and a file updating module, wherein the code module is used for acquiring code data and a code template, and combining the code data and the code model to generate a file to be updated;
a judging module: the system comprises a source code file storage module, a grammar model generation module and a database module, wherein the source code file storage module is used for storing a source code file corresponding to a file to be updated in a preset engineering library;
a comparison module: the grammar model is used for loading the file to be updated and the source code file, respectively generating a first grammar tree of the file to be updated and a second grammar tree of the source code file, analyzing and comparing the first grammar tree and the second grammar tree, and determining code blocks with differences in the file to be updated as content to be inserted;
an output module: the system comprises a source code file, a file to be updated and a source code file, wherein the source code file is used for storing a content to be inserted, the file to be updated and the source code file are respectively analyzed to obtain a first hash table of the file to be updated and a second hash table of the source code file, the first hash table and the second hash table are compared according to a preset hash function, the insertion position of the content to be inserted in the source code file is determined according to the result obtained by comparison, and the content to be inserted is inserted into the insertion position to generate a target file.
To achieve the above object, the present invention also provides an electronic device, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein, the first and the second end of the pipe are connected with each other,
the memory stores a program executable by the at least one processor to enable the at least one processor to perform the non-overlay update code method of any of claims 1 to 7.
To achieve the above object, the present invention further provides a computer readable medium storing non-overlay update code, which when executed by a processor implements the steps of the non-overlay update code method according to any one of claims 1 to 7.
The method and the device have the advantages that the file to be updated generated by the code generator and the source code file of the preset engineering library are obtained, the type of the file to be updated is obtained through the preset grammar model, the file to be updated is loaded through the grammar model and is compared with the source code file, and the contents to be inserted, which code blocks are the same, updated, deleted or newly added between the file to be updated and the source code file, can be found out.
And analyzing the file to be updated and the source code file respectively, comparing the first hash table of the file to be updated and the second hash table of the source code file obtained by analysis, and obtaining the insertion position of the file to be updated in the source code file by utilizing the characteristic of quickly searching contents of the hash tables.
The source code file is divided into a plurality of code blocks to be updated according to the combination of the obtained content to be inserted and the insertion position, the code blocks with the same content as the content of the file to be updated can be reserved and not updated, and the problems of easy occurrence of BUG and low efficiency in code updating are avoided.
Drawings
FIG. 1 is a flowchart of a preferred embodiment of a non-overlay code update method according to the present invention;
FIG. 2 is a block diagram of a non-overlay code update apparatus according to a preferred embodiment of the present invention;
FIG. 3 is a diagram of an electronic device according to a preferred embodiment of the present invention;
the objects, features and advantages of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention can acquire and process related data based on an artificial intelligence technology. Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The invention provides a non-coverage code updating method. Referring to fig. 1, a method flow diagram of an embodiment of a non-overlay code updating method according to the present invention is shown. The method may be performed by an electronic device, which may be implemented by software and/or hardware. The non-overlay update code method includes the following steps S10-S40:
step S10: and acquiring code data and a code template, and combining the code data and the code model to generate a file to be updated.
The specific step S10 includes:
acquiring data table structure information and engineering configuration information of a generated code from a preset database as code data, and acquiring a code template of the type of the generated code;
and filling the data table structure information and the engineering configuration information into the code template according to the engine framework of the code template to generate the file to be updated.
In this embodiment, after a user codes a generated code at a user side, a code generation request is sent to a server, a background process of the server receives and analyzes the code request, obtains data table structure information and engineering configuration information of the coded code stored in a preset database (for example, the preset database is a local memory database), where the engineering configuration information includes an engineering name, a port number and engineering dependent configuration information, the data table structure information includes a table name, a field type and a field attribute, and the generated code device includes a visual interface and/or a code frame of the code interface.
The background process also obtains a corresponding template file in a preset database according to the file type of the written code, obtains a code template configured with the template file (for example, the code template corresponding to the java file type is a code template such as controller, service, etc., and the code template corresponding to the pom file type is a code template of maven) from a preset engineering library (for example, the preset engineering library is a database for storing source codes, and the source codes refer to old version codes of running application programs) according to the template file, and fills the data table structure information and the engineering configuration information into the code template according to an engine frame of the code template to generate a file to be updated, wherein the file to be updated may include a java file, a pom file, a xml or a properties configuration file, and the file to be updated refers to a new version code file updated aiming at the old version codes of running application programs.
In one embodiment, the populating the data table structure information and the engineering configuration information into the code template according to the engine framework of the code template, and generating the file to be updated includes:
reading the preset mapping relation among the data table structure information, the engineering configuration information and the code template path according to the engine frame of the code template,
and filling the table name, the field type and the field attribute of the data table structure information and the engineering configuration information to a position corresponding to a code template according to the preset mapping relation, and generating the file to be updated.
For example, the name of the first row field of the data table and the content of the first row field of the data table are filled into the corresponding first row field position of the code template. After filling, replacing the attribute of the first row field of the code template with the attribute of the first row field of the data table, wherein the attribute replacement specifically comprises the following steps: the first row field attribute of the code template is tableName, and the data table field attribute $ { tableName } is replaced with the code template field attribute tableName by a template engine (e.g., a velocity template engine). And repeating the steps, filling all the structural information and the engineering configuration information of the data table into the code template by the same method, and generating the file to be updated.
Step S20: and judging whether a source code file corresponding to the file to be updated is stored in a preset engineering library, and if the source code file is stored in the preset engineering library, acquiring a preset grammar model according to the type of the file to be updated.
In this embodiment, whether the path information of all source code files in the preset engineering library is consistent with the path information of the file to be updated is determined, so as to determine that the preset engineering library stores the source code file, if the source code file is stored, a preset grammar model is obtained according to the type or suffix of the file to be updated, the preset grammar model includes an AST grammar tree, an XML file parser, a YAML file parser, and the like, grammar models corresponding to different types of files are different, for example, the type of the file to be updated is java file, and the AST grammar tree model is obtained as the preset grammar model, and the type of the file to be updated is XML file, and the XML file parser is obtained as the preset grammar model for the XML file.
In an embodiment, before the determining whether the preset engineering library stores the source code file corresponding to the file to be updated, the method includes:
reading directory information of the file to be updated in a preset database, and generating path information of the file to be updated;
and scanning the path information of all the project files in the preset project library according to the path information of the file to be updated.
The method comprises the steps of reading directory information (for example, the directory information is output directory information or default directory information, if the output directory information is D: \ demo) of a preset database where a file to be updated is located, generating path information (for example, the path information is \ controller \ democontroller. java) of the file to be updated, linking the path information of the file to be updated to a project directory of a source code file (the source code refers to an old version code of an application program which is already running), and executing a command of a path existence rule to scan path information of all project files of the project library according to a preset path existence rule (for example, the path existence rule is D: \ demoproject).
The rule for judging whether the preset engineering library stores the source code file corresponding to the file to be updated is as follows: if the path information of all the source code files in the preset project library is inconsistent with the path information of the file to be updated, judging that the file to be updated does not store the corresponding source code file in the preset project library, and directly executing the file to be updated to directly output the target file.
If the path information of any source code file in the preset engineering library is consistent with the path information of the file to be updated, the file to be updated is judged to store the corresponding source code file in the preset engineering library, that is, the source code file can be updated in a non-covering manner according to the file to be updated.
All the project files in the preset project library are inquired through the path information, whether the source code file of the application program is operated exists in the file to be updated or not is judged, the corresponding source code file can be quickly and accurately inquired, and the problem of low manual inquiry efficiency can be solved.
Step S30: and loading the file to be updated and the source code file by using the grammar model, respectively generating a first grammar tree of the file to be updated and a second grammar tree of the source code file, analyzing and comparing the first grammar tree and the second grammar tree, and determining code blocks with differences in the file to be updated as content to be inserted.
In this embodiment, A Port (API) of a syntax model is utilized to load each code block of a file to be updated and a source code file, to obtain corresponding nodes, the nodes are written into an parsing module of the syntax model, and a first syntax tree of the file to be updated and a second syntax tree of the source code file are generated, respectively, where a code block is a section of code enclosed by preset symbols in a class or a method, and the preset symbols are symbols such as { }, (), [ in other words.
And comparing the number of elements and the node value of each node of the first syntax tree with the number of elements and the node value of each node of the second syntax tree, and determining the code blocks with differences in the file to be updated as the content to be inserted.
In an embodiment, the loading the file to be updated and the source code file by using the syntax model to generate a first syntax tree of the file to be updated and a second syntax tree of the source code file respectively includes:
encoding characters of each code block of the file to be updated into bytes by using a port of the grammar model, creating a node of the bytes associated with the file to be updated, writing the node into an analysis module of the grammar model, and generating a first grammar tree of the file to be updated;
and encoding the characters of each code block of the source code file into bytes by using the port of the grammar model, creating a node of the bytes related to the source code file, writing the node into a parsing module of the grammar model, and generating a second grammar tree of the source code file.
For example, characters of each code block of the file to be updated and the source code file are encoded into bytes, nodes having network topology association with attributes of the bytes are created, and data information of adjacent nodes and connecting edges of each node is read and written into a parsing module of the grammar model to generate a corresponding grammar tree. The parsing module is a JAVA Script parser, and the statements of the file to be updated and the source code file are mapped to each node in the syntax tree by means of the parsing module.
In one embodiment, the analyzing and comparing the first syntax tree with the second syntax tree to determine the code blocks with differences in the file to be updated as the content to be inserted includes:
reading the element number and the node value of each node of the first syntax tree as an array and storing the array to a first linked list of the syntax model;
reading the element number and the node value of each node of the second syntax tree as an array and storing the array to a second linked list of the syntax model;
and performing difference calculation between each array of the first linked list and the second linked list according to a preset difference calculation formula, and determining the code blocks with differences in the file to be updated as the content to be inserted according to the obtained difference values.
Traversing all nodes of the first syntax tree and the second syntax tree, taking the element quantity and the return value of each node as an array and storing the array to the corresponding linked list, calculating the difference between the arrays of the two linked lists, and quickly querying the difference between the nodes of the first syntax tree and the second syntax tree so as to determine which code blocks in the file to be updated are the content to be inserted into the source code file, wherein the element quantity of the node is that each code of each code block is taken as an element of the node, if the code block corresponding to the node comprises 10 code bytes, the element quantity of the node is 10, the return value is that the time value required for traversing the node is returned according to the preset class name when the node is traversed.
A preset difference calculation formula, comprising:
Figure BDA0003698300660000091
wherein T is the difference value, X is the number of nodes of the first linked list, Y is the number of nodes of the second linked list, C i I arrays, C, of said first linked list n The second linked list comprises a total of n arrays.
In one embodiment, after the determining, according to the obtained difference value, the different code blocks in the file to be updated as the content to be inserted includes:
inquiring a corresponding code block from the file to be updated according to each difference value;
according to a preset label rule, marking the code block with the difference value larger than a first preset value as a first type label, wherein the first type label is an updated type content to be inserted;
marking the code blocks with the difference values larger than a second preset value as second type labels, wherein the second type labels are newly added type contents to be inserted;
and marking the code blocks with the difference values larger than a third preset value as third type labels, wherein the third type labels are deletion type contents to be inserted.
The preset label rule is as follows: the preset values are set to three levels, the three levels are sequentially a first preset value < a second preset value, for example, the difference value corresponding to one code block is 3, the preset values of the three levels are sequentially set to be that the first preset value is less than or equal to 1, the second preset value is less than or equal to 3, and the second preset value is less than or equal to 5, so that the code block with the value of 3 is marked as a second type tag and serves as the newly added type content to be inserted.
The code blocks with the difference values smaller than the first preset value are generally marked as the same type labels, if one code block is marked with the same type label, the content of the code block in the file to be updated and the content of the source code file are the same, when the target file is output, the code block of the source code file is not processed, the content is directly kept still, and therefore the code is updated without completely covering the whole source code file.
Step S40: analyzing the file to be updated and the source code file respectively to obtain a first hash table of the file to be updated and a second hash table of the source code file, comparing the first hash table with the second hash table according to a preset hash function, determining an insertion position of the content to be inserted in the source code file according to a comparison result, and inserting the content to be inserted into the insertion position to generate a target file.
In this embodiment, the content of a file to be updated is analyzed according to A Port (API) of a preset file stream, each row number is used as a hash key, field information of each row is used as a hash value, the obtained hash key and the hash value are stored in an array, a first hash table of the file to be updated is generated, and the preset file stream is a file type with A Port (API) configured for an environment variable (JDK).
Analyzing the content of the source code file according to the port of the preset file stream, taking each line number as a hash key, taking field information of each line as a hash value, storing the obtained hash key and the hash value into an array, and generating a second hash table of the source code file.
And taking the hash key of the first hash table and the number of the data elements of the hash value as an integer, inquiring the integer to the array of the second hash table according to a preset hash function, and determining the insertion position of the content to be inserted in the source code file according to a returned result.
Before outputting the target file, the grammar model verifies whether the grammar of the content to be inserted is correct after being inserted into the position to be inserted of the source code file, grammar conversion is executed, if the grammar is correct, the target file is directly output, and if the grammar is wrong, grammar errors are prompted so that developers can modify the grammar errors.
In an embodiment, the comparing the first hash table with the second hash table according to a preset hash function, and determining an insertion position of the content to be inserted in the source code file according to a result obtained by the comparing includes:
reading the number of data elements of the hash key of the first hash table, and reading the number of data elements of the hash value of the first hash table as an integer;
and judging whether the integer is stored in a second hash table according to a preset hash function, if the integer is not stored in the second hash table, inserting the integer into the second hash table, and determining the insertion position of the content to be inserted in the source code file according to the position of the integer inserted into the second hash table.
The method comprises the steps of reading hash keys in a first row of a first hash table and the number of data elements of hash values to serve as an integer, inquiring whether the integer is stored in an array of a second hash table or not according to a preset hash function, and if the integer is stored in the second hash table, feeding back a value prompt when the inquiry is successful, namely, storing field information in the first row of the first hash table in the second hash table, wherein the content of the position is the same as that of the field information in the first row of the first hash table.
If the second hash table does not store the integer, the failure prompt is fed back when the query fails, and the integer is inserted into the hash table, that is, the field information of the first row of the first hash table is not stored in the second hash table, and the position is the insertion position of the field information of the first row of the first hash table, so that the content to be inserted of the file to be updated can be judged to be inserted into the position of the source code file, and then, which type of updating editing is performed at the insertion position according to the class tag of the content to be inserted.
For example, reading the hash key in the first row of the first hash table and the number of data elements of the hash value as an integer, setting a return value as an integer value of a key field of the second hash table, querying each array of the second hash table according to a preset hash function, and if the integer is stored in the second hash table, determining that an element with a subscript of a K hash address P of the second hash table is less than or equal to 0, indicating that there is no conflict at the position, and feeding back a return value prompt when querying is successful; and if the subscript of the second hash table is that the elements of the K hash address P are more than 0, the position is in conflict, a failure prompt is fed back when the query fails, and the integer is inserted into the hash table.
In another implementation, the content to be inserted is inserted into the insertion position obtained by comparing the first hash table with the second hash table to generate the target file. If the content to be inserted is the new class label, the new adding operation of the node with the relevant attribute is realized by executing a birthdate command, if the content to be inserted is the updated class label, the updating operation of the node with the relevant attribute is realized by executing a realname command, and if the content to be inserted is the deleted class label, the deleting operation of the node with the relevant attribute is realized by executing an age command.
Referring to fig. 2, a functional block diagram of the non-overlay code updating apparatus 100 according to the present invention is shown.
The non-overlay update code device 100 of the present invention may be installed in an electronic device. According to the implemented functions, the non-overlay update code device 100 may include an obtaining module 110, an obtaining module 20, a comparing module 130, and an outputting module 140. A module according to the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and can perform a fixed function, and are stored in a memory of the electronic device.
In this embodiment, the functions of the modules/units are as follows:
the acquisition module 110: the system comprises a code module, a code module and a file updating module, wherein the code module is used for acquiring code data and a code template, and combining the code data and the code model to generate a file to be updated;
the judging module 120: the system comprises a source code file storage module, a grammar model generation module and a database module, wherein the source code file storage module is used for storing a source code file corresponding to a file to be updated in a preset engineering library;
the alignment module 130: the grammar model is used for loading the file to be updated and the source code file, respectively generating a first grammar tree of the file to be updated and a second grammar tree of the source code file, analyzing and comparing the first grammar tree and the second grammar tree, and determining code blocks with differences in the file to be updated as content to be inserted;
the output module 140: the system comprises a source code file, a file to be updated and a source code file, wherein the source code file is used for storing a content to be inserted, the file to be updated and the source code file are respectively analyzed to obtain a first hash table of the file to be updated and a second hash table of the source code file, the first hash table and the second hash table are compared according to a preset hash function, the insertion position of the content to be inserted in the source code file is determined according to the result obtained by comparison, and the content to be inserted is inserted into the insertion position to generate a target file.
In one embodiment, the obtaining code data and a code template, and combining the code data and the code model to generate a file to be updated includes:
acquiring data table structure information and engineering configuration information of a generated code from a preset database as code data, and acquiring a code template of the type of the generated code;
and filling the data table structure information and the engineering configuration information into the code template according to the engine framework of the code template to generate the file to be updated.
In one embodiment, the populating the data table structure information and the engineering configuration information into the code template according to the engine framework of the code template, and generating the file to be updated includes:
reading the preset mapping relation among the data table structure information, the engineering configuration information and the code template path according to the engine frame of the code template,
and filling the table name, the field type and the field attribute of the data table structure information and the engineering configuration information to a position corresponding to a code template according to the preset mapping relation, and generating the file to be updated.
In an embodiment, before the determining whether the preset engineering library stores the source code file corresponding to the file to be updated, the method includes:
reading directory information of the file to be updated in a preset database, and generating path information of the file to be updated;
and scanning the path information of all the project files in the preset project library according to the path information of the file to be updated.
In one embodiment, the loading the file to be updated and the source code file by using the syntax model to generate a first syntax tree of the file to be updated and a second syntax tree of the source code file, respectively, includes:
encoding characters of each code block of the file to be updated into bytes by using a port of the grammar model, creating nodes of the bytes related to the file to be updated, writing the nodes into an analysis module of the grammar model, and generating a first grammar tree of the file to be updated;
and encoding the characters of each code block of the source code file into bytes by using the port of the grammar model, creating nodes of the bytes related to the source code file, writing the nodes into an analysis module of the grammar model, and generating a second grammar tree of the source code file.
In one embodiment, the analyzing and comparing the first syntax tree with the second syntax tree to determine the code blocks with differences in the file to be updated as the content to be inserted includes:
reading the element number and the node value of each node of the first syntax tree as an array and storing the array to a first linked list of the syntax model;
reading the element number and the node value of each node of the second syntax tree as an array and storing the array to a second linked list of the syntax model;
and performing difference calculation between each array of the first linked list and the second linked list according to a preset difference calculation formula, and determining the code blocks with differences in the file to be updated as the content to be inserted according to the obtained difference values.
In an embodiment, the comparing the first hash table with the second hash table according to a preset hash function, and determining an insertion position of the content to be inserted in the source code file according to a result obtained by the comparing includes:
reading the number of data elements of the hash key of the first hash table, and reading the number of data elements of the hash value of the first hash table as an integer;
judging whether the integer is stored in a second hash table or not according to a preset hash function, if the integer is not stored in the second hash table, inserting the integer into the second hash table, and determining the insertion position of the content to be inserted in the source code file according to the position of the integer inserted into the second hash table.
Fig. 3 is a schematic diagram of an electronic device 1 according to a preferred embodiment of the invention.
The electronic device 1 includes but is not limited to: memory 11, processor 12, display 13, and network interface 14. The electronic device 1 is connected to a network through a network interface 14 to obtain raw data. The network may be a wireless or wired network such as an Intranet (Internet), the Internet (Internet), a global system for mobile communications (GSM), Wideband Code Division Multiple Access (WCDMA), a 4G network, a 5G network, Bluetooth (Bluetooth), Wi-Fi, or a call network.
The memory 11 includes at least one type of readable medium including a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the storage 11 may be an internal storage unit of the electronic device 1, such as a hard disk or a memory of the electronic device 1. In other embodiments, the memory 11 may also be an external storage device of the electronic device 1, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash card (FlashCard), or the like, which is equipped with the electronic device 1. Of course, the memory 11 may also comprise both an internal memory unit and an external memory device of the electronic device 1. In this embodiment, the memory 11 is generally used for storing an operating system installed in the electronic device 1 and various types of application software, such as program codes of the non-overlay update code 10. Further, the memory 11 may also be used to temporarily store various types of data that have been output or are to be output.
Processor 12 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. The processor 12 is typically used for controlling the overall operation of the electronic device 1, such as performing data interaction or communication related control and processing. In this embodiment, the processor 12 is configured to execute the program code stored in the memory 11 or process data, for example, execute the program code of the non-overlay update code 10.
The display 13 may be referred to as a display screen or display unit. In some embodiments, the display 13 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an organic light-emitting diode (OLED) touch panel, or the like. The display 13 is used for displaying information processed in the electronic device 1 and for displaying a visual work interface, e.g. displaying the results of data statistics.
The network interface 14 may optionally comprise a standard wired interface, a wireless interface (e.g. WI-FI interface), the network interface 14 typically being used for establishing a communication connection between the electronic device 1 and other electronic devices.
Fig. 3 only shows the electronic device 1 with components 11-14 and the non-overlay update code 10, but it is to be understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead.
Optionally, the electronic device 1 may further include a user interface, the user interface may include a Display (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface may further include a standard wired interface and a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an organic light-emitting diode (OLED) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device 1 and for displaying a visualized user interface.
The electronic device 1 may further include a Radio Frequency (RF) circuit, a sensor, an audio circuit, and the like, which are not described in detail herein.
In the above embodiment, the processor 12 when executing the non-overlay update code 10 stored in the memory 11 may implement the following steps:
acquiring code data and a code template, and combining the code data and the code model to generate a file to be updated;
judging whether a preset engineering library stores a source code file corresponding to the file to be updated or not, and if the preset engineering library stores the source code file, acquiring a preset grammar model according to the type of the file to be updated;
loading the file to be updated and the source code file by using the grammar model, respectively generating a first grammar tree of the file to be updated and a second grammar tree of the source code file, analyzing and comparing the first grammar tree and the second grammar tree, and determining code blocks with differences in the file to be updated as content to be inserted;
analyzing the file to be updated and the source code file respectively to obtain a first hash table of the file to be updated and a second hash table of the source code file, comparing the first hash table with the second hash table according to a preset hash function, determining an insertion position of the content to be inserted in the source code file according to a comparison result, and inserting the content to be inserted into the insertion position to generate a target file.
The storage device may be the memory 11 of the electronic device 1, or may be another storage device communicatively connected to the electronic device 1.
For a detailed description of the above steps, please refer to the above description of fig. 2 regarding a functional block diagram of an embodiment of the non-coverage update code apparatus 100 and fig. 1 regarding a flowchart of an embodiment of a non-coverage update code method.
In addition, the embodiment of the present invention further provides a computer-readable medium, which may be non-volatile or volatile. The computer readable medium may be any one or any combination of hard disks, multi-media cards, SD cards, flash memory cards, SMC, Read Only Memory (ROM), Erasable Programmable Read Only Memory (EPROM), portable compact disc read only memory (CD-ROM), USB memory, and the like. The computer readable medium includes a storage data area and a storage program area, the storage data area stores data created according to usage of a blockchain node, the storage program area stores non-coverage update code 10, and the non-coverage update code 10 realizes the following operations when being executed by a processor:
acquiring code data and a code template, and combining the code data and the code template to generate a file to be updated;
judging whether a preset engineering library stores a source code file corresponding to the file to be updated or not, and if the preset engineering library stores the source code file, acquiring a preset grammar model according to the type of the file to be updated;
loading the file to be updated and the source code file by using the grammar model, respectively generating a first grammar tree of the file to be updated and a second grammar tree of the source code file, analyzing and comparing the first grammar tree and the second grammar tree, and determining code blocks with differences in the file to be updated as content to be inserted;
analyzing the file to be updated and the source code file respectively to obtain a first hash table of the file to be updated and a second hash table of the source code file, comparing the first hash table with the second hash table according to a preset hash function, determining an insertion position of the content to be inserted in the source code file according to a comparison result, and inserting the content to be inserted into the insertion position to generate a target file.
The embodiment of the computer readable medium of the present invention is substantially the same as the embodiment of the non-overlay code update method, and will not be described herein again.
In another embodiment, in order to further ensure the privacy and security of all the data, all the data may be stored in a node of a block chain. Such as the location of insertion, the content to be inserted, and all of these data can be stored in block link points.
It should be noted that the blockchain in the present invention is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
It should be noted that the above-mentioned numbers of the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments. And the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention essentially or contributing to the prior art can be embodied in the form of a software product, which is stored in a medium (such as ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (such as a mobile phone, a computer, an electronic device, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A non-overlay update code method, the method comprising:
acquiring code data and a code template, and combining the code data and the code model to generate a file to be updated;
judging whether a preset engineering library stores a source code file corresponding to the file to be updated or not, and if the preset engineering library stores the source code file, acquiring a preset grammar model according to the type of the file to be updated;
loading the file to be updated and the source code file by using the grammar model, respectively generating a first grammar tree of the file to be updated and a second grammar tree of the source code file, analyzing and comparing the first grammar tree and the second grammar tree, and determining code blocks with differences in the file to be updated as content to be inserted;
analyzing the file to be updated and the source code file respectively to obtain a first hash table of the file to be updated and a second hash table of the source code file, comparing the first hash table with the second hash table according to a preset hash function, determining an insertion position of the content to be inserted in the source code file according to a comparison result, and inserting the content to be inserted into the insertion position to generate a target file.
2. The non-overlay code update method of claim 1, wherein the obtaining code data and a code template, and combining the code data and the code model to generate a file to be updated comprises:
acquiring data table structure information and engineering configuration information of a generated code from a preset database as code data, and acquiring a code template of the type of the generated code;
and filling the data table structure information and the engineering configuration information into the code template according to the engine framework of the code template to generate the file to be updated.
3. The non-overlay code update method of claim 2, wherein the populating the code template with the data table structure information and the engineering configuration information according to the engine framework of the code template, generating the file to be updated, comprises:
reading the preset mapping relation among the data table structure information, the engineering configuration information and the code template path according to the engine frame of the code template,
and filling the table name, the field type and the field attribute of the data table structure information and the engineering configuration information to a position corresponding to a code template according to the preset mapping relation, and generating the file to be updated.
4. The non-overlay code updating method according to claim 1, wherein before the determining whether the preset engineering library stores the source code file corresponding to the file to be updated, the method comprises:
reading directory information of the file to be updated in a preset database, and generating path information of the file to be updated;
and scanning the path information of all the project files in the preset project library according to the path information of the file to be updated.
5. The non-overlay code update method of claim 1, wherein the loading the file to be updated and the source code file using the grammar model to generate a first grammar tree of the file to be updated and a second grammar tree of the source code file, respectively, comprises:
encoding characters of each code block of the file to be updated into bytes by using a port of the grammar model, creating nodes of the bytes related to the file to be updated, writing the nodes into an analysis module of the grammar model, and generating a first grammar tree of the file to be updated;
and encoding the characters of each code block of the source code file into bytes by using the port of the grammar model, creating a node of the bytes related to the source code file, writing the node into a parsing module of the grammar model, and generating a second grammar tree of the source code file.
6. The method of claim 1, wherein the analyzing and comparing the first syntax tree with the second syntax tree to determine the different code blocks in the file to be updated as the content to be inserted comprises:
reading the element number and the node value of each node of the first syntax tree as an array and storing the array to a first linked list of the syntax model;
reading the element number and the node value of each node of the second syntax tree as an array and storing the array to a second linked list of the syntax model;
and performing difference calculation on each array of the first linked list and the second linked list according to a preset difference calculation formula, and determining code blocks with differences in the file to be updated as content to be inserted according to the obtained difference values.
7. The non-overlay code updating method according to claim 1, wherein the comparing the first hash table and the second hash table according to a preset hash function, and determining an insertion position of the content to be inserted in the source code file according to a result obtained by the comparing comprises:
reading the number of data elements of the hash key of the first hash table, and reading the number of data elements of the hash value of the first hash table as an integer;
and judging whether the integer is stored in a second hash table according to a preset hash function, if the integer is not stored in the second hash table, inserting the integer into the second hash table, and determining the insertion position of the content to be inserted in the source code file according to the position of the integer inserted into the second hash table.
8. An apparatus for non-overlay update code, the apparatus comprising:
an acquisition module: the system comprises a code module, a code module and a file updating module, wherein the code module is used for acquiring code data and a code template, and combining the code data and the code model to generate a file to be updated;
a judging module: the system comprises a source code file storage module, a grammar model generation module and a database module, wherein the source code file storage module is used for storing a source code file corresponding to a file to be updated in a preset engineering library;
a comparison module: the grammar model is used for loading the file to be updated and the source code file, respectively generating a first grammar tree of the file to be updated and a second grammar tree of the source code file, analyzing and comparing the first grammar tree and the second grammar tree, and determining code blocks with differences in the file to be updated as content to be inserted;
an output module: the system comprises a source code file, a file to be updated and a source code file, wherein the source code file is used for being stored in a file storage device, the file to be updated and the source code file are respectively analyzed to obtain a first hash table of the file to be updated and a second hash table of the source code file, the first hash table and the second hash table are compared according to a preset hash function, an inserting position of the content to be inserted in the source code file is determined according to a result obtained by comparison, and the content to be inserted is inserted into the inserting position to generate a target file.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a program executable by the at least one processor to enable the at least one processor to perform the non-overlay update code method of any of claims 1 to 7.
10. A computer readable medium, characterized in that it stores a non-overlay update code, which when executed by a processor implements the non-overlay update code method according to any of claims 1 to 7.
CN202210686903.4A 2022-06-16 2022-06-16 Non-overlay code updating method, device, equipment and medium Pending CN114924771A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210686903.4A CN114924771A (en) 2022-06-16 2022-06-16 Non-overlay code updating method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210686903.4A CN114924771A (en) 2022-06-16 2022-06-16 Non-overlay code updating method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN114924771A true CN114924771A (en) 2022-08-19

Family

ID=82814175

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210686903.4A Pending CN114924771A (en) 2022-06-16 2022-06-16 Non-overlay code updating method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN114924771A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115357252A (en) * 2022-10-08 2022-11-18 成都数联云算科技有限公司 Source code file generation method and device, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115357252A (en) * 2022-10-08 2022-11-18 成都数联云算科技有限公司 Source code file generation method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN106951228B (en) Method and device for processing differences in version iteration
CN111142903B (en) Configuration file interactive updating method and device based on file comparison
CN109901834B (en) Document page generation method, device, computer equipment and storage medium
US11775414B2 (en) Automated bug fixing using deep learning
CN109670053B (en) Data object mapping method, device, equipment and computer readable storage medium
US20070266378A1 (en) Source code generation method, apparatus, and program
CN110825619A (en) Automatic generation method and device of interface test case and storage medium
CN111459495B (en) Unit test code file generation method, electronic device and storage medium
CN111538942B (en) Expression processing method, electronic device and storage medium
CN113704706B (en) Code reinforcement method and device
CN112166419A (en) Electronic device for detecting software bugs and method for operating the same
CN102402480A (en) Tool for debugging (testing) command line of circuit board firmware
CN112559354A (en) Front-end code specification detection method and device, computer equipment and storage medium
US20210365258A1 (en) Method and system for updating legacy software
CN111694613A (en) Decoupling method between application program modules, electronic device and storage medium
CN108694049B (en) Method and equipment for updating software
CN113377661A (en) Interface testing method and device, electronic equipment and storage medium
CN114924771A (en) Non-overlay code updating method, device, equipment and medium
CN112769706A (en) Componentized routing method and system
CN116560683A (en) Software updating method, device, equipment and storage medium
CN114461217A (en) Code compiling method and device, electronic equipment and storage medium
CN112527738A (en) Project description file optimization method, system and storage medium
CN114816971A (en) Data processing method, related equipment and storage medium
CN112597023A (en) Case management method and device based on guide picture, computer equipment and storage medium
CN115291887A (en) Code generation method, device, equipment and storage medium

Legal Events

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