All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nextbreakpoint.flink.dummies.MeasuredTemperatureProcess Maven / Gradle / Ivy

There is a newer version: 0.0.6
Show newest version
/*
 * 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