public List < T > collect ( ) throws Exception { final String id = new AbstractID ( ) . toString ( ) ; final TypeSerializer < T > serializer = getType ( ) . createSerializer ( getExecutionEnvironment ( ) . getConfig ( ) ) ; this . output ( new Utils . CollectHelper <> ( id , serializer ) ) . name ( "collect()" ) ; JobExecutionResult res = getExecutionEnvironment ( ) . execute ( ) ; ArrayList < byte [ ] > accResult = res . getAccumulatorResult ( id ) ; if ( accResult != null ) { try { return SerializedListAccumulator . deserializeList ( accResult , serializer ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( "Cannot find type class of collected data type." , e ) ; } catch ( IOException e ) { throw new RuntimeException ( "Serialization error while deserializing collected data" , e ) ; } } else { throw new RuntimeException ( "The call to collect() could not retrieve the DataSet." ) ; } }
Convenience method to get the elements of a DataSet as a List . As DataSet can contain a lot of data this method should be used with caution .