CN117555533A - Code generation method, electronic device and storage medium - Google Patents
Code generation method, electronic device and storage medium Download PDFInfo
- Publication number
- CN117555533A CN117555533A CN202410047518.4A CN202410047518A CN117555533A CN 117555533 A CN117555533 A CN 117555533A CN 202410047518 A CN202410047518 A CN 202410047518A CN 117555533 A CN117555533 A CN 117555533A
- Authority
- CN
- China
- Prior art keywords
- code
- target
- node
- data processing
- execution file
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 53
- 238000012545 processing Methods 0.000 claims abstract description 118
- 238000012795 verification Methods 0.000 claims description 62
- 238000004364 calculation method Methods 0.000 claims description 20
- 230000004044 response Effects 0.000 claims description 15
- 238000004590 computer program Methods 0.000 claims description 4
- 238000012163 sequencing technique Methods 0.000 claims description 4
- 238000004458 analytical method Methods 0.000 abstract description 6
- 238000011161 development Methods 0.000 abstract description 3
- 238000004891 communication Methods 0.000 description 11
- 230000006870 function Effects 0.000 description 8
- 230000008569 process Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 5
- ZLIBICFPKPWGIZ-UHFFFAOYSA-N pyrimethanil Chemical compound CC1=CC(C)=NC(NC=2C=CC=CC=2)=N1 ZLIBICFPKPWGIZ-UHFFFAOYSA-N 0.000 description 4
- 238000005070 sampling Methods 0.000 description 4
- 238000012216 screening Methods 0.000 description 4
- 238000012790 confirmation Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000002776 aggregation Effects 0.000 description 2
- 238000004220 aggregation Methods 0.000 description 2
- 238000013475 authorization Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 2
- 230000008901 benefit Effects 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 2
- 230000009467 reduction Effects 0.000 description 2
- 238000006722 reduction reaction Methods 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 238000012935 Averaging Methods 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 230000004931 aggregating effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000007619 statistical method Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/447—Target code generation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE 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/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The code generation method comprises the steps of determining a target output node according to a code generation instruction, finding a target data processing node according to the target output node, namely finding the code of the target data processing node, and generating the target code according to the code of a data source node, the code of the data processing node and the code of the target output node, namely directly obtaining the code of the data processing node which is required to be output according to the code generation instruction, wherein the obtained code can be directly used when data of different service types are subjected to data statistics analysis, and secondary development is not needed.
Description
Technical Field
The present disclosure relates to the field of data statistics analysis technologies, and in particular, to a code generation method, an electronic device, and a storage medium.
Background
When data statistics analysis is performed on data of different service types, screening, calculation, connection and other processes are generally required to be performed on the data to obtain data statistics results, and code writing may be also required to be performed on each data processing to complete special data processing. The common processing mode is to complete data statistics analysis by writing business statistics codes of various platforms, and when different data sources, different data formats, different data types and different statistics results are output, developers are required to independently develop the codes, so that business requirements cannot be met flexibly.
Disclosure of Invention
In view of the foregoing, an object of the present application is to provide a code generation method, an electronic device, and a storage medium, so as to solve the problem that codes need to be developed independently and cannot be used flexibly when data statistics analysis is performed on data of different service types.
Based on the above object, the present application provides a code generation method, including:
in response to receiving a code generation instruction, determining a target output node in a plurality of output nodes of a pre-created flow chart according to the code generation instruction, wherein the pre-created flow chart comprises a data source node, a plurality of data processing nodes and a plurality of output nodes corresponding to the data processing nodes one by one, the data source node configures a first execution file, each data processing node configures a second execution file, and each output node configures a third execution file;
determining an associated target data processing node according to the target output node;
and generating target codes according to the code generation instruction, the first execution file, the second execution file of the target data processing node and the third execution file of the target output node.
Optionally, the code generation instructions include a computer programming language type;
the generating the target code according to the code generating instruction, the first execution file, the second execution file of the target data processing node and the third execution file of the target output node includes:
searching code information containing the computer programming language type in the first execution file according to the computer programming language type to obtain first target code information;
searching code information containing the computer programming language type in a second execution file of the target data processing node according to the computer programming language type to obtain second target code information;
searching code information containing the computer programming language type in a third execution file of the target output node according to the computer programming language type to obtain third target code information;
and generating the target code according to the first target code information, the second target code information and the third target code information.
Optionally, the generating the object code according to the first object code information, the second object code information and the third object code information includes:
And sequencing and integrating the first target code information, the second target code information and the third target code information according to the sequence of a preset execution flow to generate the target code.
Optionally, the creating process of the flowchart includes:
creating a data source node, establishing a link between the data source node and a target database according to preset first configuration information, and generating a first execution file corresponding to the data source node;
creating at least one data processing node according to a preset execution flow, and establishing links between the data processing nodes, links between the data processing nodes and the data source nodes and links between the data processing nodes and a pre-stored code library, a local code library and an external code library according to preset second configuration information;
searching target codes matched with the data processing nodes in a pre-stored code library, a local code library and an external code library according to the second configuration information; generating a second execution file corresponding to the data processing node according to the second configuration information and the target code;
Creating a plurality of output nodes corresponding to the data processing nodes one by one, creating links between each output node and the corresponding data processing node according to preset third configuration information, and generating a third execution file corresponding to the output node;
and generating a flow chart according to the link relation among the nodes.
Optionally, the second configuration information includes a task type and a task identifier;
searching target codes for the data processing node to execute in a pre-stored code base, a local code base and an external code base according to the second configuration information, wherein the target codes comprise:
when the task type is a calculation type, searching codes containing the task identification in a local code library and/or an external code library according to the task identification, and taking the codes as the target codes;
and when the task type is a connection type, searching a code containing the identifier in a preset storage code library according to the task identifier, and taking the code as the target code.
Optionally, after generating the flowchart, the method further includes:
responding to receiving a verification instruction, and respectively connecting the data source node, the data processing node and the output node with a background verification interface;
Verifying each node based on the background configuration information database to obtain a verification result of each node;
and determining that the configuration information of the node which is failed to pass the verification is wrong in response to the verification result being that the verification is failed.
Optionally, the verifying each node based on the background configuration information database to obtain a verification result includes:
acquiring configuration information of each node;
and matching the acquired configuration information with a background configuration information database, if the matching rate reaches a preset matching rate threshold value, determining that the verification result is passed, and if the matching rate does not reach the preset matching rate threshold value, determining that the verification result is not passed.
Optionally, the method further comprises:
inputting the target code into a preset verification model to obtain a verification operation result;
comparing the verification operation result with a real result to obtain a verification result;
determining that the target code is correct in response to the verification result being completely consistent;
and in response to the verification result being incomplete, determining the target code error, and outputting an error result log.
Based on the same inventive concept, the present disclosure also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable by the processor, the processor implementing the method as described above when executing the computer program.
Based on the same inventive concept, the present disclosure also provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the method as described above.
As can be seen from the foregoing, the code generation method, the electronic device and the storage medium provided by the present application, the code generation method includes: when a code generation instruction sent by a certain output node based on a pre-created flow chart is received, determining a target output node in a plurality of output nodes in the pre-created flow chart according to the code generation instruction, wherein the pre-created flow chart comprises a data source node, a plurality of data processing nodes and a plurality of output nodes corresponding to the data processing nodes one by one, the data source node configures a first execution file, each data processing node configures a second execution file, and each output node configures a third execution file; in this way, the code can be generated based on the target output node that the user wants to generate the code. Because the first execution file, the second execution file and the third execution file are all code files, when the codes are generated, the data processing node corresponding to the target output node is found according to the target output node, and the second execution file of the target data processing node is found, so that the code file of the target data processing node is obtained. And generating a target code according to the code generation instruction, the first execution file, the second execution file of the target data processing node and the third execution file of the target output node, so that the code which the user wants to generate can be directly obtained through the code generation instruction. According to the method and the device, the target output node is determined according to the code generation instruction, then the target data processing node is found according to the target output node, the code of the target data processing node is found, and then the target code is generated according to the code of the data source node, the code of the target data processing node and the code of the target output node, namely the code of the data processing node which is required to be output is directly obtained according to the code generation instruction, so that the obtained code can be directly used when data of different service types are subjected to data statistical analysis, and secondary development is not required.
Drawings
In order to more clearly illustrate the technical solutions of the present application or related art, the drawings that are required to be used in the description of the embodiments or related art will be briefly described below, and it is apparent that the drawings in the following description are only embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort to those of ordinary skill in the art.
Fig. 1 is a schematic flow chart of a code generation method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a process of creating a flow according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a code generating device according to an embodiment of the present application;
fig. 4 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail below with reference to the accompanying drawings.
It should be noted that unless otherwise defined, technical or scientific terms used in the embodiments of the present application should be given the ordinary meaning as understood by one of ordinary skill in the art to which the present application belongs. The terms "first," "second," and the like, as used in embodiments of the present application, do not denote any order, quantity, or importance, but rather are used to distinguish one element from another. The word "comprising" or "comprises", and the like, means that elements or items preceding the word are included in the element or item listed after the word and equivalents thereof, but does not exclude other elements or items. The terms "connected" or "connected," and the like, are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "upper", "lower", "left", "right", etc. are used merely to indicate relative positional relationships, which may also be changed when the absolute position of the object to be described is changed.
Embodiments of the present application are described in detail below with reference to the accompanying drawings.
Referring to fig. 1, the present application provides a code generation method, including the steps of:
step 102, in response to receiving a code generation instruction, determining a target output node in a plurality of output nodes of a pre-created flow chart according to the code generation instruction, wherein the pre-created flow chart comprises a data source node, a plurality of data processing nodes and a plurality of output nodes corresponding to the data processing nodes one by one, the data source node configures a first execution file, each data processing node configures a second execution file, and each output node configures a third execution file.
In this step, the pre-created flowchart includes a data source node, a plurality of data processing nodes and a plurality of output nodes corresponding to the data processing nodes one by one, where the data processing nodes may be data processing nodes such as screening, reduction, conversion, aggregation statistics, sampling, SQL codes, left connection, right connection, ranking, sorting, counting, maximum value, minimum value, average value, and the like. The user can select the corresponding data processing node to generate codes according to the needs, for example, the user clicks a code generation button of the flow chart creation interface to send a code generation instruction to the control system. Illustratively, the user wants to ask for the code of the average node, then the user creates the averaged data processing node of the interface by selecting the flow chart and clicking the generate code button to send a code generation instruction to the control system. After receiving the code generation instruction, the control system determines a target output node in the plurality of output nodes according to the code generation instruction. So that a corresponding data processing node is found from the target output node.
And 104, determining an associated target data processing node according to the target output node.
In the step, after the control system receives the code generation instruction, the code generation instruction is analyzed to obtain an output identifier of a corresponding output node, a target output node is determined according to the output identifier of the output node, and a target data processing node associated with the target output node is found according to the target output node.
And 106, generating target codes according to the code generation instruction, the first execution file, the second execution file of the target data processing node and the third execution file of the target output node.
In this step, the code generation instruction includes a code generation rule, where the code generation rule may be a computer programming language type used in code generation, and the control system analyzes the code generation instruction to obtain the code generation rule, and generates the target code by using the first execution file, the second execution file of the target data processing node, and the third execution file of the target output node according to the computer programming language type.
Through steps 102-106, when a code generation instruction based on a certain node of the pre-created flowchart is received, a target output node is determined from a plurality of output nodes in the pre-created flowchart according to the code generation instruction, so that code generation can be performed according to the target output node of the code which the user wants to generate. Because the first execution file, the second execution file and the third execution file are all code files, when the codes are generated, the data processing node corresponding to the target output node is found according to the target output node, and the second execution file of the target data processing node is found, so that the code file of the target data processing node is obtained. And generating a target code according to the code generation instruction, the first execution file, the second execution file of the target data processing node and the third execution file of the target output node, so that the code which the user wants to generate can be directly obtained through the code generation instruction. The method and the device realize that codes of target data processing nodes to be output are directly obtained according to the code generation instruction, and can directly use the obtained codes without secondary development when data of different service types are subjected to data statistics analysis.
In some embodiments, the code generation instructions include a computer programming language type;
the generating the target code according to the code generating instruction, the first execution file, the second execution file of the target data processing node and the third execution file of the target output node includes:
searching code information containing the computer programming language type in the first execution file according to the computer programming language type to obtain first target code information;
searching code information containing the computer programming language type in a second execution file of the target data processing node according to the computer programming language type to obtain second target code information;
searching code information containing the computer programming language type in a third execution file of the target output node according to the computer programming language type to obtain third target code information;
and generating the target code according to the first target code information, the second target code information and the third target code information.
Specifically, in the present embodiment, exemplary types of computer programming languages include Java language and Scala language. The first execution file, the second execution file and the third execution file comprise two types of computer programming languages, namely Java language and Scala language. The Java language and the Scala language are equally divided into two files, namely, the first execution file, the second execution file and the third execution file comprise Java language execution files and Scala language execution files. According to the class computer programming language type (the example, the computer programming language type requiring code generation in the code instruction is Java language), searching code information containing the computer programming language type (Java language) in a first execution file (namely, java language execution file in the first execution file) to obtain first target code information; namely, the Java language execution file is found in the first execution file, and the code information in the Java language execution file is used as first target code information. Searching code information containing the computer programming language type (Java language) in a second execution file according to the level computer programming language type (Java language), namely, the Java language execution file in the second execution file, so as to obtain second target code information; namely, the Java language execution file is found in the second execution file, and the code information in the Java language execution file is used as second target code information. Searching code information containing the computer programming language type (Java language) in a third execution file according to the level computer programming language type (Java language), namely, the Java language execution file in the third execution file, so as to obtain third target code information; namely, the Java language execution file is found in the third execution file, and the code information in the Java language execution file is used as third target code information. And generating object code information according to the first object code information, the second object code information and the third object code information. That is, the object code information is generated from the codes in each of the Java language execution file in the first execution file, the Java language execution file in the second execution file, and the Java language execution file in the third execution file. Therefore, the corresponding codes of the computer programming language type can be obtained according to the computer programming language type, and the codes of the computer programming language type required by the user are generated, namely, the codes corresponding to the target data processing nodes are directly obtained and can be called by other systems, so that the problem that the staff need to rewrite the codes for the same calculation is avoided.
On the basis of the above embodiment, the generating the object code according to the first object code information, the second object code information, and the third object code information includes:
and sequencing and integrating the first target code information, the second target code information and the third target code information according to the sequence of a preset execution flow to generate the target code.
Specifically, the codes in each of the Java language execution file in the first execution file, the Java language execution file in the second execution file, and the Java language execution file in the third execution file are ordered and integrated in the order of a preset execution flow (the preset execution flow is the execution flow that wants to create a flowchart), and the target code is generated. Therefore, the corresponding codes of the computer programming language type can be obtained according to the computer programming language type, and the method is applicable to execution systems of different computer programming languages, so that the situation that a worker writes the codes again is avoided.
In some embodiments, as shown in fig. 2, the creation process of the flowchart includes the following steps:
Step 202, creating a data source node, establishing a link between the data source node and a target database according to preset first configuration information, and generating a first execution file corresponding to the data source node;
step 204, creating at least one data processing node according to a preset execution flow, and establishing a link between the data processing nodes, a link between the data processing node and the data source node, and a link between the data processing node and a pre-stored code library, a local code library and an external code library according to preset second configuration information;
step 206, searching the target codes matched with the data processing nodes in a pre-stored code library, a local code library and an external code library according to the second configuration information; generating a second execution file corresponding to the data processing node according to the second configuration information and the target code;
step 208, creating a plurality of output nodes corresponding to the data processing nodes one by one, creating links between each output node and the corresponding data processing node according to preset third configuration information, and generating a third execution file corresponding to the output node;
Step 210, generating a flow chart according to the link relation among the nodes.
Specifically, when creating a flow chart, creating each node according to a flow required by a user based on a flow chart creation interface, firstly creating a data source node, enabling a developer to drag the data source node to a flow chart creation area on the flow chart creation interface, popping up a code input box for the developer to input configuration information on the interface of the flow chart creation area after receiving an instruction for creating the data source node, enabling the developer to input the first configuration information to the code input box, clicking a confirmation button, enabling the control system to receive preset first configuration information, and establishing a link between the data source node and a target database according to the preset first configuration information (namely, the first task information for the control system to execute according to the first task information); the first configuration information may be input configuration information, for example, a developer inputs a link address parameter of a database to which the data source node needs to be linked, and a user name and a password set in a connection process, where the input configuration information corresponds to a condition. After the control system receives the conditions, related codes are called in a local database according to the conditions, and a first execution file corresponding to the data source node is generated according to the codes and the conditions so as to generate the codes of the data source node according to the first execution file.
Illustratively, the java code is generated as follows:
DataSourceSettings dataSourceSettings = new DataSourceSettings(url, user, password, authFiles);
DataSource dataSource = new DataSource(dataSourceSettings);
dataSource.filter(sql);
wherein url is a connection address parameter which can be resolved by a connection library of the relational database, the big data component and the graph database, user is a user name, password is a password, authFiles are authentication files, and the parameter can be optional or null.
Secondly, when creating the data processing node, creating according to a preset execution flow (flow required by a user), dragging the data processing point to a flow chart creation area on a flow chart creation interface by a developer, after receiving an instruction for creating the data processing node, popping up a code input box for the developer to input configuration information on the interface of the flow chart creation area by a control system, inputting second configuration information to the code input box by the developer, clicking a confirmation button, receiving preset second configuration information by the control system, and establishing a link between the data processing node and a link between the data processing node and a pre-stored code library, a local code library and an external code library according to the preset second configuration information (namely, the second task information is used for the control system to execute according to the second task information); the second configuration information may be configuration information such as a relationship between input data processing nodes, and the control system may call related codes in the local database after receiving the input information, where the codes may include a link statement between the data processing node and the data source node, and a link statement between the data node and a pre-stored code library, a local code library, and an external code library, and search, according to the second configuration information, a target code matching with the data processing node in the stored code library, the local code library, and the external code library, so that when the data processing node performs data processing, data and results of other data processing nodes and the data source node may be called, and each data and result is calculated according to the target code. And generating a second execution file corresponding to the output node according to the input second configuration information, related sentences of the control system call and target codes of the data processing nodes, so as to generate codes of the data processing nodes according to the second execution file.
Again, when creating output nodes, one output node is set on each data processing node. The developer pulls the output node to the flow chart creation area on the flow chart creation interface and corresponds to the data processing node, after receiving an instruction for creating the output node, the control system pops up a code input frame for the developer to input configuration information on the interface of the flow chart creation area, the developer can input third configuration information to the code input frame, after clicking a confirmation button, the control system receives preset third configuration information, and according to the preset third configuration information (namely, second task information, for the control system to execute according to the second task information), a link between the output node and the corresponding data output node is established; the third configuration information may be configuration information such as a relationship between the input data processing node and the output node, and the control system invokes a relevant code in the local database after receiving the input information, where the code may include a link statement between the output node and a corresponding data output node, so as to implement a link between the output node and each data processing node. And generating a third execution file corresponding to the output node according to the input configuration information and related sentences of the control system call so as to generate the code of the output node according to the third execution file. After the link relation of each node is established, generating a flow chart according to the link relation among the nodes. So that the user can generate the codes of the nodes to be output according to the nodes of the flow chart. Avoiding the user from redevelopment of the code again.
In some embodiments, the second configuration information includes a task type and a task identification;
searching target codes for the data processing node to execute in a pre-stored code base, a local code base and an external code base according to the second configuration information, wherein the target codes comprise:
when the task type is a calculation type, searching codes containing the task identification in a local code library and/or an external code library according to the task identification, and taking the codes as the target codes;
and when the task type is a connection type, searching a code containing the identifier in a preset storage code library according to the task identifier, and taking the code as the target code.
Specifically, the second configuration information includes a task type and a task identifier, the task type includes a calculation type and a connection type, and the calculation type includes: screening, reducing, converting, aggregating statistics, sampling, SQL codes, ranking, ordering, counting, maximizing, minimizing and averaging; the connection types include: left connection and right connection. When the task type is a calculation type, the processing node is required to perform corresponding calculation. Wherein the second configuration information may set different parameters according to the calculation type. For screening, reduction, conversion and SQL codes, the user can customize input codes to process each piece of data, and only relevant field name parameters are required to be set for aggregation statistics, left connection, right connection, ranking, sequencing, counting, maximum value calculation, minimum value calculation and average value calculation, and sampling proportion or random fixed data record number is required to be set for sampling. When the task type is a connection type, the processing node is only a connection node, and is only used for connecting the data processing node with other data processing nodes so as to realize the calculation of the other data processing nodes. When the data processing node is of a calculation type, relevant calculation codes are needed, the calculation codes are stored in a local code library and an external code library in the control system in advance, and codes containing task identifications are searched in the local code library and/or the external code library according to the task identifications and are used as target codes. When the task type is the connection type, connection of each data processing node is needed, and at this time, the connection needs to be achieved according to the calculation requirement of a user, therefore, codes input by the user are needed to be achieved, the codes input by the user are stored in a preset storage code library, and when the task type is the connection type, codes containing identification need to be searched in the preset storage code library according to the task identification, and the codes are used as target codes. Therefore, when the flow chart is created, the creation of the flow chart can be realized by inputting a small amount of codes, and the workload of a developer is saved.
The codes stored in the local code library can be codes with simpler calculation, and the codes stored in the external code library can be codes with more complex calculation degree. After the data processing node is created, the control system searches the local database for the code containing the task identifier according to the first configuration information, if the code containing the task identifier is not found, a code plug-in can be prompted to be added to a user on a flow chart creation interface, the user selects to add the code plug-in, which is equivalent to establishing connection between the data processing node and an external code library, and when the external code library is called, a class name is set in the external code library for specifying a main code class name path used by the code plug-in, for example: com.java.alg.filter; the function name is set for specifying a function name function_name used in the main code, for example: a fileip; setting parameter names and types for specifying all parameters and types of functions, which can be a plurality of parameters, wherein the parameter names are legal java language variable naming grammar, supporting java basic types, and comprising the following steps: string, integer, long, short, float, double, boolean, byte, char; setting a return value type for specifying a return value type of a function, wherein the type supports a java basic type; setting remarks for annotating and describing the code plug-ins; based on the above settings, in the settings using the function, code calls for the function will be automatically generated per node type, namely: function_name (param 1, param2, param 3).
Taking a code plug-in example as an example, how the generated code plug-in can be used is described:
a code call similar to the following will be generated for a flow node using the function:
@filterIp("192.168.1.1","192.168.1.2","/home",1698474678)
for a flow node that generates SQL code, the SQL code may filter conditions for SQL input by the user. The following code is generated:
select srcIp, dstIp, uri, time from table_uri_log where @filterIp(srcIp, dstIp, uri, time) is true。
in some embodiments, after generating the flowchart, further comprising:
responding to receiving a verification instruction, and respectively connecting the data source node, the data processing node and the output node with a background verification interface;
verifying each node based on the background configuration information database to obtain a verification result of each node;
and determining that the configuration information of the node which is failed to pass the verification is wrong in response to the verification result being that the verification is failed.
Specifically, after the flow chart is created, in order to avoid a certain node creation error, the created flow chart needs to be verified, a verification button is clicked on a flow chart creation interface to send a verification instruction to a control system, and the control system respectively connects a data source node, a data processing node and an output node with a background verification interface after receiving the verification instruction; the background verification interface is linked with the background configuration information database; verifying each node based on the background configuration information database to obtain a verification result of each node; when the verification result is not passed, determining that the configuration information of the nodes which are not passed by the verification is wrong, and enabling a developer to find the corresponding nodes according to the verification result and modify the configuration information until the verification result is passed, so that the developer can conveniently verify the flow chart without repeatedly confirming codes. And the workload of the developer is saved.
In some embodiments, the verifying each node based on the background configuration information database to obtain a verification result includes:
acquiring configuration information of each node;
and matching the acquired configuration information with a background configuration information database, if the matching rate reaches a preset matching rate threshold value, determining that the verification result is passed, and if the matching rate does not reach the preset matching rate threshold value, determining that the verification result is not passed.
Specifically, the background configuration information database stores pre-stored configuration information of each node; when each node is verified, firstly, configuration information of each node is obtained, the configuration information is matched with pre-stored configuration information of each node, the matching rate reaches a preset matching rate (for example, 95%), the verification result is determined to be passed, and if the matching rate does not reach a preset matching rate threshold, the verification result is determined to not pass. Therefore, by verifying the matching information, the normal configuration information of each node can be ensured, the correct operation of the flow chart is ensured, and an accurate code is generated.
In some embodiments, the method further comprises:
inputting the target code into a preset verification model to obtain a verification operation result;
Comparing the verification operation result with a real result to obtain a verification result;
determining that the target code is correct in response to the verification result being completely consistent;
and in response to the verification result being incomplete, determining the target code error, and outputting an error result log.
Specifically, the preset verification model may be a model pre-stored in the control system for running codes, the preset verification model runs according to the input target codes to obtain verification running results, the control system compares the verification running results with real results, and if the comparison results are completely consistent, the target codes are determined to be correct; if the verification results are not completely consistent, for example, a numerical error exists, determining that the target point code is wrong, and outputting a wrong result record log for a developer to check, so that the reason of the target code error can be found according to the wrong result record log.
It should be noted that, the method of the embodiments of the present application may be performed by a single device, for example, a computer or a server. The method of the embodiment can also be applied to a distributed scene, and is completed by mutually matching a plurality of devices. In the case of such a distributed scenario, one of the devices may perform only one or more steps of the methods of embodiments of the present application, and the devices may interact with each other to complete the methods.
It should be noted that some embodiments of the present application are described above. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments described above and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
Based on the same inventive concept, the application also provides a code generating device corresponding to the method of any embodiment.
Referring to fig. 3, the code generating apparatus includes:
a first determining module 302, configured to determine a target output node from a plurality of output nodes of a pre-created flowchart according to a code generation instruction in response to receiving the code generation instruction, where the pre-created flowchart includes a data source node, a plurality of data processing nodes, and a plurality of output nodes corresponding to the plurality of data processing nodes one to one, the data source node configures a first execution file, each of the data processing nodes configures a second execution file, and each of the output nodes configures a third execution file;
A second determining module 304 configured to determine an associated target data processing node from the target output node;
the generating module 306 is configured to generate a target code according to the code generating instruction, the first execution file, the second execution file of the target data processing node, and the third execution file of the target output node.
For convenience of description, the above devices are described as being functionally divided into various modules, respectively. Of course, the functions of each module may be implemented in the same piece or pieces of software and/or hardware when implementing the present application.
The device of the foregoing embodiment is configured to implement a code generation method corresponding to any one of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiment, which is not described herein.
Based on the same inventive concept, the application also provides an electronic device corresponding to the method of any embodiment, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes the code generation method of any embodiment when executing the program.
Fig. 4 shows a more specific hardware architecture of an electronic device according to this embodiment, where the device may include: a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050. Wherein processor 1010, memory 1020, input/output interface 1030, and communication interface 1040 implement communication connections therebetween within the device via a bus 1050.
The processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit ), microprocessor, application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc. for executing relevant programs to implement the technical solutions provided in the embodiments of the present disclosure.
The Memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory ), static storage device, dynamic storage device, or the like. Memory 1020 may store an operating system and other application programs, and when the embodiments of the present specification are implemented in software or firmware, the associated program code is stored in memory 1020 and executed by processor 1010.
The input/output interface 1030 is used to connect with an input/output module for inputting and outputting information. The input/output module may be configured as a component in a device (not shown) or may be external to the device to provide corresponding functionality. Wherein the input devices may include a keyboard, mouse, touch screen, microphone, various types of sensors, etc., and the output devices may include a display, speaker, vibrator, indicator lights, etc.
Communication interface 1040 is used to connect communication modules (not shown) to enable communication interactions of the present device with other devices. The communication module may implement communication through a wired manner (such as USB, network cable, etc.), or may implement communication through a wireless manner (such as mobile network, WIFI, bluetooth, etc.).
Bus 1050 includes a path for transferring information between components of the device (e.g., processor 1010, memory 1020, input/output interface 1030, and communication interface 1040).
It should be noted that although the above-described device only shows processor 1010, memory 1020, input/output interface 1030, communication interface 1040, and bus 1050, in an implementation, the device may include other components necessary to achieve proper operation. Furthermore, it will be understood by those skilled in the art that the above-described apparatus may include only the components necessary to implement the embodiments of the present description, and not all the components shown in the drawings.
The electronic device of the foregoing embodiment is configured to implement a code generation method corresponding to any one of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiment, which is not described herein.
Based on the same inventive concept, corresponding to any of the above-described embodiments of the method, the present application further provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform a code generation method as described in any of the above-described embodiments.
The computer readable media of the present embodiments, including both permanent and non-permanent, removable and non-removable media, may be used to implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device.
The storage medium of the foregoing embodiments stores computer instructions for causing the computer to perform a code generating method as described in any of the foregoing embodiments, and has the advantages of the corresponding method embodiments, which are not described herein.
It will be appreciated that before using the technical solutions of the various embodiments in the disclosure, the user may be informed of the type of personal information involved, the range of use, the use scenario, etc. in an appropriate manner, and obtain the authorization of the user.
For example, in response to receiving an active request from a user, a prompt is sent to the user to explicitly prompt the user that the operation it is requesting to perform will require personal information to be obtained and used with the user. Therefore, the user can select whether to provide personal information to the software or hardware such as the electronic equipment, the application program, the server or the storage medium for executing the operation of the technical scheme according to the prompt information.
As an alternative but non-limiting implementation, in response to receiving an active request from a user, the manner in which the prompt information is sent to the user may be, for example, a popup, in which the prompt information may be presented in a text manner. In addition, a selection control for the user to select to provide personal information to the electronic device in a 'consent' or 'disagreement' manner can be carried in the popup window.
It will be appreciated that the above-described notification and user authorization process is merely illustrative, and not limiting of the implementations of the present disclosure, and that other ways of satisfying relevant legal regulations may be applied to the implementations of the present disclosure.
Those of ordinary skill in the art will appreciate that: the discussion of any of the embodiments above is merely exemplary and is not intended to suggest that the scope of the application (including the claims) is limited to these examples; the technical features of the above embodiments or in the different embodiments may also be combined within the idea of the present application, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of brevity.
Additionally, well-known power/ground connections to Integrated Circuit (IC) chips and other components may or may not be shown within the provided figures, in order to simplify the illustration and discussion, and so as not to obscure the embodiments of the present application. Furthermore, the devices may be shown in block diagram form in order to avoid obscuring the embodiments of the present application, and this also takes into account the fact that specifics with respect to implementation of such block diagram devices are highly dependent upon the platform on which the embodiments of the present application are to be implemented (i.e., such specifics should be well within purview of one skilled in the art). Where specific details (e.g., circuits) are set forth in order to describe example embodiments of the application, it should be apparent to one skilled in the art that embodiments of the application can be practiced without, or with variation of, these specific details. Accordingly, the description is to be regarded as illustrative in nature and not as restrictive.
While the present application has been described in conjunction with specific embodiments thereof, many alternatives, modifications, and variations of those embodiments will be apparent to those skilled in the art in light of the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
The present embodiments are intended to embrace all such alternatives, modifications and variances which fall within the broad scope of the appended claims. Accordingly, any omissions, modifications, equivalents, improvements and/or the like which are within the spirit and principles of the embodiments are intended to be included within the scope of the present application.
Claims (10)
1. A code generation method, comprising:
in response to receiving a code generation instruction, determining a target output node in a plurality of output nodes of a pre-created flow chart according to the code generation instruction, wherein the pre-created flow chart comprises a data source node, a plurality of data processing nodes and a plurality of output nodes corresponding to the data processing nodes one by one, the data source node configures a first execution file, each data processing node configures a second execution file, and each output node configures a third execution file;
Determining an associated target data processing node according to the target output node;
and generating target codes according to the code generation instruction, the first execution file, the second execution file of the target data processing node and the third execution file of the target output node.
2. The method of claim 1, wherein the code generation instructions comprise a computer programming language type;
the generating the target code according to the code generating instruction, the first execution file, the second execution file of the target data processing node and the third execution file of the target output node includes:
searching code information containing the computer programming language type in the first execution file according to the computer programming language type to obtain first target code information;
searching code information containing the computer programming language type in a second execution file of the target data processing node according to the computer programming language type to obtain second target code information;
searching code information containing the computer programming language type in a third execution file of the target output node according to the computer programming language type to obtain third target code information;
And generating the target code according to the first target code information, the second target code information and the third target code information.
3. The method of claim 2, wherein the generating the object code from the first object code information, the second object code information, and the third object code information comprises:
and sequencing and integrating the first target code information, the second target code information and the third target code information according to the sequence of a preset execution flow to generate the target code.
4. The method of claim 1, wherein the creating of the flowchart comprises:
creating a data source node, establishing a link between the data source node and a target database according to preset first configuration information, and generating a first execution file corresponding to the data source node;
creating at least one data processing node according to a preset execution flow, and establishing links between the data processing nodes, links between the data processing nodes and the data source nodes and links between the data processing nodes and a pre-stored code library, a local code library and an external code library according to preset second configuration information;
Searching target codes matched with the data processing nodes in a pre-stored code library, a local code library and an external code library according to the second configuration information; generating a second execution file corresponding to the data processing node according to the second configuration information and the target code;
creating a plurality of output nodes corresponding to the data processing nodes one by one, creating links between each output node and the corresponding data processing node according to preset third configuration information, and generating a third execution file corresponding to the output node;
and generating a flow chart according to the link relation among the nodes.
5. The method of claim 4, wherein the second configuration information includes a task type and a task identification;
searching target codes for the data processing node to execute in a pre-stored code base, a local code base and an external code base according to the second configuration information, wherein the target codes comprise:
when the task type is a calculation type, searching codes containing the task identification in a local code library and/or an external code library according to the task identification, and taking the codes as the target codes;
And when the task type is a connection type, searching a code containing the identifier in a preset storage code library according to the task identifier, and taking the code as the target code.
6. The method of claim 4, further comprising, after generating the flow chart:
responding to receiving a verification instruction, and respectively connecting the data source node, the data processing node and the output node with a background verification interface;
verifying each node based on the background configuration information database to obtain a verification result of each node;
and determining that the configuration information of the node which is failed to pass the verification is wrong in response to the verification result being that the verification is failed.
7. The method of claim 6, wherein verifying each node based on the background configuration information database, to obtain a verification result, comprises:
acquiring configuration information of each node;
and matching the acquired configuration information with a background configuration information database, if the matching rate reaches a preset matching rate threshold value, determining that the verification result is passed, and if the matching rate does not reach the preset matching rate threshold value, determining that the verification result is not passed.
8. The method according to claim 1, wherein the method further comprises:
inputting the target code into a preset verification model to obtain a verification operation result;
comparing the verification operation result with a real result to obtain a verification result;
determining that the target code is correct in response to the verification result being completely consistent;
and in response to the verification result being incomplete, determining the target code error, and outputting an error result log.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any of claims 1 to 8 when the program is executed by the processor.
10. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method of any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410047518.4A CN117555533B (en) | 2024-01-12 | 2024-01-12 | Code generation method, electronic device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410047518.4A CN117555533B (en) | 2024-01-12 | 2024-01-12 | Code generation method, electronic device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN117555533A true CN117555533A (en) | 2024-02-13 |
CN117555533B CN117555533B (en) | 2024-04-12 |
Family
ID=89817159
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410047518.4A Active CN117555533B (en) | 2024-01-12 | 2024-01-12 | Code generation method, electronic device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117555533B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070233655A1 (en) * | 2006-04-03 | 2007-10-04 | National Instruments Corporation | Graphical program representation of queries |
CN109189383A (en) * | 2018-08-28 | 2019-01-11 | 厦门海迈科技股份有限公司 | The generation method of code file, calculates equipment and storage medium at device |
CN111399827A (en) * | 2020-03-09 | 2020-07-10 | 北京国信会视科技有限公司 | Descriptive object code automatic generation method for sensor data processing |
CN112199086A (en) * | 2020-09-18 | 2021-01-08 | 北京达佳互联信息技术有限公司 | Automatic programming control system, method, device, electronic device and storage medium |
CN112947914A (en) * | 2021-03-31 | 2021-06-11 | 中国建设银行股份有限公司 | Code generation method and device based on model, computer equipment and medium |
CN114118811A (en) * | 2021-11-29 | 2022-03-01 | 深圳壹账通智能科技有限公司 | Service code generation method, service code execution method, service code generation device, service code execution equipment and storage medium |
-
2024
- 2024-01-12 CN CN202410047518.4A patent/CN117555533B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20070233655A1 (en) * | 2006-04-03 | 2007-10-04 | National Instruments Corporation | Graphical program representation of queries |
CN109189383A (en) * | 2018-08-28 | 2019-01-11 | 厦门海迈科技股份有限公司 | The generation method of code file, calculates equipment and storage medium at device |
CN111399827A (en) * | 2020-03-09 | 2020-07-10 | 北京国信会视科技有限公司 | Descriptive object code automatic generation method for sensor data processing |
CN112199086A (en) * | 2020-09-18 | 2021-01-08 | 北京达佳互联信息技术有限公司 | Automatic programming control system, method, device, electronic device and storage medium |
CN112947914A (en) * | 2021-03-31 | 2021-06-11 | 中国建设银行股份有限公司 | Code generation method and device based on model, computer equipment and medium |
CN114118811A (en) * | 2021-11-29 | 2022-03-01 | 深圳壹账通智能科技有限公司 | Service code generation method, service code execution method, service code generation device, service code execution equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN117555533B (en) | 2024-04-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108415832B (en) | Interface automation test method, device, equipment and storage medium | |
CA2915619C (en) | Method and apparatus for customized software development kit (sdk) generation | |
US9811605B2 (en) | Methods, apparatuses and computer program products for automated learning of data models | |
US11093222B2 (en) | Generating interfaces from annotated entity definitions for developing applications | |
US10671613B2 (en) | Data source binding using an OData model | |
CN111506579B (en) | Method, program and equipment for generating intelligent contract code | |
US9582270B2 (en) | Effective feature location in large legacy systems | |
CN111581920A (en) | Document conversion method, device, equipment and computer storage medium | |
CN111260336B (en) | Service checking method, device and equipment based on rule engine | |
CN110647471A (en) | Interface test case generation method, electronic device and storage medium | |
CN113778897B (en) | Automatic test method, device and equipment for interface and storage medium | |
CN111240955A (en) | Automatic testing method and device for Http interface, storage medium and electronic device | |
CN110888794B (en) | Interface testing method and device | |
CN114579452A (en) | Interface influence detection method and related equipment | |
CN111026670A (en) | Test case generation method, test case generation device, and storage medium | |
CN115599359A (en) | Code generation method, device, equipment and medium | |
CN115599386A (en) | Code generation method, device, equipment and storage medium | |
CN113535141A (en) | Database operation code generation method and device | |
EP3438818A1 (en) | Method and device for compiling computer language | |
CN112988600A (en) | Service scene testing method and device, electronic equipment and storage medium | |
CN117555533B (en) | Code generation method, electronic device and storage medium | |
CN113536748A (en) | Method and device for generating chart data | |
CN116578282A (en) | Code generation method, device, electronic equipment and medium | |
US20160070564A1 (en) | Dynamically schematized log messages for software applications | |
US20150121351A1 (en) | Generating configuration data based on application definitions |
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 |