修饰符和类型 | 方法和描述 |
---|---|
Table |
aggregate(GroupByAggregationOnColumn... aggregates)
根据索引表示的列组进行聚合。用法:aggregate(count(), max(2),...); 示例: 输入: 1, 1, 1 1, 2, 1 2, 4, 5 table.groupBy(0, 2).count() col0, col1 输出: 1, 1 1, 2 2, 1 ==> 聚合计数
|
Table |
aggregateWindows(AggregationOverWindow... windowAggregates)
根据参数中指定的窗口,在 Table/投影上计算基于行的窗口聚合函数。
|
Table |
aggregateWindowsOverRanges(AggregationOverWindow... windowAggregates)
根据参数中指定的窗口,在 Table/投影上计算基于范围的窗口聚合函数。
|
ContiguousTable[] |
contiguousSplitGroups()
根据分组键将单个表中的组拆分成单独的表。
|
ContigSplitGroupByResult |
contiguousSplitGroupsAndGenUniqKeys()
类似于
contiguousSplitGroups() ,返回一个额外的唯一键表,其中每行对应一个组拆分。 |
Table |
replaceNulls(ReplacePolicyWithColumn... replacements) |
Table |
scan(GroupByScanAggregationOnColumn... aggregates) |
public Table aggregate(GroupByAggregationOnColumn... aggregates)
public Table aggregateWindows(AggregationOverWindow... windowAggregates)
AggregationOverWindow
参数表示,指示:1. Aggregation.Kind
,2. 当前行在一个窗口内前面和后面的行数,3. 定义窗口内的最小观测数量。此方法返回一个 Table
实例,每个指定窗口聚合对应一个结果列。在此示例中,对于以下输入: [ // 用户ID, 销售额 { "user1", 10 }, { "user2", 20 }, { "user1", 20 }, { "user1", 10 }, { "user2", 30 }, { "user2", 80 }, { "user1", 50 }, { "user1", 60 }, { "user2", 40 } ] 按 user_id
进行分区(分组)会产生以下 sales_amt
向量(有两个组,每个 distinct user_id
一个): [ 10, 20, 10, 50, 60, 20, 30, 80, 40 ] <-------user1-------->|<------user2-------> SUM 聚合应用于前面 1 行和后面 1 行,最小周期为 1。因此,聚合窗口宽度为 3 行,产生以下列: [ 30, 40, 80, 120, 110, 50, 130, 150, 120 ]windowAggregates
- 要执行的窗口聚合IllegalArgumentException
- 如果窗口参数不是 WindowOptions.FrameType.ROWS
类型,即为窗口聚合指定了时间戳列。public Table aggregateWindowsOverRanges(AggregationOverWindow... windowAggregates)
AggregationOverWindow
参数表示,指示:1. Aggregation.Kind
,2. 基于哪个时间戳列定义窗口的索引,2. 窗口中要考虑的当前行日期之前和之后的“天”数,3. 定义窗口内的最小观测数量。此方法返回一个 Table
实例,每个指定窗口聚合对应一个结果列。在此示例中,对于以下输入: [ // 用户, 销售额, YYYYMMDD (日期) { "user1", 10, 20200101 }, { "user2", 20, 20200101 }, { "user1", 20, 20200102 }, { "user1", 10, 20200103 }, { "user2", 30, 20200101 }, { "user2", 80, 20200102 }, { "user1", 50, 20200107 }, { "user1", 60, 20200107 }, { "user2", 40, 20200104 } ] 按 user_id
进行分区(分组),并按 date
排序,会产生以下 sales_amt
向量(有两个组,每个 distinct user_id
一个): 日期 :(202001-) [ 01, 02, 03, 07, 07, 01, 01, 02, 04 ] 输入: [ 10, 20, 10, 50, 60, 20, 30, 80, 40 ] <-------user1-------->|<---------user2---------> SUM 聚合应用于之前 1 天和之后 1 天,最小周期为 1。因此,聚合窗口宽度为 3 *天*,产生以下输出列: 结果: [ 30, 40, 30, 110, 110, 130, 130, 130, 40 ]windowAggregates
- 要执行的窗口聚合IllegalArgumentException
- 如果窗口参数不是 WindowOptions.FrameType.RANGE
类型,或者 orderBys 不是(布尔值除外)整数类型,即未为聚合指定时间戳列。public Table scan(GroupByScanAggregationOnColumn... aggregates)
public Table replaceNulls(ReplacePolicyWithColumn... replacements)
public ContiguousTable[] contiguousSplitGroups()
public ContigSplitGroupByResult contiguousSplitGroupsAndGenUniqKeys()
contiguousSplitGroups()
,返回一个额外的唯一键表,其中每行对应一个组拆分。根据分组键将单个表中的组拆分成单独的表。每个拆分后的表代表一个单独的组。示例,参见 contiguousSplitGroups()
中的示例。ContigSplitGroupByResult 中的 uniqKeysTable
是: a b 注意:只有 2 行,因为只有 2 个拆分组。版权所有 © 2025。保留所有权利。