flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lydia Ickler <ickle...@googlemail.com>
Subject normalizing DataSet with cross()
Date Tue, 22 Mar 2016 13:21:06 GMT
Hi all,

I have a question.
If I have a DataSet DataSet<Tuple3<Integer, Integer, Double>> ds and I want to
normalize all values (at position 2) in it by the maximum of the DataSet (ds.aggregate(Aggregations.MAX,
How do I tackle that?

If I use the cross operator my result changes every time I run the program (see code below)
Any suggestions?

Thanks in advance!
ds.cross(ds.aggregate(Aggregations.MAX, 2)).map(new normalizeByMax());
public static final class normalizeByMax implements
        MapFunction<Tuple2<Tuple3<Integer, Integer, Double>, Tuple3<Integer,
Integer, Double>>,
                Tuple3<Integer, Integer, Double>> {

    public Tuple3<Integer, Integer, Double> map(
            Tuple2<Tuple3<Integer, Integer, Double>, Tuple3<Integer, Integer,
Double>> value)
            throws Exception {
        return new Tuple3<Integer, Integer, Double>(value.f0.f0,value.f0.f1,value.f0.f2/value.f1.f2);

View raw message