[
https://issues.apache.org/jira/browse/BEAM-7726?focusedWorklogId=278618&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-278618
]
ASF GitHub Bot logged work on BEAM-7726:
----------------------------------------
Author: ASF GitHub Bot
Created on: 18/Jul/19 00:13
Start Date: 18/Jul/19 00:13
Worklog Time Spent: 10m
Work Description: youngoli commented on pull request #9080: [BEAM-7726]
Implement State Backed Iterables in Go SDK
URL: https://github.com/apache/beam/pull/9080#discussion_r304686804
##########
File path: sdks/go/pkg/beam/core/runtime/exec/datasource.go
##########
@@ -262,3 +282,60 @@ func (n *DataSource) Split(splits []int64, frac float32)
(int64, error) {
// return an error.
return 0, fmt.Errorf("failed to split at requested splits: {%v},
DataSource at index: %v", splits, c)
}
+
+type concatReStream struct {
+ first, next ReStream
+}
+
+func (c *concatReStream) Open() (Stream, error) {
+ firstStream, err := c.first.Open()
+ if err != nil {
+ return nil, err
+ }
+ return &concatStream{first: firstStream, nextStream: c.next}, nil
+}
+
+type concatStream struct {
+ first Stream
+ nextStream ReStream
+}
+
+// Close nils the stream.
+func (s *concatStream) Close() error {
+ if s.first == nil {
+ return nil
+ }
+ defer func() {
+ s.first = nil
+ s.nextStream = nil
+ }()
+ return s.first.Close()
+}
+
+func (s *concatStream) Read() (*FullValue, error) {
+ if s.first == nil { // When the stream is closed.
+ return nil, io.EOF
+ }
+ fv, err := s.first.Read()
+ if err == nil {
+ return fv, nil
+ }
+ if err == io.EOF {
+ if err := s.first.Close(); err != nil {
+ s.nextStream = nil
+ return nil, err
+ }
+ if s.nextStream == nil {
+ s.first = nil
+ return nil, io.EOF
+ }
+ s.first, err = s.nextStream.Open()
Review comment:
Just checking my understanding here: nextStream here is opening an
elementStream reading from the state-backed iterable (ScopedStateReader in
statemgr.go), so that new stream will automatically get continuations from the
state channel, right? It took me a while to trace how this was working, so I
wanna confirm that I understood it correctly.
----------------------------------------------------------------
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: 278618)
Time Spent: 1h 20m (was: 1h 10m)
> [Go SDK] State Backed Iterables
> -------------------------------
>
> Key: BEAM-7726
> URL: https://issues.apache.org/jira/browse/BEAM-7726
> Project: Beam
> Issue Type: Improvement
> Components: sdk-go
> Affects Versions: Not applicable
> Reporter: Robert Burke
> Assignee: Robert Burke
> Priority: Major
> Fix For: Not applicable
>
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> The Go SDK should support the State backed iterables protocol per the proto.
> [https://github.com/apache/beam/blob/master/model/pipeline/src/main/proto/beam_runner_api.proto#L644]
>
> Primary case is for iterables after CoGBKs.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)