flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From otherwise777 <wou...@onzichtbaar.net>
Subject Retrieving a single element from a DataSet
Date Wed, 26 Oct 2016 12:41:51 GMT
I'm currently making a shortest path algorithm in Gelly using DataSets,
here's a piece of the code i've started with:
    public DataSet<Vertex&lt;K,Long>> ShortestPathsEAT(K startingnode) {
        DataSet<Vertex&lt;K,Long>> results =
this.getVertices().distinct().map(new MapFunction<Vertex&lt;K, VV>,
Vertex<K, Long>>() {
            public Vertex<K, Long> map(Vertex<K, VV> value) throws Exception
                if (startingnode == value.getId()) {
                    return new Vertex<K, Long>(value.getId(), 0L);
                } else {
                    return new Vertex<K, Long>(value.getId(),
        return results;

For this i need the index of the starting node, now i could just pass this
as a value, but i want to execute this algorithm on the first element from
my DataSet, i know i can get this element with ,first(1) but that function
returns a DataSet and not the actual element.

I looked for a similar question and got to the following topic [1] Which
kinda gave me the feeling that it's not possible at all to retrieve a single
element from a set, is that correct?
What would be a good way to fix this issue?


View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Retrieving-a-single-element-from-a-DataSet-tp9731.html
Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.

View raw message