A data calculation method and device
By using directed acyclic graph algorithm and data association relationship tables in the data calculation method, a group graph-shaped link diagram is generated and the calculation model is traversed, the problem of low reusability of personalized business logic in the prior art is solved, and general calculation and efficient maintenance of complex attribute data are realized.
Patent Information
- Application Number
- CN202110019733.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-07
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2041-01-07
AI Technical Summary
In the prior art, proprietary personalized business logic is low in reusability and difficult to maintain when processing data with different complex attribute types.
A general data calculation method is adopted to receive data requests, extract request attributes and parameter values, form a request group, retrieve data association relationship tables, and generate a group graph-shaped link diagram using directed acyclic graph algorithm, and traverse the graph to call the calculation model to calculate the value of the request attribute.
It realizes general calculations for data with different attribute complexity, improving logical reusability and maintenance ease.
Smart Images

Figure CN113779484B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data calculation method and device. Background Art
[0002] Data has attribute characteristics. Data with complex attributes can be constructed or calculated from data with low-order simple attributes. For data with different types of complex attributes, the existing technology often develops proprietary personalized business logic to perform data calculations.
[0003] In the process of implementing the present invention, there are at least the following problems in the prior art:
[0004] Proprietary personalized business logic has low reusability and is difficult to maintain. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a data calculation method and device, which can satisfy the calculation of data with different attribute complexity with a universal data calculation method, and the method has strong logic reusability and is easy to maintain.
[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a data calculation method is provided, comprising:
[0007] Receiving a data request, extracting one or more request attributes and input parameter values in the data request;
[0008] The one or more request attributes constitute a request group, retrieve a data association table, and use a directed acyclic graph algorithm to take the request group as a destination node to generate a corresponding group graph link graph; wherein the group graph link graph indicates the attribute identifier to be calculated for determining the request attribute, the attribute group composed of the attribute to be calculated, and the dependency relationship between the attribute groups;
[0009] The group graph link graph is traversed using a directed acyclic graph algorithm, and a corresponding calculation model is called based on the identifier of the attribute to be calculated in the attribute group, and then the value of the one or more requested attributes is calculated according to the input parameter value in the data request and output.
[0010] Optionally, the retrieving the data association relationship table, using a directed acyclic graph algorithm with the request group as the destination node to generate a corresponding group graph link graph, includes:
[0011] Retrieve the data association table to obtain the dependency relationship between attributes and the relationship between attributes and groups;
[0012] For each request attribute in the request group, based on the dependency relationship, a directed acyclic graph algorithm is used to generate an attribute link graph of the request attribute with the request attribute as the destination node;
[0013] For all attributes to be calculated in the attribute link graph, attribute groups are obtained by aggregating the attributes to be calculated based on the belonging relationship to serve as group nodes, and the request group is used as the destination node to generate the group graph link graph.
[0014] Optionally, generating a corresponding group graph link graph further includes:
[0015] A parameter group is formed according to the input parameter values in the data request to serve as the starting node of the group graph link diagram.
[0016] Optionally, before traversing the group graph-like link graph using a directed acyclic graph algorithm, the method further includes:
[0017] Acquire a set of routing conditions between attribute groups, determine one or more routing conditions in the set of routing conditions, and the dependent attribute groups and the attribute groups to be calculated corresponding to the routing conditions; and,
[0018] When the directed acyclic graph algorithm is used to traverse the group graph-like link graph, if it is determined according to the routing condition that the condition is not satisfied, the corresponding routing from the dependent attribute group to the attribute group to be calculated is terminated.
[0019] Optionally, the traversing the group graph-like link graph using a directed acyclic graph algorithm and calling a corresponding calculation model based on the to-be-calculated attribute identifier in the attribute group includes:
[0020] Using a directed acyclic graph algorithm to traverse the group graph-like link graph, triggering the counters of the attribute groups in sequence;
[0021] The data getter is used to call the corresponding calculation model according to the to-be-calculated attribute identifier in the corresponding attribute group.
[0022] Optionally, calculating the values of the one or more request attributes according to input parameter values in the data request includes:
[0023] According to the triggering order of the data accessors of the attribute group, the parameter group consisting of the input parameter value is used as the starting trigger, and the data storage medium corresponding to the attribute group is accessed by the data accessors in turn to read the data value used to calculate the attribute to be calculated in the attribute group, and then the corresponding calculation model is called to perform calculation based on the data value;
[0024] Until the group graph link graph traversal is completed, the value of one or more request attributes in the request group is obtained.
[0025] Optionally, when the attribute to be calculated is a native attribute, after calling the corresponding calculation model to perform calculation based on the data value, the method further includes: determining the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, calling the parsing method corresponding to the attribute group, and performing data format conversion on the calculated result;
[0026] When the attribute to be calculated is a composite attribute, after calling the corresponding calculation model to perform calculation based on the data value, it also includes: determining the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, calling the merging method corresponding to the attribute group, and performing data merging on the calculated results.
[0027] According to another aspect of an embodiment of the present invention, there is provided a data computing device, comprising:
[0028] A receiving module, used for receiving a data request and extracting one or more request attributes and input parameter values in the data request;
[0029] A graph forming module, configured to form a request group with the one or more request attributes, retrieve a data association table, and generate a corresponding group graph link graph with the request group as a destination node using a directed acyclic graph algorithm; wherein the group graph link graph indicates an attribute identifier to be calculated for determining the request attribute, an attribute group composed of the attribute to be calculated, and a dependency relationship between the attribute groups;
[0030] A calculation module is used to traverse the group graph link graph using a directed acyclic graph algorithm, call the corresponding calculation model based on the attribute identifier to be calculated in the attribute group, and then calculate the value of the one or more requested attributes according to the input parameter value in the data request, and output it.
[0031] Optionally, the mapping module retrieves the data association table, uses a directed acyclic graph algorithm to take the request group as the destination node, and generates a corresponding group graph link graph, including:
[0032] Retrieve the data association table to obtain the dependency relationship between attributes and the relationship between attributes and groups;
[0033] For each request attribute in the request group, based on the dependency relationship, a directed acyclic graph algorithm is used to generate an attribute link graph of the request attribute with the request attribute as the destination node;
[0034] For all attributes to be calculated in the attribute link graph, attribute groups are obtained by aggregating the attributes to be calculated based on the belonging relationship to serve as group nodes, and the request group is used as the destination node to generate the group graph link graph.
[0035] Optionally, the mapping module generates a corresponding group graph link graph, further comprising:
[0036] A parameter group is formed according to the input parameter values in the data request to serve as the starting node of the group graph link diagram.
[0037] Optionally, before traversing the group graph-like link graph using a directed acyclic graph algorithm, the method further includes:
[0038] Acquire a set of routing conditions between attribute groups, determine one or more routing conditions in the set of routing conditions, and the dependent attribute groups and the attribute groups to be calculated corresponding to the routing conditions; and,
[0039] When the directed acyclic graph algorithm is used to traverse the group graph-like link graph, if it is determined according to the routing condition that the condition is not satisfied, the corresponding routing from the dependent attribute group to the attribute group to be calculated is terminated.
[0040] Optionally, the calculation module uses a directed acyclic graph algorithm to traverse the group graph-like link graph, and calls a corresponding calculation model based on the attribute identifier to be calculated in the attribute group, including:
[0041] Using a directed acyclic graph algorithm to traverse the group graph-like link graph, triggering the counters of the attribute groups in sequence;
[0042] The data getter is used to call the corresponding calculation model according to the to-be-calculated attribute identifier in the corresponding attribute group.
[0043] Optionally, the calculation module calculates the value of the one or more request attributes according to the input parameter value in the data request, including:
[0044] According to the triggering order of the data accessors of the attribute group, the parameter group consisting of the input parameter value is used as the starting trigger, and the data storage medium corresponding to the attribute group is accessed by the data accessors in turn to read the data value used to calculate the attribute to be calculated in the attribute group, and then the corresponding calculation model is called to perform calculation based on the data value;
[0045] Until the group graph link graph traversal is completed, the value of one or more request attributes in the request group is obtained.
[0046] Optionally, when the attribute to be calculated is a native attribute, after the calculation module calls the corresponding calculation model to perform calculation based on the data value, it further includes: determining the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, calling the parsing method corresponding to the attribute group, and performing data format conversion on the calculated result;
[0047] When the attribute to be calculated is a composite attribute, after calling the corresponding calculation model to perform calculation based on the data value, the calculation module further includes: determining the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, calling the merging method corresponding to the attribute group, and performing data merging on the calculated results.
[0048] According to another aspect of an embodiment of the present invention, there is provided a data computing electronic device, comprising:
[0049] one or more processors;
[0050] a storage device for storing one or more programs,
[0051] When the one or more programs are executed by the one or more processors, the one or more processors implement the data calculation method provided by the present invention.
[0052] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the data calculation method provided by the present invention is implemented.
[0053] An embodiment of the above invention has the following advantages or beneficial effects: because it adopts a directed acyclic graph algorithm to construct a group graph link graph corresponding to the data request based on the data association relationship table according to the data request, and then traverses the group graph link graph, so as to trigger the calculation method of the attributes in the group in sequence based on the input parameter value in the data request, so that when the traversal is completed, the result of the data request can be obtained. Therefore, the technical means overcomes the technical problem of low reusability and difficult maintenance of business logic caused by formulating proprietary personalized business logic for data with different complex attribute types in the prior art, and thus can use a universal data calculation method to meet the calculation of data with different attribute complexities, and the calculation method has strong logical reusability and is easy to maintain.
[0054] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0056] Figure 1 is a schematic diagram of the main process of a data calculation method according to the first embodiment of the present invention;
[0057] Figure 2 is a schematic diagram of a group graph-like link graph in a data calculation method according to a second embodiment of the present invention;
[0058] Figure 3is a schematic diagram of a system architecture of a data calculation method according to a third embodiment of the present invention;
[0059] Figure 4 is a schematic diagram of main modules of a data computing device according to a fourth embodiment of the present invention;
[0060] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0061] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0062] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0063] Figure 1 is a schematic diagram of the main process of a data calculation method according to the first embodiment of the present invention. Figure 1 As shown, including:
[0064] Step S101: receiving a data request, and extracting one or more request attributes and input parameter values in the data request;
[0065] Step S102: forming a request group with the one or more request attributes, retrieving a data association table, and using a directed acyclic graph algorithm to take the request group as a destination node to generate a corresponding group graph link graph; wherein the group graph link graph indicates the attribute identifier to be calculated for determining the request attribute, the attribute group composed of the attribute to be calculated, and the dependency relationship between the attribute groups;
[0066] Step S103: Use a directed acyclic graph algorithm to traverse the group graph link graph, call the corresponding calculation model based on the attribute identifier to be calculated in the attribute group, and then calculate the value of the one or more requested attributes according to the input parameter value in the data request, and output it.
[0067] The data request may include input parameter value information and the requested data attributes. For example, the data request may be: when conditions X and Y are met, request to return the value of the data with data attribute Z. In this request, the input parameter values can be extracted according to conditions X and Y, and the requested attribute information can be extracted according to "data attribute is Z" (the requested attribute of this request is "Z").
[0068] The data association relationship table can be pre-configured, which can include the association dependency between attributes (specifically, when the attribute value of attribute P needs to be determined by the attribute value of attribute Q, attribute P can be considered to be dependent on attribute Q), and can also include the attribution relationship between attributes and attribute groups (specifically, attributes with the same characteristics can be classified into the same group). By configuring the data association relationship table, the dependency relationship between attributes and the attribution relationship between attributes and attribute groups can be dynamically planned. When there is an attribute update or an attribute dependency update, only the data association relationship table needs to be modified; thus, it can be flexibly applied to various business scenarios.
[0069] Based on the data association table, the directed acyclic graph algorithm (DAG (Directed Acyclic Graph) algorithm) is used to construct the graph, which can prevent the appearance of circular dependencies and avoid infinite loops, thereby avoiding the exhaustion of system resources and the inability of the system to provide services normally. In the graph, groups are used as nodes, and traversal can be performed at the group granularity, saving resource space while not affecting the representation of dependency relationships between attributes.
[0070] The calculation models corresponding to various attributes can be pre-configured. In the calculation models, logical operation rules and data acquisition rules can be formulated. Various capabilities can also be configured, such as parameter parsing capability, composite attribute merging capability, attribute value conversion capability, attribute and group routing capability, group value parsing capability, data acquisition device routing capability, etc., for data calculation calls. Rules or capabilities can be configured for a group, and the rules or capabilities can be used to calculate the attribute values in the group, so there is no need to configure each attribute separately, thus saving resources.
[0071] The present invention can extract one or more request attributes and input parameter values from the data request, construct a group graph link graph corresponding to the data request based on the data association relationship table and the directed acyclic graph algorithm, and then traverse the group graph link graph to trigger the calculation method of the attributes in the group in sequence based on the input parameter values in the data request, so that when the traversal is completed, the result of the data request can be obtained. The present invention can satisfy the calculation of data with different attribute complexity with a universal data calculation method, and the calculation method has strong logic reusability and is easy to maintain.
[0072] In some embodiments, the calling of the data association relationship table uses a directed acyclic graph algorithm to generate a corresponding group graph link graph with the request group as the destination node, including:
[0073] Retrieve the data association table to obtain the dependency relationship between attributes and the relationship between attributes and groups;
[0074] For each request attribute in the request group, based on the dependency relationship, a directed acyclic graph algorithm is used to generate an attribute link graph of the request attribute with the request attribute as the destination node;
[0075] For all attributes to be calculated in the attribute link graph, attribute groups are obtained by aggregating the attributes to be calculated based on the belonging relationship to serve as group nodes, and the request group is used as the destination node to generate the group graph link graph.
[0076] Furthermore, in some embodiments, the generating of the corresponding group graph-like link graph further includes: forming a parameter group according to the input parameter value in the data request to serve as the starting node of the group graph-like link graph.
[0077] Based on the dependency relationship between attributes, an attribute link can be generated for each request attribute in the request group, and then the attribute links can be combined based on the affiliation relationship between the attribute and the group to obtain a group graph-like link diagram with the group as the granularity; in some practical applications, a group graph-like link diagram with the group as the granularity can also be directly generated based on the above-mentioned dependency relationship and affiliation relationship.
[0078] The directed acyclic graph algorithm (DAG (Directed Acyclic Graph) algorithm) is used for graph composition. During the graph composition process, it can monitor whether there is a circular dependency in the data association table. If it exists, the graph cannot be composed normally, thereby preventing the occurrence of circular dependencies and avoiding infinite loops, thereby avoiding exhaustion of system resources and making the system unable to provide services normally.
[0079] In some embodiments, before traversing the group graph-like link graph using a directed acyclic graph algorithm, the method further includes:
[0080] Acquire a set of routing conditions between attribute groups, determine one or more routing conditions in the set of routing conditions, and the dependent attribute groups and the attribute groups to be calculated corresponding to the routing conditions; and,
[0081] When the directed acyclic graph algorithm is used to traverse the group graph-like link graph, if it is determined according to the routing condition that the condition is not satisfied, the corresponding routing from the dependent attribute group to the attribute group to be calculated is terminated.
[0082] Figure 2 is a schematic diagram of a group graph-like link graph in a data calculation method according to a second embodiment of the present invention; Figure 2 The group graph link graph in is constructed with the parameter group as the starting node and the request group as the destination node; Figure 2 As shown:
[0083] Group A, Group C, and Group E depend on the parameter group; Group B depends on Group A; Group D can depend on Group C if the routing conditions are met; Group F depends on Group C and Group E; Group G depends on Group G; Request Group depends on Group B, Group D, and Group G;
[0084] For group D and group C, only when the routing conditions are met will they be routed to group D and trigger the data acquisition logic of group D, otherwise the routing from group C to group D is terminated. The routing conditions can be set according to specific business scenarios, such as: "All attributes to be calculated in group C are successfully obtained" or "The current time is over 12:00" and other conditions can be set.
[0085] In some embodiments, the traversing the group graph-like link graph using a directed acyclic graph algorithm and calling a corresponding calculation model based on the to-be-calculated attribute identifier in the attribute group includes:
[0086] The group graph link graph is traversed by using a directed acyclic graph algorithm to trigger the counters of the attribute groups in sequence; the counters are used to call the corresponding calculation model according to the identifier of the attribute to be calculated in the corresponding attribute group.
[0087] Furthermore, in some embodiments, calculating the values of the one or more request attributes according to the input parameter values in the data request includes:
[0088] According to the triggering order of the data accessors of the attribute group, the parameter group consisting of the input parameter value is used as the starting trigger, and the data storage medium corresponding to the attribute group is accessed by the data accessors in turn to read the data value used to calculate the attribute to be calculated in the attribute group, and then the corresponding calculation model is called to perform calculation based on the data value;
[0089] Until the group graph link graph traversal is completed, the value of one or more request attributes in the request group is obtained.
[0090] For the constructed group graph link graph, the DAG (Directed Acyclic Graph) algorithm is used to traverse the entire link. In actual execution, the parameter group can be started, and the group execution counters can be triggered one by one. Before the actual execution of the data acquisition, the routing capability can be executed to determine whether the routing conditions of the group meet the data acquisition requirements, and then determine whether to enable the computing resources for the data acquisition operation;
[0091] For groups that meet the routing conditions, the data acquisition capability of the pre-configured counter can be triggered to perform the data acquisition operation. Counters of different attribute groups can correspond to different storage media, such as database, Redis cache, remote service, memory, etc. The encapsulation of data acquisition logic can provide a common interface in some practical applications to shield the differences in data acquisition logic.
[0092] Until the group graph link graph traversal is completed, at this time, all the corresponding counters of the group have completed the counter operation, and the request attributes in the request group have also completed the value operation, the value of one or more request attributes in the request group can be obtained. A result collector can be set. When the result collector obtains the value of one or more request attributes in the request group, it can start to respond to the request result of the data request and return the value of one or more request attributes as the request result.
[0093] In some embodiments, when the attribute to be calculated is a native attribute, after calling the corresponding calculation model to perform calculation based on the data value, the method further includes: determining the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, calling the parsing method corresponding to the attribute group, and performing data format conversion on the calculated result;
[0094] When the attribute to be calculated is a composite attribute, after calling the corresponding calculation model to perform calculation based on the data value, it also includes: determining the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, calling the merging method corresponding to the attribute group, and performing data merging on the calculated results.
[0095] Attributes can be divided into native attributes and composite attributes. Composite attributes can be obtained by combining and arranging other native attributes or composite attributes (for example, connecting the attribute values of two native attributes through the symbol " / " to obtain the attribute value of a composite attribute). In some practical applications, the specific value-taking logic of native attributes and composite attributes can be different. After using the calculation model to take values for native attributes, the value resolution strategy can be obtained from the group to which it belongs, and then the value-taking logic is executed according to the value resolution strategy. In some applications, after taking values for native attributes, value conversion capabilities can also be configured to perform post-processing of attribute values by executing this capability. After using the calculation model to take values for composite attributes, the value merging capability can be used to merge dependent attribute values according to the merging strategy.
[0096] Figure 3 is a schematic diagram of a system architecture of a data calculation method according to a third embodiment of the present invention. Figure 3 As shown, including:
[0097] The interface layer is used to receive data requests and extract input parameter values and request attributes;
[0098] The business layer is used to configure the data association table and build the corresponding group graph link diagram based on the data association table and the information in the data request.
[0099] The data layer is used to configure different data storage media to store various information used to calculate data attribute values.
[0100] According to the method in the present invention, an arrangable model of native attributes, composite attributes and main-sub-attribute groups can be provided. The arrangable model can be applied to complex business data requests, and complex problems can be decomposed into a number of simple sub-problems in multiple dimensions, and finally the business data request results can be obtained according to demand and in order. The data acquisition framework system constructed using the method in the present invention can integrate a set of abstract capabilities (such as: parameter parsing capability, composite attribute merging capability, attribute value conversion capability, attribute and group routing capability, group value parsing capability, data acquisition device routing capability and data acquisition device data acquisition capability, etc.), which universally encapsulates common logic, supports high scalability, and has high reusability.
[0101] like Figure 3 As shown, the data request may include input parameter values, such as a specific product number (input parameter 1), terminal type (input parameter 2), and site information (input parameter 3). These input parameters may be encapsulated as parameter attributes, and these parameter attributes are classified into parameter groups; attribute fields 1, 2, 3, 4, and 5 in the data request are request attributes, which may form a request group.
[0102] by Figure 3 The following example illustrates the process of calculating the request attribute value in a request group:
[0103] For request attribute 1:
[0104] Depend on Figure 3 It can be seen that the request attribute 1 depends on the composite attribute A, which is composed of the native attribute a. It can be considered that the composite attribute A depends on the native attribute a, and the native attribute a belongs to the subgroup 1 in the main group 1; then the value acquisition process of the request attribute 1 can be:
[0105] Based on the parameter group, the value of native attribute a in subgroup 1 in main group 1 is calculated, and then the value of composite attribute A is calculated based on the value of native attribute a, and then the value of request attribute 1 is calculated based on the value of composite attribute A.
[0106] Figure 4 is a schematic diagram of main modules of a data computing device according to a fourth embodiment of the present invention, such as Figure 4 As shown, the data computing device 400 includes:
[0107] The receiving module 401 is used to receive a data request and extract one or more request attributes and input parameter values in the data request;
[0108] A graph forming module 402 is used to form a request group with the one or more request attributes, retrieve a data association relationship table, and use a directed acyclic graph algorithm to take the request group as a destination node to generate a corresponding group graph link graph; wherein the group graph link graph indicates the attribute identifier to be calculated for determining the request attribute, the attribute group composed of the attribute to be calculated, and the dependency relationship between the attribute groups;
[0109] The calculation module 403 is used to traverse the group graph link graph using a directed acyclic graph algorithm, call the corresponding calculation model based on the attribute identifier to be calculated in the attribute group, and then calculate the value of the one or more requested attributes according to the input parameter value in the data request, and output it.
[0110] The data request may include input parameter value information and the requested data attributes. For example, the data request may be: when conditions X and Y are met, request to return the value of the data with data attribute Z. In this request, the input parameter values can be extracted according to conditions X and Y, and the requested attribute information can be extracted according to "data attribute is Z" (the requested attribute of this request is "Z").
[0111] The data association relationship table can be pre-configured, which can include the association dependency between attributes (specifically, when the attribute value of attribute P needs to be determined by the attribute value of attribute Q, attribute P can be considered to be dependent on attribute Q), and can also include the attribution relationship between attributes and attribute groups (specifically, attributes with the same characteristics can be classified into the same group). By configuring the data association relationship table, the dependency relationship between attributes and the attribution relationship between attributes and attribute groups can be dynamically planned. When there is an attribute update or an attribute dependency update, only the data association relationship table needs to be modified; thus, it can be flexibly applied to various business scenarios.
[0112] Based on the data association table, the directed acyclic graph algorithm (DAG (Directed Acyclic Graph) algorithm) is used to construct the graph, which can prevent the appearance of circular dependencies and avoid infinite loops, thereby avoiding the exhaustion of system resources and the inability of the system to provide services normally. In the graph, groups are used as nodes, and traversal can be performed at the group granularity, saving resource space while not affecting the representation of dependency relationships between attributes.
[0113] The calculation models corresponding to various attributes can be pre-configured. In the calculation models, logical operation rules and data acquisition rules can be formulated. Various capabilities can also be configured, such as parameter parsing capability, composite attribute merging capability, attribute value conversion capability, attribute and group routing capability, group value parsing capability, data acquisition device routing capability, etc., for data calculation calls. Rules or capabilities can be configured for a group, and the rules or capabilities can be used to calculate the attribute values in the group, so there is no need to configure each attribute separately, thus saving resources.
[0114] The present invention can extract one or more request attributes and input parameter values according to the data request, construct a group graph link graph corresponding to the data request based on the data association relationship table and a directed acyclic graph algorithm, and then traverse the group graph link graph using a directed acyclic graph algorithm to trigger the calculation method of the attributes in the group in sequence based on the input parameter values in the data request, so that when the traversal is completed, the result of the data request can be obtained. The present invention can meet the calculation of data with different attribute complexity with a universal data calculation method, and the calculation method has strong logic reusability and is easy to maintain.
[0115] In some embodiments, the mapping module retrieves the data association table, uses a directed acyclic graph algorithm to generate a corresponding group graph link graph with the request group as the destination node, including:
[0116] Retrieve the data association relationship table to obtain the dependency relationship between attributes and the affiliation relationship between attributes and groups; for each request attribute in the request group, based on the dependency relationship, adopt a directed acyclic graph algorithm with the request attribute as the destination node to generate an attribute link graph of the request attribute; for the attributes to be calculated in all attribute link graphs, aggregate the attributes to be calculated based on the affiliation relationship to obtain attribute groups as group nodes, and use the request group as the destination node to generate the group graph link graph.
[0117] Furthermore, in some embodiments, the mapping module generates a corresponding group graph-like link graph, and further includes: forming a parameter group according to an input parameter value in the data request to serve as a starting node of the group graph-like link graph.
[0118] Based on the dependency relationship between attributes, an attribute link can be generated for each request attribute in the request group, and then the attribute links can be combined based on the affiliation relationship between the attribute and the group to obtain a group graph-like link diagram with the group as the granularity; in some practical applications, a group graph-like link diagram with the group as the granularity can also be directly generated based on the above-mentioned dependency relationship and affiliation relationship.
[0119] The directed acyclic graph algorithm (DAG (Directed Acyclic Graph) algorithm) is used for graph composition. During the graph composition process, it can monitor whether there is a circular dependency in the data association table. If it exists, the graph cannot be composed normally, thereby preventing the occurrence of circular dependencies and avoiding infinite loops, thereby avoiding exhaustion of system resources and making the system unable to provide services normally.
[0120] In some embodiments, before traversing the group graph-like link graph using a directed acyclic graph algorithm, the method further includes:
[0121] Acquire a set of routing conditions between attribute groups, determine one or more routing conditions in the set of routing conditions, and the dependent attribute groups and the attribute groups to be calculated corresponding to the routing conditions; and,
[0122] When the directed acyclic graph algorithm is used to traverse the group graph-like link graph, if it is determined according to the routing condition that the condition is not satisfied, the corresponding routing from the dependent attribute group to the attribute group to be calculated is terminated.
[0123] For example, if group D can rely on group C when the routing conditions are met, it means that for group D and group C, only when the routing conditions are met will they be routed to group D and trigger the data acquisition logic of group D, otherwise the routing from group C to group D will be terminated. Routing conditions can be set according to specific business scenarios, such as: "All attributes to be calculated in group C are successfully obtained" or "The current time is over 12:00" and other conditions can be set.
[0124] In some embodiments, the calculation module uses a directed acyclic graph algorithm to traverse the group graph-like link graph, and calls a corresponding calculation model based on the attribute identifier to be calculated in the attribute group, including:
[0125] The group graph link graph is traversed by using a directed acyclic graph algorithm to trigger the counters of the attribute groups in sequence; the counters are used to call the corresponding calculation model according to the identifier of the attribute to be calculated in the corresponding attribute group.
[0126] Furthermore, in some embodiments, the calculation module calculates the value of the one or more request attributes according to the input parameter value in the data request, including:
[0127] According to the triggering order of the data accessors of the attribute group, the parameter group consisting of the input parameter value is used as the starting trigger, and the data storage medium corresponding to the attribute group is accessed by the data accessors in turn to read the data value used to calculate the attribute to be calculated in the attribute group, and then the corresponding calculation model is called to perform calculation based on the data value;
[0128] Until the group graph link graph traversal is completed, the value of one or more request attributes in the request group is obtained.
[0129] For the constructed group graph link graph, the DAG (Directed Acyclic Graph) algorithm is used to traverse the entire link. In actual execution, the parameter group can be started, and the group execution counters can be triggered one by one. Before the actual execution of the data acquisition, the routing capability can be executed to determine whether the routing conditions of the group meet the data acquisition requirements, and then determine whether to enable the computing resources for the data acquisition operation;
[0130] For groups that meet the routing conditions, the data acquisition capability of the pre-configured counter can be triggered to perform the data acquisition operation. Counters of different attribute groups can correspond to different storage media, such as database, Redis cache, remote service, memory, etc. The encapsulation of data acquisition logic can provide a common interface in some practical applications to shield the differences in data acquisition logic.
[0131] Until the group graph link graph traversal is completed, at this time, all the corresponding counters of the group have completed the counter operation, and the request attributes in the request group have also completed the value operation, the value of one or more request attributes in the request group can be obtained. A result collector can be set. When the result collector obtains the value of one or more request attributes in the request group, it can start to respond to the request result of the data request and return the value of one or more request attributes as the request result.
[0132] In some embodiments, when the attribute to be calculated is a native attribute, after the calculation module calls the corresponding calculation model to perform calculation based on the data value, it further includes: determining the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, calling the parsing method corresponding to the attribute group, and performing data format conversion on the calculated result;
[0133] When the attribute to be calculated is a composite attribute, after calling the corresponding calculation model to perform calculation based on the data value, the calculation module further includes: determining the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, calling the merging method corresponding to the attribute group, and performing data merging on the calculated results.
[0134] Attributes can be divided into native attributes and composite attributes. Composite attributes can be obtained by combining and arranging other native attributes or composite attributes (for example, connecting the attribute values of two native attributes through the symbol " / " to obtain the attribute value of a composite attribute). In some practical applications, the specific value-taking logic of native attributes and composite attributes can be different. After using the calculation model to take values for native attributes, the value resolution strategy can be obtained from the group to which it belongs, and then the value-taking logic is executed according to the value resolution strategy. In some applications, after taking values for native attributes, value conversion capabilities can also be configured to perform post-processing of attribute values by executing this capability. After using the calculation model to take values for composite attributes, the value merging capability can be used to merge dependent attribute values according to the merging strategy.
[0135] According to the method in the present invention, an arrangable model of native attributes, composite attributes and main-sub-attribute groups can be provided. The arrangable model can be applied to complex business data requests, and complex problems can be decomposed into a number of simple sub-problems in multiple dimensions, and finally the business data request results can be obtained according to demand and in order. The data acquisition framework system constructed using the method in the present invention can integrate a set of abstract capabilities (such as: parameter parsing capability, composite attribute merging capability, attribute value conversion capability, attribute and group routing capability, group value parsing capability, data acquisition device routing capability and data acquisition device data acquisition capability, etc.), which universally encapsulates common logic, supports high scalability, and has high reusability.
[0136] Figure 5 An exemplary system architecture 500 is shown to which the data computing method or data computing device according to the embodiment of the present invention can be applied.
[0137] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0138] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Terminal devices 501, 502, 503 can be installed with various applications that require data acquisition, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0139] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0140] Server 505 may be a server that provides various services, such as a background management server that provides support for shopping websites browsed by users using terminal devices 501, 502, and 503. The background management server may analyze and process the received data such as data calculation requests, and feed back the processing results to the terminal device.
[0141] It should be noted that the data calculation method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the data calculation device is generally arranged in the server 505 .
[0142] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0143] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0144] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0145] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0146] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0147] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0148] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0149] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor. For example, it may be described as follows: a processor includes a receiving module, a composition module, and a calculation module. The names of these modules do not, in some cases, constitute limitations on the modules themselves.
[0150] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: step S101, receiving a data request, extracting one or more request attributes and input parameter values in the data request; step S102, forming a request group with the one or more request attributes, calling a data association relationship table, using a directed acyclic graph algorithm with the request group as the destination node, and generating a corresponding group graph link graph; wherein the group graph link graph indicates the attribute identifier to be calculated for determining the request attribute, the attribute group composed of the attribute to be calculated, and the dependency relationship between the attribute groups; step S103, using a directed acyclic graph algorithm to traverse the group graph link graph, calling a corresponding calculation model based on the attribute identifier to be calculated in the attribute group, and then calculating the value of the one or more request attributes according to the input parameter value in the data request, and outputting it.
[0151] According to the technical solution of the embodiment of the present invention, a group graph-like link graph corresponding to the data request is constructed based on the data association relationship table and a directed acyclic graph algorithm according to the data request, and then the group graph-like link graph is traversed to trigger the calculation method of the attributes in the group in sequence based on the input parameter value in the data request, so that when the traversal is completed, the result of the data request can be obtained. Therefore, the technical problem of low reusability and difficult maintenance of business logic caused by formulating proprietary personalized business logic for data with different complex attribute types in the prior art is overcome, and a universal data calculation method can be used to satisfy the calculation of data with different attribute complexities, and the calculation method has strong logic reusability and is easy to maintain.
[0152] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data calculation method, characterized in that: include: Receiving a data request, extracting one or more request attributes and input parameter values in the data request; The one or more request attributes constitute a request group, retrieve a data association table, and use a directed acyclic graph algorithm to take the request group as a destination node to generate a corresponding group graph link graph; wherein the group graph link graph indicates the attribute identifier to be calculated for determining the request attribute, the attribute group composed of the attribute to be calculated, and the dependency relationship between the attribute groups; Use a directed acyclic graph algorithm to traverse the group graph link graph, call the corresponding calculation model based on the attribute identifier to be calculated in the attribute group, and then calculate the value of the one or more requested attributes according to the input parameter value in the data request, and output it; wherein, when the attribute to be calculated is a native attribute, call the corresponding calculation model to perform calculation based on the data value, determine the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, call the parsing method corresponding to the attribute group, and convert the calculated result into a data format; when the attribute to be calculated is a composite attribute, call the corresponding calculation model to perform calculation based on the data value, determine the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, call the merging method corresponding to the attribute group, and merge the calculated result.
2. The method according to claim 1, characterized in that The calling of the data association relationship table, using a directed acyclic graph algorithm with the request group as the destination node, to generate a corresponding group graph link graph, includes: Retrieve the data association table to obtain the dependency relationship between attributes and the relationship between attributes and groups; For each request attribute in the request group, based on the dependency relationship, a directed acyclic graph algorithm is used to generate an attribute link graph of the request attribute with the request attribute as the destination node; For all attributes to be calculated in the attribute link graph, attribute groups are obtained by aggregating the attributes to be calculated based on the belonging relationship to serve as group nodes, and the request group is used as the destination node to generate the group graph link graph.
3. The method according to claim 2, characterized in that The generating of the corresponding group graph-like link graph further includes: A parameter group is formed according to the input parameter values in the data request to serve as the starting node of the group graph link diagram.
4. The method according to claim 3, characterized in that Before using the directed acyclic graph algorithm to traverse the group graph-like link graph, the method further includes: Acquire a set of routing conditions between attribute groups, determine one or more routing conditions in the set of routing conditions, and the dependent attribute groups and the attribute groups to be calculated corresponding to the routing conditions; and, When the directed acyclic graph algorithm is used to traverse the group graph-like link graph, if it is determined according to the routing condition that the condition is not satisfied, the corresponding routing from the dependent attribute group to the attribute group to be calculated is terminated.
5. The method according to claim 3, characterized in that: The step of traversing the group graph-like link graph using a directed acyclic graph algorithm and calling a corresponding calculation model based on the attribute identifier to be calculated in the attribute group includes: Using a directed acyclic graph algorithm to traverse the group graph-like link graph, triggering the counters of the attribute groups in sequence; The data getter is used to call the corresponding calculation model according to the to-be-calculated attribute identifier in the corresponding attribute group.
6. The method according to claim 5, characterized in that The calculating the values of the one or more request attributes according to the input parameter values in the data request includes: According to the triggering order of the data accessors of the attribute group, the parameter group consisting of the input parameter value is used as the starting trigger, and the data storage medium corresponding to the attribute group is accessed by the data accessors in turn to read the data value used to calculate the attribute to be calculated in the attribute group, and then the corresponding calculation model is called to perform calculation based on the data value; Until the group graph link graph traversal is completed, the value of one or more request attributes in the request group is obtained.
7. A data computing device, characterized in that: include: A receiving module, used for receiving a data request and extracting one or more request attributes and input parameter values in the data request; A graph forming module, configured to form a request group with the one or more request attributes, retrieve a data association table, and generate a corresponding group graph link graph with the request group as a destination node using a directed acyclic graph algorithm; wherein the group graph link graph indicates an attribute identifier to be calculated for determining the request attribute, an attribute group composed of the attribute to be calculated, and a dependency relationship between the attribute groups; A calculation module is used to traverse the group graph link graph using a directed acyclic graph algorithm, call the corresponding calculation model based on the attribute identifier to be calculated in the attribute group, and then calculate the value of the one or more requested attributes according to the input parameter value in the data request, and output it; wherein, when the attribute to be calculated is a native attribute, call the corresponding calculation model to perform calculation based on the data value, determine the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, call the parsing method corresponding to the attribute group, and convert the calculated result into a data format; when the attribute to be calculated is a composite attribute, call the corresponding calculation model to perform calculation based on the data value, determine the attribute group to which the attribute to be calculated belongs according to the attribute to be calculated, call the merging method corresponding to the attribute group, and merge the calculated result.
8. A data computing electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Group discovery method based on data enhancement and non-negative matrix sparse decomposition
CN110136017A
Data processing method and device, storage medium and electronic equipment
CN110415107A