Offline model processing method, device, storage medium and processor
By deleting calculation nodes that are not related to the target output node in the offline big data modeling platform, the problem of waste of resources is solved, and more efficient calculations are achieved.
Patent Information
- Application Number
- CN202111329172.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-10
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2041-11-10
AI Technical Summary
In offline big data modeling platforms, there are often computing nodes that are independent of the target output node in the user-arranged model, resulting in waste of resources.
By determining the target output node of the user's selection in the offline model, find the parent node of the target output node again, until the root node is obtained, and the node other than the node included in the query results is deleted to get updated Later offline model.
By deleting nodes that are not related to the target output node, the waste of resources is avoided and the calculation efficiency is improved.
Smart Images

Figure CN114218265B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to an offline model processing method, device, storage medium and processor. Background Art
[0002] In the offline big data modeling platform, the platform provides users with the ability to orchestrate business model graphs. The model graph is a directed acyclic graph (DAG) composed of several "SQL nodes" or "script nodes". The platform can schedule and execute according to the model graph (DAG) orchestrated by the user, where each node corresponds to an offline computing task. Since the model is a combination of a series of computing logics built by the user according to the business, each model will have at least one target output node. When the user selects several target output nodes, there are often some computing nodes in the model that are not related to the target output nodes. Calculation of these nodes will lead to a waste of resources.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present invention provide an offline model processing method, device, storage medium and processor to at least solve the technical problem of waste of resources when using the offline model for calculation due to the presence of computing nodes unrelated to the target output node in the offline model of the related art.
[0005] According to one aspect of an embodiment of the present invention, a method for processing an offline model is provided, comprising: determining a target output node selected by a user in the offline model, wherein the offline model is composed of a plurality of nodes based on offline calculations, and the node represents a calculation rule; searching the offline model for the parent node of the target output node and the parent node of the parent node of the target output node in a one-by-one traversal manner until the node found is a root node, thereby obtaining a query result, wherein the query result includes at least one queried node; deleting nodes in the offline model except the nodes included in the query result, thereby obtaining an updated offline model; and performing calculations using the updated offline model.
[0006] Furthermore, the method also includes: if the target output node is multiple nodes, searching for the parent node of each target output node and the parent node of the parent node of each target output node in the offline model one by one, until the node found is the root node, to obtain multiple query sub-results; and using the multiple query sub-results as the query result.
[0007] Furthermore, deleting the nodes in the offline model except the nodes included in the query result to obtain an updated offline model includes: deleting the nodes in the offline model except the nodes included in the query sub-result respectively to obtain multiple sub-models; and merging the multiple sub-models to obtain an updated offline model.
[0008] Furthermore, after deleting the nodes in the offline model except the nodes included in the query result to obtain the updated offline model, the method further includes: starting from the root node of the updated offline model, determining whether the current node in the updated offline model is an SQL node, wherein the SQL node represents a calculation rule described by an SQL script; if the current node is an SQL node, starting to merge, adding the current node to a merge list, and traversing the child nodes of the current node to determine whether the child nodes are SQL nodes, until the traversed node is the root node, to obtain a final merge list; merging the nodes in the final merge list, constructing a single-node field for the merged node, and using the merged node with the constructed single-node field as the fused node in the updated offline model; if the traversed node is not an SQL node, constructing a single-node field for the non-SQL node, and using the non-SQL node with the constructed single-node field as the original node in the updated offline model; obtaining an optimized offline model based on the fused node and the original node.
[0009] Furthermore, when merging the nodes in the final merge list, the method also includes: when the current node meets any preset rule, stopping merging the current node in the final merge list, wherein the preset rule at least includes: the current node is a SQL node with an out-degree greater than 1, the child nodes of the current node include nodes with an in-degree greater than 1, the child nodes of the current node are non-SQL nodes, the current node is an output node that is not a leaf node, and the current node is a leaf node.
[0010] Furthermore, before obtaining the optimized offline model based on the fused node and the original node, the method also includes: determining whether the nodes in the updated offline model have been traversed; if the nodes in the updated offline model have been traversed, determining that the optimization of the updated offline model is completed, and executing the step of obtaining the optimized offline model based on the fused node and the original node.
[0011] Further, using the updated offline model to perform calculations includes: using the optimized offline model to perform calculations.
[0012] According to another aspect of an embodiment of the present invention, there is also provided an offline model processing device, comprising: a first determination unit, used to determine a target output node selected by a user in an offline model, wherein the offline model is composed of a plurality of nodes based on offline calculations, and the nodes represent a calculation rule; a first search unit, used to search the parent node of the target output node and the parent node of the parent node of the target output node in the offline model in a one-by-one traversal manner until the node found is a root node, to obtain a query result, wherein the query result includes at least one queried node; a first processing unit, used to delete nodes in the offline model except the nodes included in the query result, to obtain an updated offline model; and a calculation unit, used to perform calculations using the updated offline model.
[0013] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, wherein the storage medium includes a stored program, wherein when the program is run, the device where the storage medium is located is controlled to execute any one of the above-mentioned offline model processing methods.
[0014] According to another aspect of an embodiment of the present invention, a processor is further provided, wherein the processor is used to run a program, wherein the program executes any one of the above-mentioned offline model processing methods when running.
[0015] In an embodiment of the present invention, a method of deleting nodes irrelevant to a target output node in an offline model is adopted. Specifically, in the offline model, a target output node selected by a user is determined, wherein the offline model is composed of a plurality of nodes based on offline calculations, and the node represents a calculation rule; a parent node of the target output node and a parent node of the parent node of the target output node are searched in the offline model one by one by traversing until the node found is a root node, thereby obtaining a query result, wherein the query result includes at least one queried node; nodes other than the nodes included in the query result are deleted from the offline model to obtain an updated offline model; and calculations are performed using the updated offline model, thereby achieving a technical effect of avoiding waste of resources when using the updated offline model for calculations, thereby solving the technical problem of waste of resources when using the offline model for calculations due to the presence of calculation nodes irrelevant to the target output node in the offline model of the related technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0017] Figure 1is a hardware structure block diagram of a computer terminal according to an embodiment of the present invention;
[0018] Figure 2 is a flowchart of a method for processing an offline model provided according to Embodiment 1 of the present invention;
[0019] Figure 3 This is a schematic diagram of an offline model provided according to the first embodiment of the present invention. Figure 1 ;
[0020] Figure 4 This is a schematic diagram of an offline model provided according to the first embodiment of the present invention. Figure 2 ;
[0021] Figure 5 This is a schematic diagram of an offline model provided according to the first embodiment of the present invention. Figure 3 ;
[0022] Figure 6 This is a schematic diagram of an offline model provided according to the first embodiment of the present invention. Figure 4 ;
[0023] Figure 7 This is a schematic diagram of an offline model provided according to the first embodiment of the present invention. Figure 5 ;
[0024] Figure 8 This is a schematic diagram of an offline model provided according to the first embodiment of the present invention. Figure 6 ;
[0025] Fig. 9 This is a schematic diagram of an offline model provided according to the first embodiment of the present invention. Figure 7 ;
[0026] Fig.10 This is a schematic diagram of an offline model provided according to the first embodiment of the present invention. Figure 8 ;
[0027] Fig.11 This is a schematic diagram of an offline model provided according to the first embodiment of the present invention. Figure 9 ;
[0028] Fig.12 is a schematic diagram of an optional offline model processing method provided according to Embodiment 1 of the present invention;
[0029] Fig.13 is a schematic diagram of an offline model processing device provided according to Embodiment 2 of the present invention;
[0030] Fig.14 is a structural block diagram of an optional computer terminal according to an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0034] Offline computing: Offline computing is computing that is performed under the premise that all input data is known before the calculation begins and the input data will not change.
[0035] Node: A basic unit in the model, representing a calculation rule, which can be a SQL script, Shell script, Python script, etc.
[0036] Offline node: An offline node is a node based on offline computing.
[0037] Model: A model is a directed acyclic graph (DAG) consisting of several nodes, with the following characteristics: the results produced by the upstream nodes will serve as the input of the downstream nodes.
[0038] Offline model: An offline model refers to a model composed of a series of offline nodes.
[0039] Example 1
[0040] According to an embodiment of the present invention, an embodiment of a method for processing an offline model is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0041] The method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing an offline model processing method. Figure 1 As shown, the computer terminal 10 (or mobile device 10) may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0042] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0043] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the offline model processing method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the offline model processing method of the above-mentioned application is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0044] The transmission device is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device can be a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly.
[0045] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0046] Under the above operating environment, this application provides Figure 2 The processing method of the offline model is shown. Figure 2 4 is a flowchart of a method for processing an offline model according to the first embodiment of the present invention.
[0047] Step S101, in the offline model, determining the target output node selected by the user, wherein the offline model is composed of a plurality of nodes based on offline calculations, and a node represents a calculation rule.
[0048] For example, offline models such as Figure 3 As shown, the dotted box is the target output node selected by the user.
[0049] Step S102, using a one-by-one traversal method, searching the parent node of the target output node and the parent node of the parent node of the target output node in the offline model until the node found is the root node, and obtaining a query result, wherein the query result includes at least one queried node.
[0050] by Figure 3 For example, in Figure 3 In the process, the parent node of the target output node selected by the user is searched in the offline model one by one, and the parent node of the parent node is searched until the node found is the root node. The node found is, Figure 4 The nodes shown in .
[0051] Step S103, deleting nodes in the offline model except the nodes included in the query result, to obtain an updated offline model.
[0052] Will Figure 3 Delete the nodes in the offline model except the nodes included in the query result to obtain the updated offline model, that is, Figure 4 Represents the model.
[0053] Step S104, performing calculations using the updated offline model.
[0054] Through the above steps, the nodes irrelevant to the target output node in the offline model are deleted, and the technical effect of avoiding resource waste when using the updated offline model for calculation is achieved, thereby solving the technical problem of resource waste when using the offline model for calculation due to the presence of computing nodes irrelevant to the target output node in the offline model of the related technology.
[0055] Optionally, in the offline model processing method provided in the embodiment of the present application, the method also includes: if the target output node is multiple nodes, searching for the parent node of each target output node and the parent node of the parent node of each target output node in the offline model one by one, until the node found is the root node, to obtain multiple query sub-results; and using the multiple query sub-results as the query result.
[0056] like Figure 5 As shown, the nodes in the two dotted boxes in the offline model represent the target output nodes selected by the user, and the parent node of each target output node and the parent node of the parent node of each target output node are searched one by one until the node found is the root node, and multiple query sub-results are obtained, for example, query sub-result one (CUSTOM_SQL, FILTER, DATA_SOURCE) and query sub-result two (FILTER, JOIN, CUSTOM_SQL, FILTER, DATA_SOURCE, FILTER, DATA_SOURCE, FILTER).
[0057] For another example, the two target output nodes selected by the user are as follows Figure 6 As shown, the parent node of each target output node and the parent node of the parent node of each target output node are searched one by one until the node found is the root node, and multiple query sub-results are obtained, for example, the first query sub-result (CUSTOM_SQL, FILTER, DATA_SOURCE) and the second query sub-result (FILTER, FILTER, DATA_SOURCE).
[0058] In the case where the target output node selected by the user is multiple nodes, multiple query sub-results can be accurately obtained through the above solution.
[0059] Optionally, in the offline model processing method provided in an embodiment of the present application, the nodes in the offline model except the nodes included in the query result are deleted to obtain an updated offline model, which includes: deleting the nodes in the offline model except the nodes included in the query sub-result respectively to obtain multiple sub-models; and merging the multiple sub-models to obtain an updated offline model.
[0060] For example, Figure 5 Delete all nodes except query sub-result 1 (CUSTOM_SQL, FILTER, DATA_SOURCE) to get Figure 7 The submodel shown. Figure 5 Delete all nodes except query sub-result 2 (FILTER, JOIN, CUSTOM_SQL, FILTER, DATA_SOURCE, FILTER, DATA_SOURCE, FILTER) to get Figure 8 The submodel shown. Figure 7 The submodel shown is similar to Figure 8 The sub-models shown are merged to obtain an updated offline model.
[0061] For example, Figure 6 Delete all nodes except the first query sub-result (CUSTOM_SQL, FILTER, DATA_SOURCE) to obtain sub-model 1. Figure 6 Delete all nodes except the second query sub-result (FILTER, FILTER, DATA_SOURCE) to obtain sub-model 2. Sub-model 1 and sub-model 2 are merged to obtain Fig. 9 The model shown will Fig. 9 The model shown is taken as the updated offline model.
[0062] Optionally, in the offline model processing method provided in the embodiment of the present application, after deleting the nodes in the offline model except the nodes included in the query result to obtain the updated offline model, the method further includes: starting from the root node of the updated offline model, determining whether the current node in the updated offline model is an SQL node, wherein the SQL node represents a calculation rule described by an SQL script; if the current node is an SQL node, starting to merge, adding the current node to a merge list, and traversing the child nodes of the current node to determine whether the child nodes are SQL nodes until the traversed node is the root node, thereby obtaining a final merge list; merging the nodes in the final merge list, constructing a single-node field for the merged node, and using the merged node of the constructed single-node field as the fused node in the updated offline model; if the traversed node is not an SQL node, constructing a single-node field for the non-SQL node, and using the non-SQL node of the constructed single-node field as the original node in the updated offline model; obtaining an optimized offline model based on the fused node and the original node. Optionally, using the updated offline model to perform calculations includes: using the optimized offline model to perform calculations.
[0063] Based on the idea of merging all SQL nodes in the offline model into a large node to reduce the computer resources occupied by the execution of multiple single SQL tasks, in the above technical solution, by merging the SQL nodes in the updated offline model, that is, partially merging the nodes in the offline model to optimize multiple nodes of the offline model, an optimized offline model is obtained, thereby further reducing the resource consumption when using the offline model for calculation.
[0064] Optionally, in the offline model processing method provided in the embodiment of the present application, when merging the nodes in the final merge list, the method also includes: when the current node meets any preset rule, stopping merging the current node in the final merge list, wherein the preset rule includes at least: the current node is a SQL node with an out-degree greater than 1, the child nodes of the current node include nodes with an in-degree greater than 1, the child nodes of the current node are non-SQL nodes, the current node is an output node that is not a leaf node, and the current node is a leaf node.
[0065] The rules in the preset rules are explained as follows: If the current node is a SQL node with an out-degree greater than 1, the result of the node may be reused by multiple downstream nodes, so the merging of the current node is stopped. If the child nodes of the current node include nodes with an in-degree greater than 1, it means that the child nodes of the current node are nodes for intersection, union, difference operations, etc., and the computational complexity increases when merging is possible, so the merging of the current node is stopped. If the child nodes of the current node are non-SQL nodes, for example, data synchronization nodes, API nodes, SHELL script nodes, PYTHON script nodes, etc., the merging of the current node is stopped. Since the merged node has no output result, if the current node is an output node that is not a leaf node, the output node can only be the last node in the field, so the merging of the current node is stopped. If the current node is a leaf node, the current node is required to output the result, so the merging of the current node is stopped.
[0066] For example, the updated offline model is Fig.10 As shown, Fig.10 The SQL nodes in the Fig.10 The nodes in the dashed box in the model are merged to obtain Fig.11 The model in which Fig.11 The nodes in the middle rectangular dotted box represent merge nodes, which are the result of merging multiple SQL nodes. The merging method can parse SQL, recompose multiple SQLs into one SQL, and optimize SQL with the help of SQL execution engine.
[0067] Through the above scheme, the rules for merging the nodes in the merge list are defined, the accuracy of the node merging is guaranteed, and thus the accuracy of the optimized offline model is guaranteed.
[0068] Optionally, in the offline model processing method provided in the embodiment of the present application, before obtaining the optimized offline model based on the fused node and the original node, the method also includes: determining whether the nodes in the updated offline model have been traversed; if the nodes in the updated offline model have been traversed, determining that the optimization of the updated offline model is completed, and executing the step of obtaining the optimized offline model based on the fused node and the original node.
[0069] Through the above scheme, before obtaining the optimized offline model, it is necessary to traverse all nodes in the updated offline model. After the traversal is completed, the nodes in the merge list can be partially merged, and the nodes that cannot be merged are retained to obtain the fused nodes and the original nodes, thereby obtaining the optimized offline model. By traversing all nodes in the model and distinguishing the SQL nodes and non-SQL nodes in the model, the accuracy of the optimized offline model is guaranteed.
[0070] Optionally, the nodes of the updated offline model are merged into an optimized schematic diagram, such as Fig.12 As shown, traversal starts at the root node of the updated offline model, and it is determined whether the current traversed node is a SQL node. If so, the current node is added to the merge list, and the nodes in the updated offline model are partially merged according to the preset rules based on the nodes in the merge list. After the local merge stops, the nodes in the merge list are merged, and STAGE (that is, the field of a single node) is constructed for non-SQL nodes in the offline model or SQL nodes in the merge list that do not meet the preset rules, and it is determined whether the updated offline model is optimized. If the optimization is completed, the optimized offline model is obtained.
[0071] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0072] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0073] Example 2
[0074] According to an embodiment of the present invention, a device for implementing the above-mentioned offline model processing method is also provided. Fig.13 As shown, the device includes: a first determining unit 1301, a first searching unit 1302, a first processing unit 1303 and a calculating unit 1304.
[0075] A first determining unit 1301 is used to determine a target output node selected by a user in an offline model, wherein the offline model is composed of a plurality of nodes based on offline calculations, and the node represents a calculation rule;
[0076] The first search unit 1302 is used to search the parent node of the target output node and the parent node of the parent node of the target output node in the offline model in a traversal manner one by one until the node found is a root node, thereby obtaining a query result, wherein the query result includes at least one queried node;
[0077] The first processing unit 1303 is used to delete nodes in the offline model except the nodes included in the query result to obtain an updated offline model;
[0078] The calculation unit 1304 is used to perform calculations using the updated offline model.
[0079] In summary, in the offline model processing device provided in the embodiment of the present application, the target output node selected by the user is determined in the offline model by the first determination unit 1301, wherein the offline model is composed of multiple nodes based on offline calculation, and the node represents a calculation rule; the first search unit 1302 uses a one-by-one traversal method to search the parent node of the target output node and the parent node of the parent node of the target output node in the offline model until the node found is the root node, and obtains the query result, wherein the query result includes at least one queried node; the first processing unit 1303 deletes the nodes in the offline model except the nodes included in the query result, and obtains the updated offline model; the calculation unit 1304 performs calculation using the updated offline model. The technical effect of avoiding resource waste when using the updated offline model for calculation is achieved, thereby solving the technical problem that there is resource waste when using the offline model for calculation due to the presence of calculation nodes unrelated to the target output node in the offline model of the related technology.
[0080] Optionally, in the offline model processing device provided in the embodiment of the present application, the device also includes: a second search unit, which is used to, if the target output node is multiple nodes, use a one-by-one traversal method in the offline model to search for the parent node of each target output node and the parent node of the parent node of each target output node, until the node found is the root node, to obtain multiple query sub-results; a second determination unit, which is used to use the multiple query sub-results as the query result.
[0081] Optionally, in the offline model processing device provided in an embodiment of the present application, the processing unit includes: a first processing module, used to delete nodes other than the nodes included in the query sub-results in the offline model to obtain multiple sub-models; and a merging module, used to merge the multiple sub-models to obtain an updated offline model.
[0082] Optionally, in the offline model processing device provided in the embodiment of the present application, the device further includes: a first judgment unit, which is used to delete the nodes in the offline model except the nodes included in the query result to obtain the updated offline model, and then, starting from the root node of the updated offline model, judge whether the current node in the updated offline model is an SQL node, wherein the SQL node represents a calculation rule described by an SQL script; a traversal unit, which is used to start merging if the current node is an SQL node, and add the current node to the merge list, and traverse the child nodes of the current node to judge whether the child node is an SQL node until the traversed node is the root node, thereby obtaining a final merged list; a merging unit is used to merge the nodes in the final merged list, construct a single-node field for the merged node, and use the merged node with the constructed single-node field as the fusion node in the updated offline model; a constructing unit is used to construct a single-node field for the non-SQL node if the traversed node is not an SQL node, and use the non-SQL node with the constructed single-node field as the original node in the updated offline model; a third determining unit is used to obtain an optimized offline model according to the fusion node and the original node.
[0083] Optionally, in the offline model processing device provided in the embodiment of the present application, the device also includes: a second processing unit, used to stop merging the current node in the final merge list when the current node meets any preset rule when merging the nodes in the final merge list, wherein the preset rule includes at least: the current node is a SQL node with an out-degree greater than 1, the child nodes of the current node include nodes with an in-degree greater than 1, the child nodes of the current node are non-SQL nodes, the current node is an output node that is not a leaf node, and the current node is a leaf node.
[0084] Optionally, in the offline model processing device provided in the embodiment of the present application, the device also includes: a second judgment unit, used to judge whether the nodes in the updated offline model have been traversed before obtaining the optimized offline model based on the fused node and the original node; a fourth determination unit, used to determine that the optimization of the updated offline model is completed if the nodes in the updated offline model have been traversed, and execute the step of obtaining the optimized offline model based on the fused node and the original node.
[0085] Optionally, in the offline model processing device provided in the embodiment of the present application, the calculation unit is also used to perform calculations using the optimized offline model.
[0086] It should be noted that the first determining unit 1301, the first searching unit 1302, the first processing unit 1303 and the calculating unit 1304 described above correspond to steps S101 to S104 in Embodiment 1, and the examples and application scenarios implemented by the two modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above Embodiment 1. It should be noted that the above modules, as part of the device, can be run in the computer terminal 10 provided in Embodiment 1.
[0087] Example 3
[0088] The embodiment of the present invention can provide a computer terminal, which can be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal can also be replaced by a terminal device such as a mobile terminal.
[0089] Optionally, in this embodiment, the computer terminal may be located in at least one network device among a plurality of network devices of the computer network.
[0090] In this embodiment, the above-mentioned computer terminal can execute the program code of the following steps in the processing method of the offline model of the application: in the offline model, determine the target output node selected by the user, wherein the offline model is composed of multiple nodes based on offline calculations, and the node represents a calculation rule; use a one-by-one traversal method to search for the parent node of the target output node and the parent node of the parent node of the target output node in the offline model until the node found is the root node, and obtain the query result, wherein the query result includes at least one queried node; delete the nodes in the offline model except the nodes included in the query result to obtain an updated offline model; and use the updated offline model to perform calculations.
[0091] The above-mentioned computer terminal can execute the program code of the following steps in the processing method of the offline model of the application: the method also includes: if the target output node is multiple nodes, the parent node of each target output node and the parent node of the parent node of each target output node are searched one by one in the offline model until the node found is the root node, and multiple query sub-results are obtained; and the multiple query sub-results are used as the query result.
[0092] The above-mentioned computer terminal can execute the program code of the following steps in the processing method of the offline model of the application: deleting the nodes in the offline model except the nodes included in the query result, and obtaining the updated offline model includes: deleting the nodes in the offline model except the nodes included in the query sub-result respectively to obtain multiple sub-models; merging the multiple sub-models to obtain the updated offline model.
[0093] The computer terminal can execute the program code of the following steps in the processing method of the offline model of the application: after deleting the nodes in the offline model except the nodes included in the query result to obtain the updated offline model, the method further includes: starting from the root node of the updated offline model, judging whether the current node in the updated offline model is an SQL node, wherein the SQL node represents the calculation rule described by the SQL script; if the current node is an SQL node, starting to merge, and adding the current node to the merge list, and traversing the child nodes of the current node, judging whether the child nodes are SQL nodes, until the traversed node is the root node, to obtain the final merge list; merging the nodes in the final merge list, constructing a single node field for the merged node, and using the merged node of the constructed single node field as the fusion node in the updated offline model; if the traversed node is not an SQL node,
[0094] The node constructs a single-node field, and uses the non-SQL node that constructs the single-node field as the original node in the updated offline model; and obtains the optimized offline model based on the fused node and the original node.
[0095] The above-mentioned computer terminal can execute the program code of the following steps in the processing method of the offline model of the application: when merging the nodes in the final merge list, the method also includes: when the current node meets any preset rule, stop merging the current node in the final merge list, wherein the preset rule at least includes: the current node is a SQL node with an out-degree greater than 1, the child nodes of the current node include nodes with an in-degree greater than 1, the child nodes of the current node are non-SQL nodes, the current node is an output node that is not a leaf node, and the current node is a leaf node.
[0096] The above-mentioned computer terminal can execute the program code of the following steps in the processing method of the offline model of the application: before obtaining the optimized offline model based on the fused node and the original node, the method also includes: judging whether the nodes in the updated offline model have been traversed; if the nodes in the updated offline model have been traversed, it is determined that the optimization of the updated offline model is completed, and the step of obtaining the optimized offline model based on the fused node and the original node is executed.
[0097] The computer terminal can execute the program code of the following steps in the method for processing the offline model of the application: using the updated offline model to perform calculations includes: using the optimized offline model to perform calculations.
[0098] Optionally, Fig.14is a structural block diagram of a computer terminal according to an embodiment of the present invention. Fig.14 As shown, the computer terminal may include: one or more ( Fig.14 Only one processor and memory are shown.
[0099] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the offline model processing method and device in the embodiment of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the above-mentioned offline model processing method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0100] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: determine the target output node selected by the user in the offline model, wherein the offline model is composed of multiple nodes based on offline calculations, and the node represents a calculation rule; use a one-by-one traversal method to search for the parent node of the target output node and the parent node of the parent node of the target output node in the offline model until the node found is the root node, and obtain the query result, wherein the query result includes at least one queried node; delete the nodes in the offline model except the nodes included in the query result to obtain an updated offline model; and use the updated offline model to perform calculations.
[0101] Optionally, the processor may also execute the program code of the following steps: the method also includes: if the target output node is multiple nodes, searching for the parent node of each target output node and the parent node of the parent node of each target output node in the offline model one by one, until the node found is the root node, to obtain multiple query sub-results; and using the multiple query sub-results as the query result.
[0102] Optionally, the processor may also execute the program code of the following steps: deleting the nodes in the offline model except the nodes included in the query result, and obtaining an updated offline model includes: deleting the nodes in the offline model except the nodes included in the query sub-result respectively, to obtain multiple sub-models; merging the multiple sub-models to obtain an updated offline model.
[0103] Optionally, the processor may also execute the following program code: after deleting the nodes in the offline model except the nodes included in the query result to obtain the updated offline model, the method may further include: starting from the root node of the updated offline model, determining whether the current node in the updated offline model is an SQL node, wherein the SQL node represents a calculation rule described by an SQL script; if the current node is an SQL node, starting to merge, adding the current node to a merge list, and traversing the child nodes of the current node to determine whether the child nodes are SQL nodes, until the traversed node is the root node, to obtain a final merge list; merging the nodes in the final merge list, constructing a single-node field for the merged node, and using the merged node with the constructed single-node field as the fused node in the updated offline model; if the traversed node is not an SQL node, constructing a single-node field for the non-SQL node, and using the non-SQL node with the constructed single-node field as the original node in the updated offline model; obtaining an optimized offline model based on the fused node and the original node.
[0104] Optionally, the processor may also execute the program code of the following steps: when merging the nodes in the final merge list, the method further includes: when the current node meets any preset rule, stopping merging the current node in the final merge list, wherein the preset rule includes at least: the current node is a SQL node with an out-degree greater than 1, the child nodes of the current node include nodes with an in-degree greater than 1, the child nodes of the current node are non-SQL nodes, the current node is an output node of a non-leaf node, and the current node is a leaf node.
[0105] Optionally, the processor may also execute the program code of the following steps: before obtaining the optimized offline model based on the fused node and the original node, the method further includes: determining whether the nodes in the updated offline model have been traversed; if the nodes in the updated offline model have been traversed, determining that the optimization of the updated offline model is completed, and executing the step of obtaining the optimized offline model based on the fused node and the original node.
[0106] Optionally, the processor may also execute program code of the following steps: using the updated offline model to perform calculations includes: using the optimized offline model to perform calculations.
[0107] By adopting the embodiment of the present invention, a solution of an offline model processing method is provided. By adopting a method of deleting nodes that are not related to the target output node in the offline model, specifically, in the offline model, the target output node selected by the user is determined, wherein the offline model is composed of multiple nodes based on offline calculations, and the node represents a calculation rule; by adopting a one-by-one traversal method, the parent node of the target output node and the parent node of the parent node of the target output node are searched in the offline model until the node found is the root node, and a query result is obtained, wherein the query result includes at least one queried node; the nodes in the offline model other than the nodes included in the query result are deleted to obtain an updated offline model; the updated offline model is used to perform calculations, thereby achieving the technical effect of avoiding resource waste when using the updated offline model for calculations, thereby solving the technical problem of resource waste when using the offline model for calculations due to the presence of calculation nodes that are not related to the target output node in the offline model of the related technology.
[0108] It can be understood by those skilled in the art that Fig.14 The structure shown is for illustration only, and the computer terminal may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Fig.14 The structure of the electronic device is not limited. For example, the computer terminal 10 may also include Fig.14 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Fig.14 Different configurations shown.
[0109] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0110] Example 4
[0111] The embodiment of the present invention further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the offline model processing method provided in the first embodiment.
[0112] Optionally, in this embodiment, the above storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.
[0113] Optionally, in this embodiment, the storage medium is configured to store program code for executing the following steps: determining a target output node selected by a user in an offline model, wherein the offline model is composed of multiple nodes based on offline calculations, and the node represents a calculation rule; searching the offline model for the parent node of the target output node and the parent node of the parent node of the target output node in a one-by-one traversal manner until the node found is a root node, thereby obtaining a query result, wherein the query result includes at least one queried node; deleting nodes in the offline model except the nodes included in the query result to obtain an updated offline model; and performing calculations using the updated offline model.
[0114] The storage medium is also configured to store program codes for executing the following steps: the method also includes: if the target output node is a plurality of nodes, searching for the parent node of each target output node and the parent node of the parent node of each target output node in the offline model one by one in a traversal manner until the node found is a root node, thereby obtaining a plurality of query sub-results; and using the plurality of query sub-results as the query result.
[0115] The storage medium is also configured to store program code for executing the following steps: deleting nodes in the offline model except the nodes included in the query result to obtain an updated offline model, including: deleting nodes in the offline model except the nodes included in the query sub-result respectively to obtain multiple sub-models; merging the multiple sub-models to obtain an updated offline model.
[0116] The storage medium is also configured to store a program code for executing the following steps: after deleting the nodes in the offline model except the nodes included in the query result to obtain the updated offline model, the method further comprises: starting from the root node of the updated offline model, determining whether the current node in the updated offline model is an SQL node, wherein the SQL node represents a calculation rule described by an SQL script; if the current node is an SQL node, starting to merge, adding the current node to a merge list, and traversing the child nodes of the current node to determine whether the child nodes are SQL nodes, until the traversed node is the root node, to obtain a final merge list; merging the nodes in the final merge list, constructing a single-node field for the merged node, and using the merged node with the constructed single-node field as the fused node in the updated offline model; if the traversed node is not an SQL node, constructing a single-node field for the non-SQL node, and using the non-SQL node with the constructed single-node field as the original node in the updated offline model; obtaining an optimized offline model based on the fused node and the original node.
[0117] The storage medium is also configured to store program code for executing the following steps: when merging the nodes in the final merge list, the method also includes: when the current node meets any preset rule, stopping merging the current node in the final merge list, wherein the preset rule at least includes: the current node is a SQL node with an out-degree greater than 1, the child nodes of the current node include nodes with an in-degree greater than 1, the child nodes of the current node are non-SQL nodes, the current node is an output node that is not a leaf node, and the current node is a leaf node.
[0118] The storage medium is also configured to store program codes for executing the following steps: before obtaining an optimized offline model based on the fused node and the original node, the method further includes: determining whether the nodes in the updated offline model have been traversed; if the nodes in the updated offline model have been traversed, determining that the optimization of the updated offline model is completed, and executing the step of obtaining an optimized offline model based on the fused node and the original node.
[0119] The storage medium is also configured to store program codes for executing the following steps: performing calculations using the updated offline model includes performing calculations using the optimized offline model.
[0120] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0121] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0122] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0123] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0124] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0125] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0126] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for processing an offline model, characterized in that: include: In the offline model, determining a target output node selected by a user, wherein the offline model is composed of a plurality of nodes based on offline calculations, and the node represents a calculation rule; In a one-by-one traversal manner, the parent node of the target output node and the parent node of the parent node of the target output node are searched in the offline model until the node found is a root node, thereby obtaining a query result, wherein the query result includes at least one queried node; Deleting nodes in the offline model except the nodes included in the query result to obtain an updated offline model; Calculations are performed using the updated offline model.
2. The method according to claim 1, characterized in that The method further comprises: If the target output node is a plurality of nodes, the parent node of each target output node and the parent node of the parent node of each target output node are searched one by one in the offline model until the node found is the root node, thereby obtaining a plurality of query sub-results; The multiple query sub-results are used as the query result.
3. The method according to claim 2, characterized in that Deleting nodes in the offline model except the nodes included in the query result, and obtaining an updated offline model includes: In the offline model, nodes other than the nodes included in the query sub-result are deleted respectively to obtain a plurality of sub-models; The multiple sub-models are merged to obtain an updated offline model.
4. The method according to claim 1, characterized in that After deleting the nodes in the offline model except the nodes included in the query result to obtain an updated offline model, the method further includes: Starting from the root node of the updated offline model, determining whether the current node in the updated offline model is an SQL node, wherein the SQL node represents a calculation rule described by an SQL script; If the current node is a SQL node, start merging, add the current node to the merge list, and traverse the child nodes of the current node to determine whether the child nodes are SQL nodes, until the traversed node is the root node, and obtain the final merge list; Merging the nodes in the final merge list, constructing a single-node field for the merged nodes, and using the merged node of the constructed single-node field as a fusion node in the updated offline model; If the traversed node is not an SQL node, construct a single-node field for the non-SQL node, and use the non-SQL node for which the single-node field is constructed as the original node in the updated offline model; An optimized offline model is obtained according to the fused nodes and the original nodes.
5. The method according to claim 4, characterized in that When merging the nodes in the final merged list, the method further includes: When the current node meets any preset rule, stop merging the current node in the final merge list, wherein the preset rule includes at least: the current node is a SQL node with an out-degree greater than 1, the child nodes of the current node include nodes with an in-degree greater than 1, the child nodes of the current node are non-SQL nodes, the current node is an output node that is not a leaf node, and the current node is a leaf node.
6. The method according to claim 4, characterized in that Before obtaining the optimized offline model according to the fused node and the original node, the method further includes: Determining whether all nodes in the updated offline model have been traversed; If all nodes in the updated offline model have been traversed, it is determined that the optimization of the updated offline model is completed, and a step of obtaining an optimized offline model based on the fused nodes and the original nodes is executed.
7. The method according to claim 4, characterized in that Using the updated offline model to perform calculations includes: using the optimized offline model to perform calculations.
8. An off-line model processing device, characterized in that: include: A first determination unit is used to determine a target output node selected by a user in an offline model, wherein the offline model is composed of a plurality of nodes based on offline calculations, and the node represents a calculation rule; A first search unit is used to search the parent node of the target output node and the parent node of the parent node of the target output node in the offline model in a traversal manner one by one until the node found is a root node, thereby obtaining a query result, wherein the query result includes at least one queried node; A first processing unit, configured to delete nodes in the offline model except the nodes included in the query result, to obtain an updated offline model; A computing unit is used to perform computing using the updated offline model.
9. A computer-readable storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the offline model processing method according to any one of claims 1 to 7.
10. A processor, characterized in that: The processor is used to run a program, wherein the program, when running, executes the offline model processing method described in any one of claims 1 to 7.
Citation Information
Patent Citations
System and method of efficiently representing and searching directed acyclic graph structures in databases
CN101421729A
Database query method and device, server and medium
CN110471916A