Robert Metzger created FLINK-1569:

             Summary: Object reuse mode is not working with KeySelector 
                 Key: FLINK-1569
             Project: Flink
          Issue Type: Bug
          Components: Java API
    Affects Versions: 0.9
            Reporter: Robert Metzger

The following code works correctly when object reuse is switched off.
When switching it on, the results are wrong.
Using a string-based key selection (putting "name") works for both cases.
        public void testWithAvroGenericSer() throws Exception {
                final ExecutionEnvironment env = 
        //      env.getConfig().enableObjectReuse();
                Path in = new Path(inFile.getAbsoluteFile().toURI());

                AvroInputFormat<User> users = new AvroInputFormat<User>(in, 
                DataSet<User> usersDS = env.createInput(users);

                DataSet<Tuple2<String, Integer>> res = usersDS.groupBy(new 
KeySelector<User, String>() {
                        public String getKey(User value) throws Exception {
                                return String.valueOf(value.getName());
                }).reduceGroup(new GroupReduceFunction<User, Tuple2<String, 
Integer>>() {
                        public void reduce(Iterable<User> values, 
Collector<Tuple2<String, Integer>> out) throws Exception {
                                for(User u : values) {
                                        out.collect(new Tuple2<String, 
Integer>(u.getName().toString(), 1));

                env.execute("Avro Key selection");

                expected = "(Charlie,1)\n(Alyssa,1)\n";

This message was sent by Atlassian JIRA

Reply via email to