Real-time data statistical method, device, electronic device and storage medium

By storing real-time data in different fields in stages and performing formula calculations in big data scenarios, the problem of inaccurate data statistics is solved, and timely response and accurate statistics are achieved when data requests are received.

CN115827721BActive Publication Date: 2025-09-12SENSOR NETWORKS TECH BEIJING CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211259722.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-14
Publication Date
2025-09-12
Estimated Expiration
2042-10-14

AI Technical Summary

Technical Problem

In the big data scenario, in the existing technology, new real-time data is generated during the data statistics request process, resulting in the inability to count the newly generated data during the statistics process, resulting in inaccurate data statistics.

Method used

By monitoring real-time data on the target date and storing it in different fields, real-time data on the target date, the day before the target date, N days before the target date, and the first day of the N days before the target date are stored respectively. The data in these fields are used to perform formula calculations to count the real-time data within (N+1) consecutive days including the target date.

Benefits of technology

It solves the problem of inaccurate data statistics, ensures timely response when receiving data requests, and avoids statistical inaccuracies caused by new real-time data generated during the processing of data statistics requests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115827721B_ABST
    Figure CN115827721B_ABST
Patent Text Reader

Abstract

The present application relates to the field of big data and discloses a method, device, electronic device, and storage medium for real-time data statistics. The method comprises: storing real-time data generated on a target date in a first field; obtaining data stored in a second field, data stored in a third field, and data stored in a fourth field; the second field is used to store real-time data generated on the first date; the third field is used to store real-time data generated within N consecutive days before the first date; the fourth field is used to store real-time data generated on the first day of the N consecutive days before the first date; the first date is the date corresponding to the day before the target date; and based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, statistics are performed on real-time data within (N+1) consecutive days including the target date. The present application can ensure the accuracy of real-time data statistics.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of big data technology, and more specifically, to a statistical method, device, electronic device and storage medium for real-time data. Background Art

[0002] In related technologies, in big data scenarios, after receiving a data statistics request, new real-time data is still being generated during the statistics based on the data statistics request. This will cause the newly generated data in the statistics process to not be counted, resulting in inaccurate data statistics. Summary of the Invention

[0003] In view of the above problems, the embodiments of the present application propose a real-time data statistics method, device, electronic device and storage medium to solve the problem of inaccurate data statistics in related technologies.

[0004] According to one aspect of an embodiment of the present application, a method for counting real-time data is provided, including: if real-time data is monitored on a target date, storing the monitored real-time data in a first field; obtaining data stored in a second field, data stored in a third field, and data stored in a fourth field; wherein the second field is used to store real-time data generated on a first date; the third field is used to store real-time data generated within N consecutive days before the first date; the fourth field is used to store real-time data generated on the first day of N consecutive days before the first date; the first date refers to the date corresponding to the day before the target date; N is a positive integer; based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, counting real-time data within (N+1) consecutive days including the target date.

[0005] In some embodiments, counting real-time data for consecutive (N+1) days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field includes:

[0006] Use the following formula to obtain real-time data within (N+1) days, including the target date:

[0007] K=K1+K2+K3-K4;

[0008] Among them, K is the real-time data within (N+1) consecutive days including the target date; K1 is the data stored in the first field; K2 is the data stored in the second field; K3 is the data stored in the third field; K4 is the data stored in the fourth field.

[0009] In some embodiments, before counting the real-time data for consecutive (N+1) days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, the method further includes:

[0010] The real-time data generated within N consecutive days before the first date is stored in the third field, and the real-time data generated on the first day of the N consecutive days before the first date is stored in the fourth field;

[0011] The real-time data monitored on the first date is stored in the second field.

[0012] In some embodiments, if the real-time data generated is monitored on the target date, before storing the monitored real-time data in the first field, the method further includes:

[0013] Acquire real-time data statistics configuration information, where the real-time data statistics configuration information indicates a statistics period;

[0014] The date corresponding to the last day of the current statistical period is used as the target date, and the total number of days corresponding to the statistical period is used as N+1.

[0015] In some embodiments, before counting the real-time data for consecutive (N+1) days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, the method further includes:

[0016] If the real-time data generated on the first day of the N consecutive days before the first date is not obtained, the real-time data generated on the first day of the N consecutive days before the first date is set to empty.

[0017] In some embodiments, after counting the real-time data for (N+1) consecutive days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, the method further includes:

[0018] If the current time reaches the end time of the target date, the date corresponding to the last day of the next statistical cycle will be used as the new target date.

[0019] In some embodiments, after counting the real-time data for (N+1) consecutive days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, the method further includes:

[0020] Perform batch calculations on real-time data within (N+1) consecutive days including the target date.

[0021] According to one aspect of an embodiment of the present application, a real-time data statistics device is provided, comprising:

[0022] A first storage module is configured to store the monitored real-time data in a first field if the real-time data is monitored on a target date;

[0023] The acquisition module is used to acquire data stored in the second field, the data stored in the third field, and the data stored in the fourth field; wherein the second field is used to store real-time data generated on a first date; the third field is used to store real-time data generated within N consecutive days before the first date; and the fourth field is used to store real-time data generated on the first day of the N consecutive days before the first date; the first date is the date corresponding to the day before the target date; and N is a positive integer;

[0024] The statistics module is used to count the real-time data within (N+1) consecutive days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field and the data stored in the fourth field.

[0025] According to one aspect of an embodiment of the present application, an electronic device is provided, including: a processor; a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the real-time data statistical method as described above is implemented.

[0026] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the real-time data statistics method as described above is implemented.

[0027] According to one aspect of an embodiment of the present application, a computer program product is provided, which includes computer instructions, and when the computer instructions are executed by a processor, the above-mentioned real-time data statistical method is implemented.

[0028] In the solution of the present application, in order to obtain real-time data within (N+1) consecutive days including the target date, the real-time data is classified and stored in stages, and the data before the target date is pre-stored in the second field, the third field, and the fourth field. That is, the real-time data generated on the first date (i.e., the day before the target date) is stored in the second field, the real-time data generated within N consecutive days before the first date is stored in the third field; and the real-time data generated on the first day of the N consecutive days before the first date is stored in the fourth field. The real-time data generated on the target date is stored in the first field. After that, the real-time data for the (N+1) consecutive days including the target date can be counted based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field.

[0029] In this way, if a data statistics request is received at any time during the target date, the required real-time data can be obtained in units of fields, and the real-time data for consecutive (N+1) days including the target date can be obtained statistically.

[0030] Since the data generated on the target date is stored in the first field, all data generated on the same day are stored in the first field. When performing data statistics, as long as real-time data on the target date is needed, the data stored in the first field can be directly read, without the need to use the time when the data statistics request is obtained as the dividing point to divide the real-time data generated on the target date. This can solve the problem of inaccurate data statistics caused by the generation of new real-time data in the process of processing data statistics requests in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] The accompanying drawings are incorporated into 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 those skilled in the art can derive other drawings based on these drawings without inventive effort.

[0032] Figure 1 It is a schematic diagram of an application scenario of the present application according to an embodiment of the present application.

[0033] Figure 2 The figure is a flowchart of a real-time data statistics method according to an embodiment of the present application.

[0034] Figure 3 yes Figure 2 The steps before step 210 in the corresponding embodiment are shown in the flowchart of an embodiment.

[0035] Figure 4 FIG. 4 is a block diagram of a real-time data statistics device according to an embodiment of the present application.

[0036] Figure 5 A schematic structural diagram of an electronic device suitable for implementing the embodiments of the present application is shown. DETAILED DESCRIPTION

[0037] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many 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 thorough and complete and will fully convey the concepts of the example embodiments to those skilled in the art.

[0038] 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 so as to provide a full understanding of the embodiments of the present application. However, it will be appreciated by those skilled in the art 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, implementations or operations are not shown or described in detail to avoid blurring the various aspects of the application.

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

[0040] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.

[0041] It should be noted that the term "plurality" used in this document refers to two or more. "And / or" describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A alone, A and B together, or B alone. The character " / " generally indicates an "or" relationship between the associated objects.

[0042] In related technologies, in big data scenarios, after receiving a data statistics request, new real-time data is still being generated during the statistics based on the data statistics request. This will cause the newly generated data in the statistics process to not be counted, resulting in inaccurate data statistics.

[0043] Specifically, since data statistics are performed based on the timestamp carried by the real-time data only after receiving the data statistics request, and it takes a certain amount of time to perform data statistics, especially when the amount of real-time data to be counted is large, in the relevant technology, if at time A on a certain day, a data statistics request is received indicating that the real-time data generated within a continuous week including the current day should be counted, since during the data statistics process, the data platform also receives newly generated real-time data in real time, usually, time A is used as the dividing point, and for the current day, the real-time data generated before time A and the data generated within 6 days before the current day are counted, and then the two parts of data are superimposed to obtain statistical data. Assuming that the time when the statistical data is obtained is time B, it can be seen from the above process that the real-time data received by the data platform from time A to time B has not been counted, resulting in inaccurate real-time data being counted.

[0044] Figure 1 is a schematic diagram of an application scenario of the present application according to an embodiment of the present application, such as Figure 1 As shown, the application scenario includes multiple first devices 110 and a big data platform 120, and each first device 110 is connected to the big data platform via a wired or wireless network.

[0045] The first device 110 may be any electronic device such as a smartphone, tablet computer, laptop computer, desktop computer, vehicle-mounted device, or service terminal. The real-time data generated by the first device may include operational behavior data generated by a user triggering a control in an interactive interface displayed by the first device, image, video, voice, and other data collected in real time by the first device, feedback data from advertisements delivered to the first device, and log information generated by the first device (e.g., user operation date, device security detection log, device update log, etc.).

[0046] It is understandable that in the specific implementation of this application, related data such as user information (such as operation behavior data, user portrait data) is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0047] In the Internet of Things scenario, the first device 110 can also be an Internet of Things device, such as a CNC machine tool, a CNC grinder, a CNC milling machine, various sensors (such as temperature sensors, humidity sensors, speed sensors, etc.), detection equipment, etc. In this case, the real-time data generated by the first device can be the working data of the Internet of Things device (such as data used to indicate the working status), and the sensor data collected by the sensor, etc.

[0048] The big data platform 120 can be a server cluster composed of one or more servers, or a cloud server, and is not specifically limited here. The big data platform 120 can obtain real-time data generated by the first device 110 in real time and process the real-time data generated by the first device 110, such as filtering, performing statistics on the real-time data according to the methods provided in this application, and performing batch calculations on the statistically analyzed real-time data, and is not specifically limited here.

[0049] In some embodiments, after receiving the real-time data generated by the first device 110, the big data platform 120 can store the received real-time data in an offline storage device, so that in a subsequent process, the real-time data generated on different dates can be obtained from the offline storage device and statistics can be performed, and then batch calculations can be performed on the real-time data generated within at least two days obtained by statistics.

[0050] The following is a detailed description of the implementation details of the technical solution of the embodiment of the present application:

[0051] Figure 2 is a flow chart of a real-time data statistics method according to an embodiment of the present application. The method can be executed by an electronic device with processing capabilities, which can be Figure 1 It is executed on a computing node in the big data platform, and is not specifically limited here. Figure 2 As shown, the method includes at least steps 210 to 230, which are described in detail as follows:

[0052] Step 210: If real-time data is monitored during the target date, the monitored real-time data is stored in the first field.

[0053] In this application, the real-time data statistics performed are real-time data generated within at least two days. In other words, it is real-time data across dates. More specifically, the real-time data statistics performed are real-time data generated within at least two consecutive days. The target date refers to the end date of data generation in a real-time data statistics process. For example, if it is necessary to count the real-time data generated during the period from August 15, 2022 to August 25, 2022, August 25, 2022 will be used as the target date. For another example, if it is necessary to count the real-time data generated in the last week, and the dates corresponding to the last week are from October 3, 2022 to October 9, 2022, October 9, 2022 will be used as the target date.

[0054] In some embodiments, the electronic device may perform real-time data statistics in response to a received data statistics request. The data statistics request may indicate a cutoff date for the generation of the real-time data to be counted, i.e., a target date. Furthermore, as described above, the real-time data statistics performed in this application are real-time data generated within at least two consecutive days. The data statistics request may also indicate a target number of days, which refers to the number of consecutive days of real-time data to be counted.

[0055] It can also be understood that the statistics of real-time data performed in this application are to count the number of consecutive days as the target number of days, and the real-time data generated during the time period of the target date as the target date. Continuing with the above example, if it is necessary to count the real-time data generated during the period from August 15, 2022 to August 25, 2022, the corresponding target number of days is 11. In this application, the target number of days is N+1 below, where N is a positive integer. In a specific embodiment, the target number of days can be specified according to actual needs and is not specifically limited here.

[0056] The first field is used to store real-time data generated on the target date. In step 210, the first field is pre-configured for the target date. Subsequently, on the target date, the acquired real-time data is determined based on the timestamp carried by the real-time data to determine whether it is real-time data generated on the target date. If so, the real-time data is stored in the first field.

[0057] In some embodiments, a message middleware can be set up between the generator of real-time data (e.g., the first device described above) and the electronic device. Then, based on the publish-subscribe model of the message middleware, the electronic device acts as the subscriber of the real-time data, and the message middleware can publish the real-time data generated by the real-time data generator to the electronic device in real time. Thus, in step 210, the real-time data monitored is the real-time data subscribed by the electronic device.

[0058] Step 220, obtain the data stored in the second field, the data stored in the third field, and the data stored in the fourth field; wherein the second field is used to store real-time data generated on a first date; the third field is used to store real-time data generated within N consecutive days before the first date; the fourth field is used to store real-time data generated on the first day of the N consecutive days before the first date; the first date refers to the date corresponding to the day before the target date; and N is a positive integer.

[0059] In this application, for ease of distinction, the field used to store real-time data generated on the first date is called the second field, the field used to store real-time data generated within N days before the first date is called the third field, and the field used to store real-time data generated on the first day of the N days before the first date is called the fourth field.

[0060] An example is now used to illustrate the real-time data stored in the second field, the third field, and the fourth field: assuming that the real-time data currently to be counted is the real-time data generated between August 15, 2022 and August 25, 2022, then August 25, 2022 is the target date, the target number of days is N+1=11, and correspondingly, N is equal to 10; the first date is August 24, 2022; the time period indicated by N days before the first date is August 14, 2022 to August 23, 2022; the first day of the N days before the first date refers to the first day of the N days before the first date in chronological order. In this example, the first day of the N days before the first date is August 14, 2022.

[0061] Therefore, in this example, the real-time data stored in the second field is the real-time data generated on August 24, 2022; the real-time data stored in the third field is the real-time data generated in the time period from August 14, 2022 to August 23, 2022; the real-time data stored in the fourth field is the real-time data generated on August 14, 2022.

[0062] In some embodiments, before step 220, the method further includes: storing the real-time data generated within N consecutive days before the first date in the third field, and storing the real-time data generated on the first day of the N consecutive days before the first date in the fourth field; and storing the real-time data monitored on the first date in the second field.

[0063] That is, before the target date, real-time data prior to the target date is prepared. Specifically, data monitoring is performed on the first date, and real-time data generated on the first date is stored in the second field. From the stored real-time data, based on the timestamp carried by the real-time data, real-time data generated within N days prior to the first date is determined and stored in the third field. Real-time data generated on the first day of the N days prior to the first date is determined and stored in the fourth field.

[0064] In this way, since the real-time data that may be needed for real-time data statistics is prepared before the target date, if a data request is received at any time on the target date, the data stored in the second field, the third field and the fourth field can be directly read without classifying and summarizing the data before the target date after receiving the data request, thereby ensuring timely response to the data request.

[0065] Step 230 , based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, statistics are collected for the real-time data within (N+1) consecutive days including the target date.

[0066] Among them, the real-time data within (N+1) days including the target date refers to the real-time data generated within the past (N+1) consecutive days including the target date. It can also be understood that it refers to the real-time data generated during the first time period, wherein the first time period refers to the time period of (N+1) consecutive days from the second date to the target date. It can be understood that based on the target date and N, the second date can be determined accordingly, that is, the second date = target date - N. For example, if the target date is August 15, 2022, and N is 10, then the second date is August 5, 2022. Correspondingly, the first time period refers to the time period from August 5, 2022 to August 15, 2022.

[0067] In a specific embodiment, step 230 includes obtaining real-time data within (N+1) days including the target date according to the following formula:

[0068] K=K1+K2+K3-K4;

[0069] Among them, K is the real-time data within (N+1) consecutive days including the target date; K1 is the data stored in the first field; K2 is the data stored in the second field; K3 is the data stored in the third field; K4 is the data stored in the fourth field.

[0070] It is understood that the real-time data generated within N consecutive days prior to a first date includes the real-time data generated within the first of the N consecutive days prior to the first date. In other words, the data stored in the fourth field is actually also stored in the third field. Therefore, by subtracting the data stored in the fourth field from the data stored in the third field, the real-time data generated during the second time period can be obtained. The second time period refers to the period from the second day to the Nth day of the N consecutive days prior to the first date. It is understood that the Nth day of the N consecutive days prior to the first date is the day before the first date. For example, if the first date is September 10, 2022, and N is 10, then the second time period is September 1, 2022, to September 9, 2022.

[0071] In some embodiments, step 230 includes: in response to the received calculation request, based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, counting the real-time data within (N+1) consecutive days including the target date.

[0072] That is, after receiving a calculation request, the real-time data for the consecutive (N+1) days including the target date is counted according to the calculation request; thereafter, batch calculation (also known as batch calculation) can be performed on the real-time data for the consecutive (N+1) days including the target date. Of course, if no calculation request is received, step 230 is not executed.

[0073] In the solution of the present application, in order to obtain real-time data within (N+1) consecutive days including the target date, the real-time data is classified and stored in stages, and the data before the target date is pre-stored in the second field, the third field, and the fourth field. That is, the real-time data generated on the first date (i.e., the day before the target date) is stored in the second field, the real-time data generated within N consecutive days before the first date is stored in the third field; and the real-time data generated on the first day of the N consecutive days before the first date is stored in the fourth field. The real-time data generated on the target date is stored in the first field. After that, the real-time data for the (N+1) consecutive days including the target date can be counted based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field.

[0074] In this way, if a data statistics request is received at any time during the target date, the required real-time data can be obtained in units of fields, and the real-time data for consecutive (N+1) days including the target date can be obtained statistically.

[0075] Since the data generated on the target date is stored in the first field, all data generated on the same day are stored in the first field. When performing data statistics, as long as real-time data on the target date is needed, the data stored in the first field can be directly read, without the need to use the time when the data statistics request is obtained as the dividing point to divide the real-time data generated on the target date. This can solve the problem of inaccurate data statistics caused by the generation of new real-time data in the process of processing data statistics requests in the prior art.

[0076] In addition, in the present application, since the real-time data generated on the target date is stored in the first field, and the real-time data generated on the day before the target date (i.e., the first date) is stored in the second field, it is equivalent to classifying and summarizing the real-time data in two stages, namely, the first stage: on the first date, the real-time data generated on the first date is monitored in real time and stored in the second field, and the real-time data generated within N consecutive days before the first date is stored in the third field, and the real-time data generated on the first of the N consecutive days before the first date is stored in the fourth field; the second stage: on the target date, the real-time data generated on the target date is monitored in real time and stored in the first field. By classifying and summarizing the real-time data in two stages, it is ensured that when the time reaches the start time of the target date, all the real-time data before the target date has been classified and summarized. In this way, there is no need to count the real-time data generated before the target date on the target date, that is, there is no need to store the corresponding real-time data in the second field, the third field, and the fourth field on the target date. Therefore, when a data statistics request is received at any time on the target date, the real-time data stored in the second field, the third field, and the fourth field can be directly used, thereby ensuring the response speed to the data statistics request.

[0077] In some embodiments, before step 210, Figure 3 As shown, the method further includes:

[0078] Step 310: Acquire real-time data statistics configuration information, where the real-time data statistics configuration information indicates a statistics period.

[0079] Step 320: The date corresponding to the last day of the current statistical period is used as the target date, and the total number of days corresponding to the statistical period is used as N+1.

[0080] In a specific embodiment, the real-time data statistical configuration information can be determined according to the generation cycle of the real-time data targeted by the batch calculation. Specifically, the generation cycle of the real-time data targeted by the batch calculation is used as the statistical cycle. For example, if a batch calculation is specified to calculate real-time data generated within a month, the generation cycle of the real-time data targeted by the batch calculation is one month. Thereafter, one month can be used as the statistical cycle indicated by the real-time statistical configuration information. Thereafter, in different statistical cycles, the last day of each statistical cycle is used as the target date, and the total number of days corresponding to the statistical cycle is used as N+1, and the value of N can be determined accordingly.

[0081] Since the generation period of the real-time data targeted by the batch calculation is used as the statistical period, it is ensured that the data counted according to the method of the present application can be directly applied to the batch calculation, thereby improving the efficiency of the batch calculation.

[0082] In some embodiments, before step 230, the method further includes: if the real-time data generated on the first day of the N consecutive days before the first date is not obtained, setting the real-time data generated on the first day of the N consecutive days before the first date to empty.

[0083] In some application scenarios, for example, real-time data statistics need to be collected based on a specified statistical period, such as a monthly or weekly statistical period. When statistical periods are crossed, real-time data generated in the previous statistical period may be discarded. Therefore, if real-time data generated on a particular day or days in the previous statistical period is needed during the collection of real-time data within the current statistical period, the corresponding real-time data generated on that day or days in the previous statistical period cannot be obtained because the real-time data generated in the previous statistical period has been discarded. In this case, the real-time data in the previous statistical period that cannot be obtained can be set to null.

[0084] Therefore, when the total number of days corresponding to the statistical period is taken as N+1, the first day of the N consecutive days before the first date is in the previous statistical period, not the current statistical period. In this case, it may be impossible to obtain the real-time data generated on the first day of the N consecutive days before the first date. In this case, the real-time data generated on the first day of the N consecutive days before the first date is set to empty. Correspondingly, the real-time data generated on the first day of the N consecutive days before the first date represented in the third field and the fourth field is empty. This ensures that the real-time data within the continuous (N+1) days including the target date can be determined according to the method provided in this application.

[0085] Of course, in other embodiments, even in different statistical periods, if the real-time data generated in the previous statistical period is not discarded in the current statistical period, then the real-time data generated on the first day of N consecutive days before the first date can be stored in the fourth field and the third field.

[0086] In some embodiments, after step 230, the method further includes: if the current time reaches the end of the target date, setting the date corresponding to the last day of the next statistical period as the new target date. Thereafter, real-time data statistics are performed for the next statistical period according to steps 210-230 above.

[0087] The solution of this application is now described in detail with reference to three specific embodiments. Specific embodiment 1

[0089] Assume that you want to count the real-time data generated within 30 consecutive days before August 31, 2022. Correspondingly, the target date is August 31, 2022, N+1=30, and the first date is August 30, 2022.

[0090] On August 30, 2022, three fields are obtained for August 30, 2022: today_current, today_middle, and today_first. The today_current field is used to store real-time data generated on August 30, 2022; the today_middle field is used to store real-time data generated within 29 consecutive days before August 30, 2022 (i.e., real-time data generated between August 1, 2022 and August 29, 2022); and the today_first field is used to store real-time data generated on the first of the 29 consecutive days before August 30, 2022 (i.e., real-time data generated on August 1, 2022).

[0091] On August 30, 2022, the real-time data generated on that day is monitored and stored in the today_current field.

[0092] When the time crosses August 30, 2022, and is at the starting moment of August 31, 2022, the today_current, today_middle, and today_first set for August 30, 2022 will be adjusted to yesterday_current, yesterday_middle, and yesterday_first respectively; and the today_current field will be set accordingly for August 31, 2022, among which the today_current field set for August 31, 2022 is used to store the real-time data generated on August 31, 2022.

[0093] In this embodiment, the today_current field set for August 31, 2022 is equivalent to the first field above; the yesterday_current field is equivalent to the second field above; the yesterday_middle field is equivalent to the third field above; and the yesterday_first field is equivalent to the fourth field above.

[0094] If a calculation request is received at any time on August 31, 2022, the real-time data K generated within 30 consecutive days with August 31, 2022 as the deadline can be obtained according to the following formula:

[0095] K(2022-8-31,30)=K1(today_current)+K2(yesterday_current)+K3(yesterday_middle)-K4(yesterday_first);

[0096] Among them, K1 (today_current) represents the real-time data stored in the today_current field set on August 31, 2022; K2 (yesterday_current) represents all real-time data stored in the yesterday_current field; K3 (yesterday_middle) represents all real-time data stored in the yesterday_middle field; K4 (yesterday_first) represents all real-time data stored in the yesterday_first field.

[0097] After that, the real-time data generated within 30 consecutive days with August 31, 2022 as the deadline will be used for batch calculations. Specific embodiment 2

[0099] Suppose we want to count real-time data generated during the second week of September 2022. The second week of September 2022 corresponds to the time period from September 5, 2022, to September 11, 2022. In this case, September 11, 2022, is the target date, N+1=7, and the first date is September 10, 2022.

[0100] On September 10, 2022, three fields are obtained for September 10, 2022: today_current, today_middle, and today_first. The today_current field is used to store real-time data generated on September 10, 2022; the today_middle field is used to store real-time data generated within the six consecutive days before September 10, 2022 (i.e., real-time data generated between September 4, 2022 and September 9, 2022); and the today_first field is used to store real-time data generated on the first of the six consecutive days before September 10, 2022 (i.e., real-time data generated on September 4, 2022).

[0101] On September 10, 2022, the real-time data generated on that day is monitored and stored in the today_current field.

[0102] When the time crosses September 10, 2022, and is at the starting moment of September 11, 2022, the today_current, today_middle, and today_first set for September 10, 2022 will be adjusted to yesterday_current, yesterday_middle, and yesterday_first respectively; and the today_current field will be set correspondingly for September 11, 2022, among which the today_current field set for September 11, 2022 is used to store the real-time data generated on September 11, 2022.

[0103] In this embodiment, the today_current field set for September 11, 2022 is equivalent to the first field above; the yesterday_current field is equivalent to the second field above; the yesterday_middle field is equivalent to the third field above; and the yesterday_first field is equivalent to the fourth field above.

[0104] In the present embodiment, since September 4, 2022 is not located in the second week of September 2022 (i.e., within the time period from September 5, 2022 to September 11, 2022), the real-time data generated on September 4, 2022 can also be set to null. Correspondingly, the yesterday_first field corresponds to null, and the real-time data generated on September 4, 2022 in the yesterday_middle field corresponds to null. In this way, it is avoided that the real-time data outside this week is included in the real-time data statistics of this week, and the data processing capacity is increased. Moreover, in some scenarios, when crossing weeks, the real-time data of the previous week is discarded, and the real-time data is re-recorded in the new week. Thus, in this case, if the real-time data of the previous week needs to be introduced for statistical purposes, the real-time data of the previous week is set to null.

[0105] If a calculation request is received at any time on September 11, 2022, indicating that the real-time data within the week ending on September 11, 2022 will be calculated, the real-time data generated within the week ending on September 11, 2022, can be obtained using the following formula: K(2022-9-11,7):

[0106] K(2022-9-11,7)=K1(today_current)+K2(yesterday_current)+K3(yesterday_middle)-K4(yesterday_first);

[0107] In this embodiment, K1 (today_current) represents the real-time data stored in the today_current field set on September 11, 2022; K2 (yesterday_current) represents all real-time data stored in the yesterday_current field; K3 (yesterday_middle) represents all real-time data stored in the yesterday_middle field; K4 (yesterday_first) represents all real-time data stored in the yesterday_first field.

[0108] After that, the real-time data generated within a consecutive week with September 11, 2022 as the deadline will be used for batch calculations. Specific embodiment three

[0110] Assume that we want to count the real-time data generated in August. The corresponding target date is August 31, 2022, N+1=31, and the first date is August 30, 2022.

[0111] On August 30, 2022, three fields are obtained for August 30, 2022: today_current, today_middle, and today_first. The today_current field is used to store real-time data generated on August 30, 2022; the today_middle field is used to store real-time data generated within the 30 consecutive days before August 30, 2022 (that is, real-time data generated between July 31, 2022 and August 29, 2022); and the today_first field is used to store real-time data generated on the first of the 30 consecutive days before August 30, 2022 (that is, real-time data generated on July 31, 2022).

[0112] On August 30, 2022, the real-time data generated on that day is monitored and stored in the today_current field.

[0113] When the time crosses August 30, 2022, and is at the starting moment of August 31, 2022, the today_current, today_middle, and today_first set for August 30, 2022 will be adjusted to yesterday_current, yesterday_middle, and yesterday_first respectively; and the today_current field will be set accordingly for August 31, 2022, among which the today_current field set for August 31, 2022 is used to store the real-time data generated on August 31, 2022.

[0114] In this embodiment, the today_current field set for August 31, 2022 is equivalent to the first field above; the yesterday_current field is equivalent to the second field above; the yesterday_middle field is equivalent to the third field above; and the yesterday_first field is equivalent to the fourth field above.

[0115] In this embodiment, since July 31, 2022 is not in August 2022, the data for July 2022 may have been discarded during the data statistics stage for August. In this case, the real-time data generated on July 31, 2022 can be set to empty. Correspondingly, the yesterday_first field is empty, and the yesterday_middle field indicates that the real-time data generated on July 31, 2022 is empty. Therefore, the smooth progress of data statistics according to the method of this application can be guaranteed.

[0116] If a calculation request is received at any time on August 31, 2022, the real-time data K(8) generated within one month with August 31, 2022 as the deadline can be obtained according to the following formula:

[0117] K(8)=K1(today_current)+K2(yesterday_current)+K3(yesterday_middle)-K4(yesterday_first);

[0118] Among them, K1 (today_current) represents the real-time data stored in the today_current field set on August 31, 2022; K2 (yesterday_current) represents all real-time data stored in the yesterday_current field; K3 (yesterday_middle) represents all real-time data stored in the yesterday_middle field; K4 (yesterday_first) represents all real-time data stored in the yesterday_first field.

[0119] After that, the real-time data generated within one consecutive month with August 31, 2022 as the deadline will be used for batch calculations.

[0120] The following describes an embodiment of the device of the present application, which can be used to perform the method described in the above embodiment of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the above method embodiment of the present application.

[0121] Figure 4 This is a block diagram of a real-time data statistics device according to an embodiment of the present application. The real-time data statistics device can be configured in an electronic device to execute the real-time data statistics method provided by the present application. The electronic device can be a server, a cloud server, or a computing node in a big data platform. Figure 4 As shown, the real-time data statistics device includes:

[0122] The first storage module 410 is configured to store the monitored real-time data in a first field if the real-time data is monitored on the target date;

[0123] The acquisition module 420 is configured to acquire data stored in the second field, the third field, and the fourth field; wherein the second field is configured to store real-time data generated on a first date; the third field is configured to store real-time data generated within N consecutive days prior to the first date; and the fourth field is configured to store real-time data generated on the first day of the N consecutive days prior to the first date; the first date is the date corresponding to the day before the target date; and N is a positive integer.

[0124] The statistics module 430 is used to count the real-time data within (N+1) consecutive days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field and the data stored in the fourth field.

[0125] In some embodiments, the statistics module 430 is further configured to:

[0126] Use the following formula to obtain real-time data within (N+1) days, including the target date:

[0127] K=K1+K2+K3-K4;

[0128] Among them, K is the real-time data within (N+1) consecutive days including the target date; K1 is the data stored in the first field; K2 is the data stored in the second field; K3 is the data stored in the third field; K4 is the data stored in the fourth field.

[0129] In some embodiments, the real-time data statistics device also includes: a second storage module, used to store the real-time data generated within N consecutive days before the first date into the third field, and to store the real-time data generated on the first day of the N consecutive days before the first date into the fourth field; a third storage module, used to store the real-time data monitored on the first date into the second field.

[0130] In some embodiments, the real-time data statistics device also includes: a request acquisition module for obtaining real-time data statistics configuration information, wherein the real-time data statistics configuration information indicates a statistical period; a first determination module for taking the date corresponding to the last day of the current statistical period as the target date, and the total number of days corresponding to the statistical period as N+1.

[0131] In some embodiments, the real-time data statistics device also includes: a configuration module for setting the real-time data generated on the first day of N consecutive days before the first date to empty if the real-time data generated on the first day of N consecutive days before the first date is not obtained.

[0132] In some embodiments, the real-time data statistics device further includes: a second determination module configured to set the date corresponding to the last day of the next statistical cycle as the new target date if the current time reaches the end time of the target date.

[0133] In some embodiments, the statistical device for real-time data further includes: a batch calculation module for performing batch calculation on the real-time data within (N+1) consecutive days including the target date.

[0134] Figure 5 FIG1 is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. The electronic device can be used to execute the real-time data statistics method provided by the present application.

[0135] like Figure 5As shown, the electronic device may include: a processor 701, such as a CPU, a network interface 704, a user interface 703, a memory 705, and a communication bus 702. Among them, the communication bus 702 is used to realize the connection and communication between these components. The user interface 703 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and optionally, the user interface 703 may also include a standard wired interface and a wireless interface. The network interface 704 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 705 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 705 may optionally also be a storage device independent of the aforementioned processor 701.

[0136] Those skilled in the art will understand that Figure 5 The structure of the electronic device shown in the figure does not constitute a limitation of the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0137] like Figure 5 As shown, the memory 705 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a program for implementing a statistical method for real-time data.

[0138] exist Figure 5 In the electronic device shown, the network interface 704 is mainly used to communicate with other devices, such as Figure 1 The user interface 703 can be used to connect to a client (user end) and perform data communication with the client; and the processor 701 can be used to call a program for implementing a real-time data statistics method stored in the memory 705 and execute the steps of the real-time data statistics method in any of the above method embodiments.

[0139] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the real-time data statistical method in any of the above method embodiments is implemented.

[0140] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media can 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 can be any tangible medium containing or storing a program that can 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 can include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, or any suitable combination thereof.

[0141] According to one aspect of an embodiment of the present application, a computer program product is provided, which includes computer instructions, and when the computer instructions are executed by a processor, the real-time data statistics method in any of the above method embodiments is implemented.

[0142] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, program segment, or part of the code, and the above-mentioned module, program segment, or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that 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 flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

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

[0144] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments 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 embodiments of the present application.

[0145] Those skilled in the art will readily conceive of other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of this application and include common knowledge or customary techniques in the art that are not disclosed herein.

[0146] It should be understood that the present application is not limited to the exact structures 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 statistical method for real-time data, characterized in that: include: Acquire real-time data statistics configuration information, where the real-time data statistics configuration information indicates a statistics period; The date corresponding to the last day of the current statistical period is used as the target date, and the total number of days corresponding to the statistical period is used as N+1; If real-time data is monitored during the target date, the monitored real-time data is stored in the first field; Get the data stored in the second field, the data stored in the third field, and the data stored in the fourth field; the second field is used to store real-time data generated on a first date; the third field is used to store real-time data generated within N consecutive days before the first date; the fourth field is used to store real-time data generated on the first day of the N consecutive days before the first date; the first date is the date corresponding to the day before the target date; N is a positive integer; Real-time data within (N+1) consecutive days including the target date are counted based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field.

2. The method according to claim 1, characterized in that The method of counting real-time data within (N+1) consecutive days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field includes: Use the following formula to obtain real-time data within (N+1) days, including the target date: K=K1+K2+K3-K4; Among them, K is the real-time data within (N+1) consecutive days including the target date; K1 is the data stored in the first field; K2 is the data stored in the second field; K3 is the data stored in the third field; K4 is the data stored in the fourth field.

3. The method according to claim 1, characterized in that Before counting the real-time data for consecutive (N+1) days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, the method further includes: The real-time data generated within N consecutive days before the first date is stored in the third field, and the real-time data generated on the first day of the N consecutive days before the first date is stored in the fourth field; The real-time data monitored on the first date is stored in the second field.

4. The method according to claim 1, wherein Before counting the real-time data for consecutive (N+1) days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, the method further includes: If the real-time data generated on the first day of the N consecutive days before the first date is not obtained, the real-time data generated on the first day of the N consecutive days before the first date is set to empty.

5. The method according to claim 1, wherein After counting the real-time data for consecutive (N+1) days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, the method further includes: If the current time reaches the end time of the target date, the date corresponding to the last day of the next statistical cycle will be used as the new target date.

6. The method according to claim 1, characterized in that After counting the real-time data for consecutive (N+1) days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field, and the data stored in the fourth field, the method further includes: Perform batch calculations on real-time data within (N+1) consecutive days including the target date.

7. A real-time data statistics device, characterized in that: include: A request acquisition module is used to obtain real-time data statistics configuration information, where the real-time data statistics configuration information indicates a statistics period; A first determination module is configured to use the date corresponding to the last day of the current statistical period as the target date, and the total number of days corresponding to the statistical period as N+1; A first storage module is configured to store the monitored real-time data in a first field if the real-time data is monitored on a target date; The acquisition module is used to acquire data stored in the second field, the data stored in the third field, and the data stored in the fourth field; wherein the second field is used to store real-time data generated on a first date; the third field is used to store real-time data generated within N consecutive days before the first date; and the fourth field is used to store real-time data generated on the first day of the N consecutive days before the first date; the first date is the date corresponding to the day before the target date; and N is a positive integer; The statistics module is used to count the real-time data within (N+1) consecutive days including the target date based on the data stored in the first field, the data stored in the second field, the data stored in the third field and the data stored in the fourth field.

8. An electronic device, characterized in that: include: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium having computer-readable instructions stored thereon, characterized in that: When the computer-readable instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method, device, equipment and system for processing data and storage medium

    CN114416817A