【发布时间】:2019-02-09 06:45:06
【问题描述】:
考虑我这样做:
DataStream<POJO> ds = ...
ds.assignTimestampsAndWatermarks(CustomAssigner)
.windowAll(...)
.apply(someFunction) //THIS FUNCTION CHANGES THE TIMESTAMP FIELD IN THE EVENTS
.assignTimestampsAndWatermarks(AnotherCustomAssigner)
这有效吗?我不知道水印/时间戳是全局的还是仅保留在数据流中?
编辑
class POJO{
int timestamp;
String someDetail; //key by this
...
}
数据流 ds = ....
ds.assignTimeStampsAndWatermarks(new AssignerWithPunctuatedWatermarks(){
long maxTS = Long.MIN_VALUE;
Watermarks checkAndGetNextWater(POJO, p, long l){
maxTS = max(...)
return new Watermarks(maxTS);
}
long ExtractTS(POJO p, long l){
maxTS = max(...)
return p.timeStamp;
}
}).keyBy(someDetail property)
.window(TumblingWindow(1 min))
.apply(new AllWindowFunction<POJO, POJO, String, TimeWindow>(){
public void apply(...){
POJO newPOJO = ...;
for(POJO it : iterable){
newPOJO.timeStamp += ...
}
collector.collect(newPOJO);
}
})
现在我想知道
如果我应该再次分配时间戳,因为我想做windowAll,然后再次apply。
assignTimestamp...
.windowAll(..)
.apply(some other allwindow function)
【问题讨论】:
-
谁能解释一下什么是对象重用?我应该使用
apply还是别的什么?
标签: java apache-flink