flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From subash basnet <yasub...@gmail.com>
Subject Datastream reset variable in every-time window in map function
Date Sun, 06 Nov 2016 21:15:41 GMT
Hello there,

I have a requirement to reset variable after every-time window in map
function. Once I set a value to the variable it continues through the next
time window also. I would want the variable to have the same original value
on every next time window.
Eg:
DataStream<Tuple1<X>> grid = Y.map(new
AddCountAppender()).keyBy(2).timeWindow(Time.seconds(10)).reduce(new
test()).map(new testMap());

public static final class FindOutlierGrid
extends RichMapFunction<Tuple1<X>, Tuple1<X>> {
int count = 0;

@Override
public void open(Configuration parameters) throws Exception {
super.open(parameters);
}

public FindOutlierGrid() {
this.count = 0;
}

@Override
public Tuple1<X> map(Tuple1<X> gd) throws Exception {
count++;
}
}

In above map function, I would want count to be zero on every next time
window. But value of count is zero only at start and never get's
initialized to zero again. What could be the way to achieve this on every
next time window?

Best Regards,
Subash Basnet

Mime
View raw message