Method, device, readable medium and electronic device for calculating index data

By preprocessing the original data and classifying the calculation indicators, reusable components are generated, which solves the problem of wasted computer memory resources in traditional indicator calculation methods, improves the calculation efficiency of indicators and saves computing resources.

CN114254918BActive Publication Date: 2025-04-29PING AN SECURITIES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111563635.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-20
Publication Date
2025-04-29
Estimated Expiration
2041-12-20

AI Technical Summary

Technical Problem

Traditional metric calculation methods have problems with wasting computer memory resources, resulting in wasting computing resources.

Method used

By preprocessing the original data, storing it in the form of a set data structure, and classifying the calculation indicators, reusable components are generated, so as to obtain the required data during the indicator calculation process and reduce memory usage.

Benefits of technology

Improve the computing efficiency of indicators, avoid duplicate data access, reduce memory usage, and save computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114254918B_ABST
    Figure CN114254918B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, readable medium and electronic device for calculating index data, the method comprising: preprocessing the original data to store the original data in the form of a set data structure; classifying the index to be calculated and generating a reusable component for each type of index to be calculated; based on the reusable component, obtaining the original data required for the index to be calculated from the set data structure for calculation, and obtaining the calculation result of the index to be calculated. The technical solution provided by the embodiment of the present application makes it more convenient and quick to obtain the original data during the index calculation process, avoids the access to duplicate data, improves the efficiency of index calculation, reduces the memory usage during the index calculation process, and saves computing resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and specifically relates to a method, device, readable medium and electronic device for calculating indicator data. Background Art

[0002] With the development of computer technology, more and more data are available on the Internet, and big data analysis is becoming more and more popular. Index calculation is an important part of big data analysis and an important application of business intelligence in the Internet era. The traditional index calculation method is to obtain thousands of data from the database for cumulative calculation each time the index data is calculated. In a computer, each calculation requires the construction of an object, and each object will occupy a certain amount of computer memory. The traditional index calculation method, which creates an object for each calculation, will greatly occupy computer memory and cause a waste of computing resources.

[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0004] The purpose of the present application is to provide a method, device, readable medium and electronic device for calculating indicator data, so as to solve the problem of waste of computer memory resources in the indicator calculation process in the related art.

[0005] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.

[0006] According to one aspect of an embodiment of the present application, a method for calculating indicator data is provided, including:

[0007] Preprocessing the original data to store the original data in a set data structure;

[0008] Categorize the indicators to be calculated and generate reusable components for each category of indicators to be calculated;

[0009] Based on the reusable component, the target data required for the indicator to be calculated is obtained from the original data of the set data structure to perform calculation, so as to obtain the calculation result of the indicator to be calculated.

[0010] According to one aspect of an embodiment of the present application, there is provided a device for calculating indicator data, including:

[0011] A data preprocessing module, used for preprocessing the original data to store the original data in the form of a set data structure;

[0012] The indicator classification module is used to classify the indicators to be calculated and generate reusable components for each type of indicators to be calculated;

[0013] The indicator calculation module is used to obtain the target data required for the indicator to be calculated from the original data of the set data structure based on the reusable component to calculate and obtain the calculation result of the indicator to be calculated.

[0014] In one embodiment of the present application, the data preprocessing module includes:

[0015] An arrangement order determination unit is used to traverse all indicators to be calculated and determine the arrangement order of the indicator periods of each indicator to be calculated, wherein the indicator periods with smaller periods are arranged in front and the indicator periods with larger periods are arranged in the back;

[0016] The data storage unit is used to store the original data corresponding to each indicator to be calculated in the form of a set data structure in sequence according to the arrangement order.

[0017] In one embodiment of the present application, the setting data structure is a key-value pair; the data storage unit is specifically used for:

[0018] The name field of the original data is stored as a key, the numerical value of the original data is stored as a value, and a key-value pair is formed based on the key and the value, so that the original data is stored in the form of a key-value pair.

[0019] In one embodiment of the present application, the indicator classification module is specifically used to:

[0020] If the indicator to be calculated has a first identifier, determining the indicator to be calculated as a first type of indicator, and generating a first reusable component for the first type of indicator;

[0021] If the indicator to be calculated has a second identifier, determining the indicator to be calculated as a second type of indicator, and generating a second reusable component for the second type of indicator;

[0022] If the indicator to be calculated does not have an identifier, the indicator to be calculated is determined as a third type of indicator, and a third reusable component is generated for the third type of indicator.

[0023] In one embodiment of the present application, the indicator calculation module includes:

[0024] An object generation unit, used to determine a current reusable component according to the type of the current indicator to be calculated;

[0025] A data writing unit, used for acquiring the current target data required by the current indicator to be calculated from the set data structure, and writing the current target data into the current reusable component;

[0026] The indicator calculation unit is used to perform indicator calculation based on the current reusable component written into the current target data to obtain the calculation result of the current indicator to be calculated.

[0027] In one embodiment of the present application, the indicator calculation unit is specifically used to:

[0028] If the current indicator to be calculated is a first-category indicator or a second-category indicator, performing incremental calculation on the current target data written into the current reusable component;

[0029] If the current indicator to be calculated is a third-category indicator, the current target data written into the current reusable component is fully calculated.

[0030] In one embodiment of the present application, the indicator calculation module further includes:

[0031] The data clearing unit is used to delete the data in the current reusable component if there is data in the current reusable component.

[0032] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for calculating indicator data in the above technical solution is implemented.

[0033] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor executes the executable instructions to enable the electronic device to perform a method for calculating indicator data as in the above technical solution.

[0034] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method for calculating the indicator data in the above technical solution.

[0035] In the technical solution provided in the embodiment of the present application, the original data is preprocessed to store the original data in the form of a set data structure, so that it is more convenient and faster to obtain the original data during the indicator calculation process, avoiding access to duplicate data and improving the efficiency of indicator calculation; and, the indicators to be calculated are classified and processed, and reusable components are generated for each type of indicator to be calculated, which reduces the memory usage during the indicator calculation process and saves computing resources.

[0036] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0038] Figure 1 The exemplary system architecture block diagram applying the technical solution of the present application is schematically shown.

[0039] Figure 2 A flowchart of a method for calculating indicator data provided by an embodiment of the present application is schematically shown.

[0040] Figure 3 The flowchart schematically shows a method for calculating indicator data provided by a specific embodiment of the present application.

[0041] Figure 4 The structural block diagram of the indicator data calculation device provided in an embodiment of the present application is schematically shown.

[0042] Figure 5 The structure block diagram of a computer system suitable for implementing an electronic device of an embodiment of the present application is schematically shown. DETAILED DESCRIPTION

[0043] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.

[0044] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.

[0045] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0046] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0047] Figure 1 The exemplary system architecture block diagram applying the technical solution of the present application is schematically shown.

[0048] like Figure 1 As shown, the system architecture 100 may include a terminal device 110, a network 120, and a server 130. The terminal device 110 may include various electronic devices such as a smart phone, a tablet computer, a laptop computer, and a desktop computer. The server 130 may be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The network 120 may be a communication medium of various connection types that can provide a communication link between the terminal device 110 and the server 130, such as a wired communication link or a wireless communication link.

[0049] According to the implementation requirements, the system architecture in the embodiment of the present application can have any number of terminal devices, networks and servers. For example, the server 130 can be a server group composed of multiple server devices. In addition, the technical solution provided in the embodiment of the present application can be applied to the terminal device 110, can also be applied to the server 130, or can be implemented by the terminal device 110 and the server 130 together, and the present application does not make any special restrictions on this.

[0050] For example, the calculation method of the indicator data provided in the embodiment of the present application is implemented by the server 130. Specifically, the server 130 pre-processes the raw data to store the raw data in the form of a set data structure, wherein the raw data can be collected by the terminal device 110 and stored in the database. Then the server 130 classifies the indicators to be calculated and generates a reusable component for each type of indicator to be calculated. Finally, based on the reusable component, the server 130 obtains the raw data required for the indicator to be calculated from the set data structure for calculation, and obtains the calculation result of the indicator to be calculated.

[0051] In one embodiment of the present application, after the server 130 obtains the calculation result of the indicator to be calculated, the calculation result can be sent to the terminal device 110 so that the user can obtain the calculation result of the indicator through the terminal device 110.

[0052] In one embodiment of the present application, the method for calculating the indicator data provided in the embodiment of the present application can also be implemented by the terminal device 110. Specifically, the terminal device 110 collects raw data and pre-processes the raw data to store the raw data in the form of a set data structure. The terminal device 110 then classifies the indicators to be calculated and generates reusable components for each type of indicator to be calculated. Finally, based on the reusable components, the terminal device 110 obtains the raw data required for the indicator to be calculated from the set data structure for calculation, obtains the calculation result of the indicator to be calculated, and displays the calculation result on a graphical user interface so that the user can know the calculation result.

[0053] The calculation of the indicator data provided in this application is described in detail below in conjunction with specific implementation methods.

[0054] Figure 2 A flowchart of a method for calculating indicator data provided by an embodiment of the present application is schematically shown. The method can be implemented by a terminal device, such as Figure 1 The terminal device 110 shown; the method can also be implemented by a server, such as Figure 1 The server 130 shown. Figure 2 As shown, the method for calculating the indicator data provided in the embodiment of the present application includes steps 210 to 230, which are specifically as follows:

[0055] Step 210: pre-process the original data to store the original data in the form of a set data structure.

[0056] Specifically, raw data is the data needed for indicator calculation, which is provided by different data sources and usually stored in a database. Data source refers to the object from which raw data is collected. For example, a company includes multiple departments, and each department can collect data. Then, each department of the company is equivalent to the source of raw data. The raw data collected by these departments will be uniformly stored in the database to facilitate the search and use of raw data.

[0057] The data storage formats of the original data provided by different data sources may be different, and preprocessing the original data is actually to unify the format of the original data. In the embodiment of the present application, the original data is preprocessed according to the set data structure so that the original data is stored in the form of the set data structure.

[0058] In one embodiment of the present application, the original data is preprocessed according to the set data structure, that is, the original data is stored according to the set logical relationship, for example, stored in the order of data generation time, stored according to the hierarchical relationship between the data sources corresponding to the data, etc.

[0059] In one embodiment of the present application, before the raw data is preprocessed, the corresponding raw data is obtained according to the indicator to be calculated. The indicator is an index, specification, standard, etc. that is expected to be achieved, and is a measurement parameter. The raw data required to calculate different indicators are also different. For example, if the indicator to be calculated is the quarterly profit of a department of the company, the raw data obtained is the data corresponding to the department; if the indicator to be calculated is the overall quarterly profit of the company, the raw data obtained is the data corresponding to all departments of the company.

[0060] In one embodiment of the present application, an indicator usually has a time period, which is recorded as an indicator period, and the indicator period specifies the time range of the raw data to be obtained. For example, if the indicator to be calculated is the company's overall quarterly profit, the indicator period is one quarter (3 months); if the indicator to be calculated is the company's total profit for a year, the indicator period is one year; if the indicator to be calculated is the company's profit for the day, the indicator period is one day. In general, the indicator period can be hours, days, weeks, months, quarters, years, etc. In some specific cases, it can also be minutes or other specified periods.

[0061] In one embodiment of the present application, preprocessing the original data may include: traversing all indicators to be calculated, determining the arrangement order of the indicator periods of each indicator to be calculated; according to the arrangement order, storing the original data corresponding to each indicator to be calculated in the form of a set data structure.

[0062] Specifically, a user may need to calculate multiple indicators. A user generally refers to the object of calculating indicators, which may be a single person, an organization, an enterprise, a department of an enterprise, etc. For example, the indicators to be calculated for a company may include hundreds of thousands.

[0063] In an embodiment of the present application, traversing all indicators to be calculated may be traversing all indicators to be calculated that are currently required to be calculated, or traversing all indicators to be calculated for the current user. To determine the order of arrangement of the indicator periods of each indicator to be calculated, the indicator periods are arranged in order of size, with the indicator periods with smaller periods arranged in front and the indicator periods with larger periods arranged in the back. Then, according to the order of arrangement of the indicator periods, the original data corresponding to each indicator to be calculated is stored in the form of a set data structure in sequence, that is, the original data corresponding to the indicator to be calculated with a smaller indicator period is first stored in the set data structure, and then the original data corresponding to the indicator to be calculated with a larger indicator period is stored in the set data structure.

[0064] In one embodiment of the present application, the indicator period refers to the time range required for indicator calculation, which can be days, weeks, months, years, etc. For example, if the indicator is a company's profit for one year, the indicator period is one year. The minimum indicator period that can contain all indicators to be calculated is equivalent to the maximum value of the indicator periods corresponding to all indicators to be calculated.

[0065] In one embodiment of the present application, the data structure is set to a Map data structure. The Map data structure is a dictionary data structure, and its data is stored in the form of a key-value pair. The "key" is equivalent to the name of the data, and the "value" is the specific value of the data. Therefore, the Map data structure is also a key-value pair structure. Then, the process of storing the original data in the form of a set data structure is: store the name field of the original data as a key, store the value of the original data as a value, and form a key-value pair based on the key and value, so that the original data is stored in the form of a key-value pair. For example, the original data is a company profit: 3 million yuan, then "company profit" is the "key" and "3 million yuan" is the "value", thereby forming a key-value pair.

[0066] In one embodiment of the present application, in the Map data structure, the scope of "key" is not limited to strings, but all types of values ​​can be used as "keys", that is, Map provides key-value pairs in the form of "value-value", which is a more complete hash structure.

[0067] In one embodiment of the present application, when the original data is stored in the form of a set data structure, the original data is first divided according to the user name or user ID, and then the original data corresponding to a user is formed into a Map data structure. In the Map data structure of a certain user, multiple Map data may be included, that is, multiple key-value pairs.

[0068] In one embodiment of the present application, when an indicator has other attributes such as time attributes or organizational attributes, such an indicator is called an extended indicator, which is similar to a multi-dimensional indicator. When the indicator to be calculated is an extended indicator, the original data corresponding to the indicator will form multiple nested Map structures. For example, the extended indicator of the company's profit last quarter is the indicator "company profit" plus the time attribute "last quarter". For another example, the extended indicator of the company's Shanghai sales department's profit last year is the indicator "company profit" plus the time attribute "last year" and the organizational attribute "Shanghai sales department". Since such extended indicators are usually uncertain and difficult to manage, the embodiment of the present application actually realizes the automatic expansion of indicators by constructing them as nested Map structures, that is, the extended indicators can be automatically obtained according to the nested Map structure without manual management, thereby improving the convenience of indicator management.

[0069] In one embodiment of the present application, the final data structure formed according to the extended index and the general index (indicator other than the extended index) is Map <Map<string,double> > form, which is equivalent to storing all the data required for each indicator for each user in the corresponding Map. The maximum indicator period in the Map is actually the minimum time period that can contain all indicators.

[0070] Step 220: Categorize the indicators to be calculated, and generate a reusable component for each category of the indicators to be calculated.

[0071] Specifically, the indicators to be calculated can be divided into different categories according to different classification rules. For example, the indicators to be calculated can be classified according to the indicator period, and the indicators to be calculated in the same indicator period can be classified into the same category. A component refers to an object that can be instantiated, assembled, and managed. A reusable component means that the component can be reused, not disposable. Generating a reusable component for each type of indicator to be calculated means that one type of indicator to be calculated corresponds to one reusable component.

[0072] In one embodiment of the present application, when setting the indicator to be calculated, the user will set an identifier for the indicator to be calculated to distinguish the type of the indicator to be calculated. Therefore, the process of classifying the indicator to be calculated and generating reusable components includes: if the indicator to be calculated has a first identifier, the indicator to be calculated is determined as a first-category indicator, and a first reusable component is generated for the first-category indicator; if the indicator to be calculated has a second identifier, the indicator to be calculated is determined as a second-category indicator, and a second reusable component is generated for the second-category indicator; if the indicator to be calculated does not have an identifier, the indicator to be calculated is determined as a third-category indicator, and a third reusable component is generated for the third-category indicator.

[0073] Specifically, the indicators to be calculated are divided into three categories: first-category indicators, second-category indicators and third-category indicators, wherein the first-category indicators have a first identifier, the second-category indicators have a second identifier, and the third-category indicators have no identifier. Furthermore, the first-category indicators correspond to the first reusable component, the second-category indicators correspond to the second reusable component, and the third-category indicators correspond to the third reusable component.

[0074] In one embodiment of the present application, the indicators to be calculated are classified according to the calculation method of the indicators, that is, the category of the indicators to be calculated reflects the calculation method of the indicators to be calculated to a certain extent. The first category of indicators is full cumulative indicators. Full cumulative indicators are indicators that require the addition of all historical data, generally the sum of all values ​​from the user's account opening to the present, for example, calculating the total consumption of each customer from registration to the present. The second category of indicators is first-time value indicators. First-time value indicators are indicators calculated based on the data of a certain first behavior of the user, generally the date when the ordinary indicator of each time period exceeds the set value for the first time from the user's account opening to the present, for example, calculating the time when each customer's first consumption exceeds the specified amount. Ordinary indicators are indicators other than full cumulative indicators and first-time indicators.

[0075] In one embodiment of the present application, the reusable component is a JavaBean component, also known as a Bean object. A Bean object is a Java class written in accordance with certain specifications. In general, a Bean object will occupy a certain memory space in a computer. During the execution of a computer program, relevant calculations are achieved by writing data to the memory space occupied by the Bean object (also known as writing a Bean object). When the calculation is completed, the memory space occupied by the Bean object will not be managed. During the next calculation, a new Bean object will be constructed to reoccupy the memory space. In this way, when the amount of calculation is large, a waste of memory space is caused. However, the reusable Bean object of the present application, after the calculation is completed, deletes the data written in the memory space occupied by the reusable Bean object, flushes and writes new data, and achieves relevant calculations of the new data, thereby realizing the reuse of the Bean object and achieving the effect of saving memory resources.

[0076] In one embodiment of the present application, since reusable components are generated for the classified indicators to be calculated, in a UDF (User Defined Function) function, three different types of indicators correspond to three Bean objects.

[0077] Step 230: Based on the reusable component, the target data required for the indicator to be calculated is obtained from the original data of the set data structure to perform calculation, and the calculation result of the indicator to be calculated is obtained.

[0078] Specifically, the calculation of indicator data based on the repeatable component is to write the target data required for the indicator to be calculated into the reusable component, and then implement the indicator calculation based on the reusable component with the written data to obtain the calculation result of the indicator to be calculated.

[0079] In the technical solution provided in the embodiment of the present application, the original data is preprocessed to store the original data in the form of a set data structure, so that it is more convenient and faster to obtain the original data during the indicator calculation process, avoiding access to duplicate data and improving the efficiency of indicator calculation; and, the indicators to be calculated are classified and processed, and reusable components are generated for each type of indicator to be calculated, which reduces the memory usage during the indicator calculation process and saves computing resources.

[0080] In one embodiment of the present application, there are multiple indicators to be calculated and they are of different types. The process of calculating the indicator data based on repeatable components can be: determining the current reusable component according to the type of the current indicator to be calculated; obtaining the current target data required for the current indicator to be calculated from the set data structure, and writing the current target data into the current reusable component; performing indicator calculation based on the current reusable component that writes the current target data, and obtaining the calculation result of the current indicator to be calculated.

[0081] Specifically, first determine the current reusable component according to the type of the current indicator to be calculated. For example, if the current indicator to be calculated is a first-class indicator, determine the component as the first reusable component. Then obtain the current target data from the set data structure, and write the current target data into the current reusable component. When obtaining the current target data, it is necessary to obtain it according to the indicator cycle of the current indicator to be calculated, that is, the generation time of the current target data obtained should be within the indicator cycle of the current indicator to be calculated. For example, if the current indicator to be calculated is the company's total sales in 2020, the current target data obtained should be data between January 1, 2020 and December 31, 2020. Finally, calculate based on the current reusable component that writes the current target data to obtain the calculation result of the current indicator to be calculated.

[0082] In one embodiment of the present application, before writing the current target data into the current reusable component, it is also necessary to determine whether there is data in the current reusable component. If there is data in the current reusable component, the data in the current reusable component is deleted before writing the current target data into the current reusable component.

[0083] In one embodiment of the present application, after obtaining the calculation result of the current indicator to be calculated, the current target data in the current reusable component is deleted so as to write the original data of the next indicator to be calculated.

[0084] In one embodiment of the present application, the indicator calculation is performed according to the type of the indicator to be calculated, specifically: if the current indicator to be calculated is a first-category indicator or a second-category indicator, an incremental calculation is performed on the current target data written in the current reusable component; if the current indicator to be calculated is a third-category indicator, a full calculation is performed on the current target data written in the current reusable component.

[0085] Specifically, incremental calculation refers to adding new data on the basis of historical data to obtain a calculation result, and full calculation refers to accumulating all data to obtain a calculation result. In an embodiment of the present application, the first type of indicator is a full cumulative indicator, the second type of indicator is a first value indicator, and the third type of indicator is an ordinary indicator. For full cumulative indicators and first value indicators, incremental calculation is used. For full cumulative indicators, the current data is added to the historical indicator results obtained by the previous calculation to obtain the current full cumulative indicator. For the first value indicator, if there is an indicator calculation result that meets the conditions before, there is no need to continue the calculation. If there is no indicator calculation result that meets the conditions, the current data is added to the historical indicator results obtained by the previous calculation through incremental calculation. Once the calculation result meets the conditions, the calculation of the first value indicator can be omitted later. Compared with obtaining data every time to calculate the first value indicator, incremental calculation can effectively reduce the amount of data calculation and improve calculation efficiency. For ordinary indicators, it is necessary to obtain the calculation result through full calculation.

[0086] In one embodiment of the present application, it is also possible to determine whether to use incremental calculation or full calculation based on whether the indicator to be calculated has a corresponding historical indicator result. For indicators to be calculated that have historical indicator results, such indicators are usually full cumulative indicators or first value indicators, and the calculation results can be obtained by using the incremental calculation method. For ordinary indicators and full cumulative indicators or first value indicators without historical indicator results, it is necessary to obtain all the original data corresponding to the indicator for calculation, that is, to use the full calculation method to obtain the calculation result.

[0087] In one embodiment of the present application, when calculating the indicators to be calculated, the calculation can also be performed according to the priority of the indicators. For example, the full cumulative indicator has the highest calculation priority, the ordinary indicator has the second highest calculation priority, and the first value indicator has the lowest calculation priority. Since both the full cumulative indicator and the first value indicator adopt an incremental calculation method, some first value indicators may be included in the process of calculating the full cumulative indicator; similarly, some first value indicators may also be included in the calculation process of the ordinary indicator. Therefore, the full cumulative indicator is calculated first, and the ordinary indicator is calculated second. In this way, some first value indicators can be calculated at the same time. The first value indicator calculated at the end only needs to consider the first value indicators not involved in the full cumulative indicator and the ordinary indicator. In this way, the efficiency of indicator calculation is improved.

[0088] In one embodiment of the present application, when obtaining the raw data required for the indicator, a time window can be set according to the indicator period of the indicator to be calculated, and the raw data can be obtained by sliding the time window in the Map data structure. Since the Map structure data is already the minimum time period containing all indicators, all indicators of a user can be calculated by traversing the Map structure once, without accessing duplicate data. It can be seen that the time complexity of the calculation is proportional to the size of the Map structure.

[0089] In one embodiment of the present application, since the original data is stored in a Map structure according to the index period size, when traversing the Map structure to calculate the index, on the one hand, when calculating the index of the small period, a part of the data of the large period index is calculated; on the other hand, when calculating the large period index, the small period index is calculated, which improves the calculation efficiency of the index data.

[0090] Figure 3 The following is a flow chart schematically showing a method for calculating indicator data provided by a specific embodiment of the present application. Figure 3 As shown, the method includes:

[0091] S310, obtaining raw data. Raw data is provided by different data sources. The data source refers to the object from which the raw data is collected. For example, a company includes multiple departments, and each department can collect data. Then, each department of the company is equivalent to the source of raw data. The raw data collected by these departments will be uniformly stored in the database. Therefore, this step is to obtain raw data from the database.

[0092] S320, pre-process the original data to generate Map structure data. The indicators to be calculated can form a list, and the indicator period may span multiple time periods, such as 1m, 3m, 1y, etc. Traverse all indicators and calculate the minimum time window that best contains all indicator periods, that is, the maximum indicator period among all indicator periods. Then, according to the time window, put the original data contained in the time into the Map structure. If it is an extended indicator, similar to the multi-dimensional case, it is constructed into multiple nested Maps. The final data structure is Map <Map<string,double> >, that is, for each user, all the historical data required by each indicator is in the corresponding Map.

[0093] S330, generating a Java internal Bean object for the indicator to be calculated. First, the indicator to be calculated is classified, such as divided into full cumulative indicators, first value indicators and common indicators, and then a Bean object is generated for each type of indicator.

[0094] S340. Determine whether there are historical indicator results for the indicator to be calculated. If there are historical indicator results, an incremental calculation method is used; if there are no historical indicator results (that is, the historical indicator is empty), a full calculation method is used. The aggregation algorithms for indicators are as follows: avg (average value), sum (sum), min (minimum value), max (maximum value), tavg (trading day average). The full cumulative indicator is the sum of all values ​​from the customer's account opening to the present, and the first indicator is the date when the ordinary indicator of each time window exceeds the set value for the first time from the customer's account opening to the present. By definition, the full cumulative indicator can be calculated incrementally, adding today's results to yesterday's indicator value; for the first indicator, once the date of the first exceedance is calculated, this date will not change in the subsequent time. After special processing of incremental calculation, the scanning and calculation of data can be effectively reduced. Ordinary indicators and other indicators without historical results need to be obtained through full calculation.

[0095] S350. Calculate according to the calculation method of the indicator to be calculated to obtain the indicator calculation result. Calculate the indicators in the following order during the calculation process: give priority to fully accumulated indicators, then ordinary indicators, and finally first value indicators. Finally, calculate each indicator Bean of each customer, and the calculation order is also optimized. Because the Map structure data is already the minimum time window containing all indicators, all indicators can be calculated by traversing the Map structure once, that is, when the number of indicators is much smaller than the historical data, the time complexity of the calculation is only proportional to the Size of the Map structure, and there is no repeated data access.

[0096] It should be noted that although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0097] The following introduces an apparatus embodiment of the present application, which can be used to execute the method for calculating the indicator data in the above-mentioned embodiment of the present application. Figure 4 The structure block diagram of the device for calculating the index data provided by the embodiment of the present application is schematically shown. Figure 4 As shown, the calculation device of the indicator data includes:

[0098] The data preprocessing module 410 is used to preprocess the original data so as to store the original data in the form of a set data structure;

[0099] The indicator classification module 420 is used to classify the indicators to be calculated and generate a reusable component for each type of indicator to be calculated;

[0100] The indicator calculation module 430 is used to obtain the target data required for the indicator to be calculated from the original data of the set data structure based on the reusable component, and obtain the calculation result of the indicator to be calculated.

[0101] In one embodiment of the present application, the data preprocessing module 410 includes:

[0102] An arrangement order determination unit is used to traverse all indicators to be calculated and determine the arrangement order of the indicator periods of each indicator to be calculated, wherein the indicator periods with smaller periods are arranged in front and the indicator periods with larger periods are arranged in the back;

[0103] The data storage unit is used to store the original data corresponding to each indicator to be calculated in the form of a set data structure in sequence according to the arrangement order.

[0104] In one embodiment of the present application, the setting data structure is a key-value pair; the data storage unit is specifically used for:

[0105] The name field of the original data is stored as a key, the numerical value of the original data is stored as a value, and a key-value pair is formed based on the key and the value, so that the original data is stored in the form of a key-value pair.

[0106] In one embodiment of the present application, the indicator classification module 420 is specifically used to:

[0107] If the indicator to be calculated has a first identifier, determining the indicator to be calculated as a first type of indicator, and generating a first reusable component for the first type of indicator;

[0108] If the indicator to be calculated has a second identifier, determining the indicator to be calculated as a second type of indicator, and generating a second reusable component for the second type of indicator;

[0109] If the indicator to be calculated does not have an identifier, the indicator to be calculated is determined as a third type of indicator, and a third reusable component is generated for the third type of indicator.

[0110] In one embodiment of the present application, the indicator calculation module 430 includes:

[0111] An object generation unit, used to determine a current reusable component according to the type of the current indicator to be calculated;

[0112] A data writing unit, used for acquiring the current target data required by the current indicator to be calculated from the set data structure, and writing the current target data into the current reusable component;

[0113] The indicator calculation unit is used to perform indicator calculation based on the current reusable component written into the current target data to obtain the calculation result of the current indicator to be calculated.

[0114] In one embodiment of the present application, the indicator calculation unit is specifically used to:

[0115] If the current indicator to be calculated is a first-category indicator or a second-category indicator, performing incremental calculation on the current target data written into the current reusable component;

[0116] If the current indicator to be calculated is a third-category indicator, the current target data written into the current reusable component is fully calculated.

[0117] In one embodiment of the present application, the indicator calculation module 430 further includes:

[0118] The data clearing unit is used to delete the data in the current reusable component if there is data in the current reusable component.

[0119] The specific details of the indicator data calculation device provided in each embodiment of the present application have been described in detail in the corresponding method embodiments and will not be repeated here.

[0120] Figure 5 The structure block diagram of a computer system for implementing an electronic device according to an embodiment of the present application is schematically shown.

[0121] It should be noted that Figure 5 The computer system 500 of the electronic 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 application.

[0122] like Figure 5As shown, the computer system 500 includes a central processing unit 501 (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory 502 (ROM) or the program loaded from the storage part 508 to the random access memory 503 (RAM). Various programs and data required for system operation are also stored in the random access memory 503. The central processing unit 501, the read-only memory 502 and the random access memory 503 are connected to each other through a bus 504. The input / output interface 505 (Input / Output interface, i.e., I / O interface) is also connected to the bus 504.

[0123] The following components are connected to the input / output interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a local area network card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the input / output interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed so that a computer program read therefrom is installed into the storage section 508 as needed.

[0124] In particular, according to an embodiment of the present application, the process described in each method flow chart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer readable medium, and the computer program contains a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processor 501, various functions defined in the system of the present application are executed.

[0125] It should be noted that the computer-readable medium shown in the embodiment of the present application 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, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, 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), a 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 application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals 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 process programs 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 processed using any suitable medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0126] 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 application. 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.

[0127] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0128] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.

[0129] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary technical means in the art that are not disclosed in the present application.

[0130] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A method for calculating indicator data, characterized in that: include: The name field of the original data is stored as a key, the value of the original data is stored as a value, and a key-value pair is formed based on the key and the value, so that the original data is stored in the form of a key-value pair; The indicators to be calculated are classified and a reusable component is generated for each type of the indicators to be calculated; wherein, when setting the indicators to be calculated, an identifier is set for the indicators to be calculated to distinguish the types of the indicators to be calculated; Determine the current reusable component according to the type of the current indicator to be calculated; Acquire current target data required for the current indicator to be calculated from the original data stored in the form of key-value pairs, and write the current target data into the current reusable component; An indicator calculation is performed based on the current reusable component written into the current target data to obtain a calculation result of the current indicator to be calculated.

2. The method for calculating index data according to claim 1, characterized in that: The method includes storing the name field of the original data as a key, storing the value of the original data as a value, and forming a key-value pair based on the key and the value, so that the original data is stored in the form of a key-value pair, including: Traverse all the indicators to be calculated, and determine the order of the indicator periods of the indicators to be calculated, wherein the indicator periods with smaller periods are arranged in front, and the indicator periods with larger periods are arranged in the back; According to the arrangement order, the name field of the original data corresponding to each indicator to be calculated is stored as a key, and the numerical value of the original data is stored as a value. A key-value pair is formed based on the key and the value, so that the original data is stored in the form of a key-value pair.

3. The method for calculating index data according to claim 1, characterized in that: The indicators to be calculated are classified and reusable components are generated for each type of indicator to be calculated, including: If the indicator to be calculated has a first identifier, determining the indicator to be calculated as a first type of indicator, and generating a first reusable component for the first type of indicator; If the indicator to be calculated has a second identifier, determining the indicator to be calculated as a second type of indicator, and generating a second reusable component for the second type of indicator; If the indicator to be calculated does not have an identifier, the indicator to be calculated is determined as a third type of indicator, and a third reusable component is generated for the third type of indicator.

4. The method for calculating index data according to claim 1, characterized in that: Metric calculations are based on the current reusable components that write the current target data, including: If the current indicator to be calculated is a first-category indicator or a second-category indicator, performing incremental calculation on the current target data written into the current reusable component; If the current indicator to be calculated is a third-category indicator, the current target data written into the current reusable component is fully calculated.

5. The method for calculating index data according to claim 1, characterized in that: Before writing the current target data into the current reusable component, the method further comprises: If there is data in the current reusable component, the data in the current reusable component is deleted.

6. A device for calculating index data, characterized in that: include: A data preprocessing module, used for storing the name field of the original data as a key, storing the numerical value of the original data as a value, and forming a key-value pair based on the key and the value, so that the original data is stored in the form of a key-value pair; The indicator classification module is used to classify the indicators to be calculated and generate reusable components for each type of indicators to be calculated; wherein, when setting the indicators to be calculated, an identifier is set for the indicators to be calculated to distinguish the types of the indicators to be calculated; The indicator calculation module is used to determine the current reusable component according to the type of the current indicator to be calculated; obtain the current target data required for the current indicator to be calculated from the original data stored in the form of key-value pairs, and write the current target data into the current reusable component; perform indicator calculation based on the current reusable component that writes the current target data, and obtain the calculation result of the current indicator to be calculated.

7. A computer-readable medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method for calculating the indicator data described in any one of claims 1 to 5 is implemented.

8. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor executes the executable instructions to enable the electronic device to execute the indicator data calculation method described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data mining structure

    US20050021489A1

  • Machine learning semantic model

    US20140046879A1