CN109992259B - Function dynamic creating method and device and electronic equipment - Google Patents

Function dynamic creating method and device and electronic equipment Download PDF

Info

Publication number
CN109992259B
CN109992259B CN201910300273.0A CN201910300273A CN109992259B CN 109992259 B CN109992259 B CN 109992259B CN 201910300273 A CN201910300273 A CN 201910300273A CN 109992259 B CN109992259 B CN 109992259B
Authority
CN
China
Prior art keywords
function
statement
java
grammar
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.)
Active
Application number
CN201910300273.0A
Other languages
Chinese (zh)
Other versions
CN109992259A (en
Inventor
张永飞
易祖建
杨尧
王诗强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Sefon Software Co Ltd
Original Assignee
Chengdu Sefon Software 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 Chengdu Sefon Software Co Ltd filed Critical Chengdu Sefon Software Co Ltd
Priority to CN201910300273.0A priority Critical patent/CN109992259B/en
Publication of CN109992259A publication Critical patent/CN109992259A/en
Application granted granted Critical
Publication of CN109992259B publication Critical patent/CN109992259B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

When the obtained SQL statement of the storage process comprises a function creation statement and a storage process creation statement, analyzing the function creation statement and the storage process creation statement respectively to generate a corresponding first java file and a corresponding second java file, compiling the function creation statement and the storage process creation statement respectively to obtain a first executable file and a second executable file, and finally loading the first executable file and the second executable file into a memory. Therefore, the self-defined function can be dynamically created in the process of creating and storing, the calling of the self-defined function in the subsequent storing process is facilitated, and the self-defined function and the storing process of java can support the use of cross-platforms based on the universality of java codes.

Description

Function dynamic creating method and device and electronic equipment
Technical Field
The application relates to the technical field of databases, in particular to a method and a device for dynamically creating a function and electronic equipment.
Background
In a traditional relational database, a database self-defining function and a storage process play an important role, are very commonly used and are indispensable capacity of database software. Each function of the traditional database creation and storage process can only be independently carried out, and if a user-defined function needs to be called in the storage process, the function needs to be created and compiled to be used. The self-defined function can not be dynamically established in the execution of the storage process, and the flexibility is limited to a certain extent.
Disclosure of Invention
In view of the foregoing, an object of the present application is to provide a method, an apparatus and an electronic device for dynamically creating a function to improve the above problem.
The embodiment of the application provides a method for dynamically creating a function, which comprises the following steps:
acquiring SQL sentences of a stored process, wherein the SQL sentences comprise function creation sentences and stored process creation sentences;
analyzing the function creating statement and the storage process creating statement to obtain a first java file corresponding to the function creating statement and a second java file corresponding to the storage process creating statement;
compiling the first java file to generate a first executable file, and compiling the second java file to generate a second executable file;
and loading the first executable file and the second executable file into a memory.
Optionally, the method further comprises:
and associating and saving the function creation statement and the first executable file, and associating and saving the stored process creation statement and the second executable file.
Optionally, the step of analyzing the function creation statement and the stored procedure creation statement to obtain a first java file corresponding to the function creation statement and a second java file corresponding to the stored procedure creation statement includes:
analyzing the function creating statement by using a grammar analyzing tool according to a first preset grammar rule to obtain a first java file corresponding to the function creating statement;
and analyzing the stored process creating statement by using the grammar analyzing tool based on a second preset grammar rule to obtain a second java file corresponding to the stored process creating statement.
Optionally, the step of analyzing the function creation statement by using a grammar analysis tool according to a first preset grammar rule to obtain a first java file corresponding to the function creation statement includes:
analyzing the grammar of the function creation statement by using a grammar analysis tool according to a first preset grammar rule to generate a grammar tree, wherein the grammar tree comprises a plurality of nodes;
reading node information of each node contained in the syntax tree, and obtaining attribute information of the syntax tree according to the node information of each node;
and converting the function creating statement into a first java file according to the attribute information.
Optionally, the attribute information includes a function name, a parameter list, and an operation expression, and the step of converting the function creation statement into a first java file according to the attribute information includes:
converting the function name into a java file name;
generating a java code module according to the parameter list;
converting the operational expression into a java class expression;
writing the generated code module and the java class expression into a pre-generated java file, and naming the java file by using the java class file name to obtain a first java file corresponding to the function creation statement.
Optionally, the first preset grammar rule includes a lexical analysis rule and a grammar analysis rule, and the step of generating a grammar tree by analyzing the grammar of the function creation statement by using a grammar analysis tool according to the first preset grammar rule includes:
performing lexical analysis on the function creating statement by using the lexical analysis rule and the grammar analysis tool to obtain a lexical analysis result of the function creating statement;
and analyzing the lexical analysis result based on the grammar analysis rule and the grammar analysis tool to obtain a grammar tree corresponding to the function creation statement.
Optionally, the step of loading the first executable file and the second executable file into the memory includes:
acquiring a function running instance in the first executable file, and registering the function running instance in a function support list configured in advance in a memory;
and acquiring a storage process running instance in the second executable file, and registering the storage process running instance in a pre-configured storage process list in a memory.
Another embodiment of the present application provides a function dynamic creation apparatus, including:
the acquisition module is used for acquiring SQL sentences of the stored procedures, wherein the SQL sentences comprise function creation sentences and stored procedure creation sentences;
the analysis module is used for analyzing the function creation statement and the storage process creation statement to obtain a first java file corresponding to the function creation statement and a second java file corresponding to the storage process creation statement;
the compiling module is used for compiling the first java file to generate a first executable file and compiling the second java file to generate a second executable file;
and the loading module is used for loading the first executable file and the second executable file into the memory.
Another embodiment of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the method described above when executing the computer program.
Another embodiment of the present application provides a readable storage medium, on which a computer program is stored, which, when being executed by a processor, performs the above-mentioned method.
According to the method, the device and the electronic equipment for dynamically creating the function, when the obtained SQL sentence of the storage process comprises the function creating sentence and the storage process creating sentence, the function creating sentence and the storage process creating sentence are analyzed respectively to generate the corresponding first java file and second java file, the function creating sentence and the storage process creating sentence are compiled respectively to obtain the first executable file and the second executable file, and finally the first executable file and the second executable file are loaded into the memory. Therefore, the self-defined function can be dynamically created in the process of creating and storing, the calling of the self-defined function in the subsequent storing process is facilitated, and the self-defined function and the storing process of java can support the use of cross-platforms based on the universality of java codes.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 is a schematic structural block diagram of an electronic device provided in an embodiment of the present application.
Fig. 2 is a flowchart of a method for dynamically creating a function according to an embodiment of the present application.
Fig. 3 is a flow chart of sub-steps included in step 220 of fig. 2.
Fig. 4 is a flowchart of the sub-steps involved in step 240 of fig. 2.
Fig. 5 is a functional block diagram of a function dynamic creation apparatus according to an embodiment of the present application.
Icon: 10-an electronic device; 110-a processor; 120-a memory; 130-a memory controller; 140-means for dynamic creation of functions; 141-an acquisition module; 142-a parsing module; 143-a compilation module; 144-load module.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present application without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
Fig. 1 is a schematic block diagram of an electronic device 10 according to a preferred embodiment of the present application. As shown in fig. 1, the electronic device 10 includes a function dynamic creation apparatus 140, a memory 120, a storage controller 130, and a processor 110. These components communicate with each other via one or more communication buses/signal lines.
The memory 120 may be used to store software programs and modules, such as corresponding program instructions/modules in the function dynamic creation apparatus 140 in the embodiment of the present application, and the processor 110 executes various functional applications and data processing, such as the function dynamic creation method provided in the embodiment of the present application, by executing the software programs and modules stored in the memory 120.
The Memory 120 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like. Access to the memory 120 by the processor 110, and possibly other components, may be under the control of a memory controller 130.
The processor 110 may be an integrated circuit chip having signal processing capabilities. The Processor 110 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also as Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), application-specific programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and the like, that may implement or perform the methods, steps, and logic blocks disclosed in embodiments of the present application. A general purpose processor may be a microprocessor or the processor 110 may be any conventional processor or the like.
In the embodiment of the present application, the electronic device 10 may be a server, a Personal Computer (PC), a tablet computer, or the like.
It will be appreciated that the configuration shown in FIG. 1 is merely illustrative and that electronic device 10 may include more or fewer components than shown in FIG. 1 or may have a different configuration than shown in FIG. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
With reference to fig. 2, an embodiment of the present application further provides a function dynamic creation method applicable to the electronic device 10. Wherein the method steps defined by the method-related flow may be implemented by the processor 110. The specific process shown in fig. 2 will be described in detail below.
Step 210, obtaining an SQL statement of a stored procedure, where the SQL statement includes a function creation statement and a stored procedure creation statement.
Step 220, analyzing the function creating statement and the storage process creating statement to obtain a first java file corresponding to the function creating statement and a second java file corresponding to the storage process creating statement.
In this embodiment, an SQL statement of a stored procedure input by a user into the electronic device 10 is received, where the SQL statement includes a stored procedure creating statement, and if creation of a custom function is required while creating the stored procedure, the input SQL statement also includes a function creating statement. Wherein, the SQL statement input by the user can support SQL99 standard syntax.
Generally, the function realized by the stored procedure is more complex, and the realization function of the custom function is more targeted. The stored procedures are powerful and can perform a series of database operations including modifying tables, whereas custom functions cannot be used to perform a set of operations that modify the state of the global database. And for stored procedures it may return parameters such as record sets. Whereas custom functions can only return values or table objects. The custom function can only RETURN one variable, the storage process can RETURN a plurality of variables, the storage process does not need to RETURN the type when declaring, the custom function needs to describe the RETURN type when declaring, and a function body needs to contain an effective RETURN statement.
In addition, non-deterministic functions may be used in the storage process, while built-in non-deterministic functions are not allowed in the custom functions. In addition, the stored procedures are typically executed as a separate part, while custom functions may be invoked as part of the query statement.
In this embodiment, the received function creation statement and the storage process creation statement are respectively analyzed to obtain a first java file corresponding to the function creation statement and a second java file corresponding to the storage process creation statement. Optionally, a first preset grammar rule applicable to the custom function parsing and a second preset grammar rule applicable to the stored procedure may be preset. Referring to fig. 3, the parsing of the function creation statement and the storage procedure creation statement may be performed by the following steps:
step 221, analyzing the function creating statement by using a grammar analyzing tool according to a first preset grammar rule to obtain a first java file corresponding to the function creating statement.
Step 222, analyzing the stored procedure creating statement by using the grammar analyzing tool based on a second preset grammar rule to obtain a second java file corresponding to the stored procedure creating statement.
Optionally, the function creation statement and the storage process creation statement are parsed by a grammar parsing tool according to a first preset grammar rule and a second preset grammar rule which are preset respectively, so as to obtain a corresponding first java file and a corresponding second java file respectively. In this embodiment, the grammar parsing tool may be lexical and grammatical parsing tools in lex and yacc systems, or may be a grammar parsing tool based on Flex and Bison.
In this embodiment, the syntax of the function creation statement may be parsed by a grammar parsing tool according to a first preset grammar rule to generate a grammar tree. Wherein the generated syntax tree includes a plurality of nodes. The attribute information of the syntax tree can be obtained according to the node information of each node by reading the node information of each node included in the syntax tree. And converting the function creating statement into a first java file according to the obtained attribute information.
And when the sentence is created in the storage process, the grammar of the sentence created in the storage process can be analyzed by utilizing a grammar analysis tool by utilizing a second preset grammar rule to generate a grammar tree of the storage process. And reading the node information of each node of the syntax tree, and obtaining the attribute of the syntax tree according to the obtained node information of each node. And finally, converting the storage process creation statement into a second java file according to the obtained attribute information.
Optionally, in this embodiment, the first preset grammar rule includes a lexical analysis rule and a grammar analysis rule, and when the function creation statement is analyzed by using the first preset grammar rule, the following process may be performed:
and carrying out lexical analysis on the function creation statement by using the lexical analysis rule and the grammar analysis tool to obtain a lexical analysis result of the function creation statement. And analyzing the lexical analysis result based on the grammar analysis rule and the grammar analysis tool to obtain a grammar tree corresponding to the function creation statement.
Similarly, the second preset grammar rule also includes a lexical analysis rule and a grammatical analysis rule, and similarly, the lexical analysis rule and the grammar analysis tool included in the second preset grammar rule are used for performing lexical analysis on the stored procedure creating statement to obtain a lexical analysis result of the stored procedure creating statement. And analyzing the lexical analysis result based on the grammar analysis rule and the grammar analysis tool contained in the second preset grammar rule to obtain a grammar tree corresponding to the created sentence in the storage process.
In this embodiment, the attribute information of the syntax tree includes a function name, a parameter list, and an operation expression, and when the function creation statement is converted into the first java file according to the attribute information, the following process may be performed:
as can be seen from the above, the syntax tree is generated according to the function creation statement, and the function name in the attribute information of the syntax tree is the function name of the function creation statement based on the SQL statement. The function name may be converted to a java class file name. And generating a java class code module, namely a method code in the java class, according to the parameter list in the attribute information of the syntax tree. And converting the operation expression in the attribute information of the syntax tree into a java class expression. And finally, writing the generated code module and the java class expression into a pre-generated java file corresponding to the self-defined function, and naming the java file by using the java class file name to obtain a first java file corresponding to the function creation statement.
Similar to the above manner, on the basis of obtaining the syntax tree corresponding to the storage process creation statement, the attribute information of the syntax tree is obtained. Similarly, the attribute information of the syntax tree corresponding to the stored procedure creating statement includes a function name, which is the function name of the stored procedure creating statement based on the SQL statement. In addition, the attribute information of the syntax tree further includes a parameter list and an operation expression. The function name of the stored procedure creation statement may be converted to a java class file name. And generating a java code module according to the parameter list, and converting the operation expression into a method code in the java class. And finally, writing the generated code module and the java class expression into a java file which is established in advance and corresponds to the storage process, naming the file by using the obtained java class file name, and obtaining a second java file corresponding to the storage process creation statement.
Step 230, compiling the first java file to generate a first executable file, and compiling the second java file to generate a second executable file.
Step 240, loading the first executable file and the second executable file into a memory.
In this embodiment, in order to facilitate subsequent fast and direct calling of the corresponding file, the first java file and the second java file may be compiled to obtain a first executable file and a second executable file, and the first executable file and the second executable file are loaded into the memory. Thus, the call can be directly made subsequently.
Optionally, referring to fig. 4, the first executable file and the second executable file may be loaded into the memory by:
step 241, obtaining a function running instance in the first executable file, and registering the function running instance in a function support list configured in advance in a memory.
Step 242, obtaining the storage process running instance in the second executable file, and registering the storage process running instance in a storage process list configured in advance in the memory.
In this embodiment, a function support list and a storage procedure list are pre-established and stored in the internal storage device of the electronic device 10. After the first executable file is obtained through compiling, the function running instance in the first executable file can be obtained, and the obtained function running instance is added into a pre-configured function support list. Similarly, after the second executable file is obtained through compiling, the stored process running instance in the second executable file is obtained, and the stored process running instance is added to a pre-configured stored process list.
Further, for the reusability of the code and the subsequent quick modification of the corresponding code, the method for dynamically creating the function provided by the embodiment further includes the following steps:
and associating and saving the function creation statement with the first executable file, and associating and saving the stored procedure creation statement with the second executable file. Therefore, the incidence relation between the function creation statement and the first executable file is established, and when the first executable file needs to be modified subsequently, the data source of the SQL statement can be quickly found, so that the modification operation of the data is facilitated. Similarly, the incidence relation between the storage process creation statement and the second executable file is established, and when the second executable file needs to be modified, the SQL statement of the corresponding storage process can be quickly found out, so that the modification operation is realized.
In this embodiment, the function creation statement is associated with the first executable file and then persisted, and the storage process creation statement is associated with the second executable file and then persisted. After the current program exits, data in the program can still be reserved for the program to use when the program operates again by adopting a persistent storage mode. The specific way of persistent saving may be to save in a file, a database, or a save disk.
The dynamic function creating scheme provided by the embodiment realizes conversion of the SQL statements created in the function creating and storing process into java codes, so that the unification of the code types of the user-defined function and the storing process is realized. And dynamically compiling the converted java code, and registering the compiled function running instance and the storage process running instance in a memory, so that a user can use the storage process in the big data conveniently and the capability of calling the function in the subsequent storage process is supported. In addition, the java class is relatively universal to different systems, so that the cross-platform use of the custom function and the storage process of the java class is supported.
Referring to fig. 5, another embodiment of the present application further provides a function dynamic creation apparatus 140 applied to the electronic device 10. The dynamic function creating device 140 includes an obtaining module 141, an analyzing module 142, a compiling module 143, and a loading module 144.
The obtaining module 141 is configured to obtain an SQL statement of a stored procedure, where the SQL statement includes a function creation statement and a stored procedure creation statement. Specifically, the obtaining module 141 may be configured to perform step 210 shown in fig. 2, and a specific operation method may refer to a detailed description of step 210.
An analyzing module 142, configured to analyze the function creating statement and the storage process creating statement to obtain a first java file corresponding to the function creating statement and a second java file corresponding to the storage process creating statement. Specifically, the parsing module 142 may be configured to execute step 220 shown in fig. 2, and the detailed description of step 220 may be referred to for a specific operation method.
And the compiling module 143 is configured to compile the first java file to generate a first executable file, and compile the second java file to generate a second executable file. Specifically, the compiling module 143 may be configured to execute step 230 shown in fig. 2, and the detailed description of step 230 may be referred to for a specific operation method.
A loading module 144, configured to load the first executable file and the second executable file into a memory. Specifically, the loading module 144 may be configured to execute step 240 shown in fig. 2, and a specific operation method may refer to a detailed description of step 240.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working process of the apparatus described above may refer to the corresponding process in the foregoing method, and will not be described in too much detail herein.
Embodiments of the present application further provide a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by the processor 110, can implement the above function dynamic creation method.
To sum up, according to the method, the apparatus, and the electronic device 10 for dynamically creating a function provided in the embodiments of the present application, when an obtained SQL statement of a storage process includes a function creation statement and a storage process creation statement, the function creation statement and the storage process creation statement are respectively analyzed to generate a corresponding first java file and a corresponding second java file, and then the function creation statement and the storage process creation statement are respectively compiled to obtain a first executable file and a second executable file, and the first executable file and the second executable file are loaded into a memory. Therefore, the self-defined function can be dynamically created in the process of creating and storing, the calling of the self-defined function in the subsequent storing process is facilitated, and the self-defined function and the storing process of java can support the use of cross-platforms based on the universality of java codes.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus 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, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for dynamically creating a function, the method comprising:
acquiring SQL sentences of a stored process, wherein the SQL sentences comprise function creation sentences and stored process creation sentences;
analyzing the function creating statement and the storage process creating statement to obtain a first java file corresponding to the function creating statement and a second java file corresponding to the storage process creating statement;
compiling the first java file to generate a first executable file, and compiling the second java file to generate a second executable file;
and loading the first executable file and the second executable file into a memory.
2. The method of dynamic function creation as claimed in claim 1, further comprising:
and associating and saving the function creation statement and the first executable file, and associating and saving the stored process creation statement and the second executable file.
3. The method according to claim 1, wherein the step of parsing the function creation statement and the stored procedure creation statement to obtain a first java file corresponding to the function creation statement and a second java file corresponding to the stored procedure creation statement comprises:
analyzing the function creating statement by using a grammar analyzing tool according to a first preset grammar rule to obtain a first java file corresponding to the function creating statement;
and analyzing the stored process creating statement by using the grammar analyzing tool based on a second preset grammar rule to obtain a second java file corresponding to the stored process creating statement.
4. The method for dynamically creating a function according to claim 3, wherein the step of analyzing the function creation statement by using a grammar analysis tool according to a first preset grammar rule to obtain a first java file corresponding to the function creation statement comprises:
analyzing the grammar of the function creation statement by using a grammar analysis tool according to a first preset grammar rule to generate a grammar tree, wherein the grammar tree comprises a plurality of nodes;
reading node information of each node contained in the syntax tree, and obtaining attribute information of the syntax tree according to the node information of each node;
and converting the function creating statement into a first java file according to the attribute information.
5. The method of claim 4, wherein the attribute information includes a function name, a parameter list, and an operation expression, and the step of converting the function creation statement into the first java file according to the attribute information includes:
converting the function name into a java file name;
generating a java code module according to the parameter list;
converting the operational expression into a java class expression;
writing the generated code module and the java class expression into a pre-generated java file, and naming the java file by using the java class file name to obtain a first java file corresponding to the function creation statement.
6. The method for dynamically creating a function according to claim 4, wherein the first preset grammar rule includes a lexical analysis rule and a grammar analysis rule, and the step of generating a grammar tree by analyzing the grammar of the function creation sentence by using a grammar analysis tool according to the first preset grammar rule includes:
performing lexical analysis on the function creating statement by using the lexical analysis rule and the grammar analysis tool to obtain a lexical analysis result of the function creating statement;
and analyzing the lexical analysis result based on the grammar analysis rule and the grammar analysis tool to obtain a grammar tree corresponding to the function creation statement.
7. The method for dynamically creating a function according to claim 1, wherein the step of loading the first executable file and the second executable file into a memory comprises:
acquiring a function running instance in the first executable file, and registering the function running instance in a function support list configured in advance in a memory;
and acquiring a storage process running instance in the second executable file, and registering the storage process running instance in a pre-configured storage process list in a memory.
8. An apparatus for dynamically creating a function, the apparatus comprising:
the acquisition module is used for acquiring SQL sentences of the stored procedures, wherein the SQL sentences comprise function creation sentences and stored procedure creation sentences;
the analysis module is used for analyzing the function creation statement and the storage process creation statement to obtain a first java file corresponding to the function creation statement and a second java file corresponding to the storage process creation statement;
the compiling module is used for compiling the first java file to generate a first executable file and compiling the second java file to generate a second executable file;
and the loading module is used for loading the first executable file and the second executable file into the memory.
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 one of claims 1-7 when executing the computer program.
10. A readable storage medium, having stored thereon a computer program which, when executed by a processor, performs the method of any one of claims 1-7.
CN201910300273.0A 2019-04-15 2019-04-15 Function dynamic creating method and device and electronic equipment Active CN109992259B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910300273.0A CN109992259B (en) 2019-04-15 2019-04-15 Function dynamic creating method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910300273.0A CN109992259B (en) 2019-04-15 2019-04-15 Function dynamic creating method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN109992259A CN109992259A (en) 2019-07-09
CN109992259B true CN109992259B (en) 2020-10-30

Family

ID=67133621

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910300273.0A Active CN109992259B (en) 2019-04-15 2019-04-15 Function dynamic creating method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN109992259B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111078197B (en) * 2019-11-21 2023-05-09 北京明略软件系统有限公司 Method and device for generating executable file
CN110989998A (en) * 2019-12-16 2020-04-10 重庆锐云科技有限公司 Method for writing code into dynamic sql statement, program code execution method and platform
CN111722849A (en) * 2020-07-17 2020-09-29 思客云(北京)软件技术有限公司 Method, system and device for realizing virtual compiling of JAVA language
CN112363727A (en) * 2020-11-10 2021-02-12 中国平安人寿保险股份有限公司 JAVA conversion method and device of SQL (structured query language) code, computer equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012104065A (en) * 2010-11-12 2012-05-31 Fuji Electric Co Ltd Language conversion apparatus and language conversion program
CN104461531A (en) * 2014-12-02 2015-03-25 福建工程学院 Implementing method for self-defined functions of reporting system
CN104794147A (en) * 2013-12-30 2015-07-22 深圳键桥通讯技术股份有限公司 Heterogeneous database access method
CN108255967A (en) * 2017-12-26 2018-07-06 平安科技(深圳)有限公司 Call method, device, storage medium and the terminal of storing process

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101410836B (en) * 2006-06-08 2012-05-30 国际商业机器公司 A method for providing access to data stored in a database to an application
CN102955801B (en) * 2011-08-25 2017-06-16 中兴通讯股份有限公司 Data control method and system based on distributed data base system
CN102629277A (en) * 2012-03-21 2012-08-08 北京英孚斯迈特信息技术有限公司 General structured query language (SQL) data processing method and system
CN106339384B (en) * 2015-07-07 2021-03-09 小米科技有限责任公司 Storage process conversion method and device
CN109408493A (en) * 2018-10-17 2019-03-01 成都四方伟业软件股份有限公司 A kind of moving method and system of data source

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012104065A (en) * 2010-11-12 2012-05-31 Fuji Electric Co Ltd Language conversion apparatus and language conversion program
CN104794147A (en) * 2013-12-30 2015-07-22 深圳键桥通讯技术股份有限公司 Heterogeneous database access method
CN104461531A (en) * 2014-12-02 2015-03-25 福建工程学院 Implementing method for self-defined functions of reporting system
CN108255967A (en) * 2017-12-26 2018-07-06 平安科技(深圳)有限公司 Call method, device, storage medium and the terminal of storing process

Also Published As

Publication number Publication date
CN109992259A (en) 2019-07-09

Similar Documents

Publication Publication Date Title
CN109992259B (en) Function dynamic creating method and device and electronic equipment
US20130332449A1 (en) Generating data processing code from a directed acyclic graph
CN107133052B (en) Flow creation method and device
CN109933571B (en) Database design document generation method, device and computer readable storage medium
CN102841841B (en) A kind of test asserts processing method and system
JPS63181033A (en) Automatic program generating system
CN107622080B (en) Data processing method and equipment
CN108196876B (en) PHP service configuration method based on file and central server
CN107015839B (en) Method and device for realizing front-end event agent
CN101430643A (en) Method and apparatus for providing item development environment, and item development system
CN113268500B (en) Service processing method and device and electronic equipment
CN111443901B (en) Java reflection-based service expansion method and device
CN112069456A (en) Model file generation method and device, electronic equipment and storage medium
CN112861501A (en) Report generation method and device, electronic equipment and computer readable storage medium
CN113434533A (en) Data tracing tool construction method, data processing method, device and equipment
CN116028028A (en) Request function generation method, device, equipment and storage medium
CN109558121B (en) Interface driver development method, device, equipment and storage medium
US10606568B2 (en) Method and apparatus for compiling computer language
CN113987337A (en) Search method, system, equipment and storage medium based on componentized dynamic arrangement
TWI501152B (en) Method for simplifying interfaces having dynamic libraries
US20210216526A1 (en) Autonomous self-healing application data validation using database configurations
CN114385145A (en) Web system back-end architecture design method and computer equipment
US10789235B2 (en) Base user defined functions
CN112181398A (en) Configuration file processing device, method and storage medium
CN110795451B (en) SQL fingerprint restoring method, SQL fingerprint restoring device, SQL fingerprint restoring computer 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
GR01 Patent grant
GR01 Patent grant