[
https://issues.apache.org/jira/browse/BEAM-8612?focusedWorklogId=341574&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-341574
]
ASF GitHub Bot logged work on BEAM-8612:
----------------------------------------
Author: ASF GitHub Bot
Created on: 12/Nov/19 00:45
Start Date: 12/Nov/19 00:45
Worklog Time Spent: 10m
Work Description: lostluck commented on pull request #10066: [BEAM-8612]
Convert []beam.T to the underlying type []T when passed to a universal type.
URL: https://github.com/apache/beam/pull/10066#discussion_r344972612
##########
File path: sdks/go/pkg/beam/core/runtime/exec/fullvalue.go
##########
@@ -151,6 +156,12 @@ func ConvertFn(from, to reflect.Type) func(interface{})
interface{} {
}
return ret.Interface()
}
+
+ case typex.IsList(from) && typex.IsUniversal(from.Elem()) &&
typex.IsUniversal(to):
+ return func(v interface{}) interface{} {
+ return Convert(v, to)
Review comment:
Never call Convert from ConvertFn. The point of ConvertFn is to avoid
re-computing the type comparisons, and the typex.IsUniversals and similar per
element.
Instead, write it the other way around. Convert can call ConvertFn, since
it's already paying the heavier call cost anyway.
----------------------------------------------------------------
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: 341574)
Time Spent: 20m (was: 10m)
> Convert []beam.T to the underlying type []T when passed to a DoFn with
> universal typed (beam.X) input
> -----------------------------------------------------------------------------------------------------
>
> Key: BEAM-8612
> URL: https://issues.apache.org/jira/browse/BEAM-8612
> Project: Beam
> Issue Type: New Feature
> Components: sdk-go
> Reporter: Tianyang Hu
> Assignee: Tianyang Hu
> Priority: Minor
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Say there are two DoFn: f1, f2.
> - f1 declares the output type as []beam.T, and each element has the
> underlying type int.
> - f2 declares the input type as []int
> Passing f1 output to f2 works well. The conversion from []beam.T to []int
> happens at:
> https://github.com/apache/beam/blob/c7be0643934a87d73483cf1fd3199a425508b03c/sdks/go/pkg/beam/core/runtime/exec/fullvalue.go#L108
> But it doesn't work if f2 declares the input type as beam.X and type casts it
> to []int. This is because there's no type conversion when passing []beam.T to
> beam.X.
> We may consider supporting the above case by converting []beam.T to the
> underlying type []T when it's passed to a universal type.
> An issue is that if []beam.T is nil or empty, we don't know its underlying
> element type (unless we know which concrete type beam.T or beam.X is bound
> to, but this mapping doesn't seem to be kept at runtime?). In such case, we
> have to pass []beam.T to beam.X as is.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)