[
https://issues.apache.org/jira/browse/BEAM-4813?focusedWorklogId=126733&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-126733
]
ASF GitHub Bot logged work on BEAM-4813:
----------------------------------------
Author: ASF GitHub Bot
Created on: 24/Jul/18 16:50
Start Date: 24/Jul/18 16:50
Worklog Time Spent: 10m
Work Description: lostluck commented on a change in pull request #5994:
[BEAM-4813] Refactor Go Dataflow runner and translation
URL: https://github.com/apache/beam/pull/5994#discussion_r203810553
##########
File path: sdks/go/pkg/beam/core/util/reflectx/util.go
##########
@@ -0,0 +1,92 @@
+// 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 reflectx
+
+import (
+ "fmt"
+ "reflect"
+)
+
+// ShallowClone creates a shallow copy of the given value. Most
+// useful for slices and maps.
+func ShallowClone(v interface{}) interface{} {
+ if v == nil {
+ return nil
+ }
+ val := reflect.ValueOf(v)
+
+ t := val.Type()
+ switch t.Kind() {
+ case reflect.Slice:
+ if val.IsNil() {
+ return reflect.Zero(t).Interface() // don't allocate
for zero values
+ }
+
+ size := val.Len()
+ ret := reflect.MakeSlice(t, size, size)
+ for i := 0; i < size; i++ {
+ ret.Index(i).Set(val.Index(i))
+ }
+ return ret.Interface()
+
+ case reflect.Map:
+ if val.IsNil() {
+ return reflect.Zero(t).Interface() // don't allocate
for zero values
+ }
+
+ ret := reflect.MakeMapWithSize(t, val.Len())
+ keys := val.MapKeys()
+ for _, key := range keys {
+ ret.SetMapIndex(key, val.MapIndex(key))
+ }
+ return ret.Interface()
+
+ case reflect.Array, reflect.Chan, reflect.Interface, reflect.Func,
reflect.Invalid:
+ panic(fmt.Sprintf("unsupported type for clone: %v", t))
+
+ default:
+ return v
+ }
+}
+
+// MergeMaps merges two maps of type map[K]*V, with the second overwriting
values
+// into the first (and mutating it). If the overwriting value is nil, the key
is
+// deleted.
+func MergeMaps(a, b interface{}) {
Review comment:
The overwriting behaviour doesn't read as a "merge" to me. Consider renaming
this UpdateMap(base, updates interface{}) instead, since the second map is
operating as a lift of updates, rather than a straight merge.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: 126733)
Time Spent: 1h 40m (was: 1.5h)
> Make Go Dataflow translation use protos directly
> ------------------------------------------------
>
> Key: BEAM-4813
> URL: https://issues.apache.org/jira/browse/BEAM-4813
> Project: Beam
> Issue Type: Improvement
> Components: sdk-go
> Reporter: Henning Rohde
> Assignee: Henning Rohde
> Priority: Major
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
> The Go SDK maintains 2 pipeline translations and keeps various tweaks in
> sync. It would be better to remove the Dataflow one and extract a more
> flexible (such as running as a separate proxy) translation from proto to
> v1beta3.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)