java - Why are all elements printed although they are the same in mapWithState -


i'm sending 3 times same object javapairdstream. i'm updating it's state it's saved 3 times. printing javapairdstream confirms this.

function3<inputmessagekey, optional<inputmessage>, state<inputmessage>, tuple2<inputmessagekey, inputmessage>> mappingfunction = new function3<inputmessagekey, optional<inputmessage>, state<inputmessage>, tuple2<inputmessagekey, inputmessage>>() {         @override         public tuple2<inputmessagekey, inputmessage> call(inputmessagekey key, optional<inputmessage> value, state<inputmessage> state) {             inputmessage inputmessage = value.get();             tuple2<inputmessagekey, inputmessage> output = new tuple2<>(key, inputmessage);             state.update(inputmessage);             return output;         }     }; 

printing stream:

(com.input.inputmessagekey@220593a0,com.input.inputmessage@781bfd72) (com.input.inputmessagekey@220593a0,com.input.inputmessage@781bfd72) (com.input.inputmessagekey@220593a0,com.input.inputmessage@781bfd72) 

it's not saved 3 times. you're returning tuple2 object you've created @ end of function, , what's being printed out. if want see internal state that's saved, use javamapwithstatedstream.statesnapshots in graph instead iterating output of mapwithstate.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

android - CoordinatorLayout, FAB and container layout conflict -