Implementation method of grouping window function time_window based on distributed database KaiwuDB

CN120763251BActive Publication Date: 2026-08-21山东浪潮数据库技术有限公司 +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510941307.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-09
Publication Date
2026-08-21
Estimated Expiration
2045-07-09

AI Technical Summary

Technical Problem

[0006]本发明的技术任务是提供一种基于分布式数据库KaiwuDB的分组窗口函数time_window实现方法,来解决如何在分布式数据库KaiwuDB中实现时间窗口分组函数的问题

Benefits of technology

[0046] (i) This invention adds a grouping window function to a distributed database to increase the database's ability to manipulate data;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120763251B_ABST
    Figure CN120763251B_ABST
Patent Text Reader

Abstract

The application discloses a grouping window function time_window implementation method based on a distributed database KaiwuDB and belongs to the technical field of databases. The technical problem to be solved by the application is how to implement a time window grouping function in the distributed database KaiwuDB. The technical scheme adopted is that the three nodes of table data distribution, namely, node1, node2 and node3, are sorted according to a time column, the sorted data is subjected to heap sorting in a gateway node, one row of data is sent to an upper orderedAggregator through gRPC in each row, and the orderedAggregator calculates a grouping window function of the input ordered data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database technology, specifically to an implementation method of the grouping window function time_window based on the distributed database KaiwuDB. Background Technology

[0002] The `time_window` function (or time window function) in grouping window functions is a core concept in stream processing and time-series databases, and its technical background involves three major technical fields: distributed systems, incremental computing, and real-time analysis. The following are key background points for the implementation of these technologies:

[0003] Streaming data processing challenges: Continuously generated data streams (such as IoT device data, logs, and transaction records) cannot be loaded into memory all at once; they need to be dynamically divided into time segments for aggregation calculations (such as transaction volume per minute / average temperature per 10 seconds). Traditional batch processing (such as GROUP BY) cannot meet real-time requirements.

[0004] The real-time evolution of business scenarios: In IoT time-series scenarios, such as when the business requirement is to aggregate the average temperature sensor readings every 10 minutes, traditional solutions cannot dynamically handle device disconnection / reconnection. Time window functions can adaptively group session windows. In user behavior analysis scenarios, when calculating the hourly active duration of users, traditional solutions suffer from statistical distortion when user behavior crosses the hour, while jump windows accurately align time boundaries, and so on.

[0005] Therefore, how to implement the time window grouping function in the distributed database KaiwuDB is a technical problem that urgently needs to be solved. Summary of the Invention

[0006] The technical objective of this invention is to provide an implementation method for the time_window grouping function based on the distributed database KaiwuDB, in order to solve the problem of how to implement the time window grouping function in the distributed database KaiwuDB.

[0007] The technical task of this invention is achieved in the following way: a method for implementing the grouping window function time_window based on the distributed database KaiwuDB. The method sorts the data in the three nodes node1, node2 and node3 of the table data distribution according to the time column. The sorted data is then heap sorted in the gateway node. Each row is sent to the upper-level orderedAggregator via gRPC. The orderedAggregator calculates the grouping window function on the input ordered data.

[0008] The grouping window function is nested within the orderedAggregator. Leveraging the grouping characteristics of the orderedAggregator itself, before grouping calculations, the grouping window column for each row is assigned a value called `groupValue`. `groupValue` starts at 0, and is incremented by 1 each time a new window is entered, ensuring that the grouping column values ​​for different groups processed by the orderedAggregator are different, thus achieving grouping. Rows within the same group are assigned the same `groupValue` to their grouping column. Simultaneously, the time window is divided into windows according to fixed time intervals. By default, data is sorted by timestamp, and the data is divided into multiple windows based on the duration value before aggregation calculations are performed.

[0009] As a preferred approach, when the orderedAggregator performs grouping window function calculations on the input ordered data, the following applies:

[0010] When sliding_value is set in time_window(time_value, duration_value, sliding_value), it means that the window has overlapping parts. orderedAggregator performs full grouping window function calculation on the input ordered data.

[0011] When sliding_value is not set in time_window(time_value, duration_value, sliding_value), it means that the window has no overlapping parts. orderedAggregator performs simplified grouping window function calculation on the input ordered data.

[0012] More preferably, the orderedAggregator performs simplified grouping window function calculations on the input ordered data as follows:

[0013] (1) The orderedAggregator retrieves a row of data and checks if the row is empty:

[0014] ①If row is not empty, then proceed to step (2);

[0015] ②If row is empty, then proceed to step (7);

[0016] (2) Determine if row is the first row:

[0017] If row is the first row, first create a row data storage container rowContainer, and initialize an iter pointing to the first row of rowContainer;

[0018] (3) When the new entry time is greater than or equal to tsTimeStampEnd, it means that a window has ended and the next window is switched. The start time of the next window is tsTimestampStart. When tsTimestampStart is equal to tsTimeStampEnd, the window number groupValue is incremented by 1; and the data in the container rowContainer whose time is less than the new tsTimestampStart is deleted to achieve the behavior of sliding the window backward. The iter is then pointed to the first row of the rowContainer again.

[0019] (4) Take a row of data row1 from the container rowContainer, move iter one position to the right, and reuse row to assign row1 to row;

[0020] (5) Use groupValue as an auxiliary function for the group window function column in row;

[0021] (6) The orderedAggregator performs grouping calculations according to the grouping column after group by, and jumps back to step (1);

[0022] (7) If the original data has been processed, the remaining data in the rowContainer needs to be processed now;

[0023] (8) If the new entry time is greater than or equal to tsTimeStampEnd, it means that a window has ended. Switch to the next window. The start time of the next window is tsTimestampStart. When tsTimestampStart is equal to tsTimeStampEnd, increment the window number groupValue by 1, execute the first line of the container with iter, and enter step (4). When the remaining data in the container is 0, the entire process ends.

[0024] More preferably, if `row` is the first row, first create a row data storage container `rowContainer`, initialize an iter pointing to the first row of `rowContainer`, and initialize...

[0025]

[0026] Here, tsTimeStampStart represents the start time of a time window; tsTimeStampEnd represents the end time of a window; WindowBuckt is used to calculate the time bucket of a row. When the duration of a new time exceeds the window bucket, WindowBuckt is updated and the next duration begins; a groupValue is set as a consecutive window number starting from 0, and the row is added to the row container rowContainer.

[0027] More preferably, the orderedAggregator performs simplified grouping window function calculations on the input ordered data as follows:

[0028] (1) The orderedAggregator retrieves a row of data and checks if the row is empty:

[0029] ①If row is not empty, then proceed to step (2);

[0030] ②If row is empty, the process ends;

[0031] (2) Use functions to calculate the timebucket value to determine whether the data is in a group, round the time and record it;

[0032] (3) If the new time is greater than the time recorded above after rounding, it means that the group needs to be switched, and groupValue is incremented by 1;

[0033] (4) Execute the subsequent process of orderedAggretor, perform group calculations, and jump back to step (1).

[0034] More ideally, the time should be rounded and recorded as follows:

[0035] To obtain the Unix timestamp of the raw time: convert v.Time to a Unix timestamp, then multiply by 1000 to convert it to a millisecond-level timestamp;

[0036] Calculate the interval of the time window: get the number of days of the time window from evalCtx.GroupWindow.TimeWindowHelper.Duration.Days, convert the number of days to hours, then to nanoseconds, and divide the nanoseconds by 1,000,000 to convert to milliseconds;

[0037] Rounding timestamps by window interval: Divide the original time's millisecond stamp by the window interval to obtain the rounded integer part, i.e., rounding down;

[0038] To restore the rounded timestamp: recalculate the window interval and multiply the window index by the interval to restore the rounded timestamp;

[0039] Convert to time.Time type: Convert the nanosecond-level timestamp result to the time.Time type;

[0040] Convert to database timestamp type: Convert time.Time to a timestamp type supported by the database.

[0041] An electronic device includes: a memory and at least one processor;

[0042] The memory contains computer programs;

[0043] The at least one processor executes the computer program stored in the memory, causing the at least one processor to execute the time_window implementation method of the grouped window function based on the distributed database KaiwuDB as described above.

[0044] A computer-readable storage medium storing a computer program that can be executed by a processor to implement the time_window function implementation method based on the distributed database KaiwuDB as described above.

[0045] The grouping window function time_window implementation method based on the distributed database KaiwuDB of the present invention has the following advantages:

[0046] (i) This invention adds a grouping window function to a distributed database to increase the database's ability to manipulate data;

[0047] (II) This invention utilizes the execution flow of orderedAggregator to nest grouping function operations within orderedAggregator. Before orderedAggregator performs actual grouping, the values ​​of the grouping columns in the data rows are replaced with a window number. After the values ​​of the grouping columns in the row data are replaced with the window number, the grouping characteristics of orderedAggregator can be used for grouping. The time window grouping function time_window can be implemented in a distributed database, and other grouping window functions such as count_window / state_window / session_window / event_window can be implemented similarly. Attached Figure Description

[0048] The invention will be further described below with reference to the accompanying drawings.

[0049] AppendixFigure 1 This is a flowchart illustrating the implementation of the time_window function for grouping windows based on the distributed database KaiwuDB.

[0050] Appendix Figure 2 This is a diagram illustrating the modification of grouped column data;

[0051] Appendix Figure 3 Implement a complete flowchart for the grouped window function time_window;

[0052] Appendix Figure 4 A simplified flowchart is provided for the grouped window function time_window. Detailed Implementation

[0053] The following detailed description of the implementation method of the grouping window function time_window based on the distributed database KaiwuDB of the present invention, with reference to the accompanying drawings and specific embodiments, is provided.

[0054] Example 1:

[0055] This embodiment provides an implementation method of the grouping window function `time_window` based on the distributed database KaiwuDB. `time_window(time_value, duration_value, sliding_value)` is a time window function that divides the data into windows according to time periods, and by default sorts the data by the timestamp column. The grouping window function must be used with the `GROUPBY` clause, is limited to time-series table queries, does not support nested subqueries, and follows the `GROUP BY` clause. <ptag>The `time_window(time_value, duration_value, sliding_value)` format is used, but it does not support additional grouping conditions. Furthermore, the timestamps of individual devices within the table cannot be duplicated.

[0056] The time window is divided into windows based on fixed time intervals. Data is divided into multiple windows according to the duration_value, and then aggregation calculations are performed. sliding_value represents the forward sliding time; the window length is fixed, and windows overlap according to the sliding step size. When sliding_time is not specified, i.e., when time_window(time_value, duration_value), the default is window size (i.e., duration) grouping; the window length is fixed, there is no overlap, and no sliding is required.

[0057] For example, the window starts at time t0, the first window is [t0, t0+duration), the second window is [t0+sliding_time, t0+sliding_time+duration). The sliding ends when the window reaches [t0+duration, t0+duration+sliding_time].

[0058] The following is an example of an SQL statement:

[0059] SQL

[0060] --Group the array into groups of one month each. After aggregation, shift the data forward by one day and continue grouping by one month. `ts` is the column name in table `t1`, storing the timestamp for each row of data. Key code is as follows:

[0061] select first(ts)as first,count(*)from tsdb.t1 group by time_window(ts,'1mon','1day').

[0062] The core purpose of `time_window` is to resolve the fundamental contradiction between streaming data and time series processing by dividing an infinite data stream into finite time blocks to achieve real-time aggregation computation. It is compatible with out-of-order data scenarios, ensuring time series accuracy. Its core parameters are as follows:

[0063] time_window(

[0064] time_column TIMESTAMP, -- Timestamp column (the event time or processing time must be explicitly specified).

[0065] window_duration INTERVAL, -- Window length (e.g., INTERVAL'5'MINUTE)

[0066] [slide_duration INTERVAL] -- Slide step size (optional, default = window length → jump window)

[0067] →WindowSpec

[0068] Window type implementation

[0069] Example of window type parameter configuration output

[0070] Tumbling window (time_window(ts, '5MINUTE') [12:00:00, 12:05:00)

[0071] Sliding window (time_window(ts,'10MINUTE','2MINUTE') [12:00:00,12:10:00) → [12:02:00,12:12:00)).

[0072] As attached Figure 1 As shown, this method sorts the data in the three nodes (node1, node2, and node3) according to the time column, performs heap sort on the gateway node, and sends one row of data to the upper-level orderedAggregator via gRPC for each row. The orderedAggregator performs grouping window function calculation on the input ordered data.

[0073] The grouping window function is nested within the orderedAggregator. Leveraging the grouping characteristics of the orderedAggregator itself, before grouping calculations, the grouping window column for each row is assigned a value called `groupValue`. `groupValue` starts at 0, and is incremented by 1 each time a new window is entered, ensuring that the grouping column values ​​for different groups processed by the orderedAggregator are different, thus achieving grouping. Rows within the same group are assigned the same `groupValue` to their grouping column. Simultaneously, the time window is divided into windows according to fixed time intervals. By default, data is sorted by timestamp, and the data is divided into multiple windows based on the duration value before aggregation calculations are performed.

[0074] As attached Figure 2 As shown, [t0s, t0e), [t1s, t1e), and [t2s, t2e) represent the time window ranges for executing three consecutive queries, respectively, with the sliding time representing the forward sliding time of the window. `sliding_time` represents the forward sliding time. When `sliding_time` is not specified, it defaults to the window size (i.e., duration). Query filtering, aggregation, and other operations are performed on an independent basis for each time window.

[0075] In this embodiment, when the orderedAggregator performs grouping window function calculations on the input ordered data, the following situation occurs:

[0076] When sliding_value is set in time_window(time_value, duration_value, sliding_value), it means that the window has overlapping parts. orderedAggregator performs full grouping window function calculation on the input ordered data.

[0077] When sliding_value is not set in time_window(time_value, duration_value, sliding_value), it means that the window has no overlapping parts. orderedAggregator performs simplified grouping window function calculation on the input ordered data.

[0078] As attached Figure 3 As shown, the orderedAggregator in this embodiment performs simplified grouping window function calculations on the input ordered data as follows:

[0079] (1) The orderedAggregator retrieves a row of data and checks if the row is empty:

[0080] ①If row is not empty, then proceed to step (2);

[0081] ②If row is empty, then proceed to step (7);

[0082] (2) Determine if row is the first row:

[0083] If `row` is the first row, first create a row data storage container `rowContainer`, and initialize an `iter` pointing to the first row of the `rowContainer`; specifically, if `row` is the first row, first create a row data storage container `rowContainer`, initialize an `iter` pointing to the first row of the `rowContainer`, and initialize...

[0084]

[0085] Where tsTimeStampStart represents the start time of a time window; tsTimeStampEnd represents the end time of a window; WindowBuckt is used to calculate the time bucket of a row. When the duration of a new time exceeds the window bucket, WindowBuckt is updated and the next duration begins; a groupValue is set as a consecutive window number starting from 0, and the row is added to the row container rowContainer.

[0086] (3) When the new entry time is greater than or equal to tsTimeStampEnd, it means that a window has ended and the next window is switched. The start time of the next window is tsTimestampStart. When tsTimestampStart is equal to tsTimeStampEnd, the window number groupValue is incremented by 1; and the data in the container rowContainer whose time is less than the new tsTimestampStart is deleted to achieve the behavior of sliding the window backward. The iter is then pointed to the first row of the rowContainer again.

[0087] (4) Take a row of data row1 from the container rowContainer, move iter one position to the right, and reuse row to assign row1 to row;

[0088] (5) Use groupValue as an auxiliary function for the group window function column in row;

[0089] (6) The orderedAggregator performs grouping calculations according to the grouping column after group by, and jumps back to step (1);

[0090] (7) If the original data has been processed, the remaining data in the rowContainer needs to be processed now;

[0091] (8) If the new entry time is greater than or equal to tsTimeStampEnd, it means that a window has ended. Switch to the next window. The start time of the next window is tsTimestampStart. When tsTimestampStart is equal to tsTimeStampEnd, increment the window number groupValue by 1, execute the first line of the container with iter, and enter step (4). When the remaining data in the container is 0, the entire process ends.

[0092] As attached Figure 4 As shown, the orderedAggregator in this embodiment performs simplified grouping window function calculations on the input ordered data as follows:

[0093] (1) The orderedAggregator retrieves a row of data and checks if the row is empty:

[0094] ①If row is not empty, then proceed to step (2);

[0095] ②If row is empty, the process ends;

[0096] (2) Use a function to calculate the timebucket value to determine if the data is in the same group: oldTimeUnix := v.Time.Unix() * 1000

[0097] oldTimeInterval:=((evalCtx.GroupWindow.TimeWindowHelper.Duration.Days)*int64(time.Hour)*24) / 1000000

[0098] oldTimeTrun:=oldTimeUnix / oldTimeInterval

[0099] oldTimeMul:=(evalCtx.GroupWindow.TimeWindowHelper.Duration.Days)*int64(time.Hour)*24

[0100] result:=oldTimeTrun*oldTimeMul

[0101] sts:=timeutil.Unix(0,result)

[0102] newTimeDur=tree.MakeDTimestamp(sts,0)

[0103] That is, rounding up the time and recording it;

[0104] (3) If the new time is greater than the time recorded above after rounding, it means that the group needs to be switched, and groupValue is incremented by 1;

[0105] (4) Execute the subsequent process of orderedAggretor, perform group calculations, and jump back to step (1).

[0106] Example 2:

[0107] This invention also provides an electronic device, including: a memory and a processor;

[0108] The memory stores the instructions executed by the computer.

[0109] The processor executes the computer execution instructions stored in the memory, causing the processor to execute the time_window implementation method of the grouping window function based on the distributed database KaiwuDB in any embodiment of the present invention.

[0110] The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor can be a microprocessor or any conventional processor.

[0111] Memory is used to store computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and by accessing data stored in the memory. Memory can mainly include a program storage area and a data storage area. The program storage area can store the operating system, at least one application program required for a function, etc.; the data storage area can store data created based on the use of the terminal, etc. In addition, memory can also include high-speed random access memory, and can also include non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart memory cards (SMC), secure digital cards (SD cards), flash memory cards, at least one disk storage device, flash memory devices, or other volatile solid-state storage devices.

[0112] Example 3:

[0113] This embodiment also provides a computer-readable storage medium storing multiple instructions, which are loaded by a processor to cause the processor to execute the time_window implementation method based on the distributed database KaiwuDB in any embodiment of the present invention. Specifically, a system or apparatus equipped with a storage medium may be provided, on which software program code implementing the functions of any of the above embodiments is stored, and the computer (or CPU or MPU) of the system or apparatus may read and execute the program code stored in the storage medium.

[0114] In this case, the program code read from the storage medium can itself implement the function of any of the above embodiments, and therefore the program code and the storage medium storing the program code constitute part of the present invention.

[0115] Storage media embodiments for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RYM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, program code can be downloaded from a server computer via a communication network.

[0116] Furthermore, it should be clear that not only can the program code read by the computer be executed, but also the operating system or other components operating on the computer can be instructed based on the program code to perform some or all of the actual operations, thereby realizing the function of any of the embodiments described above.

[0117] Furthermore, it is understood that the program code read from the storage medium is written to the memory set in the expansion board inserted into the computer or to the memory set in the expansion unit connected to the computer. Then, based on the instructions of the program code, the CPU or other components installed on the expansion board or expansion unit execute some and all of the actual operations, thereby realizing the function of any of the embodiments described above.

[0118] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.< / ptag>

Claims

1. A method for implementing the grouping window function time_window based on the distributed database KaiwuDB, characterized in that, This method sorts the data in the three nodes (node1, node2, and node3) according to the time column. The sorted data is then heap-sorted on the gateway node. Each row is sent to the upper-level orderedAggregator via gRPC. The orderedAggregator performs grouping window function calculations on the input ordered data. The grouping window function is nested within the orderedAggregator. Leveraging the grouping characteristics of the orderedAggregator itself, before grouping calculations, the grouping window column for each row is assigned a value called `groupValue`. `groupValue` starts at 0, and is incremented by 1 each time a new window is entered, ensuring that the grouping column values ​​for different groups processed by the orderedAggregator are different, thus achieving grouping. Rows within the same group are assigned the same `groupValue` to their grouping column. Simultaneously, the time window is divided into windows according to fixed time intervals. By default, data is sorted by timestamp, and the data is divided into multiple windows based on the duration value before aggregation calculations are performed.

2. The method for implementing the grouping window function tim e_window based on the distributed database KaiwuDB according to claim 1, characterized in that, When the orderedAggregator performs grouped window function computation on the input ordered data, the following is the case: When `sliding_value` is set in `time_window(time_value, duration_value, sliding_value)`, it means that the window has overlapping parts. `orderedAggregator` performs a complete grouping window function calculation on the input ordered data. When sliding_value is not set in time_window(time_value, duration_value, sliding_value), it means that the window has no overlapping parts. orderedAggregator performs simplified grouping window function calculation on the input ordered data.

3. The method for implementing the grouping window function time_window based on the distributed database KaiwuDB according to claim 2, characterized in that, The orderedAggregator performs simplified grouping of the input ordered data using a window function, as detailed below: (1) The orderedAggregator retrieves a row of data and checks if the row is empty: ①If row is not empty, then proceed to step (2); ②If row is empty, then proceed to step (7); (2) Determine if row is the first row: If row is the first row, first create a row data storage container rowContainer, and initialize an iter pointing to the first row of rowContainer; (3) When the new time is greater than or equal to tsTimeStampEnd, it means that a window has ended and the next window is switched. The start time of the next window is tsTimestampStart. When tsTimestampStart is equal to tsTimeStampEnd, the window number groupValue is incremented by 1; and the data in the container rowContainer whose time is less than the new tsTimestampStart is deleted to achieve the behavior of sliding the window backward. The iter is then pointed to the first row of the rowContainer again. (4) Take a row of data row1 from the container rowContainer, move iter one position to the right, and reuse row to assign row1 to row; (5) Use groupValue as an auxiliary function for the group window function column in row; (6) The orderedAggregator performs grouping calculations according to the grouping column after group by, and jumps back to step (1); (7) If the original data has been processed, the remaining data in the rowContainer needs to be processed now; (8) If the new entry time is greater than or equal to tsTimeStampEnd, it means that a window has ended. Switch to the next window. The start time of the next window is tsTimestampStart. When tsTimestampStart is equal to tsTimeStampEnd, increment the window number groupValue by 1, execute the first line of the container, and enter step (4). When the remaining data in the container is 0, the process ends.

4. The method for implementing the grouping window function time_window based on the distributed database KaiwuDB according to claim 3, characterized in that, If `row` is the first row, first create a row data storage container `rowContainer`, initialize an iter pointing to the first row of `rowContainer`, and then initialize... Here, tsTimeStampStart represents the start time of a time window; tsTimeStampEnd represents the end time of a window; WindowBuckt is used to calculate the time bucket of a row. When the duration of a new time exceeds the window bucket, WindowBuckt is updated to start the next duration; a groupValue is set as a consecutive window number starting from 0, and the row is added to the row container rowContainer.

5. The method for implementing the grouping window function time_window based on the distributed database KaiwuDB according to claim 2, characterized in that, The orderedAggregator performs simplified grouping of the input ordered data using a window function, as detailed below: (1) The orderedAggregator retrieves a row of data and checks if the row is empty: ①If row is not empty, then proceed to step (2); ②If row is empty, the process ends; (2) Use functions to calculate the timebucket value to determine whether the data is in a group, round the time and record it; (3) If the new time is greater than the time recorded above after rounding, it means that the group needs to be switched, and the group value is incremented by 1; (4) Execute the subsequent process of orderedAggretor, perform group calculations, and jump back to step (1).

6. The method for implementing the grouping window function time_window based on the distributed database KaiwuDB according to claim 5, characterized in that, The time is rounded and recorded as follows: To obtain the Unix timestamp of the raw time: convert v.Time to a Unix timestamp, then multiply by 1000 to convert it to a millisecond-level timestamp; Calculate the interval of the time window: get the number of days of the time window from evalCtx.GroupWindow.TimeWindowHelper.Duration.Days, convert the number of days to hours, then to nanoseconds, and divide the nanoseconds by 1,000,000 to convert to milliseconds; Rounding timestamps by window interval: Divide the original time's millisecond stamp by the window interval to obtain the rounded integer part, i.e., rounding down; To restore the rounded timestamp: recalculate the window interval and multiply the window index by the interval to restore the rounded timestamp; Convert to time.Time type: Convert the nanosecond-level timestamp result to the time.Time type; Convert to database timestamp type: Convert time.Time to a timestamp type supported by the database.

7. An electronic device, characterized in that, include: Memory and at least one processor; The memory contains computer programs; The at least one processor executes the computer program stored in the memory, causing the at least one processor to perform the time_window implementation method based on the distributed database KaiwuDB as described in any one of claims 1 to 6.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that can be executed by a processor to implement the time_window method for grouping window functions based on the distributed database KaiwuDB as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method and device for improving database windowing function query performance

    CN117390058A

  • A method and device for realizing database window function

    CN119759950A