CN113495908A - Data statistical method and device - Google Patents

Data statistical method and device Download PDF

Info

Publication number
CN113495908A
CN113495908A CN202010260455.2A CN202010260455A CN113495908A CN 113495908 A CN113495908 A CN 113495908A CN 202010260455 A CN202010260455 A CN 202010260455A CN 113495908 A CN113495908 A CN 113495908A
Authority
CN
China
Prior art keywords
time
data volume
grid
static
statistics
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010260455.2A
Other languages
Chinese (zh)
Other versions
CN113495908B (en
Inventor
韩金魁
姚华成
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN202010260455.2A priority Critical patent/CN113495908B/en
Publication of CN113495908A publication Critical patent/CN113495908A/en
Application granted granted Critical
Publication of CN113495908B publication Critical patent/CN113495908B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2462Approximate or statistical queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2477Temporal data queries

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Mathematical Physics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Fuzzy Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a data statistical method and device, and relates to the technical field of computers. One embodiment of the method comprises: receiving a data statistics request; wherein, the data statistics request includes: counting the termination time; determining a current time grid in a current time wheel corresponding to the counting termination time; determining a static moment according to the current time grid; the static time is the termination time of a target time interval, and the target time interval is a time interval before the current time interval; determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid; counting the data volume from the static moment to the termination moment; and calculating the data volume from the statistic starting time to the statistic ending time according to the data volume from the statistic starting time to the static time and the data volume from the static time to the statistic ending time. The embodiment can shorten the statistical time and improve the statistical efficiency.

Description

Data statistical method and device
Technical Field
The invention relates to the technical field of computers, in particular to a data statistical method and device.
Background
With the development of services and the lapse of time, the data volume in a service system can reach millions or even tens of millions, and how to perform fast and accurate statistics on the large amount of data becomes a problem to be solved urgently at present.
In the prior art, the data volume is counted through a preset asynchronous task, and the full data of a database needs to be traversed in the counting process. For example, the asynchronous task 1 is used for counting the order quantity of the point 1, the asynchronous task 2 is used for counting the order quantity of the point 2, and the corresponding statistical result can be obtained only by traversing the full data of the database in the process of executing the asynchronous task 1 and the asynchronous task 2.
In the prior art, the total data needs to be traversed, so that a long time is needed for obtaining the statistical result.
Disclosure of Invention
In view of this, embodiments of the present invention provide a data statistics method and apparatus, which can shorten statistics time and improve statistics efficiency.
In a first aspect, an embodiment of the present invention provides a data statistics method, including:
receiving a data statistics request; wherein, the data statistics request comprises: counting the termination time;
determining a current time grid in a current time wheel corresponding to the counting termination time;
determining a static moment according to the current time grid; the static time is the termination time of a target time grid, and the target time grid is a time grid before the current time grid;
determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid;
counting the data volume from the static time to the counting termination time;
and calculating the data volume from the statistics starting time to the statistics ending time according to the data volume from the statistics starting time to the static time and the data volume from the static time to the statistics ending time.
Alternatively,
further comprising:
determining the current time wheel; wherein the current time wheel comprises: a plurality of time bins;
adding a statistical task corresponding to the time grid into the time grid;
executing the statistical task to obtain the data volume corresponding to the time grid;
and storing the data volume corresponding to the time grid in the time grid.
Alternatively,
further comprising:
determining the execution time of the statistical task according to the time grid of the statistical task;
adding the statistical task and the execution time thereof into a preset delay queue;
and starting a timer to enable the timer to acquire the statistical task from the delay queue according to the execution time.
Alternatively,
the data volume corresponding to the time grid is the data volume from the starting time to the ending time of the time grid;
the determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid includes:
determining that the data volume from the statistical starting time to the static time is equal to the sum of the data volumes stored in the time cells corresponding to the statistical starting time to the static time; and the target time interval is the time interval corresponding to the static time from the counting starting time.
Alternatively,
the data volume corresponding to the time grid is the data volume from the starting time of the current time wheel to the ending time of the time grid;
the target time interval is a time interval before the current time interval;
the counting starting time is the starting time of the current time wheel;
the determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid includes:
and determining that the data volume from the statistic starting time to the static time is equal to the data volume stored in the target time interval.
Alternatively,
the data statistics request further comprises: counting scene identifications;
further comprising:
and determining a current time wheel corresponding to the statistic scene identification in a plurality of time wheels corresponding to the scene identification.
In a second aspect, an embodiment of the present invention provides a data statistics apparatus, including:
a receiving module configured to receive a data statistics request; wherein, the data statistics request comprises: counting the termination time;
the determining module is configured to determine a current time grid in a current time wheel corresponding to the counting termination time; determining a static moment according to the current time grid; the static time is the termination time of a target time grid, and the target time grid is a time grid before the current time grid; determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid;
the statistical module is configured to count the data volume from the static time to the statistical termination time; and calculating the data volume from the statistics starting time to the statistics ending time according to the data volume from the statistics starting time to the static time and the data volume from the static time to the statistics ending time.
Alternatively,
the determination module is configured to determine the current time wheel; wherein the current time wheel comprises: a plurality of time bins; adding a statistical task corresponding to the time grid into the time grid; executing the statistical task to obtain the data volume corresponding to the time grid; and storing the data volume corresponding to the time grid in the time grid.
Alternatively,
the determining module is configured to determine the execution time of the statistical task according to the time grid where the statistical task is located; adding the statistical task and the execution time thereof into a preset delay queue; and starting a timer to enable the timer to acquire the statistical task from the delay queue according to the execution time.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a method as in any one of the embodiments described above.
In a fourth aspect, the present invention provides a computer readable medium, on which a computer program is stored, and when the program is executed by a processor, the computer program implements the method according to any one of the above embodiments.
One embodiment of the above invention has the following advantages or benefits: the time grid of the time wheel stores the data volume from the statistical starting time to the static time, so that in the statistical process, only the data volume from the static time to the statistical ending time can be counted, the data volume from the statistical starting time to the static time can be directly obtained from the time wheel, the statistical time can be shortened, and the statistical efficiency can be improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a flow chart of a data statistics method provided by an embodiment of the invention;
FIG. 2 is a flow chart of a data statistics method provided by another embodiment of the present invention;
FIG. 3 is a schematic diagram of a data statistics apparatus according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 5 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
As shown in fig. 1, an embodiment of the present invention provides a data statistics method, including:
step 101: receiving a data statistics request; wherein, the data statistics request includes: and counting the termination time.
The data statistics request may be sent by a presentation device or other platform that needs to invoke the statistics. The data statistics request may further include a statistics start time, that is, the requestor specifies a statistics time period. And if the data counting request does not comprise the counting starting time, the counting starting time is the starting time of the time wheel. The statistical termination time may be the current time, a historical time before the current time, or a future time after the current time.
Step 102: and determining the current time grid in the current time wheel corresponding to the statistic termination time.
In the embodiment of the invention, the time wheel is a storage circular queue, the bottom layer is realized by adopting an array, and each element in the array can store a timing task list. The timing task list is a circular two-way linked list, each item in the linked list represents a timing task item, and the timing task item is packaged with a statistical task. The time wheel may include several time slots, for example, the time period corresponding to the time wheel is 00:00-24:00, including 12 time slots, and the time interval of each time slot is 2 hours, the time period corresponding to the first time slot is 00:00-02:00, the time period corresponding to the second time slot is 02:00-04:00, and so on. And if the counting termination time is 02:30, the current time cell is the second time cell.
The time period corresponding to the time wheel can also be 1 month, 1 year and other time intervals. If more data needs to be counted, the data amount can be stored by adopting a time slot with a smaller time period, and conversely, if less data needs to be counted, the data amount can be stored by adopting a time slot with a larger time period.
Step 103: determining a static moment according to the current time grid; the static time is the termination time of the target time interval, and the target time interval is the time interval before the current time interval.
Following the above example, if the current time bin is the second time bin, the target time bin may be the first time bin and the static time is 02: 00.
Step 104: and determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid.
The embodiment of the invention can determine the data volume from the starting time to the static time through the time wheel without inquiring a database to calculate the data volume corresponding to the time period.
Step 105: and counting the data volume from the static time to the counting termination time.
The data volume from the static time to the statistical termination time needs to be acquired by querying the database.
Step 106: and calculating the data volume from the statistic starting time to the statistic ending time according to the data volume from the statistic starting time to the static time and the data volume from the static time to the statistic ending time.
The data amount from the statistics start time to the statistics end time is the data amount from the statistics start time to the static time + the data amount from the static time to the statistics end time.
In the embodiment of the invention, the time grid of the time wheel stores the data volume from the statistical starting time to the static time, so that in the statistical process, only the data volume from the static time to the statistical ending time can be counted, and the data volume from the statistical starting time to the static time can be directly obtained from the time wheel, thereby shortening the statistical time and improving the statistical efficiency.
The data amount from the statistical start time to the statistical end time may also be sent to the requester after step 106, or the data amount from the statistical start time to the statistical end time is shown.
In one embodiment of the invention, the method further comprises:
determining a current time wheel; wherein, the current time wheel includes: a plurality of time bins;
adding a statistical task corresponding to the time grid into the time grid;
executing a statistical task to obtain a data volume corresponding to the time grid;
and storing the data volume corresponding to the time grid in the time grid.
The statistical task can count the data volume from the starting time of the target time frame to the ending time of the target time frame, and also can count the data volume from the starting time of the time wheel to the ending time of the target time frame.
In the embodiment of the invention, the data volume corresponding to the time grid can be obtained through the statistic task stored in the time grid, and the data volume stored in the time grid is obtained through statistics before the data statistic request is received, so that the data volume stored in the time grid can be directly used in the process of processing the data statistic request without traversing the full data in the database.
In one embodiment of the invention, the method further comprises:
determining the execution time of the statistical task according to the time grid of the statistical task;
adding the statistical task and the execution time thereof into a preset delay queue;
and starting a timer so that the timer acquires the statistical task from the delay queue according to the execution time.
According to the embodiment of the invention, the statistical task is accurately executed according to the corresponding execution time through the timer and the delay queue, so that the time for obtaining the final statistical result is shortened, and the statistical efficiency is improved.
In one embodiment of the present invention, the data size corresponding to the time grid is the data size from the starting time to the ending time of the time grid;
determining the data volume from the starting time to the static time according to the data volume stored in the target time grid, wherein the data volume comprises:
determining that the data volume from the statistical starting time to the static time is equal to the sum of the data volumes stored in the time cells corresponding to the statistical starting time to the static time; and the target time grid is a time grid corresponding to the static time from the statistical starting time.
In the embodiment of the present invention, the target time grid may be one or more. The data volumes from the starting time to the ending time of the time cells are stored in the time cells, if the statistical starting time to the static time correspond to a plurality of time cells, the data volumes stored in the time cells are added, the data volumes from the statistical starting time to the static time can be quickly obtained, and the data volumes from the statistical starting time to the static time do not need to be obtained by querying a database when a data statistical request is received.
In one embodiment of the invention, the data volume corresponding to the time grid is the data volume from the starting time of the current time wheel to the ending time of the time grid;
the target time interval is the time interval before the current time interval;
counting the starting time as the starting time of the current time wheel;
determining the data volume from the starting time to the static time according to the data volume stored in the target time grid, wherein the data volume comprises:
and determining that the data amount from the statistical starting time to the static time is equal to the data amount stored in the target time interval.
In the embodiment of the present invention, the data amount stored in the time grid may also be the data amount from the start time of the current time wheel to the end time of the time grid, and if the counting start time is the start time of the current time wheel, the data amount from the counting start time to the static time may be directly determined by the data amount stored in the target time wheel.
If the counting starting time is behind the starting time of the current time wheel and the counting starting time is the starting time of the time grid, determining that the data volume from the counting starting time to the static time is equal to the difference between the data volume stored in the target time grid and the data volume stored in the first time grid; the first time cell is a time cell before the time cell where the counting start time is located.
If the counting start time is after the start time of the current time wheel and the counting start time is not equal to the start time of the time cell, the data amount from the counting start time to the start time of the time cell in which the counting start time is located can be determined by querying the database.
The data amount from the statistical start time to the static time is the data amount stored in the target time slot, the data amount stored in the time slot in which the statistical start time is located, and the data amount from the statistical start time to the end time of the time slot in which the statistical start time is located.
In an embodiment of the present invention, the data statistics request further includes: counting scene identifications;
the method further comprises the following steps: and determining a current time wheel corresponding to the statistical scene identification in a plurality of time wheels corresponding to the scene identification.
In the embodiment of the present invention, time wheels corresponding to different scene identifiers may be determined to count data volumes in different scenes, for example, order taking amount may be counted, and order completion amount, registration amount, and the like may also be counted.
As shown in fig. 2, an embodiment of the present invention provides a data statistics method, including:
step 201: determining a current time wheel; wherein, the current time wheel includes: several time bins.
In an actual application scenario, time wheels corresponding to different scenario identifiers may be established, and the embodiment of the present invention is described by taking only one time wheel as an example.
The time span of the current time wheel is 1 day and comprises 12 time cells, the time span of each time cell is 2 hours, the first time cell is 00:00-02:00, the second time cell is 02:00-04:00 … …
Step 202: and adding a statistical task corresponding to the time grid into the time grid.
And the statistical task is used for counting the data volume in the time period corresponding to the time interval.
Step 203: and determining the execution time of the statistical task according to the time grid of the statistical task.
For example, the execution time of the statistical task in the first time bin is not earlier than 02: 00.
Step 204: and adding the statistical task and the execution time thereof into a preset delay queue.
Step 205: and starting a timer so that the timer acquires the statistical task from the delay queue according to the execution time.
Step 206: and executing a statistical task to obtain the data volume from the starting time to the ending time of the time grid.
Step 207: the data amount from the start time to the end time of the time grid is stored in the time grid.
Step 208: receiving a data statistics request sent by a requester; wherein, the data statistics request includes: the current time.
The current time is the statistic termination time, and the starting time of the time wheel is the statistic starting time.
The current time is 02:35,.
Step 209: and determining the current time grid in the current time wheel corresponding to the current time.
The current time is in the range of 02:00-04:00, and the corresponding current time cell is the second time cell.
Step 210: determining a static moment according to the current time grid; the static time is the termination time of the target time interval, and the target time interval is the time interval before the current time interval.
The target time bin is the first time bin.
Step 211: and determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid.
Step 212: and counting the data volume from the static moment to the current moment.
Step 213: and calculating the data volume from the statistical starting time to the current time according to the data volume from the statistical starting time to the static time and the data volume from the static time to the current time.
And the data volume from the counting starting time to the current time is the data volume from the counting starting time to the static time plus the data volume from the static time to the current time.
Step 214: and sending the data volume from the counting starting time to the current time to the requesting party.
The time grid of the time wheel stores the data volume from the statistical starting time to the static time, so that in the statistical process, only the data volume from the static time to the statistical ending time can be counted, the data volume from the statistical starting time to the static time can be directly obtained from the time wheel, the statistical time can be shortened, and the statistical efficiency can be improved.
As shown in fig. 3, an embodiment of the present invention provides a data statistics apparatus, including:
a receiving module 301 configured to receive a data statistics request; wherein, the data statistics request includes: counting the termination time;
a determining module 302 configured to determine a current time slot in the current time round corresponding to the termination time of the statistics; determining a static moment according to the current time grid; the static time is the termination time of a target time interval, and the target time interval is a time interval before the current time interval; determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid;
a statistic module 303 configured to count the data amount from the static time to the statistic termination time; and calculating the data volume from the statistic starting time to the statistic ending time according to the data volume from the statistic starting time to the static time and the data volume from the static time to the statistic ending time.
In one embodiment of the invention, the determining module 302 is configured to determine a current time round; wherein, the current time wheel includes: a plurality of time bins; adding a statistical task corresponding to the time grid into the time grid; executing a statistical task to obtain a data volume corresponding to the time grid; and storing the data volume corresponding to the time grid in the time grid.
In an embodiment of the present invention, the determining module 302 is configured to determine an execution time of the statistical task according to a time frame in which the statistical task is located; adding the statistical task and the execution time thereof into a preset delay queue; and starting a timer so that the timer acquires the statistical task from the delay queue according to the execution time.
In one embodiment of the present invention, the data size corresponding to the time grid is the data size from the starting time to the ending time of the time grid; a determining module 302 configured to determine that the data amount from the statistical start time to the static time is equal to the sum of the data amounts stored in the time bins corresponding to the statistical start time to the static time; and the target time grid is a time grid corresponding to the static time from the statistical starting time.
In one embodiment of the invention, the data volume corresponding to the time grid is the data volume from the starting time of the current time wheel to the ending time of the time grid;
the target time interval is the time interval before the current time interval;
counting the starting time as the starting time of the current time wheel;
a determining module 302 configured to determine that the amount of data from the statistical start time to the static time is equal to the amount of data stored in the target time bin.
In an embodiment of the present invention, the data statistics request further includes: counting scene identifications;
in one embodiment of the invention, a current time round corresponding to a statistical scene identity is determined among a number of time rounds corresponding to the scene identity.
An embodiment of the present invention provides an electronic device, including:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any of the embodiments described above.
Fig. 4 illustrates an exemplary system architecture 400 to which the data statistics method or data statistics apparatus of embodiments of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 401, 402, 403. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the data statistics method provided by the embodiment of the present invention is generally executed by the server 405, and accordingly, the data statistics apparatus is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, shown is a block diagram of a computer system 500 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, 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 appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a sending module, an obtaining module, a determining module, and a first processing module. The names of these modules do not form a limitation on the modules themselves in some cases, and for example, the sending module may also be described as a "module sending a picture acquisition request to a connected server".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise:
receiving a data statistics request; wherein, the data statistics request comprises: counting the termination time;
determining a current time grid in a current time wheel corresponding to the counting termination time;
determining a static moment according to the current time grid; the static time is the termination time of a target time grid, and the target time grid is a time grid before the current time grid;
determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid;
counting the data volume from the static time to the counting termination time;
and calculating the data volume from the statistics starting time to the statistics ending time according to the data volume from the statistics starting time to the static time and the data volume from the static time to the statistics ending time.
According to the technical scheme of the embodiment of the invention, the time grid of the time wheel stores the data volume from the statistic starting time to the static time, so that only the data volume from the static time to the statistic ending time can be counted in the counting process, the data volume from the statistic starting time to the static time can be directly obtained from the time wheel, the counting time can be shortened, and the counting efficiency is improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (11)

1. A method of data statistics, comprising:
receiving a data statistics request; wherein, the data statistics request comprises: counting the termination time;
determining a current time grid in a current time wheel corresponding to the counting termination time;
determining a static moment according to the current time grid; the static time is the termination time of a target time grid, and the target time grid is a time grid before the current time grid;
determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid;
counting the data volume from the static time to the counting termination time;
and calculating the data volume from the statistics starting time to the statistics ending time according to the data volume from the statistics starting time to the static time and the data volume from the static time to the statistics ending time.
2. The method of claim 1, further comprising:
determining the current time wheel; wherein the current time wheel comprises: a plurality of time bins;
adding a statistical task corresponding to the time grid into the time grid;
executing the statistical task to obtain the data volume corresponding to the time grid;
and storing the data volume corresponding to the time grid in the time grid.
3. The method of claim 2, further comprising:
determining the execution time of the statistical task according to the time grid of the statistical task;
adding the statistical task and the execution time thereof into a preset delay queue;
and starting a timer to enable the timer to acquire the statistical task from the delay queue according to the execution time.
4. The method of claim 2,
the data volume corresponding to the time grid is the data volume from the starting time to the ending time of the time grid;
the determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid includes:
determining that the data volume from the statistical starting time to the static time is equal to the sum of the data volumes stored in the time cells corresponding to the statistical starting time to the static time; and the target time interval is the time interval corresponding to the static time from the counting starting time.
5. The method of claim 2,
the data volume corresponding to the time grid is the data volume from the starting time of the current time wheel to the ending time of the time grid;
the target time interval is a time interval before the current time interval;
the counting starting time is the starting time of the current time wheel;
the determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid includes:
and determining that the data volume from the statistic starting time to the static time is equal to the data volume stored in the target time interval.
6. The method of any one of claims 1 to 5,
the data statistics request further comprises: counting scene identifications;
further comprising:
and determining a current time wheel corresponding to the statistic scene identification in a plurality of time wheels corresponding to the scene identification.
7. A data statistics apparatus, comprising:
a receiving module configured to receive a data statistics request; wherein, the data statistics request comprises: counting the termination time;
the determining module is configured to determine a current time grid in a current time wheel corresponding to the counting termination time; determining a static moment according to the current time grid; the static time is the termination time of a target time grid, and the target time grid is a time grid before the current time grid; determining the data volume from the starting time of statistics to the static time according to the data volume stored in the target time grid;
the statistical module is configured to count the data volume from the static time to the statistical termination time; and calculating the data volume from the statistics starting time to the statistics ending time according to the data volume from the statistics starting time to the static time and the data volume from the static time to the statistics ending time.
8. The apparatus of claim 7,
the determination module is configured to determine the current time wheel; wherein the current time wheel comprises: a plurality of time bins; adding a statistical task corresponding to the time grid into the time grid; executing the statistical task to obtain the data volume corresponding to the time grid; and storing the data volume corresponding to the time grid in the time grid.
9. The method of claim 8,
the determining module is configured to determine the execution time of the statistical task according to the time grid where the statistical task is located; adding the statistical task and the execution time thereof into a preset delay queue; and starting a timer to enable the timer to acquire the statistical task from the delay queue according to the execution time.
10. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
11. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN202010260455.2A 2020-04-03 2020-04-03 Data statistics method and device Active CN113495908B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010260455.2A CN113495908B (en) 2020-04-03 2020-04-03 Data statistics method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010260455.2A CN113495908B (en) 2020-04-03 2020-04-03 Data statistics method and device

Publications (2)

Publication Number Publication Date
CN113495908A true CN113495908A (en) 2021-10-12
CN113495908B CN113495908B (en) 2024-05-17

Family

ID=77995317

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010260455.2A Active CN113495908B (en) 2020-04-03 2020-04-03 Data statistics method and device

Country Status (1)

Country Link
CN (1) CN113495908B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107122355A (en) * 2016-02-24 2017-09-01 阿里巴巴集团控股有限公司 Data mover system and method
US20180278567A1 (en) * 2017-03-24 2018-09-27 International Business Machines Corporation Message queue manager
WO2018210062A1 (en) * 2017-05-18 2018-11-22 北京京东尚科信息技术有限公司 Method and device for determining inventory of items by server system
WO2019095213A1 (en) * 2017-11-16 2019-05-23 Oppo广东移动通信有限公司 Wireless communication method and terminal device
CN110297711A (en) * 2019-05-16 2019-10-01 平安科技(深圳)有限公司 Batch data processing method, device, computer equipment and storage medium
CN110704721A (en) * 2019-10-10 2020-01-17 秒针信息技术有限公司 Client data processing method and device, terminal equipment and readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107122355A (en) * 2016-02-24 2017-09-01 阿里巴巴集团控股有限公司 Data mover system and method
US20180278567A1 (en) * 2017-03-24 2018-09-27 International Business Machines Corporation Message queue manager
WO2018210062A1 (en) * 2017-05-18 2018-11-22 北京京东尚科信息技术有限公司 Method and device for determining inventory of items by server system
WO2019095213A1 (en) * 2017-11-16 2019-05-23 Oppo广东移动通信有限公司 Wireless communication method and terminal device
CN110297711A (en) * 2019-05-16 2019-10-01 平安科技(深圳)有限公司 Batch data processing method, device, computer equipment and storage medium
CN110704721A (en) * 2019-10-10 2020-01-17 秒针信息技术有限公司 Client data processing method and device, terminal equipment and readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
杨胜哲;于俊清;唐九飞;: "数据流程序动态调度与优化", 计算机工程与科学, no. 07 *

Also Published As

Publication number Publication date
CN113495908B (en) 2024-05-17

Similar Documents

Publication Publication Date Title
CN107302597B (en) Message file pushing method and device
CN108810047B (en) Method and device for determining information push accuracy rate and server
CN109039817B (en) Information processing method, device, equipment and medium for flow monitoring
CN111917687A (en) Method and device for circularly pushing reminding message
CN111800513A (en) Method and device for pushing information and computer readable medium of electronic equipment
CN110019367B (en) Method and device for counting data characteristics
CN111881329A (en) Account balance management method and system
CN109933508B (en) Method and apparatus for transmitting information
CN113312355A (en) Data management method and device
CN112884181A (en) Quota information processing method and device
CN111124858B (en) Buried point-free insertion code data processing method, system, terminal equipment and storage medium
CN110737691B (en) Method and apparatus for processing access behavior data
CN113495908B (en) Data statistics method and device
CN114817409A (en) Label generation method, device, equipment and medium
CN113114611B (en) Blacklist management method and device
CN113190558A (en) Data processing method and system
CN113722113A (en) Traffic statistic method and device
CN112688982B (en) User request processing method and device
CN113485902A (en) Method, device, equipment and computer readable medium for testing service platform
CN111786801A (en) Method and device for charging based on data flow
CN110875949A (en) Method and device for pushing information
CN114826976B (en) Statistical method and device for uplink flow data based on edge computing service
CN114997977B (en) Data processing method, device, electronic equipment and computer readable medium
CN111400322B (en) Method, apparatus, electronic device and medium for storing data
CN115396434A (en) Message processing method and device

Legal Events

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