This is my code

/DataStream<Integer> someIntegers = env.fromElements(1,2,3,4);
                
                SplitStream<Integer> s = someIntegers.split(new 
OutputSelector<Integer>()
{

                        List<String> out = new ArrayList<String>();
                        @Override
                        public Iterable<String> select(Integer arg0) {
                                if( arg0 % 2 == 0){
                                        out.add( "even" );
                                }
                                else{
                                        out.add("odd");
                                }
                                
                                return out;
                        }
                });
                s.select("even").flatMap(new FlatMapFunction<Integer,
Tuple1&lt;Integer>>() {                 
                        @Override
                        public void flatMap(Integer arg0, 
Collector<Tuple1&lt;Integer>> arg1)
throws Exception {
                                System.out.println("---------------"+arg0);
                                arg1.collect( new Tuple1<Integer>(arg0) );
                        }
                }).writeAsCsv("test",WriteMode.OVERWRITE,"," , "");/

When I run this code,

1. A folder called "test" is getting created
2. I get 4 files . File names are 1 ,2 3, 4
3. file 1 ---> 1; file 2 ---> 3 ; file 3 --> 4; File 4 --> Empty. These are
the contents

My Questions:
1. Even if I increase the count in "fromElements", I get 4 files. Why does
it create 4 files always
2. The code should split the stream in to odd and even and right now am
printing only the "Even" stream. So 3 should not be printed

I could not make out anything from this. Some help would be nice



--
View this message in context: 
http://apache-flink-mailing-list-archive.1008284.n3.nabble.com/Datastream-splitter-Confusing-behaviour-tp15138.html
Sent from the Apache Flink Mailing List archive. mailing list archive at 
Nabble.com.

Reply via email to