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

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

                Author: ASF GitHub Bot
            Created on: 21/Jul/21 18:37
            Start Date: 21/Jul/21 18:37
    Worklog Time Spent: 10m 
      Work Description: jrmccluskey commented on a change in pull request 
#15196:
URL: https://github.com/apache/beam/pull/15196#discussion_r674234919



##########
File path: sdks/go/pkg/beam/runners/direct/gbk.go
##########
@@ -100,6 +114,68 @@ func (n *CoGBK) FinishBundle(ctx context.Context) error {
        return n.Out.FinishBundle(ctx)
 }
 
+func (n *CoGBK) mergeWindows() error {
+       sort.Slice(n.wins, func(i int, j int) bool {
+               return n.wins[i].MaxTimestamp() < n.wins[j].MaxTimestamp()
+       })
+       n.mergeMap = make(map[typex.Window]int)
+       mergedWins := []typex.Window{}
+       for i := 0; i < len(n.wins); {
+               intWin, ok := n.wins[i].(window.IntervalWindow)
+               if !ok {
+                       return errors.Errorf("tried to merge non-interval 
window type")
+               }
+               mergeStart := intWin.Start
+               mergeEnd := intWin.End
+               j := i + 1
+               for j < len(n.wins) {
+                       candidateWin := n.wins[j].(window.IntervalWindow)
+                       if candidateWin.Start <= mergeEnd {
+                               mergeEnd = candidateWin.End
+                               j++
+                       } else {
+                               break
+                       }
+               }
+               for k := i; k < j; k++ {
+                       n.mergeMap[n.wins[k]] = len(mergedWins)
+               }
+               mergedWins = append(mergedWins, window.IntervalWindow{Start: 
mergeStart, End: mergeEnd})
+               i = j
+       }
+       n.wins = mergedWins
+       return nil
+}
+
+func (n *CoGBK) reprocessByWindow() error {
+       newGroups := make(map[string]*group)
+       for _, g := range n.m {
+               ws := []typex.Window{n.wins[n.mergeMap[g.key.Windows[0]]]}
+               var buf bytes.Buffer

Review comment:
       Added helper functions for the key encoding and getting the group from 
the maps. 




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


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

    Worklog Id:     (was: 626280)
    Time Spent: 10h 40m  (was: 10.5h)

> Support Go session windowing
> ----------------------------
>
>                 Key: BEAM-4152
>                 URL: https://issues.apache.org/jira/browse/BEAM-4152
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-go
>            Reporter: Henning Rohde
>            Assignee: Jack McCluskey
>            Priority: P2
>              Labels: starter
>          Time Spent: 10h 40m
>  Remaining Estimate: 0h
>
> Support session windowing and how to handle merging windows.



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

Reply via email to