CN114118770A - Index calculation method and device - Google Patents

Index calculation method and device Download PDF

Info

Publication number
CN114118770A
CN114118770A CN202111398602.3A CN202111398602A CN114118770A CN 114118770 A CN114118770 A CN 114118770A CN 202111398602 A CN202111398602 A CN 202111398602A CN 114118770 A CN114118770 A CN 114118770A
Authority
CN
China
Prior art keywords
target
index
expression
calculated
indexes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111398602.3A
Other languages
Chinese (zh)
Inventor
谭彰
徐慧
陈英杰
刘金凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Lanzhuo Industrial Internet Information Technology Co ltd
Original Assignee
Zhejiang Lanzhuo Industrial Internet Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Lanzhuo Industrial Internet Information Technology Co ltd filed Critical Zhejiang Lanzhuo Industrial Internet Information Technology Co ltd
Priority to CN202111398602.3A priority Critical patent/CN114118770A/en
Publication of CN114118770A publication Critical patent/CN114118770A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/06Resources, workflows, human or project management; Enterprise or organisation planning; Enterprise or organisation modelling
    • G06Q10/063Operations research, analysis or management
    • G06Q10/0639Performance analysis of employees; Performance analysis of enterprise or organisation operations
    • G06Q10/06393Score-carding, benchmarking or key performance indicator [KPI] analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data

Abstract

The invention provides an index calculation method and device, which comprises the steps of determining a target dependency tree corresponding to an index to be calculated from a pre-constructed dependency tree, wherein the pre-constructed dependency tree is constructed based on industrial big data; when the number of the indexes to be calculated is determined to be 1, determining the calculation sequence of the indexes to be calculated based on the positions of the indexes to be calculated in the target dependency tree; when the execution sequence of the target dependency tree reaches the calculation sequence of the index to be calculated, analyzing the initial expression of the index to be calculated to obtain a target expression; when the number of the target expressions is multiple, sequencing the target expressions according to a preset execution rule to obtain an expression execution list sequenced according to an execution sequence; and sequencing the target expressions according to the expression execution list, and sequentially processing the target expressions to determine a target index result. By means of the method, the index calculation efficiency can be improved, and calculation of indexes with different dimensions can be supported.

Description

Index calculation method and device
Technical Field
The invention relates to the technical field of data processing, in particular to an index calculation method and device.
Background
In the process of industrial big data management, the combination of business and data in an industrial big data scene is often used as an index, that is, the index is used as the basis of industrial data statistics and is also the basis for quantifying business effects.
In the prior art, an instruction set of a plurality of index instructions is obtained by analyzing a first index, and then the plurality of instructions of the instruction set are executed in sequence to calculate and analyze the index. In the index calculation process, a large amount of database connections are generated, so that the calculation efficiency is low, and the calculation of indexes with different dimensions cannot be supported.
Disclosure of Invention
In view of this, embodiments of the present invention provide an index calculation method and apparatus to solve the problems in the prior art that the calculation efficiency is low and the calculation of indexes with different dimensions cannot be supported.
In order to achieve the above purpose, the embodiments of the present invention provide the following technical solutions:
a first aspect of an embodiment of the present invention shows an index calculation method, including:
determining indexes to be calculated according to calculation requirements input by a user, and determining a target dependency tree corresponding to the indexes to be calculated from a pre-constructed dependency tree, wherein the number of the indexes to be calculated is more than one or 1, and the pre-constructed dependency tree is constructed based on industrial big data;
when the number of the indexes to be calculated is determined to be 1, determining the calculation sequence of the indexes to be calculated based on the positions of the indexes to be calculated in the target dependency tree;
when the execution sequence of the target dependency tree is determined to reach the calculation sequence of the index to be calculated, analyzing the initial expression of the index to be calculated to obtain target expressions, wherein the number of the target expressions can be 1 or more;
when the number of the target expressions is multiple, sequencing the target expressions according to a preset execution rule to obtain an expression execution list sequenced according to an execution sequence;
and processing the target expressions in sequence according to the sequence in the expression execution list, and determining a target index result.
Optionally, the sequentially processing the target expressions according to the ranks in the expression execution list to determine a target index result includes:
determining that a target expression exists in the expression execution list, analyzing the target expression, and determining a dependent item of the target expression;
if the dependency item of the target expression is only determined to be a field, acquiring the field of the target expression from an original table;
writing the fields into a target table for operation to obtain an operation result, and storing the operation result in a temporary storage table, wherein the target table is an index table with the largest dimension;
if the dependent item of the target expression is determined to be not only a field, determining the dependent item of the target expression to be the field, other indexes and other target expressions;
acquiring the field corresponding to the target expression from an original table, acquiring operation results corresponding to other target expressions from a temporary storage table, and acquiring data corresponding to other indexes from a data source table;
writing the fields, the operation results and the data corresponding to other indexes into a target table for operation to obtain operation results, and storing the operation results into the temporary storage table;
and when the target expression does not exist in the expression execution list, outputting the operation result stored in the temporary storage table as a target index result.
Optionally, the method further includes: and when the number of the target expressions is 1, processing the target expressions and determining a target index result.
Optionally, the processing the target expression and determining a target index result includes:
analyzing the target expression, and determining the dependent item of the target expression as a field and other indexes;
acquiring the field corresponding to the target expression from an original table, and acquiring data corresponding to the index from a data source table;
writing the data corresponding to the corresponding field and the index into a target table for operation to obtain an operation result, and storing the operation result in the temporary storage table;
and outputting the operation result stored in the temporary storage table as a target index result.
Optionally, the method further includes: when the number of the indexes to be calculated is determined to be multiple, determining a calculation sequence of the indexes to be calculated based on the positions of the indexes to be calculated in the target dependency tree, wherein dependency relationships exist among the indexes to be calculated, and at least one index to be calculated exists in the same calculation sequence;
when the execution sequence of the target dependency tree is determined to reach the calculation sequence of any index to be calculated, each index to be calculated is calculated in sequence based on the calculation sequence, and a target index result is determined.
A second aspect of the embodiments of the present invention shows an index calculation apparatus, including:
the device comprises a first determining unit, a second determining unit and a third determining unit, wherein the first determining unit is used for determining indexes to be calculated according to calculation requirements input by a user, and determining a target dependency tree corresponding to the indexes to be calculated from pre-constructed dependency trees, the number of the indexes to be calculated is more than or equal to 1, and the pre-constructed dependency trees are constructed on the basis of industrial big data;
a second determining unit, configured to determine a calculation order of the to-be-calculated indexes based on positions of the to-be-calculated indexes in the target dependency tree when it is determined that the number of the to-be-calculated indexes is 1;
the analysis unit is used for analyzing the initial expression of the index to be calculated when the execution sequence of the target dependency tree reaches the calculation sequence of the index to be calculated, so as to obtain target expressions, wherein the number of the target expressions can be 1 or more;
the processing unit is used for sequencing the target expressions according to a preset execution rule when the number of the target expressions is multiple to obtain an expression execution list sequenced according to an execution sequence; and processing the target expressions in sequence according to the sequence in the expression execution list to determine a target index result.
Optionally, the processing unit, configured to sequentially process the target expressions according to the ranks in the expression execution list, and determine a target index result, is specifically configured to:
determining that a target expression exists in the expression execution list, analyzing the target expression, and determining a dependent item of the target expression;
if the dependency item of the target expression is only determined to be a field, acquiring the field of the target expression from an original table;
writing the fields into a target table for operation to obtain an operation result, and storing the operation result in a temporary storage table, wherein the target table is an index table with the largest dimension;
if the dependent item of the target expression is determined to be not only a field, determining the dependent item of the target expression to be the field, other indexes and other target expressions;
acquiring the field corresponding to the target expression from an original table, acquiring operation results corresponding to other target expressions from a temporary storage table, and acquiring data corresponding to other indexes from a data source table;
writing the fields, the operation results and the data corresponding to other indexes into a target table for operation to obtain operation results, and storing the operation results into the temporary storage table;
and when the target expression does not exist in the expression execution list, outputting the operation result stored in the temporary storage table as a target index result.
Optionally, the processing unit is further configured to: and when the number of the target expressions is 1, processing the target expressions and determining a target index result.
A third aspect of the embodiments of the present invention shows an electronic device, where the electronic device is configured to run a program, where the program executes the index calculation method shown in the first aspect of the embodiments of the present invention when running.
A fourth aspect of the embodiments of the present invention shows a computer storage medium, where the storage medium includes a storage program, and where the apparatus on which the storage medium is located is controlled to execute the index calculation method as shown in the first aspect of the embodiments of the present invention when the program runs.
Based on the above method and apparatus for index calculation provided by the embodiments of the present invention, the method includes: determining indexes to be calculated according to calculation requirements input by a user, and determining a target dependency tree corresponding to the indexes to be calculated from a pre-constructed dependency tree, wherein the number of the indexes to be calculated is more than one or 1, and the pre-constructed dependency tree is constructed based on industrial big data; when the number of the indexes to be calculated is determined to be 1, determining the calculation sequence of the indexes to be calculated based on the positions of the indexes to be calculated in the target dependency tree; when the execution sequence of the target dependency tree is determined to reach the calculation sequence of the index to be calculated, analyzing the initial expression of the index to be calculated to obtain target expressions, wherein the number of the target expressions can be 1 or more; when the number of the target expressions is multiple, sequencing the target expressions according to a preset execution rule to obtain an expression execution list sequenced according to an execution sequence; and processing the target expressions in sequence according to the sequence in the expression execution list, and determining a target index result. In the embodiment of the invention, a target dependency tree corresponding to the indexes to be calculated is determined from the pre-constructed dependency tree, and then the calculation sequence of the indexes to be calculated in the target dependency tree is determined when the number of the indexes to be calculated is determined to be 1; when the execution sequence of the target dependency tree reaches the calculation sequence of the index to be calculated, analyzing the initial expression of the index to be calculated to obtain a target expression; when the number of the target expressions is determined to be multiple, sequencing the target expressions according to a preset execution rule, and generating an expression execution list sequenced according to an execution sequence; and processing the target expressions in sequence according to the sequence in the expression execution list to determine a target index result. By means of the method, the index calculation efficiency can be improved, and calculation of indexes with different dimensions can be supported.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a schematic flow chart illustrating a method for calculating an index according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating a structure of nodes in a dependency tree according to an embodiment of the present invention;
FIG. 3a is a schematic diagram illustrating a deterministic dependency tree execution batch according to an embodiment of the present invention;
FIG. 3b is a diagram illustrating another example of determining dependency tree execution batches according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a dependency tree construction, a dependency tree execution batch analysis, and a complex dependency index calculation according to an embodiment of the present invention;
FIG. 5 is a schematic flowchart illustrating a process of calculating a complex dependency indicator according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an index calculation apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In this application, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
In the embodiment of the invention, a target dependency tree corresponding to the indexes to be calculated is determined from the pre-constructed dependency tree, and then the calculation sequence of the indexes to be calculated in the target dependency tree is determined when the number of the indexes to be calculated is determined to be 1; when the execution sequence of the target dependency tree reaches the calculation sequence of the index to be calculated, analyzing the initial expression of the index to be calculated to obtain a target expression; when the number of the target expressions is determined to be multiple, sequencing the target expressions according to a preset execution rule, and generating an expression execution list sequenced according to an execution sequence; and processing the target expressions in sequence according to the sequence in the expression execution list to determine a target index result. By means of the method, the index calculation efficiency can be improved, and calculation of indexes with different dimensions can be supported.
Referring to fig. 1, a schematic flow chart of an index calculation method according to an embodiment of the present invention is shown, where the method includes:
step S101: according to the calculation requirement input by a user, determining an index to be calculated, and determining a target dependency tree corresponding to the index to be calculated from a pre-constructed dependency tree.
In step S101, the number of the indexes to be calculated is multiple or 1, and the dependency tree is constructed based on industrial big data.
In the process of specifically implementing step S101, a to-be-calculated index corresponding to a calculation demand input by a user is determined first, a consistent index is searched from a pre-constructed dependency tree based on the to-be-calculated index, and when it is determined that an index consistent with the to-be-calculated index exists in a certain dependency tree, the dependency tree is set as a target dependency tree.
It should be noted that when the number of the to-be-calculated indexes is determined to be multiple, since the indexes are all indexes required for calculation, a dependency relationship exists among the multiple to-be-calculated indexes, that is, the multiple to-be-calculated indexes exist on one dependency tree.
It should be noted that the dependency tree can be constructed by a sequential traversal method or a dot-and-dash method.
In an embodiment of the invention, a process of building a dependency book by using a hierarchical traversal method based on industrial big data comprises the following steps:
based on the original table of the database, a plurality of indexes are generated and written into the queue. When the indexes exist in the queue, the indexes are dequeued, whether nodes corresponding to the indexes exist in the dependency tree constructed currently is determined, if yes, the dependency tree is not constructed, if not, the nodes of the dependency tree are constructed based on the indexes, the dependency relationship is added according to the dependency relationship of the indexes, then the indexes depended on by the nodes are inquired from the database and added into the queue, the process is executed in a circulating mode until the queue is empty, and the fact that the queue is empty indicates that the dependency tree is constructed.
It should be noted that, assuming that there is a dependency relationship between the indexes, a dependency record is generated in the dependency table.
The node corresponding to the index, that is, the node of the dependency tree is the index, and the index includes the basic information of the index and the set of the dependency indexes.
Therefore, the dependency tree of a single index is constructed, the method is convenient when the dependency tree of the single index is obtained, most of the dependency trees are in the unit of index groups in the actual index calculation process, one index group comprises a plurality of indexes, so that the efficiency is very low by circularly obtaining the dependency relationship and the index information, and then in order to pursue the execution efficiency, the dependency tree is constructed by adopting a point-and-line method, which is a construction idea of a graph. The point-line method is, as its name implies, to construct points and lines, where the points are indexes and the lines are dependencies between them, and therefore, in another embodiment of the present invention, a process of constructing a dependency book by the point-line method based on industrial big data includes:
inquiring all indexes and dependency relations possibly related to the index group into a memory at one time from an original table of a database; and (5) screening and constructing index nodes by the circulating point set. And then screening the relationship set according to the dependency relationship, and constructing nodes according to relationship connection after circular screening, thereby completing the construction of the dependency tree.
It should be noted that the two methods depending on the tree construction can be selected under different conditions, for example, the dot-line method is selected when efficiency is sought, and the layer sequence traversal method is selected when memory consumption is sought to be small.
In the embodiment of the present invention, the structure of the node in the dependency tree may be as shown in fig. 2, and the node component of the index a includes the index basic information and the dependency index set, i.e., the dependency record. The index a generates three dependency records in the data at the time of creation, that is, the dependency index set includes three dependency records. The three dependency records are respectively the relationship between the index A and the index B, the relationship between the index A and the index C, and the relationship between the index A and the index D. That is, the index A has a dependency relationship with the index B, the index C, and the index D, respectively.
Step S102: judging whether the number of the indexes to be calculated is 1, executing the step S103 to the step S109 when determining that the number of the indexes to be calculated is 1, and executing the step S110 to the step S112 when determining that the number of the indexes to be calculated is multiple.
In the process of implementing step S102 specifically, it is necessary to determine whether the calculation requirement only needs one index, when determining that the number of the indexes to be calculated is 1, step S103 to step S109 are executed, and when determining that the number of the indexes to be calculated is multiple, step S110 to step S112 are executed.
Step S103: and determining the calculation sequence of the indexes to be calculated based on the positions of the indexes to be calculated in the target dependency tree.
Optionally, the level corresponding to the root node of the dependency tree of the target dependency tree is set to 1; then traversing the target dependency tree to determine whether a dependent node exists; if so, setting the hierarchy corresponding to the node depended by the root node of the dependency tree to be 2, namely adding 1 to the root node of the dependency tree. By analogy, the levels of each node are set in sequence; and after the assignment is finished, traversing the DFS by using depth-first traversal to assign, marking a maximum value, namely a maximum level, and then obtaining an execution batch by using a subtraction and negation mode.
For example: 3a-3b, schematic diagrams of determining execution batches for dependency trees.
As shown in fig. 3a, if the target dependency tree a has two nodes, the level corresponding to the root node 2 of the dependency tree a is set to 1, then the target dependency tree a is traversed by the DFS, so as to determine that the node dependent on the node 2 is the node 1, at this time, the level corresponding to the node 1 dependent on the root node 2 of the dependency tree is set to 2, after the assignment is completed, the DFS is traversed by the depth-first traversal, so as to mark the maximum value, that is, the maximum level, and then an execution batch is obtained by a subtraction and inversion method, where the execution batch includes the nodes 1 of the first batch and the root nodes 2 of the dependency tree of the second batch.
As shown in fig. 3b, if the target dependency tree a has 7 nodes, the hierarchy corresponding to the dependency tree root node 7 of the target dependency tree a is set to 1, then the target dependency tree a is traversed to determine that the nodes dependent on the node 7 are the node 5 and the node 6, at this time, the hierarchy corresponding to the node 5 and the node 6 dependent on the dependency tree root node 7 is set to 2, and so on, and the hierarchy of each node is set in sequence; after the assignment is finished, traversing the DFS assignment by using depth-first traversal to mark a maximum value, namely a maximum level, and then obtaining an execution batch by using a subtraction and inversion mode, wherein the execution batch comprises nodes 1, 2, 3 and 4 of a first batch, nodes 5 and 6 of a second batch and nodes 7 of a third batch.
It can be understood that the indexes of the multiple batches generated by the method are executed according to the execution sequence of the execution batches, the indexes of the same batch do not have dependency relationship and can be executed concurrently, and after all the indexes of the current batch are executed, the next batch of calculation is executed until the next batch of calculation is finished, so that the indexes, which are depended on by each index during the calculation, are calculated.
In the process of implementing step S103 specifically, the target dependency tree is traversed, and the position of the to-be-calculated index in the target dependency tree is determined, so as to determine the calculation order of the to-be-calculated index based on the execution batch of the target dependency tree, that is, when the to-be-calculated index starts to be calculated is determined by the determined execution batch of the target dependency tree.
Step S104: and judging whether the execution sequence of the target dependency tree reaches the calculation sequence of the index to be calculated, if so, executing the step S105, and if not, returning to the step 104.
In the process of specifically implementing step S104, indexes in the target dependency tree sequentially perform index calculation according to the sequence of execution batches, and determine whether the execution sequence of the target dependency tree reaches the calculation sequence of the indexes to be calculated, that is, determine whether the index currently required to be executed is the index to be calculated, if so, indicate that the index currently required to be executed is the index to be calculated, then step S105 is executed, if not, indicate that the index to be calculated has not been executed, and return to step S104.
Step S105: and analyzing the initial expression of the index to be calculated to obtain a target expression.
In step S105, the number of the target expressions may be 1 or more.
In the process of implementing step S105 specifically, the initial expression is decomposed from left to right and from inside to outside, so as to be decomposed into individual aggregation operations, and a target expression is obtained.
It should be noted that the aggregation operation may be SUM.
Further, in addition to the aggregation mode SUM described above, there are aggregation modes such as calculating the average AVG, calculating the count COU, calculating the maximum value MAX, and calculating the minimum value MIN.
Step S106: judging whether the number of the target expressions is multiple, and executing the step S107 to the step S108 when the number of the target expressions is multiple, and executing the step S109 when the number of the target expressions is 1.
In the process of implementing step S106 specifically, whether the initial expression is a complex expression can be determined by the number of target expressions, so as to calculate the number of decomposed target expressions, where when the number of target expressions is multiple, step S107 to step S108 are executed, and when the number of target expressions is 1, step S109 is executed.
Step S107: and sequencing the target expressions according to a preset execution rule to obtain an expression execution list sequenced according to an execution sequence.
In the process of implementing step S107 specifically, the target expressions are sorted in a decomposition order from left to right and from inside to outside, and an expression execution list arranged in order is generated according to the sorting order.
Step S108: and processing the target expressions in sequence according to the sequence in the expression execution list, and determining a target index result.
In the process of implementing step S108 specifically, the target expressions arranged in order in the expression execution list are processed in sequence, and a target index result is determined.
Step S109: and processing the target expression to determine a target index result.
In the process of specifically implementing step S109, the target expression at this time is a simple expression, and the target expression may be directly processed to obtain a target index result.
Step S110: and determining the calculation sequence of the indexes to be calculated based on the positions of the indexes to be calculated in the target dependency tree.
In step S110, there is a dependency relationship between the indexes to be calculated, and at least one index to be calculated exists in the same calculation order.
It should be noted that step S110 is the same as the specific implementation process of step S103, and reference may be made to this embodiment of the present invention without limitation.
Step S111: and judging whether the execution sequence of the target dependency tree reaches the calculation sequence of any index to be calculated, executing step S112 when the execution sequence of the target dependency tree reaches the calculation sequence of any index to be calculated, namely when the execution sequence of the target dependency tree reaches the calculation sequence of the index to be calculated for the first time, and if not, continuing to return to execute step S111.
It should be noted that, because there must be a dependency relationship between multiple indexes to be calculated, by determining whether the execution order of the target dependency tree reaches the calculation order of the indexes to be calculated for the first time, it is able to determine multiple indexes to be calculated that need to be executed currently, and the specific determination process is the same as that in step S104, which can be referred to each other.
S112: and calculating each index to be calculated in sequence based on the calculation sequence to determine a target index result.
In the process of implementing step S112, each of the to-be-calculated indexes is calculated in turn according to the calculation sequence, and the specific calculation processes are as described in step S106 to step S109, which can be referred to each other, so that the operation result of each to-be-calculated index is stored, and all the operation results about each to-be-calculated index are presented in the form of a table, that is, the target index result is output.
Correspondingly, the embodiment of the invention also discloses a dependency tree construction and dependency tree execution batch analysis, namely a structural diagram of dependency order analysis and complex dependency index calculation, as shown in fig. 4.
In the embodiment of the invention, a target dependency tree corresponding to the indexes to be calculated is determined from the pre-constructed dependency tree, and then the calculation sequence of the indexes to be calculated in the target dependency tree is determined when the number of the indexes to be calculated is determined to be 1; when the execution sequence of the target dependency tree reaches the calculation sequence of the index to be calculated, analyzing the initial expression of the index to be calculated to obtain a target expression; when the number of the target expressions is determined to be multiple, sequencing the target expressions according to a preset execution rule, and generating an expression execution list sequenced according to an execution sequence; and processing the target expressions in sequence according to the sequence in the expression execution list to determine a target index result. By means of the method, the index calculation efficiency can be improved, and calculation of indexes with different dimensions can be supported.
Based on the index calculation method shown in the above embodiment of the present invention, in the execution step S108, the target expressions are sequentially processed according to the ranks in the expression execution list, and a target index result is determined, as shown in fig. 5, the method includes the following steps:
step S501: judging that a target expression exists in the expression execution list, if the target expression exists in the expression execution list, executing the step S502 to the step S508, and if the target expression does not exist in the expression execution list, executing the step S509.
In the process of specifically implementing step S501, it is determined whether the expression execution list is empty, if not, step S502 to step S508 are executed, and if so, step S509 is executed.
Step S502: analyzing the target expression and determining the dependent item of the target expression.
In the process of implementing step S502 specifically, the target expression is analyzed, and a dependent item that depends on the target expression is determined.
It should be noted that dependent dependencies may be fields of the original table, and/or other dependent indicators, and/or other dependent target expressions.
Step S503: determining whether the dependent item of the target expression is only a field, and executing the steps S504 to S505 when the dependent item of the target expression is determined to be the field; if it is determined that the dependent term of the target expression is not only a field, step S506 and step S508 are performed.
Step S504: and acquiring the target expression fields from an original table.
In the process of implementing step S504 specifically, it is determined that the data on which the target expression depends is a field in the original table, so that the field of the target expression, that is, the data on which the target expression depends, is obtained from the original table.
Step S505: and writing the data corresponding to the field into a target table for operation to obtain an operation result, storing the operation result into a temporary storage table, and returning to continue executing the step S501.
In step S505, the target table is the index table with the largest ownership dimension.
Optionally, the dimensionalities of all the indexes are analyzed, and the maximum dimensionality index data is selected as a main table, that is, an index table where the index with the largest dimensionality, that is, the index with the largest dimensionality, is located is found as a target table, so that it is ensured that the fields of the expressions are not lost during combination, other index data are combined for calculation, and other indexes to be calculated can be combined to the index table without loss for calculation.
In the process of specifically implementing step S505, at this time, the data corresponding to the field is merged into the target table to execute the expression, so as to obtain an operation result corresponding to the expression, and the operation result is stored in the temporary storage table, so that other target expressions are used for calculation, that is, the process returns to continue to execute step S501.
Step S506: and determining the dependent items of the target expression as fields, other indexes and other target expressions.
In the process of implementing step S506 specifically, after determining that the target expression is analyzed, it can be determined that the field, other indexes, and other target expressions are dependent on the target expression.
Step S507: and acquiring the field corresponding to the target expression from an original table, acquiring the operation result corresponding to other target expressions from a temporary storage table, and acquiring the data corresponding to the index from a data source table.
In the process of implementing step S507 specifically, it is determined that the data on which the target expression depends is a field in the original table, an operation result corresponding to another target expression in the temporary storage table, and another index in the data source table, so as to obtain the field corresponding to the target expression from the original table, obtain the operation result corresponding to another target expression in the temporary storage table, and obtain the data corresponding to the index in the data source table.
Step S508: and writing the data corresponding to the field, the operation result and the index into a target table for operation to obtain an operation result, and storing the operation result in the temporary storage table to return to continue executing the step S501.
In the process of implementing step S508 specifically, the data corresponding to the field, the operation result, and the index are merged into the target table to execute the expression, so as to obtain the operation result corresponding to the expression, and the operation result is stored in the temporary storage table, and the process returns to continue executing step S501.
Step S509: and outputting the operation result stored in the temporary storage table as a target index result.
In the process of implementing step S509 specifically, all the operation results about the to-be-calculated index stored in the temporary storage table are presented in the form of a table, that is, a target index result is output.
In the embodiment of the invention, if the initial expression in the indexes is a complex expression and the target expression exists in the expression execution list, the target expression is analyzed, the dependent item of the target expression is determined, the data corresponding to the dependent item is written into the target list for operation, the operation result is obtained, and the target index result is further determined. By means of the method, the index calculation efficiency can be improved, and calculation of indexes with different dimensions can be supported.
Based on the index calculation method shown in the above embodiment of the present invention, in the process of executing step S109 to process the target expression and determine the target index result, the method includes the following steps:
step S11: analyzing the target expression, and determining the dependent item of the target expression as a field and other indexes.
Step S12: and acquiring the data of the field corresponding to the target expression from an original table, and acquiring the data corresponding to the index from a data source table.
Step S13: and writing the data corresponding to the corresponding fields and indexes into a target table for operation to obtain an operation result, and storing the operation result into the temporary storage table.
Step S14: and outputting the operation result stored in the temporary storage table as a target index result.
It should be noted that the specific implementation process of step S11 to step S14 is the same as the specific implementation process of step S501 to step S509, and they can be referred to each other.
In the embodiment of the invention, when the initial expression in the index is determined to be the simple expression, the target expression is analyzed, the dependent item of the target expression is determined, the data corresponding to the dependent item is written into the target table for operation, the operation result is obtained, and the target index result is further determined. By means of the method, the index calculation efficiency can be improved, and calculation of indexes with different dimensions can be supported.
Corresponding to the index calculation method shown in the above embodiment of the present invention, the embodiment of the present invention also discloses a schematic structural diagram of an index calculation apparatus, as shown in fig. 6, the apparatus includes:
the first determining unit 601 is configured to determine to-be-calculated indexes according to a calculation requirement input by a user, and determine a target dependency tree corresponding to the to-be-calculated indexes from pre-constructed dependency trees, where the number of the to-be-calculated indexes is multiple or 1, and the pre-constructed dependency trees are constructed based on industrial big data.
A second determining unit 602, configured to determine a calculation order of the to-be-calculated indicators based on positions of the to-be-calculated indicators in the target dependency tree when it is determined that the number of the to-be-calculated indicators is 1.
An analyzing unit 603, configured to, when it is determined that the execution order of the target dependency tree reaches the calculation order of the to-be-calculated index, analyze the initial expression of the to-be-calculated index to obtain a target expression, where the number of the target expressions may be 1 or more.
The processing unit 604 is configured to, when the number of the target expressions is multiple, sort the target expressions according to a preset execution rule, and obtain an expression execution list sorted according to an execution order. And processing the target expressions in sequence according to the sequence in the expression execution list, and determining a target index result.
It should be noted that, the specific principle and the implementation process of each unit in the index calculation apparatus disclosed in the embodiment of the present application are the same as those of the index calculation method described in the embodiment of the present application, and reference may be made to corresponding parts in the index calculation method disclosed in the embodiment of the present application, which are not described herein again.
In the embodiment of the invention, a target dependency tree corresponding to the indexes to be calculated is determined from the pre-constructed dependency tree, and then the calculation sequence of the indexes to be calculated in the target dependency tree is determined when the number of the indexes to be calculated is determined to be 1; when the execution sequence of the target dependency tree reaches the calculation sequence of the index to be calculated, analyzing the initial expression of the index to be calculated to obtain a target expression; when the number of the target expressions is determined to be multiple, sequencing the target expressions according to a preset execution rule, and generating an expression execution list sequenced according to an execution sequence; and processing the target expressions in sequence according to the sequence in the expression execution list to determine a target index result. By means of the method, the index calculation efficiency can be improved, and calculation of indexes with different dimensions can be supported.
Optionally, based on the index calculation apparatus shown in the foregoing embodiment of the present invention, the processing unit is a processing unit that performs processing on the target expressions in order according to the ranks in the expression execution list, and determines a target index result, and the processing unit 604 is specifically configured to:
and determining that a target expression exists in the expression execution list, analyzing the target expression, and determining the dependent item of the target expression.
And if the dependent item of the target expression is only determined to be a field, acquiring the field of the target expression from an original table.
And writing the fields into a target table for operation to obtain an operation result, and storing the operation result in a temporary storage table, wherein the target table is an index table with the largest dimension.
And if the dependent item of the target expression is determined to be not only the field, determining the dependent item of the target expression to be the field, other indexes and other target expressions.
And acquiring the field corresponding to the target expression from an original table, acquiring the operation result corresponding to other target expressions from a temporary storage table, and acquiring the data corresponding to other indexes from a data source table.
And writing the fields, the operation results and the data corresponding to other indexes into a target table for operation to obtain the operation results, and storing the operation results into the temporary storage table.
And when the target expression does not exist in the expression execution list, outputting the operation result stored in the temporary storage table as a target index result.
Optionally, the processing unit 604 is further configured to: and when the number of the target expressions is 1, processing the target expressions and determining a target index result.
Optionally, when the number of the target expressions is 1, the processing unit 604 that processes the target expressions and determines a target index result is specifically configured to:
analyzing the target expression, and determining the dependent item of the target expression as a field and other indexes; acquiring the field corresponding to the target expression from an original table, and acquiring data corresponding to the index from a data source table; writing the data corresponding to the corresponding field and the index into a target table for operation to obtain an operation result, and storing the operation result in the temporary storage table; and outputting the operation result stored in the temporary storage table as a target index result.
Optionally, the processing unit 604 is further configured to: when the number of the indexes to be calculated is determined to be multiple, determining a calculation sequence of the indexes to be calculated based on the positions of the indexes to be calculated in the target dependency tree, wherein dependency relationships exist among the indexes to be calculated, and at least one index to be calculated exists in the same calculation sequence; when the execution sequence of the target dependency tree is determined to reach the calculation sequence of any index to be calculated, each index to be calculated is calculated in sequence based on the calculation sequence, and a target index result is determined.
The embodiment of the invention also discloses electronic equipment, which is used for operating the database storage process, wherein the index calculation method disclosed in the figure 1 and the figure 5 is executed when the database storage process is operated.
The embodiment of the invention also discloses a computer storage medium, which comprises a storage database storage process, wherein when the storage database storage process runs, the equipment where the storage medium is located is controlled to execute the index calculation method disclosed in the figure 1 and the figure 5.
In the embodiment of the invention, a target dependency tree corresponding to the indexes to be calculated is determined from the pre-constructed dependency tree, and then the calculation sequence of the indexes to be calculated in the target dependency tree is determined when the number of the indexes to be calculated is determined to be 1; when the execution sequence of the target dependency tree reaches the calculation sequence of the index to be calculated, analyzing the initial expression of the index to be calculated to obtain a target expression; when the number of the target expressions is determined to be multiple, sequencing the target expressions according to a preset execution rule, and generating an expression execution list sequenced according to an execution sequence; and processing the target expressions in sequence according to the sequence in the expression execution list to determine a target index result. By means of the method, the index calculation efficiency can be improved, and calculation of indexes with different dimensions can be supported.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, the system or system embodiments are substantially similar to the method embodiments and therefore are described in a relatively simple manner, and reference may be made to some of the descriptions of the method embodiments for related points. The above-described system and system embodiments are only illustrative, wherein the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. An index calculation method, characterized by comprising:
determining indexes to be calculated according to calculation requirements input by a user, and determining a target dependency tree corresponding to the indexes to be calculated from a pre-constructed dependency tree, wherein the number of the indexes to be calculated is more than one or 1, and the pre-constructed dependency tree is constructed based on industrial big data;
when the number of the indexes to be calculated is determined to be 1, determining the calculation sequence of the indexes to be calculated based on the positions of the indexes to be calculated in the target dependency tree;
when the execution sequence of the target dependency tree is determined to reach the calculation sequence of the index to be calculated, analyzing the initial expression of the index to be calculated to obtain target expressions, wherein the number of the target expressions can be 1 or more;
when the number of the target expressions is multiple, sequencing the target expressions according to a preset execution rule to obtain an expression execution list sequenced according to an execution sequence;
and processing the target expressions in sequence according to the sequence in the expression execution list, and determining a target index result.
2. The method of claim 1, wherein the performing the target expressions in order according to the ordering in the expression execution list, and determining target metric results comprises:
determining that a target expression exists in the expression execution list, analyzing the target expression, and determining a dependent item of the target expression;
if the dependency item of the target expression is only determined to be a field, acquiring the field of the target expression from an original table;
writing the fields into a target table for operation to obtain an operation result, and storing the operation result in a temporary storage table, wherein the target table is an index table with the largest dimension;
if the dependent item of the target expression is determined to be not only a field, determining the dependent item of the target expression to be the field, other indexes and other target expressions;
acquiring the field corresponding to the target expression from an original table, acquiring operation results corresponding to other target expressions from a temporary storage table, and acquiring data corresponding to other indexes from a data source table;
writing the fields, the operation results and the data corresponding to other indexes into a target table for operation to obtain operation results, and storing the operation results into the temporary storage table;
and when the target expression does not exist in the expression execution list, outputting the operation result stored in the temporary storage table as a target index result.
3. The method of claim 1, further comprising: and when the number of the target expressions is 1, processing the target expressions and determining a target index result.
4. The method of claim 3, wherein said processing the target expression to determine a target metric result comprises:
analyzing the target expression, and determining the dependent item of the target expression as a field and other indexes;
acquiring the field corresponding to the target expression from an original table, and acquiring data corresponding to the index from a data source table;
writing the data corresponding to the corresponding field and the index into a target table for operation to obtain an operation result, and storing the operation result in the temporary storage table;
and outputting the operation result stored in the temporary storage table as a target index result.
5. The method of claim 1, further comprising: when the number of the indexes to be calculated is determined to be multiple, determining a calculation sequence of the indexes to be calculated based on the positions of the indexes to be calculated in the target dependency tree, wherein dependency relationships exist among the indexes to be calculated, and at least one index to be calculated exists in the same calculation sequence;
when the execution sequence of the target dependency tree is determined to reach the calculation sequence of any index to be calculated, each index to be calculated is calculated in sequence based on the calculation sequence, and a target index result is determined.
6. An index calculation apparatus, characterized in that the apparatus comprises:
the device comprises a first determining unit, a second determining unit and a third determining unit, wherein the first determining unit is used for determining indexes to be calculated according to calculation requirements input by a user, and determining a target dependency tree corresponding to the indexes to be calculated from pre-constructed dependency trees, the number of the indexes to be calculated is more than or equal to 1, and the pre-constructed dependency trees are constructed on the basis of industrial big data;
a second determining unit, configured to determine a calculation order of the to-be-calculated indexes based on positions of the to-be-calculated indexes in the target dependency tree when it is determined that the number of the to-be-calculated indexes is 1;
the analysis unit is used for analyzing the initial expression of the index to be calculated when the execution sequence of the target dependency tree reaches the calculation sequence of the index to be calculated, so as to obtain target expressions, wherein the number of the target expressions can be 1 or more;
the processing unit is used for sequencing the target expressions according to a preset execution rule when the number of the target expressions is multiple to obtain an expression execution list sequenced according to an execution sequence; and processing the target expressions in sequence according to the sequence in the expression execution list to determine a target index result.
7. The apparatus according to claim 6, wherein the processing unit that sequentially processes the target expressions according to the rankings in the expression execution list to determine the target index result is specifically configured to:
determining that a target expression exists in the expression execution list, analyzing the target expression, and determining a dependent item of the target expression;
if the dependency item of the target expression is only determined to be a field, acquiring the field of the target expression from an original table;
writing the fields into a target table for operation to obtain an operation result, and storing the operation result in a temporary storage table, wherein the target table is an index table with the largest dimension;
if the dependent item of the target expression is determined to be not only a field, determining the dependent item of the target expression to be the field, other indexes and other target expressions;
acquiring the field corresponding to the target expression from an original table, acquiring operation results corresponding to other target expressions from a temporary storage table, and acquiring data corresponding to other indexes from a data source table;
writing the fields, the operation results and the data corresponding to other indexes into a target table for operation to obtain operation results, and storing the operation results into the temporary storage table;
and when the target expression does not exist in the expression execution list, outputting the operation result stored in the temporary storage table as a target index result.
8. The apparatus of claim 6, wherein the processing unit is further configured to: and when the number of the target expressions is 1, processing the target expressions and determining a target index result.
9. An electronic device configured to run a program, wherein the program executes the index calculation method according to any one of claims 1 to 5.
10. A computer storage medium, characterized in that the storage medium includes a storage program, wherein when the program runs, a device in which the storage medium is located is controlled to execute the index calculation method according to any one of claims 1 to 5.
CN202111398602.3A 2021-11-19 2021-11-19 Index calculation method and device Pending CN114118770A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111398602.3A CN114118770A (en) 2021-11-19 2021-11-19 Index calculation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111398602.3A CN114118770A (en) 2021-11-19 2021-11-19 Index calculation method and device

Publications (1)

Publication Number Publication Date
CN114118770A true CN114118770A (en) 2022-03-01

Family

ID=80440456

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111398602.3A Pending CN114118770A (en) 2021-11-19 2021-11-19 Index calculation method and device

Country Status (1)

Country Link
CN (1) CN114118770A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116302513A (en) * 2023-02-28 2023-06-23 易方达基金管理有限公司 Quantization factor processing method, quantization factor processing device, computer equipment and readable storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116302513A (en) * 2023-02-28 2023-06-23 易方达基金管理有限公司 Quantization factor processing method, quantization factor processing device, computer equipment and readable storage medium

Similar Documents

Publication Publication Date Title
Branke et al. Hyper-heuristic evolution of dispatching rules: A comparison of rule representations
Lintusaari et al. ELFI: Engine for likelihood-free inference
Jiang et al. Qsynth: A tool for qos-aware automatic service composition
CN109241415B (en) Project recommendation method and device, computer equipment and storage medium
CN106909543B (en) Pattern matching method and device of rule engine
US9286032B2 (en) Automated software composition
Hunt et al. Evolving" less-myopic" scheduling rules for dynamic job shop scheduling with genetic programming
Morrison et al. Solving the pricing problem in a branch-and-price algorithm for graph coloring using zero-suppressed binary decision diagrams
Österlind et al. Enterprise architecture evaluation using utility theory
CN109308258A (en) Building method, device, computer equipment and the storage medium of test data
Ferreira et al. Effective and interpretable dispatching rules for dynamic job shops via guided empirical learning
Qasim et al. Test case prioritization techniques in software regression testing: An overview
CN114118770A (en) Index calculation method and device
Navidi et al. Adaptive submodular ranking and routing
Ferreira et al. Optimizing dispatching rules for stochastic job shop scheduling
Mota et al. A compact timed state space approach for the analysis of manufacturing systems: key algorithmic improvements
CN110968802A (en) User characteristic analysis method, analysis device and readable storage medium
Gomes Randomized Backtrack Search: Extending the reach of complete search methods
CN111008873B (en) User determination method, device, electronic equipment and storage medium
CN116167882A (en) Conditional expression dynamic configuration method, accounting condition calculation method and accounting condition calculation device
US20160217216A1 (en) Systems, methods, and devices for implementing a referral search
JP2006155344A (en) Data analyzer, data analysis program, and data analysis method
CN115759250A (en) Attribution analysis method, attribution analysis device, electronic equipment and storage medium
CN114780589A (en) Multi-table connection query method, device, equipment and storage medium
Barquero et al. Trading Accuracy for Performance in Data Processing Applications.

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination