[
https://issues.apache.org/jira/browse/BEAM-8271?focusedWorklogId=379117&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-379117
]
ASF GitHub Bot logged work on BEAM-8271:
----------------------------------------
Author: ASF GitHub Bot
Created on: 30/Jan/20 01:28
Start Date: 30/Jan/20 01:28
Worklog Time Spent: 10m
Work Description: chadrik commented on issue #10595: [BEAM-8271] Properly
encode/decode StateGetRequest/Response continuation token
URL: https://github.com/apache/beam/pull/10595#issuecomment-580042571
Ok, I’ll have another look at it.
On Wed, Jan 29, 2020 at 5:06 PM Robert Bradshaw <[email protected]>
wrote:
> It's bytes because non-trivial runners may serialize arbitrary data into
> this field used to continue the iterable. (Ids are strings because they're
> just used to compare against, and also the type of proto map keys
> constrains us here.) There shouldn't be any manipulation of this token
> except for passing it back on the client side at least--just accepting it
> and passing it back.
>
> It looks like Java treats this as a BytesString. I still think we should
> do the same.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
>
<https://github.com/apache/beam/pull/10595?email_source=notifications&email_token=AAAPOEZIZDOZV2R57LDTC53RAIRYFA5CNFSM4KG3STR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKJKUMQ#issuecomment-580037170>,
> or unsubscribe
>
<https://github.com/notifications/unsubscribe-auth/AAAPOEZ5IKZ6MDLBMGXJIYDRAIRYFANCNFSM4KG3STRQ>
> .
>
----------------------------------------------------------------
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: 379117)
Time Spent: 50m (was: 40m)
> StateGetRequest/Response continuation_token should be string
> ------------------------------------------------------------
>
> Key: BEAM-8271
> URL: https://issues.apache.org/jira/browse/BEAM-8271
> Project: Beam
> Issue Type: Improvement
> Components: beam-model
> Reporter: Chad Dombrova
> Assignee: Chad Dombrova
> Priority: Major
> Time Spent: 50m
> Remaining Estimate: 0h
>
> I've been working on adding typing to the python code and I came across a
> discrepancy between regarding the type of the continuation token. The .proto
> defines it as bytes, but the code treats it as a string (i.e. unicode):
>
> {code:java}
> // A request to get state.
> message StateGetRequest {
> // (Optional) If specified, signals to the runner that the response
> // should resume from the following continuation token.
> //
> // If unspecified, signals to the runner that the response should start
> // from the beginning of the logical continuable stream.
> bytes continuation_token = 1;
> }
> // A response to get state representing a logical byte stream which can be
> // continued using the state API.
> message StateGetResponse {
> // (Optional) If specified, represents a token which can be used with the
> // state API to get the next chunk of this logical byte stream. The end of
> // the logical byte stream is signalled by this field being unset.
> bytes continuation_token = 1;
> // Represents a part of a logical byte stream. Elements within
> // the logical byte stream are encoded in the nested context and
> // concatenated together.
> bytes data = 2;
> }
> {code}
> From FnApiRunner.StateServicer:
> {code:python}
> def blocking_get(self, state_key, continuation_token=None):
> with self._lock:
> full_state = self._state[self._to_key(state_key)]
> if self._use_continuation_tokens:
> # The token is "nonce:index".
> if not continuation_token:
> token_base = 'token_%x' % len(self._continuations)
> self._continuations[token_base] = tuple(full_state)
> return b'', '%s:0' % token_base
> else:
> token_base, index = continuation_token.split(':')
> ix = int(index)
> full_state = self._continuations[token_base]
> if ix == len(full_state):
> return b'', None
> else:
> return full_state[ix], '%s:%d' % (token_base, ix + 1)
> else:
> assert not continuation_token
> return b''.join(full_state), None
> {code}
> This could be a problem in python3.
> All other id values are string, whereas bytes is reserved for data, so I
> think that the proto should be changed to string.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)