[ 
https://issues.apache.org/jira/browse/BEAM-12204?focusedWorklogId=587611&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-587611
 ]

ASF GitHub Bot logged work on BEAM-12204:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Apr/21 03:27
            Start Date: 23/Apr/21 03:27
    Worklog Time Spent: 10m 
      Work Description: boyuanzz commented on a change in pull request #14604:
URL: https://github.com/apache/beam/pull/14604#discussion_r618913313



##########
File path: 
sdks/java/harness/src/test/java/org/apache/beam/fn/harness/state/FakeBeamFnStateClient.java
##########
@@ -93,8 +118,18 @@ public void handle(
         break;
 
       case APPEND:
-        ByteString previousValue = data.getOrDefault(request.getStateKey(), 
ByteString.EMPTY);
-        data.put(request.getStateKey(), 
previousValue.concat(request.getAppend().getData()));
+        List<ByteString> previousValue =
+            data.getOrDefault(request.getStateKey(), 
Collections.singletonList(ByteString.EMPTY));
+        List<ByteString> newValue = new ArrayList<>();
+        newValue.addAll(previousValue);
+        ByteString newData = request.getAppend().getData();
+        if (newData.size() % 2 == 0) {
+          newValue.remove(newValue.size() - 1);
+          newValue.add(previousValue.get(previousValue.size() - 
1).concat(newData));
+        } else {
+          newValue.add(newData);
+        }

Review comment:
       Just curious why it's `newData.size() % 2 == 0`?




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

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 587611)
    Time Spent: 50m  (was: 40m)

> Portable Java caches entirety of iterable side inputs.
> ------------------------------------------------------
>
>                 Key: BEAM-12204
>                 URL: https://issues.apache.org/jira/browse/BEAM-12204
>             Project: Beam
>          Issue Type: Bug
>          Components: java-fn-execution
>            Reporter: Robert Bradshaw
>            Assignee: Robert Bradshaw
>            Priority: P2
>             Fix For: 2.30.0
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> Though the data is read over the state channel in a paginated way, it is 
> wrapped in LazyCachingIteratorToIterable which forces the entire iterable to 
> be cached. On the other hand, not caching at all for re-iteration could be 
> expensive. We should do what Python does and cache a bit (e.g. the first 
> page) and still support re-iteration by re-requesting the data over the state 
> channel. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to