lukecwik commented on a change in pull request #17121:
URL: https://github.com/apache/beam/pull/17121#discussion_r831553441



##########
File path: 
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/StateFetchingIterators.java
##########
@@ -84,12 +84,27 @@ private StateFetchingIterators() {}
       StateRequest stateRequestForFirstChunk,
       Coder<T> valueCoder) {
     return new CachingStateIterable<>(
-        (Cache<StateKey, Blocks<T>>) cache,
+        (Cache<IterableCacheKey, Blocks<T>>) cache,
         beamFnStateClient,
         stateRequestForFirstChunk,
         valueCoder);
   }
 
+  @VisibleForTesting
+  static class IterableCacheKey implements Weighted {
+    private IterableCacheKey() {}
+
+    static final IterableCacheKey INSTANCE = new IterableCacheKey();
+
+    @Override
+    public long getWeight() {
+      // Ignore the actual size of this singleton because it is trivial and 
because
+      // the weight reported here will be counted many times as it is present 
in
+      // many different state subcaches.
+      return 0;

Review comment:
       The reference to the object still matters as a key even though there are 
many copies.
   
   I would still suggest weighing an instance and storing that statically or if 
there is a way to look up the cost of a pointer via JAMM or the JVM.




-- 
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