flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas FOURNIER <thomasfournier...@gmail.com>
Subject [No Subject]
Date Sun, 13 Nov 2016 22:38:49 GMT

I'm trying to assign a unique (and deterministic) ID to a globally sorted

Given a DataSet of String, I can compute the frequency of each label as

val env = ExecutionEnvironment.getExecutionEnvironment

val data = env.fromCollection(List("a","b","c","a","a","d","a","a","a","b","b","c","a","c","b","c"))

val mapping = data.map(s => (s,1))
  .reduce((a,b) => (a._1, a._2 + b._2))
  .sortPartition(1, Order.DESCENDING)

I want the most frequent label to be ID 0 and so on in decreasing order. My
idea was to use zipWithIndex. But this does not guarantee that my DataSet
will be

View raw message