[jira] [Work logged] (BEAM-9978) Add offset range restrictions to the Go SDK.

2020-05-21 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9978:


Author: ASF GitHub Bot
Created on: 22/May/20 04:07
Start Date: 22/May/20 04:07
Worklog Time Spent: 10m 
  Work Description: youngoli merged pull request #11763:
URL: https://github.com/apache/beam/pull/11763


   



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 436376)
Time Spent: 1h  (was: 50m)

> Add offset range restrictions to the Go SDK.
> 
>
> Key: BEAM-9978
> URL: https://issues.apache.org/jira/browse/BEAM-9978
> Project: Beam
>  Issue Type: Improvement
>  Components: sdk-go
>Reporter: Daniel Oliveira
>Assignee: Daniel Oliveira
>Priority: P2
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Currently these are part of the stringsplit example. but they should probably 
> be generalized and in the actual SDK, and should have adequate testing.



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


[jira] [Work logged] (BEAM-9978) Add offset range restrictions to the Go SDK.

2020-05-21 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9978:


Author: ASF GitHub Bot
Created on: 22/May/20 03:37
Start Date: 22/May/20 03:37
Worklog Time Spent: 10m 
  Work Description: youngoli commented on a change in pull request #11763:
URL: https://github.com/apache/beam/pull/11763#discussion_r429026079



##
File path: sdks/go/pkg/beam/io/rtrackers/offsetrange/offsetrange_test.go
##
@@ -0,0 +1,212 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package offsetrange
+
+import (
+   "fmt"
+   "github.com/google/go-cmp/cmp"
+   "testing"
+)
+
+// TestRestriction_EvenSplits tests various splits and checks that they all
+// follow the contract for EvenSplits. This means that all restrictions are
+// evenly split, that each restriction has at least one element, and that each
+// element is present in the split restrictions.
+func TestRestriction_EvenSplits(t *testing.T) {
+   tests := []struct {
+   rest Restriction
+   num  int64
+   }{
+   {rest: Restriction{Start: 0, End: 21}, num: 4},
+   {rest: Restriction{Start: 21, End: 42}, num: 4},
+   {rest: Restriction{Start: 0, End: 5}, num: 10},
+   {rest: Restriction{Start: 0, End: 21}, num: -1},
+   }
+   for _, test := range tests {
+   test := test
+   t.Run(fmt.Sprintf("(rest[%v, %v], splits = %v)",
+   test.rest.Start, test.rest.End, test.num), func(t 
*testing.T) {
+   r := test.rest
+
+   // Get the minimum size that a split restriction can 
be. Max size
+   // should be min + 1. This way we can check the size of 
each split.
+   num := test.num
+   if num <= 1 {
+   num = 1
+   }
+   min := (r.End - r.Start) / num
+
+   splits := r.EvenSplits(test.num)
+   prevEnd := r.Start
+   for _, split := range splits {
+   size := split.End - split.Start
+   // Check: Each restriction has at least 1 
element.
+   if size == 0 {
+   t.Errorf("split restriction [%v, %v] is 
empty, size must be greater than 0.",
+   split.Start, split.End)
+   }
+   // Check: Restrictions are evenly split.
+   if size != min && size != min+1 {
+   t.Errorf("split restriction [%v, %v] 
has unexpected size. got: %v, want: %v or %v",
+   split.Start, split.End, size, 
min, min+1)
+   }
+   // Check: All elements are still in a split 
restrictions. This
+   // logic assumes that the splits are returned 
in order which
+   // isn't guaranteed by EvenSplits, but this 
check is way easier
+   // with the assumption.
+   if split.Start != prevEnd {
+   t.Errorf("restriction range [%v, %v] 
missing after splits.",
+   prevEnd, split.Start)
+   } else {
+   prevEnd = split.End
+   }
+   }
+   if prevEnd != r.End {
+   t.Errorf("restriction range [%v, %v] missing 
after splits.",
+   prevEnd, r.End)
+   }
+   })
+   }
+}
+
+// TestTracker_TryClaim validates both success and failure cases for TryClaim.
+func TestTracker_TryClaim(t *te

[jira] [Work logged] (BEAM-9978) Add offset range restrictions to the Go SDK.

2020-05-21 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9978:


Author: ASF GitHub Bot
Created on: 22/May/20 03:36
Start Date: 22/May/20 03:36
Worklog Time Spent: 10m 
  Work Description: youngoli commented on a change in pull request #11763:
URL: https://github.com/apache/beam/pull/11763#discussion_r429025895



##
File path: sdks/go/pkg/beam/io/rtrackers/offsetrange/offsetrange_test.go
##
@@ -0,0 +1,212 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package offsetrange
+
+import (
+   "fmt"
+   "github.com/google/go-cmp/cmp"
+   "testing"
+)
+
+// TestRestriction_EvenSplits tests various splits and checks that they all
+// follow the contract for EvenSplits. This means that all restrictions are
+// evenly split, that each restriction has at least one element, and that each
+// element is present in the split restrictions.
+func TestRestriction_EvenSplits(t *testing.T) {
+   tests := []struct {
+   rest Restriction
+   num  int64
+   }{
+   {rest: Restriction{Start: 0, End: 21}, num: 4},
+   {rest: Restriction{Start: 21, End: 42}, num: 4},
+   {rest: Restriction{Start: 0, End: 5}, num: 10},
+   {rest: Restriction{Start: 0, End: 21}, num: -1},
+   }
+   for _, test := range tests {
+   test := test
+   t.Run(fmt.Sprintf("(rest[%v, %v], splits = %v)",
+   test.rest.Start, test.rest.End, test.num), func(t 
*testing.T) {
+   r := test.rest
+
+   // Get the minimum size that a split restriction can 
be. Max size
+   // should be min + 1. This way we can check the size of 
each split.
+   num := test.num
+   if num <= 1 {
+   num = 1
+   }
+   min := (r.End - r.Start) / num
+
+   splits := r.EvenSplits(test.num)
+   prevEnd := r.Start
+   for _, split := range splits {
+   size := split.End - split.Start
+   // Check: Each restriction has at least 1 
element.
+   if size == 0 {
+   t.Errorf("split restriction [%v, %v] is 
empty, size must be greater than 0.",
+   split.Start, split.End)
+   }
+   // Check: Restrictions are evenly split.
+   if size != min && size != min+1 {
+   t.Errorf("split restriction [%v, %v] 
has unexpected size. got: %v, want: %v or %v",
+   split.Start, split.End, size, 
min, min+1)
+   }
+   // Check: All elements are still in a split 
restrictions. This
+   // logic assumes that the splits are returned 
in order which
+   // isn't guaranteed by EvenSplits, but this 
check is way easier
+   // with the assumption.
+   if split.Start != prevEnd {
+   t.Errorf("restriction range [%v, %v] 
missing after splits.",
+   prevEnd, split.Start)
+   } else {
+   prevEnd = split.End
+   }
+   }
+   if prevEnd != r.End {
+   t.Errorf("restriction range [%v, %v] missing 
after splits.",
+   prevEnd, r.End)
+   }
+   })
+   }
+}
+
+// TestTracker_TryClaim validates both success and failure cases for TryClaim.
+func TestTracker_TryClaim(t *te

[jira] [Work logged] (BEAM-9978) Add offset range restrictions to the Go SDK.

2020-05-20 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9978:


Author: ASF GitHub Bot
Created on: 20/May/20 21:31
Start Date: 20/May/20 21:31
Worklog Time Spent: 10m 
  Work Description: lostluck commented on a change in pull request #11763:
URL: https://github.com/apache/beam/pull/11763#discussion_r428305778



##
File path: sdks/go/pkg/beam/io/rtrackers/offsetrange/offsetrange_test.go
##
@@ -0,0 +1,212 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package offsetrange
+
+import (
+   "fmt"
+   "github.com/google/go-cmp/cmp"
+   "testing"
+)
+
+// TestRestriction_EvenSplits tests various splits and checks that they all
+// follow the contract for EvenSplits. This means that all restrictions are
+// evenly split, that each restriction has at least one element, and that each
+// element is present in the split restrictions.
+func TestRestriction_EvenSplits(t *testing.T) {
+   tests := []struct {
+   rest Restriction
+   num  int64
+   }{
+   {rest: Restriction{Start: 0, End: 21}, num: 4},
+   {rest: Restriction{Start: 21, End: 42}, num: 4},
+   {rest: Restriction{Start: 0, End: 5}, num: 10},
+   {rest: Restriction{Start: 0, End: 21}, num: -1},
+   }
+   for _, test := range tests {
+   test := test
+   t.Run(fmt.Sprintf("(rest[%v, %v], splits = %v)",
+   test.rest.Start, test.rest.End, test.num), func(t 
*testing.T) {
+   r := test.rest
+
+   // Get the minimum size that a split restriction can 
be. Max size
+   // should be min + 1. This way we can check the size of 
each split.
+   num := test.num
+   if num <= 1 {
+   num = 1
+   }
+   min := (r.End - r.Start) / num
+
+   splits := r.EvenSplits(test.num)
+   prevEnd := r.Start
+   for _, split := range splits {
+   size := split.End - split.Start
+   // Check: Each restriction has at least 1 
element.
+   if size == 0 {
+   t.Errorf("split restriction [%v, %v] is 
empty, size must be greater than 0.",
+   split.Start, split.End)
+   }
+   // Check: Restrictions are evenly split.
+   if size != min && size != min+1 {
+   t.Errorf("split restriction [%v, %v] 
has unexpected size. got: %v, want: %v or %v",
+   split.Start, split.End, size, 
min, min+1)
+   }
+   // Check: All elements are still in a split 
restrictions. This
+   // logic assumes that the splits are returned 
in order which
+   // isn't guaranteed by EvenSplits, but this 
check is way easier
+   // with the assumption.
+   if split.Start != prevEnd {
+   t.Errorf("restriction range [%v, %v] 
missing after splits.",
+   prevEnd, split.Start)
+   } else {
+   prevEnd = split.End
+   }
+   }
+   if prevEnd != r.End {
+   t.Errorf("restriction range [%v, %v] missing 
after splits.",
+   prevEnd, r.End)
+   }
+   })
+   }
+}
+
+// TestTracker_TryClaim validates both success and failure cases for TryClaim.
+func TestTracker_TryClaim(t *te

[jira] [Work logged] (BEAM-9978) Add offset range restrictions to the Go SDK.

2020-05-20 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9978:


Author: ASF GitHub Bot
Created on: 20/May/20 19:09
Start Date: 20/May/20 19:09
Worklog Time Spent: 10m 
  Work Description: youngoli commented on pull request #11763:
URL: https://github.com/apache/beam/pull/11763#issuecomment-631668755


   R: @lostluck 



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:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 435628)
Time Spent: 20m  (was: 10m)

> Add offset range restrictions to the Go SDK.
> 
>
> Key: BEAM-9978
> URL: https://issues.apache.org/jira/browse/BEAM-9978
> Project: Beam
>  Issue Type: Improvement
>  Components: sdk-go
>Reporter: Daniel Oliveira
>Assignee: Daniel Oliveira
>Priority: P2
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> Currently these are part of the stringsplit example. but they should probably 
> be generalized and in the actual SDK, and should have adequate testing.



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


[jira] [Work logged] (BEAM-9978) Add offset range restrictions to the Go SDK.

2020-05-20 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9978:


Author: ASF GitHub Bot
Created on: 20/May/20 19:09
Start Date: 20/May/20 19:09
Worklog Time Spent: 10m 
  Work Description: youngoli opened a new pull request #11763:
URL: https://github.com/apache/beam/pull/11763


   Pretty simple. Moves some commonly desired behaviors out of the SDF
   code and into the offset range tracker/restriction code + adds tests.
   
   
   
   Thank you for your contribution! Follow this checklist to help us 
incorporate your contribution quickly and easily:
   
- [x] [**Choose 
reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and 
mention them in a comment (`R: @username`).
- [x] Format the pull request title like `[BEAM-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA 
issue, if applicable. This will automatically link the pull request to the 
issue.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [x] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more 
tips on [how to make review process 
smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   Post-Commit Tests Status (on master branch)
   

   
   Lang | SDK | Apex | Dataflow | Flink | Gearpump | Samza | Spark
   --- | --- | --- | --- | --- | --- | --- | ---
   Go | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go/lastCompletedBuild/)
 | --- | --- | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Flink/lastCompletedBuild/)
 | --- | --- | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Go_VR_Spark/lastCompletedBuild/)
   Java | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Apex/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow/lastCompletedBuild/)[![Build
 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow_Java11/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Dataflow_Java11/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink/lastCompletedBuild/)[![Build
 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink_Java11/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Flink_Java11/lastCompletedBuild/)[![Build
 
Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Batch/lastCompletedBuild/)[![Build
 
Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Flink_Streaming/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Gearpump/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Samza/lastCompletedBuild/)
 | [![Build 
Status](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_PostCommit_Java_ValidatesRunner_Spark/lastCompletedBuild/)[![Build
 
Status](https://builds.apache.org/job/beam_PostCommit_Java_PVR_Spark_Batch/lastCompletedBuild/badge/icon)](https://builds.apache.org/job/beam_Post