Patent ID: 11928113
Assignee: ZHEJIANG BANGSUN TECHNOLOGY CO., LTD.
Field: Computer technology (Electrical engineering)
Classification: CPC G  Y | IPC G

Claim 3:
4. A method of an aggregation index for improving aggregation query efficiency, comprising the following steps:
(1) definition of the aggregation index; defining the aggregation index to declare establishment rules of the index, comprising a grouping field, a slice field and method, an aggregation field and an aggregation function;
(1.1) grouping streaming data by the grouping field, and further slicing and segmenting the streaming data with a same corresponding value in the grouping field and then aggregating;
(1.2) partitioning, by the slice field and method, the grouped streaming data with finer granularity, wherein the grouped streaming data will be further segmented according to a value of the slice field and the slice method defined by a user; the slice method has three parameters: a slice starting point, a slice ending point and a slice step length; by setting the above three parameters, streaming data of a same group can be partitioned into a limited number of segments; if a range of slice field is discrete distribution, there is no need to set the slice starting point, the slice ending point or the slice step length;
(1.3) performing aggregation calculation on streaming data belonging to a same slice through the aggregation field and the aggregation function; specifically, aggregating the data in the aggregation field according to the specified aggregation function, and recording an aggregation result in a form of intermediate-state data;
(2) creation of the aggregation index: after the definition of the aggregation index is completed, establishing corresponding index metadata according to the definition wherein the index metadata comprise a grouping field, a slice field, a slice starting point, a slice ending point, a slice step length, an aggregation field and an aggregation function; constructing the aggregation index by using original streaming data, wherein the original streaming data is added into the aggregation index in sequence to the following steps:
(2.1) determining the corresponding sliced data list according to a value of the grouping field of the original streaming data;
(2.2) determining slice intermediate-state data in the sliced data list according to a value of the slice field of the original streaming data;
(2.3) updating the slice intermediate-state data according to a value of the aggregation field of the streaming data;
(2.4) positioning a storage location of the corresponding detailed data according to the sliced data and storing the streaming data;
(3) aggregation index query: using the intermediate-state data aggregation of the slice in the aggregation index, and quickly returning an aggregation query result; wherein the specific steps are as follows:
(3.1) confirming that the current query conforms to the established index data, and the query fails if the following conditions exist:
a. the index data is not grouped according to the grouping field of a query statement;
b. the index data is not sliced according to the slice field of the query statement;

(3.2) determining whether the current query hits the index data; wherein if the aggregation field and the aggregation function of the current query are consistent with the aggregation field and the aggregation function in the index data, then step (3.3) is executed; if there is any inconsistency between the aggregation function and the aggregation method, it is necessary to find all the detailed data of the slice involved in the current query, and calculate the required aggregation result according to the aggregation field and aggregation function in the query;
(3.3) determining whether the slice range of the current query is consistent with the slice intermediate-state data in the index data; wherein if the slice range of the current query can be directly combined with the slice range of one or more slice intermediate-state data in the index data, the query result can be aggregated by the aggregation result of the slice intermediate-state data; if the slice range of the current query cannot be directly combined with the slice range of the slice intermediate-state data in the index data, it is necessary to traverse and aggregate the detailed data of adjacent slices to form a query result.