Data statistics method, device, electronic equipment and storage medium
By using timed tasks and data table storage methods in data statistics, the problem of reduced statistical efficiency caused by the increase in data volume is solved, and efficient data statistics are achieved.
Patent Information
- Application Number
- CN202111531049.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2041-12-14
AI Technical Summary
As the amount of data increases, the duration of data statistics also increases, resulting in a decrease in data statistics efficiency.
The business data of the target service is obtained according to the first timing cycle according to the first timing cycle, and the business data within the cycle is counted in each dimension, and the statistical results are obtained and stored in the first data table. In response to a data statistics request for business data in any dimension, the statistical results that have been counted are directly obtained from the first data table.
It saves the overhead of data statistics, improves the efficiency of data statistics, and avoids the problem of low efficiency in real-time statistics.
Smart Images

Figure CN114416812B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data statistics method, device, electronic device and storage medium. Background Art
[0002] With the continuous development of technology, a huge amount of data will be generated in various fields of people's work and life. In related technologies, data can be counted and updated in real time by computers and displayed. However, as the amount of data increases, the time for data statistics will also increase, resulting in a decrease in the efficiency of data statistics. Summary of the invention
[0003] In order to solve the above technical problems, the present application provides a data statistics method, device, electronic device and storage medium.
[0004] According to a first aspect of the present application, a data statistics method is provided, comprising:
[0005] Obtaining service data of a target service periodically according to a first timing cycle, and performing statistics on the service data in each dimension for service data in a single first timing cycle to obtain statistical results of the service data in each dimension;
[0006] The statistical results of the business data of each dimension are stored in the first data table;
[0007] In response to a data statistics request for business data of any dimension, obtaining one or more statistical results of the business data of any dimension from the first data table;
[0008] A final statistical result of the business data of any dimension is determined according to the one or more statistical results.
[0009] Optionally, the method further includes:
[0010] Regularly detecting the business data of each dimension according to a second timing cycle;
[0011] If the business data of each dimension within a single second timing period includes business data of a target dimension, the statistical results of the business data of the target dimension are stored in a second data table; wherein the amount of data stored in the second data table is less than the amount of data stored in the first data table;
[0012] In response to a data statistics request for the business data of the target dimension, acquiring one or more statistical results of the business data of the target dimension from the second data table;
[0013] A final statistical result of the business data of the target dimension is determined according to one or more statistical results of the business data of the target dimension.
[0014] Optionally, the method further includes:
[0015] acquiring target service data from the first data table according to a third timing cycle; wherein the data state corresponding to the target service data is the target state;
[0016] For a single target service data in each of the third timing periods, if the third data table does not contain the target service data, the target service data is stored in the third data table.
[0017] Optionally, the method further includes:
[0018] acquiring the data status of the business data of the target dimension in the second data table and the data status of the business data of the target dimension in the first data table according to a fourth timing cycle;
[0019] If the data state of the business data of the target dimension in the second data table changes within the single fourth timing period, and the data state of the business data of the target dimension in the first data table does not change, then the data state of the business data of the target dimension in the first data table is synchronously updated, or,
[0020] If the data state of the business data of the target dimension in the first data table changes within the single fourth timing period, and the data state of the business data of the target dimension in the second data table does not change, the data state of the business data of the target dimension in the second data table is synchronously updated.
[0021] Optionally, the amount of business data of the target dimension is less than a preset amount, or the query frequency of the business data of the target dimension is higher than a preset frequency.
[0022] Optionally, the multiple statistical results of the business data of any dimension include: statistical results of the business data of any dimension in each of the first timing periods;
[0023] Determining the final statistical result of the business data of any dimension according to the one or more statistical results includes:
[0024] The sum of the statistical results of the business data of any dimension in each of the first timing periods is determined as the final statistical result of the business data of any dimension.
[0025] Optionally, for the service data in a single first timing period, statistics are performed on the service data in various dimensions to obtain statistical results of the service data in various dimensions, including:
[0026] For each piece of business data in a single first timing period, the dimension to which the business data belongs is determined, and 1 is added to the statistical result of the business data of the dimension, wherein the initial value of the statistical result of the business data of each dimension is 0.
[0027] According to a second aspect of the present application, a data statistics device is provided, comprising:
[0028] A timing statistics module, used for periodically acquiring the service data of the target service according to a first timing period, and for the service data in a single first timing period, performing statistics on the service data in various dimensions to obtain statistical results of the service data in various dimensions;
[0029] A first data storage module, used to store the statistical results of the business data of each dimension in a first data table;
[0030] A statistical result acquisition module, configured to, in response to a data statistical request for business data of any dimension, acquire one or more statistical results of the business data of any dimension from the first data table;
[0031] The final statistical result determination module is used to determine the final statistical result of the business data of any dimension according to the one or more statistical results.
[0032] Optionally, the data statistics device further includes:
[0033] A timing detection module, used for detecting the business data of each dimension according to a second timing period;
[0034] A second data storage module is used for storing the statistical results of the business data of the target dimension in a second data table if the business data of each dimension within a single second timing period includes the business data of the target dimension; wherein the amount of data stored in the second data table is less than the amount of data stored in the first data table;
[0035] The statistical result acquisition module is further configured to, in response to a data statistics request for the business data of the target dimension, acquire one or more statistical results of the business data of the target dimension from the second data table;
[0036] The final statistical result determination module is further used to determine the final statistical result of the business data of the target dimension according to one or more statistical results of the business data of the target dimension.
[0037] Optionally, the data statistics device further includes:
[0038] A target business data timing acquisition module, used to acquire target business data from the first data table according to a third timing period; wherein the data state corresponding to the target business data is the target state;
[0039] The third data storage module is used to store the target service data in the third data table for each of the third timing periods if the target service data is not included in the third data table.
[0040] Optionally, the data statistics device further includes:
[0041] a data status acquisition module, configured to acquire the data status of the business data of the target dimension in the second data table and the data status of the business data of the target dimension in the first data table according to a fourth timing cycle;
[0042] a first updating module, configured to synchronously update the data state of the business data of the target dimension in the second data table if the data state of the business data of the target dimension in the second data table changes within a single fourth timing period and the data state of the business data of the target dimension in the first data table does not change, or,
[0043] The second update module is used to synchronously update the data status of the business data of the target dimension in the first data table if the data status of the business data of the target dimension in the first data table changes within a single fourth timing period and the data status of the business data of the target dimension in the second data table does not change.
[0044] Optionally, the amount of business data of the target dimension is less than a preset amount, or the query frequency of the business data of the target dimension is higher than a preset frequency.
[0045] Optionally, the multiple statistical results of the business data of any dimension include: statistical results of the business data of any dimension in each of the first timing periods;
[0046] The final statistical result determination module is specifically used to determine the sum of the statistical results of the business data of any dimension in each of the first timing periods as the final statistical result of the business data of any dimension.
[0047] Optionally, the timing statistics module is specifically used to obtain business data of the target business according to a first timing period, determine the dimension to which each business data within a single first timing period belongs, and add 1 to the statistical result of the business data of the dimension, wherein the initial value of the statistical result of the business data of each dimension is 0.
[0048] According to a third aspect of the present application, an electronic device is provided, comprising: a processor, wherein the processor is configured to execute a computer program stored in a memory, wherein the computer program implements the method described in the first aspect when executed by the processor.
[0049] According to a fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method described in the first aspect is implemented.
[0050] According to a fifth aspect of the present application, a computer program product is provided. When the computer program product is run on a computer, the computer is enabled to execute the method described in the first aspect.
[0051] Compared with the prior art, the technical solution provided by the embodiments of the present application has the following advantages:
[0052] The business data of the target business can be obtained regularly according to the first timing period. Every time the business data within the first timing period is obtained, the business data within the first timing period can be counted in various dimensions to obtain the corresponding statistical results and store them in the first data table. When statistics are performed on the business data of any dimension, the already counted statistical results can be directly obtained from the first data table without the need to perform statistics from a large amount of business data. It can be seen that the application adopts the method of timed tasks, which can save the overhead of data statistics and improve the efficiency of data statistics. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0054] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0055] Figure 1 A schematic diagram showing a system architecture of an exemplary application environment of the data statistics method that can be applied to the embodiments of the present application;
[0056] Figure 2 A flow chart of the data statistics method in the embodiment of the present application;
[0057] Figure 3 This is another flow chart of the data statistics method in the embodiment of the present application;
[0058] Figure 4 This is another flow chart of the data statistics method in the embodiment of the present application;
[0059] Figure 5 A schematic diagram of the structure of a data statistics device in an embodiment of the present application;
[0060] Figure 6 A schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0061] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0062] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only part of the embodiments of the present application, rather than all of the embodiments.
[0063] Figure 1 A schematic diagram showing a system architecture of an exemplary application environment that can be applied to the data statistics method of the embodiments of the present application.
[0064] like Figure 1 As shown, the system architecture 100 may include one or more of the terminal devices 101, 102, and 103, a network 104, and a server 105. The network 104 is used as a medium for providing a communication link between the terminal devices 101, 102, 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links or optical fiber cables, etc. The terminal devices 101, 102, and 103 may be various electronic devices with display screens, including but not limited to desktop computers, portable computers, smart phones, and tablet computers, etc. It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. According to the implementation requirements, there may be any number of terminal devices, networks and servers. For example, the server 105 may be a server cluster composed of multiple servers.
[0065] The data statistics method provided in the embodiment of the present application is generally executed by the server 105, and accordingly, the data statistics device can be set in the server 105. However, it is easy for those skilled in the art to understand that the data statistics method provided in the embodiment of the present application can also be executed by the terminal device 101, the terminal device 102, and the terminal device 103. For example, the maintenance personnel can perform business operations through the applications in the terminal devices 101, 102, and 103 to generate corresponding business data. The server 105 can obtain the corresponding business data, and perform statistics on the business data to obtain corresponding statistical results. The maintenance personnel can query the corresponding statistical results through the terminal devices 101, 102, and 103.
[0066] The following first introduces the data statistics method of the embodiment of the present application in detail.
[0067] See also Figure 2 , Figure 2 A flow chart of the data statistics method in the embodiment of the present application may include the following steps:
[0068] Step S210, acquiring the business data of the target business regularly according to the first timing cycle, and performing statistics on the business data in each dimension for the business data in a single first timing cycle to obtain statistical results of the business data in each dimension.
[0069] In an embodiment of the present application, the target business may be a business related to data statistics. For example, when encountering a virus transmission infection incident, each region will conduct virus detection, and for the purpose of prevention and control, people in each region will be vaccinated. A large amount of data is generated in this process, and the data can be counted and updated in real time. The present application can count the data based on a timed task, that is, the business data of the target business can be obtained according to a preset first timing period, and each time the business data within a first timing period is obtained, the business data within the first timing period can be counted in each dimension to obtain the statistical results of the business data in each dimension.
[0070] For example, in the case of virus testing, the number of people who have made appointments, the number of people who have been tested, the number of people who have canceled their appointments, the number of people with positive test results, the number of people with negative test results, etc. In the case of vaccination, since each person may need to be vaccinated 2-3 times, the number of people who have made appointments, the number of people who have been vaccinated, the number of people who have canceled their appointments, the number of people who have completed all vaccinations, etc. can be counted.
[0071] Optionally, business data may be counted in each dimension in the following manner: for each business data in a single first timing period, the dimension to which the business data belongs is determined, and the statistical result of the business data in that dimension is increased by 1, wherein the initial value of the statistical result of the business data in each dimension is 0.
[0072] Step S220, storing the statistical results of the business data in each dimension into the first data table.
[0073] After obtaining the statistical results of the business data of each dimension, the statistical results can be stored in the first data table. In this way, when you want to query the statistical results, you can directly read the statistical results through the interface. Among them, the first data table can be a MySQL table. MySQL is a relational database management system. The relational database can store data in different tables instead of putting all the data in a large warehouse. In this way, the speed of data query and the flexibility of query can be improved.
[0074] Step S230 , in response to a data statistics request for business data of any dimension, obtaining one or more statistical results of the business data of any dimension from the first data table.
[0075] When the maintenance personnel want to query the statistical results, they can send a data statistics request, which can carry the statistical time period, statistical dimensions, etc. In response to the data statistics request, the server can directly obtain one or more statistical results corresponding to the data statistics request from the first data table without querying the corresponding business data from a large amount of data and performing statistics on the queried business data. In this way, the problem of low efficiency caused by real-time statistics can be avoided. It is understandable that the statistical time period and statistical dimensions are different, and the one or more statistical results obtained will also be different.
[0076] Step S240, determining the final statistical result of the business data in any dimension according to one or more statistical results.
[0077] In the case where there is only one statistical result, the one statistical result is the final statistical result. In the case where there are multiple statistical results, the multiple statistical results correspond to different first timing periods, and the sum of the multiple statistical results is determined as the final statistical result. Optionally, when the statistical dimension is carried in the data statistics request but the statistical time period is not carried, the statistical results of the business data of any dimension in all time periods can be counted. The multiple statistical results of the business data of any dimension may include: the statistical results of the business data of any dimension in each first timing period; the sum of the statistical results of the business data of any dimension in each first timing period is determined as the final statistical result of the business data of any dimension.
[0078] The data statistics method of the embodiment of the present application can obtain the business data of the target business according to the first timing period. Every time the business data in the first timing period is obtained, the business data in the first timing period can be counted in various dimensions to obtain the corresponding statistical results and store them in the first data table. When statistics are performed on the business data of any dimension, the statistical results that have been counted can be directly obtained from the first data table without the need to perform statistics from a large amount of business data. It can be seen that the present application adopts the method of timed tasks, which can save the overhead of data statistics and improve the efficiency of data statistics.
[0079] See also Figure 3 , Figure 3 Another flow chart of the data statistics method in the embodiment of the present application may include the following steps:
[0080] Step S310: detect the business data of each dimension according to the second timing cycle.
[0081] It is understandable that, due to the large amount of data in the first data table, if the statistical results of the business data are queried directly from the first data table, the query efficiency is low. Therefore, the business data of each dimension can be detected in the form of a timed task to detect whether the business data of each dimension contains the business data of the target dimension. The second timing period can be the same as or different from the first timing period. For example, the first timing period can be 1 hour, the second timing period can also be 1 hour, or the second timing period can be 2 hours, etc.
[0082] The target dimension business data refers to business data that does not require a full table query. Optionally, the amount of business data in the target dimension is less than a preset amount, or the query frequency of the business data in the target dimension is higher than a preset frequency. That is, for business data with a small amount of data or business data with a high query frequency, the following step S320 can be performed without performing a full table query to improve query efficiency.
[0083] Step S320: If the business data of each dimension within a single second timing period includes the business data of the target dimension, the statistical results of the business data of the target dimension are stored in the second data table.
[0084] The present application can generate a new data table, namely the second data table, in which the amount of data stored is less than the amount of data stored in the first data table. If the business data of each dimension within a single second timing period includes the business data of the target dimension, the statistical results of the business data of the target dimension are stored in the second data table. In this way, the statistical results can be directly queried from the second data table without having to query the statistical results from the first data table with a larger amount of data, thereby improving the efficiency of data statistics.
[0085] For example, in a virus detection scenario, most people only need to be tested once, but a small number of people may need to be retested. Since the number of retested people is small, when storing the retested people in the first data table, the retested people can also be stored in the second data table. In this way, when counting the retested people, the statistical results can be obtained from the second data table.
[0086] Step S330 , in response to a data statistics request for the business data of the target dimension, obtaining one or more statistical results of the business data of the target dimension from the second data table.
[0087] The data statistics request may carry a statistical dimension, and the data statistics request for business data of a target dimension may carry the target dimension. In response to the data statistics request for business data of the target dimension, the corresponding statistical result may be obtained from the second data table based on the target dimension.
[0088] Step S340, determining a final statistical result of the business data of the target dimension according to one or more statistical results of the business data of the target dimension.
[0089] When there is one statistical result, the one statistical result is the final statistical result. When there are multiple statistical results, the multiple statistical results correspond to different second timing periods, and the sum of the multiple statistical results is determined as the final statistical result.
[0090] Step S350: acquiring the data status of the business data of the target dimension in the second data table and the data status of the business data of the target dimension in the first data table according to a fourth timing cycle.
[0091] Since the first data table and the second data table contain the same business data, in order to avoid different data states of the same business data in the two data tables, a timed task can be used to periodically obtain the data states of the business data of the target dimensions in the first data table and the second data table according to a fourth timing cycle to detect whether the data state of the business data of the target dimension has changed.
[0092] Step S360: If the data state of the business data of the target dimension in the second data table changes within a single fourth timing period, and the data state of the business data of the target dimension in the first data table does not change, the data state of the business data of the target dimension in the first data table is synchronously updated.
[0093] In some scenarios, maintenance personnel change the status of the business data of the target dimension in the second data table without changing the status of the business data of the target dimension in the first data table. In this case, the data status of the business data of the target dimension in the first data table can be synchronously updated through a scheduled task.
[0094] For example, in a virus detection scenario, for re-examination personnel, since the amount of data is relatively small, the statistical results of the re-examination personnel can be stored in the second data table. If the re-examination result of a certain person is positive during the re-examination, and the previous test result is negative, the test result can be changed from negative to positive in the second data table. The maintenance personnel may not synchronize the update of the first data table when updating the second data table. Therefore, the data status of the business data of the target dimension in the first data table and the second data table can be regularly checked to change the test result in the first data table from negative to positive.
[0095] Step S370: If the data state of the business data of the target dimension in the first data table changes within a single fourth timing period, and the data state of the business data of the target dimension in the second data table does not change, the data state of the business data of the target dimension in the second data table is synchronously updated.
[0096] Similar to the aforementioned step S360, if the data state of the business data of the target dimension in the first data table changes, and the data state of the business data of the target dimension in the second data table does not change, the data state of the business data of the target dimension in the second data table can be synchronously updated.
[0097] The data statistics method of the embodiment of the present application may not use the whole table query method for the business data of the target dimension, that is, it does not query data from the first data table, but uses the method of timing tasks and generating a new data table (second data table) to save the cost of data statistics, thereby improving the efficiency of data statistics. In addition, for the problem of data inconsistency between the first data table and the second data table, synchronous updates can be performed to improve the accuracy of the data.
[0098] See also Figure 4 , Figure 4 Another flow chart of the data statistics method in the embodiment of the present application may include the following steps:
[0099] Step S410, acquiring target business data from the first data table according to a third timing cycle; wherein the data state corresponding to the target business data is the target state.
[0100] When collecting data statistics, in addition to collecting statistics by dimension, you can also collect statistics by the data status of the business data. For example, you can collect business data whose data status is the target status, that is, the target business data. Similarly, you can also use the scheduled task method to collect statistics on the target business data.
[0101] In the virus detection scenario, the test results include negative and positive. If you want to count the number of people with negative test results, then the corresponding business data with a negative data status is the target business data.
[0102] Step S420: For a single target service data in each third timing period, if the third data table does not contain the target service data, the target service data is stored in the third data table.
[0103] For the target business data, the target business data can also be stored in an independent data table (i.e., the third data table). Since there may be duplicate data in the first data table, deduplication can be performed in the process of storing the target business data in the third data table. That is, before each storage, it is confirmed whether the third data table already contains the target business data. If it is already contained, it is not stored; if it is not contained, it is stored.
[0104] For example, if a person undergoes multiple virus tests and the test results are all negative, then there will be multiple pieces of data about the person in the first data table. When storing the data of the person in the third data table, only one piece of data may be stored.
[0105] Through the above method, the target business data is stored in the third data table, so that data statistics can be performed from the third data table. Since the amount of data in the third data table is smaller than that in the first data table and does not contain duplicate data, the efficiency of data statistics can be improved.
[0106] Corresponding to the above method embodiment, the present application embodiment also provides a data statistics device, see Figure 5 , the data statistics device 500 comprises:
[0107] The timing statistics module 510 is used to obtain the service data of the target service according to the first timing cycle, and to perform statistics on the service data in each dimension for the service data in a single first timing cycle to obtain the statistical results of the service data in each dimension;
[0108] A first data storage module 520 is used to store the statistical results of the business data of each dimension in a first data table;
[0109] The statistical result acquisition module 530 is used to obtain one or more statistical results of the business data of any dimension from the first data table in response to a data statistical request for the business data of any dimension;
[0110] The final statistical result determination module 540 is used to determine the final statistical result of the business data of any dimension according to one or more statistical results.
[0111] Optionally, the data statistics device 500 further includes:
[0112] A timing detection module, used to detect the business data of each dimension according to the second timing period;
[0113] A second data storage module, configured to store the statistical results of the business data of the target dimension in a second data table if the business data of each dimension within a single second timing period includes the business data of the target dimension; wherein the amount of data stored in the second data table is less than the amount of data stored in the first data table;
[0114] The statistical result acquisition module 530 is further configured to acquire one or more statistical results of the business data of the target dimension from the second data table in response to a data statistical request for the business data of the target dimension;
[0115] The final statistical result determination module 540 is further used to determine the final statistical result of the business data of the target dimension according to one or more statistical results of the business data of the target dimension.
[0116] Optionally, the data statistics device 500 further includes:
[0117] A target business data timing acquisition module is used to obtain the target business data from the first data table according to a third timing period; wherein the data state corresponding to the target business data is the target state;
[0118] The third data storage module is used to store the target service data in the third data table for the single target service data in each third timing period if the third data table does not contain the target service data.
[0119] Optionally, the data statistics device 500 further includes:
[0120] A data status acquisition module, used to periodically acquire the data status of the business data of the target dimension in the second data table and the data status of the business data of the target dimension in the first data table according to a fourth timing cycle;
[0121] a first updating module, configured to synchronously update the data state of the business data of the target dimension in the second data table if the data state of the business data of the target dimension in the second data table changes within a single fourth timing period and the data state of the business data of the target dimension in the first data table does not change, or,
[0122] The second update module is used to synchronously update the data status of the business data of the target dimension in the first data table if the data status of the business data of the target dimension in the first data table changes within a single fourth timing period and the data status of the business data of the target dimension in the second data table does not change.
[0123] Optionally, the amount of business data of the target dimension is less than a preset amount, or the query frequency of the business data of the target dimension is higher than a preset frequency.
[0124] Optionally, the multiple statistical results of the business data in any dimension include: statistical results of the business data in any dimension in each first timing period;
[0125] The final statistical result determination module 540 is specifically configured to determine the sum of the statistical results of the business data of any dimension in each first timing period as the final statistical result of the business data of any dimension.
[0126] Optionally, the timing statistics module 510 is specifically used to obtain business data of the target business according to a first timing period, determine the dimension to which the business data belongs for each business data within a single first timing period, and add 1 to the statistical result of the business data of the dimension, wherein the initial value of the statistical result of the business data of each dimension is 0.
[0127] The specific details of each module or unit in the above device have been described in detail in the corresponding method, so they will not be repeated here.
[0128] 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.
[0129] In an exemplary embodiment of the present application, an electronic device is also provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the above-mentioned data statistics method in this exemplary embodiment.
[0130] Figure 6This is a schematic diagram of the structure of an electronic device in an embodiment of the present application. It should be noted that: Figure 6 The electronic device 600 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.
[0131] like Figure 6 As shown, electronic device 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In RAM 603, various programs and data required for system operation are also stored. Central processing unit 601, ROM 602 and RAM 603 are connected to each other via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0132] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a local area network (LAN) card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0133] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart 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 program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 609, and / or installed from a removable medium 611. When the computer program is executed by the central processing unit 601, various functions defined in the device of the present application are executed.
[0134] In an embodiment of the present application, a computer-readable storage medium is further provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned data statistics method is implemented.
[0135] It should be noted that the computer-readable storage medium shown in the present application may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, radio frequency, etc., or any suitable combination of the above.
[0136] In an embodiment of the present application, a computer program product is also provided. When the computer program product runs on a computer, the computer executes the above-mentioned data statistics method.
[0137] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0138] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data statistics method, characterized in that: The method comprises: Obtaining service data of a target service periodically according to a first timing cycle, and performing statistics on the service data in each dimension for service data in a single first timing cycle to obtain statistical results of the service data in each dimension; The statistical results of the business data of each dimension are stored in the first data table; In response to a data statistics request for business data of any dimension, obtaining one or more statistical results of the business data of any dimension from the first data table, wherein the data statistics request carries a statistical time period and a statistical dimension; Determine a final statistical result of the business data of any dimension according to the one or more statistical results; acquiring target service data from the first data table according to a third timing cycle; wherein the data state corresponding to the target service data is the target state; For a single target service data in each of the third timing periods, if the third data table does not contain the target service data, the target service data is stored in the third data table.
2. The method according to claim 1, characterized in that The method further comprises: Regularly detecting the business data of each dimension according to a second timing cycle; If the business data of each dimension within a single second timing period includes business data of a target dimension, the statistical results of the business data of the target dimension are stored in a second data table; wherein the amount of data stored in the second data table is less than the amount of data stored in the first data table; In response to a data statistics request for the business data of the target dimension, acquiring one or more statistical results of the business data of the target dimension from the second data table; A final statistical result of the business data of the target dimension is determined according to one or more statistical results of the business data of the target dimension.
3. The method according to claim 2, characterized in that The method further comprises: acquiring the data status of the business data of the target dimension in the second data table and the data status of the business data of the target dimension in the first data table according to a fourth timing cycle; If the data state of the business data of the target dimension in the second data table changes within the single fourth timing period, and the data state of the business data of the target dimension in the first data table does not change, then the data state of the business data of the target dimension in the first data table is synchronously updated, or, If the data state of the business data of the target dimension in the first data table changes within the single fourth timing period, and the data state of the business data of the target dimension in the second data table does not change, the data state of the business data of the target dimension in the second data table is synchronously updated.
4. The method according to claim 2, characterized in that: The amount of business data of the target dimension is less than a preset amount, or the query frequency of the business data of the target dimension is higher than a preset frequency.
5. The method according to claim 1, characterized in that: The multiple statistical results of the business data of any dimension include: the statistical results of the business data of any dimension in each of the first timing periods; Determining the final statistical result of the business data of any dimension according to the one or more statistical results includes: The sum of the statistical results of the business data of any dimension in each of the first timing periods is determined as the final statistical result of the business data of any dimension.
6. The method according to claim 1, characterized in that For the service data in a single first timing period, statistics are performed on the service data in various dimensions to obtain statistical results of the service data in various dimensions, including: For each piece of business data in a single first timing period, the dimension to which the business data belongs is determined, and 1 is added to the statistical result of the business data of the dimension, wherein the initial value of the statistical result of the business data of each dimension is 0.
7. A data statistics device, characterized in that: The device comprises: A timing statistics module, used for periodically acquiring the service data of the target service according to a first timing period, and for the service data in a single first timing period, performing statistics on the service data in various dimensions to obtain statistical results of the service data in various dimensions; A first data storage module, used to store the statistical results of the business data of each dimension in a first data table; a statistical result acquisition module, configured to, in response to a data statistical request for business data of any dimension, acquire one or more statistical results of the business data of any dimension from the first data table, wherein the data statistical request may carry a statistical time period and a statistical dimension; A final statistical result determination module, used to determine the final statistical result of the business data of any dimension according to the one or more statistical results; acquiring target service data from the first data table according to a third timing cycle; wherein the data state corresponding to the target service data is the target state; For a single target service data in each of the third timing periods, if the third data table does not contain the target service data, the target service data is stored in the third data table.
8. An electronic device, characterized in that: include: A processor, wherein the processor is used to execute a computer program stored in a memory, wherein the computer program, when executed by the processor, implements the steps of the method described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Data statistics method and related device
CN109840262A