[
https://issues.apache.org/jira/browse/BEAM-7726?focusedWorklogId=279101&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-279101
]
ASF GitHub Bot logged work on BEAM-7726:
----------------------------------------
Author: ASF GitHub Bot
Created on: 18/Jul/19 16:10
Start Date: 18/Jul/19 16:10
Worklog Time Spent: 10m
Work Description: lostluck commented on pull request #9080: [BEAM-7726]
Implement State Backed Iterables in Go SDK
URL: https://github.com/apache/beam/pull/9080#discussion_r305001696
##########
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:
That's right. For this use of concatStream, that's exactly what's happening.
concatReStream and concatStream are general though, so any two re-streams can
be concatenated together (including nested concat streams)
The continuations from statemgr.go took me a moment too, but fortunately
that code is already nicely written.
----------------------------------------------------------------
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: 279101)
Time Spent: 2h 10m (was: 2h)
> [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: 2h 10m
> 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)