Data processing method, device, electronic device, medium and product
By generating rule model files and directed acyclic graphs, parsing and executing rule codes, it solves the problem of low data processing efficiency caused by the increase in the number of rule engines, enables multiple model nodes to process data at the same time, and improves user experience.
Patent Information
- Application Number
- CN202211085693.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-06
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2042-09-06
AI Technical Summary
In the existing technology, changes in user needs and iteration of data scenarios lead to an increase in the number of rule engines, resulting in low data processing efficiency and affecting user experience. In addition, different rule engines cannot be shared between different rule engines, requiring frequent engine replacement.
By generating a rule model file that contains multiple model nodes and calculation engines, a directed acyclic graph is constructed, the rule code is parsed, and the corresponding engine execution code is called based on the source data, the model nodes are managed uniformly, and multiple nodes process data simultaneously.
It improves data processing efficiency, supports user-defined business rules and source data generation rule model files, and manages model nodes uniformly through directed acyclic graphs. Multiple model nodes can process data at the same time, improving data processing efficiency and user experience.
Smart Images

Figure CN115357626B
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a data processing method, device, electronic equipment, medium and product. Background Art
[0002] At present, the use of big data technology stacks to process and calculate data can meet the data processing needs of users in various fields. Different users in different fields have different data scenarios. For example, data scenarios can be production capacity data, equipment work efficiency data, and raw material utilization rate. Different rule engines need to be defined for different data scenarios, and the corresponding data needs to be processed through different rule engines.
[0003] In actual applications, user needs are constantly changing, and data scenarios are constantly iterating. Correspondingly, the number of defined rule engines is also increasing. Different rule engines cannot be shared, so when processing data, the corresponding rule engine needs to be replaced every time the data scenario changes, resulting in low data processing efficiency and affecting user experience. Summary of the invention
[0004] The present application provides a data processing method, device, electronic device, medium and product for improving data processing efficiency.
[0005] In a first aspect, the present application provides a data processing method, comprising: generating a rule model file according to user-defined business rules and source data; the rule model file defines multiple model nodes and multiple computing engines; generating a directed acyclic graph for the multiple model nodes, and parsing the rule codes corresponding to the multiple model nodes according to the rule model file; traversing the multiple model nodes in the directed acyclic graph, and for the currently traversed model node, calling the computing engine corresponding to the model node based on the source data corresponding to the model node to execute the rule code corresponding to the model node, until all model nodes are traversed to obtain the data processing result.
[0006] In a possible implementation, the rule model file includes a directed acyclic graph dependency definition; generating a directed acyclic graph for the multiple model nodes includes: generating a directed acyclic graph of the multiple model nodes according to the directed acyclic graph dependency definition in the business rule; wherein the directed acyclic graph dependency definition is used to define the dependency relationship and dependency type between the multiple model nodes, and the dependency type includes continuing execution and ending execution.
[0007] In a possible implementation, the rule model file includes a model node definition of a model node, and the model node definition of the model node includes a first field for defining a node type of the model node and a second field for defining a rule code corresponding to the model node; parsing the rule codes corresponding to the multiple model nodes according to the rule model file includes: determining the node type of each model node according to the first field in the model node definition in the business rule; if the node type of the model node is a structured query language type, parsing the built-in function code in the structured query language format in the second field corresponding to the model node to obtain the rule code corresponding to the model node; if the node type of the model node is a custom type, reading the user-defined non-structured query language format code in the second field to obtain the rule code corresponding to the model node.
[0008] In a possible implementation, the rule model file also includes a user-defined function definition, and the user-defined function definition is used to define a non-built-in function code in a user-defined structured query language format; if the node type of the model node is a structured query language type, the built-in function code in the structured query language format in the second field corresponding to the model node is parsed, including: if the node type of the model node is a structured query language type, and the user-defined function definition corresponding to the model node is a null value, the built-in function code in the structured query language format in the second field corresponding to the model node is parsed.
[0009] In a possible implementation, the method further includes: if the node type of the model node is a structured query language type, and the user-defined function definition corresponding to the model node is not an empty value, then generating a user-defined function according to the user-defined function definition; and parsing the code from the user-defined function and merging it into the rule code.
[0010] In a possible implementation, traversing the multiple model nodes in the directed acyclic graph includes: in order of the in-degree of the model nodes from small to large, taking the model node with each in-degree in the directed acyclic graph as the model node currently traversed.
[0011] In a possible implementation, the rule model file includes a computing engine definition; for the currently traversed model node, based on the source data corresponding to the model node, calling the computing engine corresponding to the model node to execute the rule code corresponding to the model node, includes: determining the computing engine corresponding to the model node according to the computing engine definition corresponding to the currently traversed model node; wherein the computing engine definition includes a computing engine specified by the user for the model node, and the computing engine includes a big data engine and / or a database engine; based on the source data corresponding to the model node, calling the computing engine corresponding to the model node to execute the rule code corresponding to the model node.
[0012] In one possible implementation, the rule model file includes a distributed lock definition; the method further includes: determining a target distributed lock corresponding to the model node according to the distributed lock definition corresponding to the currently traversed model node; wherein the distributed lock definition includes a distributed lock specified by the user for the model node; and locking the source data corresponding to the currently traversed model node through the target distributed lock until the computing engine corresponding to the model node completes execution of the rule code corresponding to the model node.
[0013] In a second aspect, the present application provides a data processing device, comprising: a generation module, used to generate a rule model file according to user-defined business rules and source data; the rule model file defines multiple model nodes and multiple computing engines; a parsing module, used to generate a directed acyclic graph for the multiple model nodes, and parse out the rule codes corresponding to the multiple model nodes according to the rule model file; a processing module, used to traverse the multiple model nodes in the directed acyclic graph, and for the currently traversed model node, based on the source data corresponding to the model node, call the computing engine corresponding to the model node to execute the rule code corresponding to the model node, until all model nodes are traversed to obtain the data processing result.
[0014] In a possible implementation, the rule model file includes a directed acyclic graph dependency definition; the parsing module is specifically used to generate a directed acyclic graph of the multiple model nodes according to the directed acyclic graph dependency definition in the business rule; wherein the directed acyclic graph dependency definition is used to define the dependency relationship and dependency type between the multiple model nodes, and the dependency type includes continuing execution and ending execution.
[0015] In a possible implementation, the rule model file includes a model node definition of a model node, and the model node definition of the model node includes a first field for defining a node type of the model node and a second field for defining a rule code corresponding to the model node; the parsing module is specifically used to determine the node type of each model node according to the first field in the model node definition in the business rule; the parsing module is specifically used to parse the built-in function code in the structured query language format in the second field corresponding to the model node if the node type of the model node is a structured query language type, so as to obtain the rule code corresponding to the model node; the parsing module is specifically used to read the user-defined non-structured query language format code in the second field if the node type of the model node is a custom type, so as to obtain the rule code corresponding to the model node.
[0016] In a possible implementation, the rule model file also includes a user-defined function definition, which is used to define a non-built-in function code in a user-defined structured query language format; the parsing module is specifically used to parse the built-in function code in the structured query language format in the second field corresponding to the model node if the node type of the model node is a structured query language type and the user-defined function definition corresponding to the model node is a null value.
[0017] In a possible implementation, the device further includes: a merging module, which is used to generate a user-defined function according to the user-defined function definition if the node type of the model node is a structured query language type and the user-defined function definition corresponding to the model node is not an empty value; and parse the code from the user-defined function and merge it into the rule code.
[0018] In a possible implementation, the device further includes: a traversal module, configured to use the model nodes with each in-degree in the directed acyclic graph as the model nodes currently traversed in order of the in-degree of the model nodes from small to large.
[0019] In one possible implementation, the rule model file includes a computing engine definition; the processing module is specifically used to determine the computing engine corresponding to the model node according to the computing engine definition corresponding to the currently traversed model node; wherein the computing engine definition includes a computing engine specified by the user for the model node, and the computing engine includes a big data engine and / or a database engine; the processing module is also specifically used to call the computing engine corresponding to the model node based on the source data corresponding to the model node to execute the rule code corresponding to the model node.
[0020] In one possible implementation, the rule model file includes a distributed lock definition; the device also includes: a definition module, used to determine the target distributed lock corresponding to the model node according to the distributed lock definition corresponding to the currently traversed model node; wherein the distributed lock definition includes a distributed lock specified by the user for the model node; the definition module is also used to lock the source data corresponding to the currently traversed model node through the target distributed lock until the computing engine corresponding to the model node completes the execution of the rule code corresponding to the model node.
[0021] In a third aspect, the present application provides an electronic device comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement any method described in the first aspect.
[0022] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by a processor as described in any one of the methods in the first aspect.
[0023] In a fifth aspect, the present application provides a computer program product, comprising a computer program, wherein the computer program is executed by a processor as in any one of the methods in the first aspect.
[0024] The data processing method, device, electronic device, medium and product provided by the present application include: generating a rule model file according to user-defined business rules and source data; the rule model file defines multiple model nodes and multiple computing engines; generating a directed acyclic graph for the multiple model nodes, and parsing the rule codes corresponding to the multiple model nodes according to the rule model file; traversing the multiple model nodes in the directed acyclic graph, and for the currently traversed model node, based on the source data corresponding to the model node, calling the computing engine corresponding to the model node to execute the rule code corresponding to the model node, until all model nodes are traversed to obtain the data processing result. The above scheme manages the model nodes uniformly through a directed acyclic graph, each node has a corresponding computing engine, and multiple model nodes can perform data processing at the same time, thereby improving data processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0026] Figure 1 A schematic diagram of an application scenario of a data processing method provided in an embodiment of the present application;
[0027] Figure 2 A flowchart of a data processing method provided in Example 1 of the present application;
[0028] Figure 3 An example of a directed acyclic graph dependency definition provided for an embodiment of the present application;
[0029] Figure 4 An example of a directed acyclic graph provided for an embodiment of the present application;
[0030] Figure 5 An example of parsing rule code provided for an embodiment of the present application;
[0031] Figure 6 This is a structural example diagram of a data processing device provided in Embodiment 2 of the present application;
[0032] Figure 7 A device block diagram of a data processing device provided in Embodiment 3 of the present application;
[0033] Figure 8 This is a schematic diagram of the structure of an electronic device provided in Example 4 of the present application.
[0034] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0035] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0036] First, let’s explain the nouns involved:
[0037] Computing engine: a software framework for processing data, including big data types and relational database types;
[0038] Structured Query Language (SQL): A computer language used to store, retrieve, and modify data stored in a relational database.
[0039] Directed Acyclic Graph: In data structures, a directed graph without cycles.
[0040] Figure 1A schematic diagram of an application scenario of a data processing method provided in an embodiment of the present application is given by combining the illustrated scenario with an example: the model nodes are uniformly managed to generate a directed acyclic graph, the directed acyclic graph includes model node 1, model node 2 and model node 3, and each model node has a corresponding computing engine. Model node 1, model node 2 and model node 3 can perform data processing through their respective corresponding computing engines at the same time. Compared with each model node performing data processing in turn, the data processing efficiency can be improved.
[0041] The technical solutions of the present application and the technical solutions of the present application are described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. In the description of the present application, unless otherwise clearly specified and limited, each term should be understood in a broad sense in the art. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0042] Embodiment 1
[0043] Figure 2 A flowchart of a data processing method provided in Embodiment 1 of the present application, the method comprising the following steps:
[0044] S201, generating a rule model file according to the business rules and source data defined by the user; the rule model file defines a plurality of model nodes and a plurality of computing engines;
[0045] S202, generating a directed acyclic graph for the multiple model nodes, and parsing the rule codes corresponding to the multiple model nodes according to the rule model file;
[0046] S203, traversing the multiple model nodes in the directed acyclic graph, and for the currently traversed model node, calling the computing engine corresponding to the model node to execute the rule code corresponding to the model node based on the source data corresponding to the model node, until all model nodes are traversed to obtain the data processing result.
[0047] As an example, the execution subject of this embodiment may be a data processing device, and there are many implementations of the data processing device. For example, it may be program software, or a medium storing relevant computer programs, such as a USB flash drive, etc.; or, the device may also be a physical device integrated or installed with relevant computer programs, such as a chip, a smart terminal, a computer, a server, etc.
[0048] In one example, a rule model file includes a directed acyclic graph dependency definition; S202 includes: generating a directed acyclic graph of the multiple model nodes according to the directed acyclic graph dependency definition in the business rule; wherein the directed acyclic graph dependency definition is used to define the dependency relationship and dependency type between the multiple model nodes, and the dependency type includes continuing execution and ending execution.
[0049] As an implementation method, Figure 3 As shown, Figure 3 This is an example of a directed acyclic graph dependency definition. The start node and end node of the directed acyclic graph dependency definition are built-in virtual nodes, which represent the start and end of the directed acyclic graph respectively. A dependency type of 1 means to continue execution, and a dependency type of 0 means to end execution. The dependency node represents the upstream node of the current node. For example, the data processing of model node 4 needs to be performed after the data processing of model node 3 is completed.
[0050] Based on the definition of directed acyclic graph dependencies, such as Figure 4 As shown, Figure 4 This is an example of a directed acyclic graph. According to the directed acyclic graph dependency definition, a directed acyclic graph is generated. For example, after the execution of model node 3, model node 4 is executed, and after the execution of model node 1, model node 2, and model node 4, the end node is entered.
[0051] Based on the above implementation methods, according to the directed acyclic graph dependency definition, the generated directed acyclic graph can reflect the user's definition of the execution order of the model nodes.
[0052] In one example, a rule model file includes a model node definition of a model node, and the model node definition of the model node includes a first field for defining a node type of the model node and a second field for defining a rule code corresponding to the model node; S202 includes: determining the node type of each model node according to the first field in the model node definition in the business rule; if the node type of the model node is a structured query language type, parsing the built-in function code in the structured query language format in the second field corresponding to the model node to obtain the rule code corresponding to the model node; if the node type of the model node is a custom type, reading the user-defined non-structured query language format code in the second field to obtain the rule code corresponding to the model node.
[0053] As an implementable method, if the user uses structured query language type code to define business rules, the first field of the model file displays the type of the model node as structured query language type. If the user uses non-structured query language type code, such as java, scala, python, shell and other programming languages to write business rules, the first field of the model file displays the type of the model node as the corresponding programming language class type. The non-structured query language type code can be run directly, so it does not need to be parsed.
[0054] It should be noted that this application does not limit the specific type of programming language.
[0055] Based on the above implementation modes, by setting different node types of model nodes, it can be applicable to various types of programming languages of users.
[0056] Furthermore, in one example, the rule model file also includes a user-defined function definition, and the user-defined function definition is used to define a non-built-in function code in a user-defined structured query language format; if the node type of the model node is a structured query language type, the built-in function code in the structured query language format in the second field corresponding to the model node is parsed, including: if the node type of the model node is a structured query language type, and the user-defined function definition corresponding to the model node is an empty value, then the built-in function code in the structured query language format in the second field corresponding to the model node is parsed.
[0057] Taking the scenario example as an example, if the built-in functions in the structured query language format cannot meet the user's business needs, the user can write a custom function in the structured query language format, and the custom function can also realize data processing.
[0058] Based on the above implementation methods, the user's data processing needs can be more fully realized through custom function definitions.
[0059] On the other hand, in another example, if the node type of the model node is a structured query language type, and the user-defined function definition corresponding to the model node is not an empty value, a user-defined function is generated according to the user-defined function definition; and the code is parsed from the user-defined function and merged into the rule code.
[0060] In combination with the above examples, as an implementable method, Figure 5 As shown, Figure 5This is an example of parsing rule code. If the user-defined function definition corresponding to the model node is not an empty value, it means that the user uses non-built-in functions of the structured query language type to customize the code in addition to the built-in functions of the structured query language type. Then, a user-defined function is generated according to the user-defined function definition, and the code is parsed from the user-defined function and merged into the rule code. It can be understood that the merged rule code contains the complete data processing rules defined by the user.
[0061] Based on the above implementation method, the code parsed from the custom function is merged into the rule code, so that data processing is performed through the complete rule code to ensure the accuracy of data processing.
[0062] In one example, S203 includes: in order of the in-degree of the model nodes from small to large, taking the model nodes with each in-degree in the directed acyclic graph as the model nodes currently traversed.
[0063] As an implementation method, Figure 4 As shown, model node 1, model node 2 and model node 3 have the same in-degree and can be used as the model nodes currently traversed at the same time. However, the in-degree of model node 4 is greater than that of model node 3, and the traversal of model node 4 needs to be performed after the traversal of model node 3 is completed. It can be understood that traversing model nodes with the same in-degree at the same time can improve the efficiency of data processing.
[0064] Based on the above implementation methods, traversing the model nodes according to the model node in-degree can improve the efficiency of data processing and comply with the model node execution order logic set by the user.
[0065] In one example, the rule model file includes control parameter definitions; S203 includes: traversing the control parameter definitions corresponding to each model node in the directed acyclic graph; if the control parameter definition allows execution, executing the rule code on the current model node; if the control parameter definition does not allow execution, skipping the model node.
[0066] Taking the scenario example as an example, a general template of business rules can be set for the same type of business, and the user can define the control parameters. The user defines the control parameters for the model nodes in the general template according to actual needs, thereby determining whether the model nodes in the general template are executed. For the same type of business, the business rule definition can be quickly and completely defined.
[0067] Based on the above implementation, by controlling parameter definition, compared with users redefining business rules every time, it can improve efficiency and reduce development difficulty.
[0068] In one example, a rule model file includes a computing engine definition; S203 includes: determining the computing engine corresponding to the model node currently traversed according to the computing engine definition corresponding to the model node; wherein the computing engine definition includes a computing engine specified by the user for the model node, and the computing engine includes a big data engine and / or a database engine; based on the source data corresponding to the model node, calling the computing engine corresponding to the model node to execute the rule code corresponding to the model node.
[0069] As an implementable method, big data engines include spark and hive, etc., and database engines include mysql and oracle, etc. Users can define the computing engine definition according to the actual application scenario.
[0070] As an example, the authentication of the computing engine is implemented through the authentication type definition. If the authentication is passed, the rule code is executed through the computing engine. For the big data engine, the authentication type is the network authorization protocol definition; for the database engine, the authentication type is the password definition. It can be understood that the authentication type can improve the security of data processing and prevent data processing through abnormal channels.
[0071] Based on the above implementation methods, various types of data engines can be used to meet the data processing needs of users in various business scenarios.
[0072] In one example, a rule model file includes a distributed lock definition; the data processing method also includes: determining a target distributed lock corresponding to a currently traversed model node based on a distributed lock definition corresponding to the model node; wherein the distributed lock definition includes a distributed lock specified by a user for the model node; and locking the source data corresponding to the currently traversed model node through the target distributed lock until a computing engine corresponding to the model node completes execution of the rule code corresponding to the model node.
[0073] As an implementable method, the computing engine instantiates the source data when executing the rule code, and the distributed lock is used to set access rights to the shared data when each model node executes the instance. For example, when instance A is updating the shared data, other instances can only wait until instance A completes the update of the shared data or exceeds the preset time limit. Distributed locks can be divided into read locks and write locks. Read locks are not mutually exclusive with each other but are mutually exclusive with write locks. There can be multiple read locks, and there can be only one write lock that is mutually exclusive with other locks.
[0074] Based on the above implementation methods, the distributed lock definition can prevent conflicts in modifying shared data when the computing engine executes the rule code, thereby ensuring the success rate of executing the rule code.
[0075] In the data processing method provided in this embodiment, a rule model file is generated according to the business rules and source data defined by the user; the rule model file defines multiple model nodes and multiple computing engines; a directed acyclic graph is generated for the multiple model nodes, and the rule codes corresponding to the multiple model nodes are parsed according to the rule model file; the multiple model nodes in the directed acyclic graph are traversed, and for the currently traversed model node, based on the source data corresponding to the model node, the computing engine corresponding to the model node is called to execute the rule code corresponding to the model node, until all model nodes are traversed to obtain the data processing result. The above scheme manages the model nodes uniformly through a directed acyclic graph, each node has a corresponding computing engine, and multiple model nodes can perform data processing at the same time, thereby improving data processing efficiency.
[0076] Embodiment 2
[0077] Figure 6 A structural diagram of a data processing device provided in Embodiment 2 of the present application is shown in FIG. Figure 6 As shown, the data processing device includes:
[0078] A generating module 61 is used to generate a rule model file according to the business rules and source data defined by the user; the rule model file defines a plurality of model nodes and a plurality of computing engines;
[0079] A parsing module 62, for generating a directed acyclic graph for the plurality of model nodes, and parsing the rule codes corresponding to the plurality of model nodes according to the rule model file;
[0080] The processing module 63 is used to traverse the multiple model nodes in the directed acyclic graph, and for the currently traversed model node, based on the source data corresponding to the model node, call the computing engine corresponding to the model node to execute the rule code corresponding to the model node, until all model nodes are traversed to obtain the data processing result.
[0081] In one example, a rule model file includes a directed acyclic graph dependency definition; a parsing module 62 is specifically used to generate a directed acyclic graph of the multiple model nodes according to the directed acyclic graph dependency definition in the business rule; wherein the directed acyclic graph dependency definition is used to define the dependency relationship and dependency type between the multiple model nodes, and the dependency type includes continuing execution and ending execution.
[0082] As an implementation method, Figure 3 As shown, Figure 3This is an example of a directed acyclic graph dependency definition. The start node and end node of the directed acyclic graph dependency definition are built-in virtual nodes, which represent the start and end of the directed acyclic graph respectively. A dependency type of 1 means to continue execution, and a dependency type of 0 means to end execution. The dependency node represents the upstream node of the current node. For example, the data processing of model node 4 needs to be performed after the data processing of model node 3 is completed.
[0083] Based on the definition of directed acyclic graph dependencies, such as Figure 4 As shown, Figure 4 This is an example of a directed acyclic graph. According to the directed acyclic graph dependency definition, a directed acyclic graph is generated. For example, after the execution of model node 3, model node 4 is executed, and after the execution of model node 1, model node 2, and model node 4, the end node is entered.
[0084] Based on the above implementation methods, according to the directed acyclic graph dependency definition, the generated directed acyclic graph can reflect the user's definition of the execution order of the model nodes.
[0085] In one example, a rule model file includes a model node definition of a model node, wherein the model node definition of the model node includes a first field for defining a node type of the model node and a second field for defining a rule code corresponding to the model node; a parsing module 62 is specifically used to determine the node type of each model node according to the first field in the model node definition in the business rule; the parsing module 62 is specifically used to parse the built-in function code in the structured query language format in the second field corresponding to the model node if the node type of the model node is a structured query language type, so as to obtain the rule code corresponding to the model node; the parsing module 62 is specifically used to read the user-defined non-structured query language format code in the second field if the node type of the model node is a custom type, so as to obtain the rule code corresponding to the model node.
[0086] As an implementable method, if the user uses structured query language type code to define business rules, the first field of the model file displays the type of the model node as structured query language type. If the user uses non-structured query language type code, such as java, scala, python, shell and other programming languages to write business rules, the first field of the model file displays the type of the model node as the corresponding programming language class type. The non-structured query language type code can be run directly, so it does not need to be parsed.
[0087] It should be noted that this application does not limit the specific type of programming language.
[0088] Based on the above implementation modes, by setting different node types of model nodes, it can be applicable to various types of programming languages of users.
[0089] Furthermore, in one example, the rule model file also includes a user-defined function definition, and the user-defined function definition is used to define a user-defined non-built-in function code in a structured query language format; the parsing module is specifically used to parse the built-in function code in the structured query language format in the second field corresponding to the model node if the node type of the model node is a structured query language type, including: if the node type of the model node is a structured query language type, and the user-defined function definition corresponding to the model node is an empty value, then the built-in function code in the structured query language format in the second field corresponding to the model node is parsed.
[0090] Taking the scenario example as an example, if the built-in functions in the structured query language format cannot meet the user's business needs, the user can write a custom function in the structured query language format, and the custom function can also realize data processing.
[0091] Based on the above implementation methods, the user's data processing needs can be more fully realized through custom function definitions.
[0092] On the other hand, in another example, the data processing device also includes: a merging module 64, which is used to generate a user-defined function according to the user-defined function definition if the node type of the model node is a structured query language type and the user-defined function definition corresponding to the model node is not an empty value; and parse the code from the user-defined function and merge it into the rule code.
[0093] In combination with the above examples, as an implementable method, Figure 5 As shown, Figure 5 This is an example of parsing rule code. If the user-defined function definition corresponding to the model node is not an empty value, it means that the user uses non-built-in functions of the structured query language type to customize the code in addition to the built-in functions of the structured query language type. Then, a user-defined function is generated according to the user-defined function definition, and the code is parsed from the user-defined function and merged into the rule code. It can be understood that the merged rule code contains the complete data processing rules defined by the user.
[0094] Based on the above implementation method, the code parsed from the custom function is merged into the rule code, so that data processing is performed through the complete rule code to ensure the accuracy of data processing.
[0095] In one example, the data processing further includes: a traversal module 65, which is used to use the model nodes with each in-degree in the directed acyclic graph as the model nodes currently traversed in the order of the in-degree of the model nodes from small to large.
[0096] As an implementation method, Figure 4 As shown, model node 1, model node 2 and model node 3 have the same in-degree and can be used as the model nodes currently traversed at the same time. However, the in-degree of model node 4 is greater than that of model node 3, and the traversal of model node 4 needs to be performed after the traversal of model node 3 is completed. It can be understood that traversing model nodes with the same in-degree at the same time can improve the efficiency of data processing.
[0097] Based on the above implementation methods, traversing the model nodes according to the model node in-degree can improve the efficiency of data processing and comply with the model node execution order logic set by the user.
[0098] In one example, the rule model file includes control parameter definitions; the processing module 63 is also used to traverse the control parameter definitions corresponding to each model node in the directed acyclic graph; if the control parameter definition is to allow execution, the rule code is executed on the current model node; if the control parameter definition is not to allow execution, the model node is skipped.
[0099] Taking the scenario example as an example, a general template of business rules can be set for the same type of business, and the user can define the control parameters. The user defines the control parameters for the model nodes in the general template according to actual needs, thereby determining whether the model nodes in the general template are executed. For the same type of business, the business rule definition can be quickly and completely defined.
[0100] Based on the above implementation, by controlling parameter definition, compared with users redefining business rules every time, it can improve efficiency and reduce development difficulty.
[0101] In one example, the rule model file includes a computing engine definition; a processing module 63 is specifically used to determine the computing engine corresponding to the model node currently traversed according to the computing engine definition corresponding to the model node; wherein the computing engine definition includes a computing engine specified by the user for the model node, and the computing engine includes a big data engine and / or a database engine; the processing module 63 is also specifically used to call the computing engine corresponding to the model node based on the source data corresponding to the model node to execute the rule code corresponding to the model node.
[0102] As an implementable method, big data engines include spark and hive, etc., and database engines include mysql and oracle, etc. Users can define the computing engine definition according to the actual application scenario.
[0103] As an example, the authentication of the computing engine is implemented through the authentication type definition. If the authentication is passed, the rule code is executed through the computing engine. For the big data engine, the authentication type is the network authorization protocol definition; for the database engine, the authentication type is the password definition. It can be understood that the authentication type can improve the security of data processing and prevent data processing through abnormal channels.
[0104] Based on the above implementation methods, various types of data engines can be used to meet the data processing needs of users in various business scenarios.
[0105] In one example, the rule model file includes a distributed lock definition; the data processing device also includes: a definition module 66, which is used to determine the target distributed lock corresponding to the model node currently traversed according to the distributed lock definition corresponding to the model node; wherein the distributed lock definition includes the distributed lock specified by the user for the model node; the definition module 66 is also used to lock the source data corresponding to the currently traversed model node through the target distributed lock until the computing engine corresponding to the model node completes the execution of the rule code corresponding to the model node.
[0106] As an implementable method, the computing engine instantiates the source data when executing the rule code, and the distributed lock is used to set access rights to the shared data when each model node executes the instance. For example, when instance A is updating the shared data, other instances can only wait until instance A completes the update of the shared data or exceeds the preset time limit. Distributed locks can be divided into read locks and write locks. Read locks are not mutually exclusive with each other but are mutually exclusive with write locks. There can be multiple read locks, and there can be only one write lock that is mutually exclusive with other locks.
[0107] Based on the above implementation methods, the distributed lock definition can prevent conflicts in modifying shared data when the computing engine executes the rule code, thereby ensuring the success rate of executing the rule code.
[0108] In the data processing device provided in this embodiment, a generation module is used to generate a rule model file according to user-defined business rules and source data; the rule model file defines multiple model nodes and multiple computing engines; a parsing module is used to generate a directed acyclic graph for the multiple model nodes, and parse out the rule codes corresponding to the multiple model nodes according to the rule model file; a processing module is used to traverse the multiple model nodes in the directed acyclic graph, and for the currently traversed model node, based on the source data corresponding to the model node, call the computing engine corresponding to the model node to execute the rule code corresponding to the model node, until all model nodes are traversed to obtain the data processing result. The above scheme manages the model nodes uniformly through a directed acyclic graph, each node has a corresponding computing engine, and multiple model nodes can perform data processing at the same time, thereby improving data processing efficiency.
[0109] Embodiment 3
[0110] Figure 7 It is a device block diagram of a data processing device according to an exemplary embodiment. The device may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0111] The apparatus 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output interface 812 , a sensor component 814 , and a communication component 816 .
[0112] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0113] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0114] The power supply component 806 provides power to the various components of the device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.
[0115] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0116] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), which is configured to receive external audio signals when the device 800 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0117] The input / output interface 812 provides an interface between the processing component 802 and the peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0118] The sensor assembly 814 includes one or more sensors for providing various aspects of the status assessment of the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, and the sensor assembly 814 can also detect the position change of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor assembly 814 can include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 can also include an optical sensor, such as a complementary metal oxide semiconductor (CMOS) image sensor or a charge-coupled device (CCD) for use in imaging applications. In some embodiments, the sensor assembly 814 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0119] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as WiFi, a second generation mobile communication technology (2nd-Generation Communication Technology, referred to as 2G), a third generation mobile communication technology (3rd-Generation Communication Technology, referred to as 3G), a fourth generation mobile communication technology (4th-Generation Communication Technology, referred to as 4G) or a fifth generation mobile communication technology (5th-Generation Communication Technology, referred to as 5G) or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (Near Field Communication, referred to as NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wide Band (UWB) technology, Bluetooth (BT) technology and other technologies.
[0120] In an exemplary embodiment, the device 800 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above method.
[0121] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of the device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0122] Embodiment 4
[0123] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 8 As shown, the electronic device includes:
[0124] The electronic device includes a processor 291 and a memory 292; it may also include a communication interface 293 and a bus 294. The processor 291, the memory 292, and the communication interface 293 may communicate with each other through the bus 294. The communication interface 293 may be used for information transmission. The processor 291 may call the logic instructions in the memory 292 to execute the method of the above embodiment.
[0125] In addition, the logic instructions in the above-mentioned memory 292 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0126] The memory 292 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present application. The processor 291 executes functional applications and data processing by running the software programs, instructions, and modules stored in the memory 292, that is, implementing the methods in the above method embodiments.
[0127] The memory 292 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 292 may include a high-speed random access memory and may also include a non-volatile memory.
[0128] An embodiment of the present application provides a non-temporary computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method described in the above embodiment.
[0129] An embodiment of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, the method described in the above embodiment is implemented.
[0130] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0131] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A data processing method, characterized in that: include: Generate rule model files based on user-defined business rules and source data; The rule model file defines a plurality of model nodes and a plurality of computing engines; Generate a directed acyclic graph for the multiple model nodes, and parse the rule codes corresponding to the multiple model nodes according to the rule model file; Traversing the multiple model nodes in the directed acyclic graph, and for the currently traversed model node, calling the computing engine corresponding to the model node to execute the rule code corresponding to the model node based on the source data corresponding to the model node, until all model nodes are traversed to obtain the data processing result; The rule model file includes a model node definition of a model node, wherein the model node definition of the model node includes a first field for defining a node type of the model node and a second field for defining a rule code corresponding to the model node; and parsing the rule codes corresponding to the plurality of model nodes according to the rule model file includes: Determining a node type of each model node according to a first field in the model node definition in the business rule; If the node type of the model node is a structured query language type, parsing the built-in function code in the structured query language format in the second field corresponding to the model node to obtain a rule code corresponding to the model node; If the node type of the model node is a user-defined type, the code in the second field in a user-defined non-structured query language format is read to obtain a rule code corresponding to the model node.
2. The method according to claim 1, characterized in that: The rule model file includes a directed acyclic graph dependency definition; the generating a directed acyclic graph for the plurality of model nodes includes: According to the directed acyclic graph dependency definition in the business rules, a directed acyclic graph of the multiple model nodes is generated; wherein the directed acyclic graph dependency definition is used to define the dependency relationship and dependency type between the multiple model nodes, and the dependency type includes continuing execution and ending execution.
3. The method according to claim 1, characterized in that The rule model file further includes a user-defined function definition, wherein the user-defined function definition is used to define a non-built-in function code in a user-defined structured query language format; if the node type of the model node is a structured query language type, parsing the built-in function code in the structured query language format in the second field corresponding to the model node includes: If the node type of the model node is a structured query language type, and the user-defined function corresponding to the model node is defined as a null value, the built-in function code in the structured query language format in the second field corresponding to the model node is parsed.
4. The method according to claim 3, characterized in that The method further comprises: If the node type of the model node is a structured query language type, and the user-defined function definition corresponding to the model node is not an empty value, a user-defined function is generated according to the user-defined function definition; and the code is parsed from the user-defined function and merged into the rule code.
5. The method according to claim 2, characterized in that: The traversing the plurality of model nodes in the directed acyclic graph comprises: According to the order of the model node in-degree from small to large, the model node under each in-degree in the directed acyclic graph is used as the model node currently traversed.
6. The method according to claim 1, characterized in that The rule model file includes a computing engine definition; for the currently traversed model node, based on the source data corresponding to the model node, calling the computing engine corresponding to the model node to execute the rule code corresponding to the model node includes: Determine the computing engine corresponding to the model node according to the computing engine definition corresponding to the currently traversed model node; wherein the computing engine definition includes the computing engine specified by the user for the model node, and the computing engine includes a big data engine and / or a database engine; Based on the source data corresponding to the model node, the computing engine corresponding to the model node is called to execute the rule code corresponding to the model node.
7. The method according to any one of claims 1 to 6, characterized in that The rule model file includes a distributed lock definition; the method further includes: Determine the target distributed lock corresponding to the model node according to the distributed lock definition corresponding to the currently traversed model node; wherein the distributed lock definition includes the distributed lock specified by the user for the model node; The source data corresponding to the currently traversed model node is locked by the target distributed lock until the computing engine corresponding to the model node completes the execution of the rule code corresponding to the model node.
8. A data processing device, characterized in that: include: A generation module is used to generate a rule model file based on user-defined business rules and source data; The rule model file defines a plurality of model nodes and a plurality of computing engines; A parsing module, used for generating a directed acyclic graph for the plurality of model nodes, and parsing the rule codes corresponding to the plurality of model nodes according to the rule model file; A processing module, used for traversing the multiple model nodes in the directed acyclic graph, and for a currently traversed model node, based on source data corresponding to the model node, calling a computing engine corresponding to the model node to execute a rule code corresponding to the model node, until all model nodes are traversed to obtain a data processing result; The rule model file includes a model node definition of a model node, wherein the model node definition of the model node includes a first field for defining a node type of the model node and a second field for defining a rule code corresponding to the model node; The parsing module is specifically used to determine the node type of each model node according to the first field in the model node definition in the business rule; The parsing module is further configured to parse the built-in function code in the structured query language format in the second field corresponding to the model node to obtain the rule code corresponding to the model node if the node type of the model node is a structured query language type; The parsing module is further specifically used to read the user-defined code in the unstructured query language format in the second field if the node type of the model node is a user-defined type, and obtain the rule code corresponding to the model node.
9. The device according to claim 8, characterized in that The rule model file includes a directed acyclic graph dependency definition; The parsing module is specifically used to generate a directed acyclic graph of the multiple model nodes according to the directed acyclic graph dependency definition in the business rules; wherein the directed acyclic graph dependency definition is used to define the dependency relationship and dependency type between the multiple model nodes, and the dependency type includes continuing execution and ending execution.
10. The device according to claim 8, characterized in that The rule model file also includes a user-defined function definition, wherein the user-defined function definition is used to define a non-built-in function code in a user-defined structured query language format; The parsing module is specifically used to parse the built-in function code in the structured query language format in the second field corresponding to the model node if the node type of the model node is a structured query language type and the user-defined function corresponding to the model node is defined as a null value.
11. The device according to claim 10, characterized in that The device also includes: A merging module is used to generate a user-defined function according to the user-defined function definition if the node type of the model node is a structured query language type and the user-defined function definition corresponding to the model node is not an empty value; and parse the code from the user-defined function and merge it into the rule code.
12. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
