在级联中是可能的。假设您的字段名称是 (url,count)。如果行包含单词google并丢弃 url 字段,则应用一个函数来添加一个名为“domain”的字段,该字段包含值 google 。现在,如果您不需要任何其他域,则将它们过滤掉。所以现在你有两个字段(域,计数),其中域仅包含单词google
现在使用级联的 AggregateBy() 、 SumBy() 函数。
SumBy any_name = new SumBy(field_name_to_sum , field_name_after_sum , dataType 类);
管道结果 = new AggregateBy("name" , Pipe.pipes(sourcePipeName) , name_of_groupBy_field , number_of_SumBy_instances , name_of_sumBy_instance);
在你的情况下,它变成
SumBy xyz = new SumBy(new Fields("count") , new Fields("combined_count") , Integer.class);
管道结果 = new AggregateBy("result" , Pipe.pipes(sourcePipeName) , new Fields("domain") , 1 , xyz);
所以现在结果管道包含一行(google,count)
所以上面的代码片段将类似于下面的 SQL 查询。
通过域从源组中选择域,总和(计数);