com.nextbreakpoint.flink.dummies.MeasuredTemperatureProcess Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.nextbreakpoint.flink.dummies Show documentation
Show all versions of com.nextbreakpoint.flink.dummies Show documentation
Collection of dummy jobs for Apache Flink
/*
* This file is part of Flink Dummies
* https://github.com/nextbreakpoint/flink-dummies
*/
package com.nextbreakpoint.flink.dummies;
import org.apache.flink.streaming.api.functions.windowing.ProcessWindowFunction;
import org.apache.flink.streaming.api.windowing.windows.TimeWindow;
import org.apache.flink.util.Collector;
import java.time.Instant;
public class MeasuredTemperatureProcess extends ProcessWindowFunction {
@Override
public void process(String locationId, ProcessWindowFunction.Context context, Iterable elements, Collector out) {
elements.forEach(temperature -> out.collect(createTemperature(locationId, context, temperature)));
}
private static MeasuredTemperature createTemperature(String locationId, ProcessWindowFunction.Context context, Temperature temperature) {
return MeasuredTemperature.builder()
.withLocationId(locationId)
.withTemperature(temperature)
.withTimestamp(Instant.ofEpochMilli(context.window().getStart()))
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy