zt52875287 commented on PR #19442:
URL: https://github.com/apache/kafka/pull/19442#issuecomment-2808061424

   > Thanks for this patch, I have a question, Will this change the order in 
the map? Will it indirectly affect anything?
   
   I’ve reviewed all call sites of `PartitionStates#set()` and confirmed that 
the input `Map` instances are all `HashMap` or Java-converted Scala `Map`s — 
both of which are unordered by nature.
   
   Specifically:
   - `SubscriptionState#assignFromUser` and `assignFromSubscribed` both use 
`HashMap`
   - `AbstractFetcherThread#updateFetchOffsetAndMaybeMarkTruncationComplete` 
constructs a Scala `Map` and calls `.asJava`, which returns a `HashMap`-backed 
implementation.
   
   In the original `PartitionStates#update` method, although entries were 
grouped by topic before inserting into the internal `LinkedHashMap`, the final 
insertion order was still influenced by the iteration order of the original 
map. In that sense, the order of the internal map was indirectly related to the 
input map's order.
   
   The new implementation with `putAll()` similarly inserts entries based on 
the input map’s iteration order. It remains dependent on the input map's order 
— which is non-deterministic in all current usages.
   
   Given that the input maps are all unordered, this change does not affect 
observable behavior.


-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to