reuvenlax commented on code in PR #41540:
URL: https://github.com/apache/beam/pull/41540#discussion_r4773411886
##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/StateFetchingIterators.java:
##########
@@ -480,7 +509,16 @@ public void append(List<T> values) {
* cache.
*/
public void append(WeightedList<T> values) {
- appendHelper(values.getBacking(), values.getWeight());
+ append(values.getBacking(), values.getWeight());
+ }
+
+ /**
+ * Appends {@code values} to the cached iterable with a pre-computed
weight (including {@code
+ * values.size() * Caches.REFERENCE_SIZE}), avoiding a {@link
WeightedList} wrapper.
+ */
+ void append(List<T> values, long valuesWeight) {
+ checkArgument(valuesWeight >= 0, "valuesWeight must be non-negative, got
%s", valuesWeight);
Review Comment:
Package-private append(List<T>, long) is called directly by BagUserState
and MultimapUserState
(mirroring clearAndAppend(List<T>, long)), and checkArgument(valuesWeight
>= 0) can't move directly into appendHelper(List<T>, long) because
append(List<T>) uses -1 as the sentinel to lazily compute weight via
Caches.weigh.
--
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]