SKHolmes commented on issue #27753:
URL: https://github.com/apache/beam/issues/27753#issuecomment-1667674140

   Okay one last paste dump to clarify the issue and hopefully help other 
people googling around for solutions as well. From what I have discovered, 
there is strange behavior when trying to use a _TupleTagList.and(TupleTag)_ 
**in a loop**, (I have tested various different loops.) My bandaid solution is 
to create the TupleTags I need one at a time which sucks because now my code 
will have to change in multiple places if I need more TupleTags of my types in 
the future.
   
   Paste of code,
   ```
        public static TupleTagList createPipelineTupleMap () {
                System.out.println("In createPipelineTupleMap");
                TupleTagList tags = TupleTagList.empty();
                HashMap<MessageType, TupleTag<Message>> map
                                = new HashMap<MessageType, TupleTag<Message>>();
                ArrayList<MessageType> types = new ArrayList<MessageType>();
                for(MessageType type : MessageType.values()) {
                        types.add(type);
                        TupleTag<Message> tag = new TupleTag<Message>(){};
                        tags.and(new TupleTag<Message>(){});
                        map.put(type, tag);
                }
                System.out.print("Tags 2: ");
                System.out.println(tags.getAll());
                System.out.printf("Tags size: %d\n", tags.size());
                System.out.println(map.entrySet());
                System.out.print("Types: ");
                System.out.println(types);
                System.out.println(tags.and(new 
TupleTag<Message>(){}).getAll());
                return tags;
        }
   ```
   Prints,
   
   > In createPipelineTupleMap                                                  
                                                                                
                             
   > Tags 2: []                                                                 
                                                                                
                             
   > Tags size: 0
   > [CURVE_INGESTION=Tag<com.example.App$6.<init>:126#8ce970b71df42503>, 
TEST=Tag<com.example.App$6.<init>:126#554dcd2b40b5f04b>]
   > Types: [CURVE_INGESTION, TEST]
   > [Tag<com.example.App$8.<init>:136#fc1e932efb9a0f58>]
   
   Apologies for being hard to read. But the gist of it is, there are no tags 
on the TupleTagList, (Tags 2: [],) after looping over all the values of my 
MessageType enum. But the loop did iterate properly hence why the map is 
populated correctly, 
([CURVE_INGESTION=Tag<com.example.App$6.<init>:126#8ce970b71df42503>, 
TEST=Tag<com.example.App$6.<init>:126#554dcd2b40b5f04b>].) I can still however 
add to the TupleTagList and print the contents as you can see when the line,
   `System.out.println(tags.and(new TupleTag<Message>(){}).getAll());`
   prints,
   
   > [Tag<com.example.App$8.<init>:136#fc1e932efb9a0f58>]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to