HeartSaVioR commented on code in PR #45341: URL: https://github.com/apache/spark/pull/45341#discussion_r1520711461
########## sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/MapStateImpl.scala: ########## @@ -73,24 +74,31 @@ class MapStateImpl[K, V]( } /** Get the map associated with grouping key */ - override def getMap(): Map[K, V] = { + override def getMap(): Iterator[(K, V)] = { val encodedGroupingKey = stateTypesEncoder.encodeGroupingKey() - store.prefixScan(encodedGroupingKey, stateName) - .map { - case iter: UnsafeRowPair => - (stateTypesEncoder.decodeCompositeKey(iter.key), - stateTypesEncoder.decodeValue(iter.value)) - }.toMap + val pairsIterator = store.prefixScan(encodedGroupingKey, stateName) + + new Iterator[(K, V)] { Review Comment: maybe final nit: your previous code just works and it seems much simpler. We just need to remove the call `.toMap` and done. Also maybe the method name to remove the map from the name? * `getIterator` - consistent with getKeys/getValues * `iterator` - consistent with Map collection. need to change other methods as well, e.g. getKeys to keys, getValues to values * `get()` - consistent with other type of state. The value of origin type is retrieved with get() consistently. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org