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

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

                Author: ASF GitHub Bot
            Created on: 12/Nov/18 20:28
            Start Date: 12/Nov/18 20:28
    Worklog Time Spent: 10m 
      Work Description: aaltay closed pull request #7002: [BEAM-3612] Type 
specialize stats package
URL: https://github.com/apache/beam/pull/7002
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/sdks/go/pkg/beam/transforms/stats/max_switch.go 
b/sdks/go/pkg/beam/transforms/stats/max_switch.go
index d26fd27a4f1..b31d41aa6dc 100644
--- a/sdks/go/pkg/beam/transforms/stats/max_switch.go
+++ b/sdks/go/pkg/beam/transforms/stats/max_switch.go
@@ -20,25 +20,8 @@ package stats
 import (
        "fmt"
        "reflect"
-
-       "github.com/apache/beam/sdks/go/pkg/beam"
 )
 
-func init() {
-       beam.RegisterFunction(maxIntFn)
-       beam.RegisterFunction(maxInt8Fn)
-       beam.RegisterFunction(maxInt16Fn)
-       beam.RegisterFunction(maxInt32Fn)
-       beam.RegisterFunction(maxInt64Fn)
-       beam.RegisterFunction(maxUintFn)
-       beam.RegisterFunction(maxUint8Fn)
-       beam.RegisterFunction(maxUint16Fn)
-       beam.RegisterFunction(maxUint32Fn)
-       beam.RegisterFunction(maxUint64Fn)
-       beam.RegisterFunction(maxFloat32Fn)
-       beam.RegisterFunction(maxFloat64Fn)
-}
-
 func findMaxFn(t reflect.Type) interface{} {
        switch t.String() {
        case "int":
diff --git a/sdks/go/pkg/beam/transforms/stats/max_switch.tmpl 
b/sdks/go/pkg/beam/transforms/stats/max_switch.tmpl
index 7fea68df34f..9424569a62a 100644
--- a/sdks/go/pkg/beam/transforms/stats/max_switch.tmpl
+++ b/sdks/go/pkg/beam/transforms/stats/max_switch.tmpl
@@ -18,16 +18,8 @@ package stats
 import (
     "fmt"
     "reflect"
-
-       "github.com/apache/beam/sdks/go/pkg/beam"
 )
 
-func init() {
-{{- range .X}}
-       beam.RegisterFunction(max{{.Name}}Fn)
-{{- end}}
-}
-
 func findMaxFn(t reflect.Type) interface{} {
     switch t.String() {
 {{- range .X}}
diff --git a/sdks/go/pkg/beam/transforms/stats/mean.go 
b/sdks/go/pkg/beam/transforms/stats/mean.go
index 3bc2c88b211..9d68231ca1b 100644
--- a/sdks/go/pkg/beam/transforms/stats/mean.go
+++ b/sdks/go/pkg/beam/transforms/stats/mean.go
@@ -22,10 +22,6 @@ import (
        "github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx"
 )
 
-func init() {
-       beam.RegisterType(reflect.TypeOf((*meanFn)(nil)).Elem())
-}
-
 // Mean returns the arithmetic mean (or average) of the elements in a 
collection.
 // It expects a PCollection<A> as input and returns a singleton 
PCollection<float64>.
 // It can only be used for numbers, such as int, uint16, float32, etc.
diff --git a/sdks/go/pkg/beam/transforms/stats/min_switch.go 
b/sdks/go/pkg/beam/transforms/stats/min_switch.go
index afa9768ee3c..75dfe729ec3 100644
--- a/sdks/go/pkg/beam/transforms/stats/min_switch.go
+++ b/sdks/go/pkg/beam/transforms/stats/min_switch.go
@@ -20,25 +20,8 @@ package stats
 import (
        "fmt"
        "reflect"
-
-       "github.com/apache/beam/sdks/go/pkg/beam"
 )
 
-func init() {
-       beam.RegisterFunction(minIntFn)
-       beam.RegisterFunction(minInt8Fn)
-       beam.RegisterFunction(minInt16Fn)
-       beam.RegisterFunction(minInt32Fn)
-       beam.RegisterFunction(minInt64Fn)
-       beam.RegisterFunction(minUintFn)
-       beam.RegisterFunction(minUint8Fn)
-       beam.RegisterFunction(minUint16Fn)
-       beam.RegisterFunction(minUint32Fn)
-       beam.RegisterFunction(minUint64Fn)
-       beam.RegisterFunction(minFloat32Fn)
-       beam.RegisterFunction(minFloat64Fn)
-}
-
 func findMinFn(t reflect.Type) interface{} {
        switch t.String() {
        case "int":
diff --git a/sdks/go/pkg/beam/transforms/stats/min_switch.tmpl 
b/sdks/go/pkg/beam/transforms/stats/min_switch.tmpl
index 117551817a0..0dd082d785c 100644
--- a/sdks/go/pkg/beam/transforms/stats/min_switch.tmpl
+++ b/sdks/go/pkg/beam/transforms/stats/min_switch.tmpl
@@ -18,16 +18,8 @@ package stats
 import (
     "fmt"
     "reflect"
-
-       "github.com/apache/beam/sdks/go/pkg/beam"
 )
 
-func init() {
-{{- range .X}}
-       beam.RegisterFunction(min{{.Name}}Fn)
-{{- end}}
-}
-
 func findMinFn(t reflect.Type) interface{} {
     switch t.String() {
 {{- range .X}}
diff --git a/sdks/go/pkg/beam/transforms/stats/stats.shims.go 
b/sdks/go/pkg/beam/transforms/stats/stats.shims.go
new file mode 100644
index 00000000000..0fbe6706ec1
--- /dev/null
+++ b/sdks/go/pkg/beam/transforms/stats/stats.shims.go
@@ -0,0 +1,535 @@
+// 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.
+
+// Code generated by starcgen. DO NOT EDIT.
+// File: stats.shims.go
+
+package stats
+
+import (
+       "reflect"
+
+       // Library imports
+       "github.com/apache/beam/sdks/go/pkg/beam/core/runtime"
+       "github.com/apache/beam/sdks/go/pkg/beam/core/typex"
+       "github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx"
+)
+
+func init() {
+       runtime.RegisterFunction(mapFn)
+       runtime.RegisterFunction(maxFloat32Fn)
+       runtime.RegisterFunction(maxFloat64Fn)
+       runtime.RegisterFunction(maxInt16Fn)
+       runtime.RegisterFunction(maxInt32Fn)
+       runtime.RegisterFunction(maxInt64Fn)
+       runtime.RegisterFunction(maxInt8Fn)
+       runtime.RegisterFunction(maxIntFn)
+       runtime.RegisterFunction(maxUint16Fn)
+       runtime.RegisterFunction(maxUint32Fn)
+       runtime.RegisterFunction(maxUint64Fn)
+       runtime.RegisterFunction(maxUint8Fn)
+       runtime.RegisterFunction(maxUintFn)
+       runtime.RegisterFunction(minFloat32Fn)
+       runtime.RegisterFunction(minFloat64Fn)
+       runtime.RegisterFunction(minInt16Fn)
+       runtime.RegisterFunction(minInt32Fn)
+       runtime.RegisterFunction(minInt64Fn)
+       runtime.RegisterFunction(minInt8Fn)
+       runtime.RegisterFunction(minIntFn)
+       runtime.RegisterFunction(minUint16Fn)
+       runtime.RegisterFunction(minUint32Fn)
+       runtime.RegisterFunction(minUint64Fn)
+       runtime.RegisterFunction(minUint8Fn)
+       runtime.RegisterFunction(minUintFn)
+       runtime.RegisterFunction(sumFloat32Fn)
+       runtime.RegisterFunction(sumFloat64Fn)
+       runtime.RegisterFunction(sumInt16Fn)
+       runtime.RegisterFunction(sumInt32Fn)
+       runtime.RegisterFunction(sumInt64Fn)
+       runtime.RegisterFunction(sumInt8Fn)
+       runtime.RegisterFunction(sumIntFn)
+       runtime.RegisterFunction(sumUint16Fn)
+       runtime.RegisterFunction(sumUint32Fn)
+       runtime.RegisterFunction(sumUint64Fn)
+       runtime.RegisterFunction(sumUint8Fn)
+       runtime.RegisterFunction(sumUintFn)
+       runtime.RegisterType(reflect.TypeOf((*meanAccum)(nil)).Elem())
+       runtime.RegisterType(reflect.TypeOf((*meanFn)(nil)).Elem())
+       runtime.RegisterType(reflect.TypeOf((*typex.T)(nil)).Elem())
+       reflectx.RegisterFunc(reflect.TypeOf((*func(float32,float32) 
(float32))(nil)).Elem(), funcMakerFloat32Float32ГFloat32)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(float64,float64) 
(float64))(nil)).Elem(), funcMakerFloat64Float64ГFloat64)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(int16,int16) 
(int16))(nil)).Elem(), funcMakerInt16Int16ГInt16)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(int32,int32) 
(int32))(nil)).Elem(), funcMakerInt32Int32ГInt32)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(int64,int64) 
(int64))(nil)).Elem(), funcMakerInt64Int64ГInt64)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(int8,int8) 
(int8))(nil)).Elem(), funcMakerInt8Int8ГInt8)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(int,int) 
(int))(nil)).Elem(), funcMakerIntIntГInt)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(meanAccum,typex.T) 
(meanAccum))(nil)).Elem(), funcMakerMeanAccumTypex۰TГMeanAccum)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(meanAccum) 
(float64))(nil)).Elem(), funcMakerMeanAccumГFloat64)
+       reflectx.RegisterFunc(reflect.TypeOf((*func([]meanAccum) 
(meanAccum))(nil)).Elem(), funcMakerSliceofMeanAccumГMeanAccum)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(typex.T) 
(typex.T,int))(nil)).Elem(), funcMakerTypex۰TГTypex۰TInt)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(uint16,uint16) 
(uint16))(nil)).Elem(), funcMakerUint16Uint16ГUint16)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(uint32,uint32) 
(uint32))(nil)).Elem(), funcMakerUint32Uint32ГUint32)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(uint64,uint64) 
(uint64))(nil)).Elem(), funcMakerUint64Uint64ГUint64)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(uint8,uint8) 
(uint8))(nil)).Elem(), funcMakerUint8Uint8ГUint8)
+       reflectx.RegisterFunc(reflect.TypeOf((*func(uint,uint) 
(uint))(nil)).Elem(), funcMakerUintUintГUint)
+       reflectx.RegisterFunc(reflect.TypeOf((*func() 
(meanAccum))(nil)).Elem(), funcMakerГMeanAccum)
+}
+
+type callerFloat32Float32ГFloat32 struct {
+       fn func(float32,float32) (float32)
+}
+
+func funcMakerFloat32Float32ГFloat32(fn interface{}) reflectx.Func {
+       f := fn.(func(float32,float32) (float32))
+       return &callerFloat32Float32ГFloat32{fn: f}
+}
+
+func (c *callerFloat32Float32ГFloat32) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerFloat32Float32ГFloat32) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerFloat32Float32ГFloat32) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(float32), args[1].(float32))
+       return []interface{}{out0}
+}
+
+func (c *callerFloat32Float32ГFloat32) Call2x1(arg0, arg1 interface{}) 
(interface{}) {
+       return c.fn(arg0.(float32), arg1.(float32))
+}
+
+type callerFloat64Float64ГFloat64 struct {
+       fn func(float64,float64) (float64)
+}
+
+func funcMakerFloat64Float64ГFloat64(fn interface{}) reflectx.Func {
+       f := fn.(func(float64,float64) (float64))
+       return &callerFloat64Float64ГFloat64{fn: f}
+}
+
+func (c *callerFloat64Float64ГFloat64) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerFloat64Float64ГFloat64) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerFloat64Float64ГFloat64) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(float64), args[1].(float64))
+       return []interface{}{out0}
+}
+
+func (c *callerFloat64Float64ГFloat64) Call2x1(arg0, arg1 interface{}) 
(interface{}) {
+       return c.fn(arg0.(float64), arg1.(float64))
+}
+
+type callerInt16Int16ГInt16 struct {
+       fn func(int16,int16) (int16)
+}
+
+func funcMakerInt16Int16ГInt16(fn interface{}) reflectx.Func {
+       f := fn.(func(int16,int16) (int16))
+       return &callerInt16Int16ГInt16{fn: f}
+}
+
+func (c *callerInt16Int16ГInt16) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerInt16Int16ГInt16) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerInt16Int16ГInt16) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(int16), args[1].(int16))
+       return []interface{}{out0}
+}
+
+func (c *callerInt16Int16ГInt16) Call2x1(arg0, arg1 interface{}) (interface{}) 
{
+       return c.fn(arg0.(int16), arg1.(int16))
+}
+
+type callerInt32Int32ГInt32 struct {
+       fn func(int32,int32) (int32)
+}
+
+func funcMakerInt32Int32ГInt32(fn interface{}) reflectx.Func {
+       f := fn.(func(int32,int32) (int32))
+       return &callerInt32Int32ГInt32{fn: f}
+}
+
+func (c *callerInt32Int32ГInt32) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerInt32Int32ГInt32) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerInt32Int32ГInt32) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(int32), args[1].(int32))
+       return []interface{}{out0}
+}
+
+func (c *callerInt32Int32ГInt32) Call2x1(arg0, arg1 interface{}) (interface{}) 
{
+       return c.fn(arg0.(int32), arg1.(int32))
+}
+
+type callerInt64Int64ГInt64 struct {
+       fn func(int64,int64) (int64)
+}
+
+func funcMakerInt64Int64ГInt64(fn interface{}) reflectx.Func {
+       f := fn.(func(int64,int64) (int64))
+       return &callerInt64Int64ГInt64{fn: f}
+}
+
+func (c *callerInt64Int64ГInt64) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerInt64Int64ГInt64) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerInt64Int64ГInt64) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(int64), args[1].(int64))
+       return []interface{}{out0}
+}
+
+func (c *callerInt64Int64ГInt64) Call2x1(arg0, arg1 interface{}) (interface{}) 
{
+       return c.fn(arg0.(int64), arg1.(int64))
+}
+
+type callerInt8Int8ГInt8 struct {
+       fn func(int8,int8) (int8)
+}
+
+func funcMakerInt8Int8ГInt8(fn interface{}) reflectx.Func {
+       f := fn.(func(int8,int8) (int8))
+       return &callerInt8Int8ГInt8{fn: f}
+}
+
+func (c *callerInt8Int8ГInt8) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerInt8Int8ГInt8) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerInt8Int8ГInt8) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(int8), args[1].(int8))
+       return []interface{}{out0}
+}
+
+func (c *callerInt8Int8ГInt8) Call2x1(arg0, arg1 interface{}) (interface{}) {
+       return c.fn(arg0.(int8), arg1.(int8))
+}
+
+type callerIntIntГInt struct {
+       fn func(int,int) (int)
+}
+
+func funcMakerIntIntГInt(fn interface{}) reflectx.Func {
+       f := fn.(func(int,int) (int))
+       return &callerIntIntГInt{fn: f}
+}
+
+func (c *callerIntIntГInt) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerIntIntГInt) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerIntIntГInt) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(int), args[1].(int))
+       return []interface{}{out0}
+}
+
+func (c *callerIntIntГInt) Call2x1(arg0, arg1 interface{}) (interface{}) {
+       return c.fn(arg0.(int), arg1.(int))
+}
+
+type callerMeanAccumTypex۰TГMeanAccum struct {
+       fn func(meanAccum,typex.T) (meanAccum)
+}
+
+func funcMakerMeanAccumTypex۰TГMeanAccum(fn interface{}) reflectx.Func {
+       f := fn.(func(meanAccum,typex.T) (meanAccum))
+       return &callerMeanAccumTypex۰TГMeanAccum{fn: f}
+}
+
+func (c *callerMeanAccumTypex۰TГMeanAccum) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerMeanAccumTypex۰TГMeanAccum) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerMeanAccumTypex۰TГMeanAccum) Call(args []interface{}) 
[]interface{} {
+       out0 := c.fn(args[0].(meanAccum), args[1].(typex.T))
+       return []interface{}{out0}
+}
+
+func (c *callerMeanAccumTypex۰TГMeanAccum) Call2x1(arg0, arg1 interface{}) 
(interface{}) {
+       return c.fn(arg0.(meanAccum), arg1.(typex.T))
+}
+
+type callerMeanAccumГFloat64 struct {
+       fn func(meanAccum) (float64)
+}
+
+func funcMakerMeanAccumГFloat64(fn interface{}) reflectx.Func {
+       f := fn.(func(meanAccum) (float64))
+       return &callerMeanAccumГFloat64{fn: f}
+}
+
+func (c *callerMeanAccumГFloat64) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerMeanAccumГFloat64) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerMeanAccumГFloat64) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(meanAccum))
+       return []interface{}{out0}
+}
+
+func (c *callerMeanAccumГFloat64) Call1x1(arg0 interface{}) (interface{}) {
+       return c.fn(arg0.(meanAccum))
+}
+
+type callerSliceofMeanAccumГMeanAccum struct {
+       fn func([]meanAccum) (meanAccum)
+}
+
+func funcMakerSliceofMeanAccumГMeanAccum(fn interface{}) reflectx.Func {
+       f := fn.(func([]meanAccum) (meanAccum))
+       return &callerSliceofMeanAccumГMeanAccum{fn: f}
+}
+
+func (c *callerSliceofMeanAccumГMeanAccum) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerSliceofMeanAccumГMeanAccum) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerSliceofMeanAccumГMeanAccum) Call(args []interface{}) 
[]interface{} {
+       out0 := c.fn(args[0].([]meanAccum))
+       return []interface{}{out0}
+}
+
+func (c *callerSliceofMeanAccumГMeanAccum) Call1x1(arg0 interface{}) 
(interface{}) {
+       return c.fn(arg0.([]meanAccum))
+}
+
+type callerTypex۰TГTypex۰TInt struct {
+       fn func(typex.T) (typex.T,int)
+}
+
+func funcMakerTypex۰TГTypex۰TInt(fn interface{}) reflectx.Func {
+       f := fn.(func(typex.T) (typex.T,int))
+       return &callerTypex۰TГTypex۰TInt{fn: f}
+}
+
+func (c *callerTypex۰TГTypex۰TInt) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerTypex۰TГTypex۰TInt) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerTypex۰TГTypex۰TInt) Call(args []interface{}) []interface{} {
+       out0, out1 := c.fn(args[0].(typex.T))
+       return []interface{}{out0, out1}
+}
+
+func (c *callerTypex۰TГTypex۰TInt) Call1x2(arg0 interface{}) (interface{}, 
interface{}) {
+       return c.fn(arg0.(typex.T))
+}
+
+type callerUint16Uint16ГUint16 struct {
+       fn func(uint16,uint16) (uint16)
+}
+
+func funcMakerUint16Uint16ГUint16(fn interface{}) reflectx.Func {
+       f := fn.(func(uint16,uint16) (uint16))
+       return &callerUint16Uint16ГUint16{fn: f}
+}
+
+func (c *callerUint16Uint16ГUint16) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerUint16Uint16ГUint16) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerUint16Uint16ГUint16) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(uint16), args[1].(uint16))
+       return []interface{}{out0}
+}
+
+func (c *callerUint16Uint16ГUint16) Call2x1(arg0, arg1 interface{}) 
(interface{}) {
+       return c.fn(arg0.(uint16), arg1.(uint16))
+}
+
+type callerUint32Uint32ГUint32 struct {
+       fn func(uint32,uint32) (uint32)
+}
+
+func funcMakerUint32Uint32ГUint32(fn interface{}) reflectx.Func {
+       f := fn.(func(uint32,uint32) (uint32))
+       return &callerUint32Uint32ГUint32{fn: f}
+}
+
+func (c *callerUint32Uint32ГUint32) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerUint32Uint32ГUint32) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerUint32Uint32ГUint32) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(uint32), args[1].(uint32))
+       return []interface{}{out0}
+}
+
+func (c *callerUint32Uint32ГUint32) Call2x1(arg0, arg1 interface{}) 
(interface{}) {
+       return c.fn(arg0.(uint32), arg1.(uint32))
+}
+
+type callerUint64Uint64ГUint64 struct {
+       fn func(uint64,uint64) (uint64)
+}
+
+func funcMakerUint64Uint64ГUint64(fn interface{}) reflectx.Func {
+       f := fn.(func(uint64,uint64) (uint64))
+       return &callerUint64Uint64ГUint64{fn: f}
+}
+
+func (c *callerUint64Uint64ГUint64) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerUint64Uint64ГUint64) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerUint64Uint64ГUint64) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(uint64), args[1].(uint64))
+       return []interface{}{out0}
+}
+
+func (c *callerUint64Uint64ГUint64) Call2x1(arg0, arg1 interface{}) 
(interface{}) {
+       return c.fn(arg0.(uint64), arg1.(uint64))
+}
+
+type callerUint8Uint8ГUint8 struct {
+       fn func(uint8,uint8) (uint8)
+}
+
+func funcMakerUint8Uint8ГUint8(fn interface{}) reflectx.Func {
+       f := fn.(func(uint8,uint8) (uint8))
+       return &callerUint8Uint8ГUint8{fn: f}
+}
+
+func (c *callerUint8Uint8ГUint8) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerUint8Uint8ГUint8) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerUint8Uint8ГUint8) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(uint8), args[1].(uint8))
+       return []interface{}{out0}
+}
+
+func (c *callerUint8Uint8ГUint8) Call2x1(arg0, arg1 interface{}) (interface{}) 
{
+       return c.fn(arg0.(uint8), arg1.(uint8))
+}
+
+type callerUintUintГUint struct {
+       fn func(uint,uint) (uint)
+}
+
+func funcMakerUintUintГUint(fn interface{}) reflectx.Func {
+       f := fn.(func(uint,uint) (uint))
+       return &callerUintUintГUint{fn: f}
+}
+
+func (c *callerUintUintГUint) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerUintUintГUint) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerUintUintГUint) Call(args []interface{}) []interface{} {
+       out0 := c.fn(args[0].(uint), args[1].(uint))
+       return []interface{}{out0}
+}
+
+func (c *callerUintUintГUint) Call2x1(arg0, arg1 interface{}) (interface{}) {
+       return c.fn(arg0.(uint), arg1.(uint))
+}
+
+type callerГMeanAccum struct {
+       fn func() (meanAccum)
+}
+
+func funcMakerГMeanAccum(fn interface{}) reflectx.Func {
+       f := fn.(func() (meanAccum))
+       return &callerГMeanAccum{fn: f}
+}
+
+func (c *callerГMeanAccum) Name() string {
+       return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerГMeanAccum) Type() reflect.Type {
+       return reflect.TypeOf(c.fn)
+}
+
+func (c *callerГMeanAccum) Call(args []interface{}) []interface{} {
+       out0 := c.fn()
+       return []interface{}{out0}
+}
+
+func (c *callerГMeanAccum) Call0x1() (interface{}) {
+       return c.fn()
+}
+
+
+
+
+// DO NOT MODIFY: GENERATED CODE
diff --git a/sdks/go/pkg/beam/transforms/stats/sum_switch.go 
b/sdks/go/pkg/beam/transforms/stats/sum_switch.go
index 4c80ec27b97..cfea44a45d2 100644
--- a/sdks/go/pkg/beam/transforms/stats/sum_switch.go
+++ b/sdks/go/pkg/beam/transforms/stats/sum_switch.go
@@ -20,25 +20,8 @@ package stats
 import (
        "fmt"
        "reflect"
-
-       "github.com/apache/beam/sdks/go/pkg/beam"
 )
 
-func init() {
-       beam.RegisterFunction(sumIntFn)
-       beam.RegisterFunction(sumInt8Fn)
-       beam.RegisterFunction(sumInt16Fn)
-       beam.RegisterFunction(sumInt32Fn)
-       beam.RegisterFunction(sumInt64Fn)
-       beam.RegisterFunction(sumUintFn)
-       beam.RegisterFunction(sumUint8Fn)
-       beam.RegisterFunction(sumUint16Fn)
-       beam.RegisterFunction(sumUint32Fn)
-       beam.RegisterFunction(sumUint64Fn)
-       beam.RegisterFunction(sumFloat32Fn)
-       beam.RegisterFunction(sumFloat64Fn)
-}
-
 func findSumFn(t reflect.Type) interface{} {
        switch t.String() {
        case "int":
diff --git a/sdks/go/pkg/beam/transforms/stats/sum_switch.tmpl 
b/sdks/go/pkg/beam/transforms/stats/sum_switch.tmpl
index ddafb95dfb4..e431318a39d 100644
--- a/sdks/go/pkg/beam/transforms/stats/sum_switch.tmpl
+++ b/sdks/go/pkg/beam/transforms/stats/sum_switch.tmpl
@@ -18,16 +18,8 @@ package stats
 import (
     "fmt"
     "reflect"
-
-       "github.com/apache/beam/sdks/go/pkg/beam"
 )
 
-func init() {
-{{- range .X}}
-       beam.RegisterFunction(sum{{.Name}}Fn)
-{{- end}}
-}
-
 func findSumFn(t reflect.Type) interface{} {
     switch t.String() {
 {{- range .X}}
diff --git a/sdks/go/pkg/beam/transforms/stats/util.go 
b/sdks/go/pkg/beam/transforms/stats/util.go
index 970c269f048..87762070b90 100644
--- a/sdks/go/pkg/beam/transforms/stats/util.go
+++ b/sdks/go/pkg/beam/transforms/stats/util.go
@@ -13,6 +13,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+// We use the almost vestigial util_gen.tmpl to be able to similarly generate 
all
+// the same function identifiers more easily for shim generation.
+// The generate statements live here since `go:generate` operates in filename 
order,
+// and this is the last file in the package.
+
+//go:generate specialize --input=util_gen.tmpl --x=integers,floats
+//go:generate gofmt -w util_gen.go
+//go:generate go generate util_gen.go
+
 package stats
 
 import (
diff --git a/sdks/go/pkg/beam/transforms/stats/util_gen.go 
b/sdks/go/pkg/beam/transforms/stats/util_gen.go
new file mode 100644
index 00000000000..d773c0f1a80
--- /dev/null
+++ b/sdks/go/pkg/beam/transforms/stats/util_gen.go
@@ -0,0 +1,20 @@
+// File generated by specialize. Do not edit.
+
+// 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 stats
+
+//go:generate starcgen 
--inputs=count.go,mean.go,max_switch.go,min_switch.go,sum_switch.go 
--identifiers=mapFn,meanFn,maxIntFn,minIntFn,sumIntFn,maxInt8Fn,minInt8Fn,sumInt8Fn,maxInt16Fn,minInt16Fn,sumInt16Fn,maxInt32Fn,minInt32Fn,sumInt32Fn,maxInt64Fn,minInt64Fn,sumInt64Fn,maxUintFn,minUintFn,sumUintFn,maxUint8Fn,minUint8Fn,sumUint8Fn,maxUint16Fn,minUint16Fn,sumUint16Fn,maxUint32Fn,minUint32Fn,sumUint32Fn,maxUint64Fn,minUint64Fn,sumUint64Fn,maxFloat32Fn,minFloat32Fn,sumFloat32Fn,maxFloat64Fn,minFloat64Fn,sumFloat64Fn
diff --git a/sdks/go/pkg/beam/transforms/stats/util_gen.tmpl 
b/sdks/go/pkg/beam/transforms/stats/util_gen.tmpl
new file mode 100644
index 00000000000..398120ab63c
--- /dev/null
+++ b/sdks/go/pkg/beam/transforms/stats/util_gen.tmpl
@@ -0,0 +1,21 @@
+// 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 stats
+
+{{with $x := .X }}
+//go:generate starcgen 
--inputs=count.go,mean.go,max_switch.go,min_switch.go,sum_switch.go 
--identifiers=mapFn,meanFn{{- range $i, $t := $x 
-}},max{{$t.Name}}Fn,min{{$t.Name}}Fn,sum{{$t.Name}}Fn{{- end -}}
+{{end}}
+


 

----------------------------------------------------------------
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: 165120)
    Time Spent: 6h 50m  (was: 6h 40m)

> Make it easy to generate type-specialized Go SDK reflectx.Funcs
> ---------------------------------------------------------------
>
>                 Key: BEAM-3612
>                 URL: https://issues.apache.org/jira/browse/BEAM-3612
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-go
>            Reporter: Henning Rohde
>            Assignee: Robert Burke
>            Priority: Major
>          Time Spent: 6h 50m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to