/
beam.shims.go
367 lines (294 loc) · 12.4 KB
/
beam.shims.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
// 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: beam.shims.go
package beam
import (
"context"
"reflect"
// Library imports
"github.com/apache/beam/sdks/v2/go/pkg/beam/core/runtime"
"github.com/apache/beam/sdks/v2/go/pkg/beam/core/runtime/exec"
"github.com/apache/beam/sdks/v2/go/pkg/beam/core/runtime/graphx/schema"
"github.com/apache/beam/sdks/v2/go/pkg/beam/core/typex"
"github.com/apache/beam/sdks/v2/go/pkg/beam/core/util/reflectx"
)
func init() {
runtime.RegisterFunction(addFixedKeyFn)
runtime.RegisterFunction(dropKeyFn)
runtime.RegisterFunction(dropValueFn)
runtime.RegisterFunction(explodeFn)
runtime.RegisterFunction(jsonDec)
runtime.RegisterFunction(jsonEnc)
runtime.RegisterFunction(makePartitionFn)
runtime.RegisterFunction(protoDec)
runtime.RegisterFunction(protoEnc)
runtime.RegisterFunction(schemaDec)
runtime.RegisterFunction(schemaEnc)
runtime.RegisterFunction(swapKVFn)
runtime.RegisterType(reflect.TypeOf((*createFn)(nil)).Elem())
schema.RegisterType(reflect.TypeOf((*createFn)(nil)).Elem())
runtime.RegisterType(reflect.TypeOf((*reflect.Type)(nil)).Elem())
schema.RegisterType(reflect.TypeOf((*reflect.Type)(nil)).Elem())
runtime.RegisterType(reflect.TypeOf((*reflectx.Func)(nil)).Elem())
schema.RegisterType(reflect.TypeOf((*reflectx.Func)(nil)).Elem())
reflectx.RegisterStructWrapper(reflect.TypeOf((*createFn)(nil)).Elem(), wrapMakerCreateFn)
reflectx.RegisterFunc(reflect.TypeOf((*func(reflect.Type, []byte) (typex.T, error))(nil)).Elem(), funcMakerReflect۰TypeSliceOfByteГTypex۰TError)
reflectx.RegisterFunc(reflect.TypeOf((*func(reflect.Type, typex.T) ([]byte, error))(nil)).Elem(), funcMakerReflect۰TypeTypex۰TГSliceOfByteError)
reflectx.RegisterFunc(reflect.TypeOf((*func([]byte, func(typex.T)) error)(nil)).Elem(), funcMakerSliceOfByteEmitTypex۰TГError)
reflectx.RegisterFunc(reflect.TypeOf((*func([]typex.T, func(typex.T)))(nil)).Elem(), funcMakerSliceOfTypex۰TEmitTypex۰TГ)
reflectx.RegisterFunc(reflect.TypeOf((*func(string, reflect.Type, []byte) reflectx.Func)(nil)).Elem(), funcMakerStringReflect۰TypeSliceOfByteГReflectx۰Func)
reflectx.RegisterFunc(reflect.TypeOf((*func(typex.T) (int, typex.T))(nil)).Elem(), funcMakerTypex۰TГIntTypex۰T)
reflectx.RegisterFunc(reflect.TypeOf((*func(typex.T) ([]byte, error))(nil)).Elem(), funcMakerTypex۰TГSliceOfByteError)
reflectx.RegisterFunc(reflect.TypeOf((*func(typex.X, typex.Y) typex.X)(nil)).Elem(), funcMakerTypex۰XTypex۰YГTypex۰X)
reflectx.RegisterFunc(reflect.TypeOf((*func(typex.X, typex.Y) typex.Y)(nil)).Elem(), funcMakerTypex۰XTypex۰YГTypex۰Y)
reflectx.RegisterFunc(reflect.TypeOf((*func(typex.X, typex.Y) (typex.Y, typex.X))(nil)).Elem(), funcMakerTypex۰XTypex۰YГTypex۰YTypex۰X)
exec.RegisterEmitter(reflect.TypeOf((*func(typex.T))(nil)).Elem(), emitMakerTypex۰T)
}
func wrapMakerCreateFn(fn interface{}) map[string]reflectx.Func {
dfn := fn.(*createFn)
return map[string]reflectx.Func{
"ProcessElement": reflectx.MakeFunc(func(a0 []byte, a1 func(typex.T)) error { return dfn.ProcessElement(a0, a1) }),
}
}
type callerReflect۰TypeSliceOfByteГTypex۰TError struct {
fn func(reflect.Type, []byte) (typex.T, error)
}
func funcMakerReflect۰TypeSliceOfByteГTypex۰TError(fn interface{}) reflectx.Func {
f := fn.(func(reflect.Type, []byte) (typex.T, error))
return &callerReflect۰TypeSliceOfByteГTypex۰TError{fn: f}
}
func (c *callerReflect۰TypeSliceOfByteГTypex۰TError) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerReflect۰TypeSliceOfByteГTypex۰TError) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerReflect۰TypeSliceOfByteГTypex۰TError) Call(args []interface{}) []interface{} {
out0, out1 := c.fn(args[0].(reflect.Type), args[1].([]byte))
return []interface{}{out0, out1}
}
func (c *callerReflect۰TypeSliceOfByteГTypex۰TError) Call2x2(arg0, arg1 interface{}) (interface{}, interface{}) {
return c.fn(arg0.(reflect.Type), arg1.([]byte))
}
type callerReflect۰TypeTypex۰TГSliceOfByteError struct {
fn func(reflect.Type, typex.T) ([]byte, error)
}
func funcMakerReflect۰TypeTypex۰TГSliceOfByteError(fn interface{}) reflectx.Func {
f := fn.(func(reflect.Type, typex.T) ([]byte, error))
return &callerReflect۰TypeTypex۰TГSliceOfByteError{fn: f}
}
func (c *callerReflect۰TypeTypex۰TГSliceOfByteError) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerReflect۰TypeTypex۰TГSliceOfByteError) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerReflect۰TypeTypex۰TГSliceOfByteError) Call(args []interface{}) []interface{} {
out0, out1 := c.fn(args[0].(reflect.Type), args[1].(typex.T))
return []interface{}{out0, out1}
}
func (c *callerReflect۰TypeTypex۰TГSliceOfByteError) Call2x2(arg0, arg1 interface{}) (interface{}, interface{}) {
return c.fn(arg0.(reflect.Type), arg1.(typex.T))
}
type callerSliceOfByteEmitTypex۰TГError struct {
fn func([]byte, func(typex.T)) error
}
func funcMakerSliceOfByteEmitTypex۰TГError(fn interface{}) reflectx.Func {
f := fn.(func([]byte, func(typex.T)) error)
return &callerSliceOfByteEmitTypex۰TГError{fn: f}
}
func (c *callerSliceOfByteEmitTypex۰TГError) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerSliceOfByteEmitTypex۰TГError) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerSliceOfByteEmitTypex۰TГError) Call(args []interface{}) []interface{} {
out0 := c.fn(args[0].([]byte), args[1].(func(typex.T)))
return []interface{}{out0}
}
func (c *callerSliceOfByteEmitTypex۰TГError) Call2x1(arg0, arg1 interface{}) interface{} {
return c.fn(arg0.([]byte), arg1.(func(typex.T)))
}
type callerSliceOfTypex۰TEmitTypex۰TГ struct {
fn func([]typex.T, func(typex.T))
}
func funcMakerSliceOfTypex۰TEmitTypex۰TГ(fn interface{}) reflectx.Func {
f := fn.(func([]typex.T, func(typex.T)))
return &callerSliceOfTypex۰TEmitTypex۰TГ{fn: f}
}
func (c *callerSliceOfTypex۰TEmitTypex۰TГ) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerSliceOfTypex۰TEmitTypex۰TГ) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerSliceOfTypex۰TEmitTypex۰TГ) Call(args []interface{}) []interface{} {
c.fn(args[0].([]typex.T), args[1].(func(typex.T)))
return []interface{}{}
}
func (c *callerSliceOfTypex۰TEmitTypex۰TГ) Call2x0(arg0, arg1 interface{}) {
c.fn(arg0.([]typex.T), arg1.(func(typex.T)))
}
type callerStringReflect۰TypeSliceOfByteГReflectx۰Func struct {
fn func(string, reflect.Type, []byte) reflectx.Func
}
func funcMakerStringReflect۰TypeSliceOfByteГReflectx۰Func(fn interface{}) reflectx.Func {
f := fn.(func(string, reflect.Type, []byte) reflectx.Func)
return &callerStringReflect۰TypeSliceOfByteГReflectx۰Func{fn: f}
}
func (c *callerStringReflect۰TypeSliceOfByteГReflectx۰Func) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerStringReflect۰TypeSliceOfByteГReflectx۰Func) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerStringReflect۰TypeSliceOfByteГReflectx۰Func) Call(args []interface{}) []interface{} {
out0 := c.fn(args[0].(string), args[1].(reflect.Type), args[2].([]byte))
return []interface{}{out0}
}
func (c *callerStringReflect۰TypeSliceOfByteГReflectx۰Func) Call3x1(arg0, arg1, arg2 interface{}) interface{} {
return c.fn(arg0.(string), arg1.(reflect.Type), arg2.([]byte))
}
type callerTypex۰TГIntTypex۰T struct {
fn func(typex.T) (int, typex.T)
}
func funcMakerTypex۰TГIntTypex۰T(fn interface{}) reflectx.Func {
f := fn.(func(typex.T) (int, typex.T))
return &callerTypex۰TГIntTypex۰T{fn: f}
}
func (c *callerTypex۰TГIntTypex۰T) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerTypex۰TГIntTypex۰T) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerTypex۰TГIntTypex۰T) Call(args []interface{}) []interface{} {
out0, out1 := c.fn(args[0].(typex.T))
return []interface{}{out0, out1}
}
func (c *callerTypex۰TГIntTypex۰T) Call1x2(arg0 interface{}) (interface{}, interface{}) {
return c.fn(arg0.(typex.T))
}
type callerTypex۰TГSliceOfByteError struct {
fn func(typex.T) ([]byte, error)
}
func funcMakerTypex۰TГSliceOfByteError(fn interface{}) reflectx.Func {
f := fn.(func(typex.T) ([]byte, error))
return &callerTypex۰TГSliceOfByteError{fn: f}
}
func (c *callerTypex۰TГSliceOfByteError) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerTypex۰TГSliceOfByteError) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerTypex۰TГSliceOfByteError) Call(args []interface{}) []interface{} {
out0, out1 := c.fn(args[0].(typex.T))
return []interface{}{out0, out1}
}
func (c *callerTypex۰TГSliceOfByteError) Call1x2(arg0 interface{}) (interface{}, interface{}) {
return c.fn(arg0.(typex.T))
}
type callerTypex۰XTypex۰YГTypex۰X struct {
fn func(typex.X, typex.Y) typex.X
}
func funcMakerTypex۰XTypex۰YГTypex۰X(fn interface{}) reflectx.Func {
f := fn.(func(typex.X, typex.Y) typex.X)
return &callerTypex۰XTypex۰YГTypex۰X{fn: f}
}
func (c *callerTypex۰XTypex۰YГTypex۰X) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerTypex۰XTypex۰YГTypex۰X) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerTypex۰XTypex۰YГTypex۰X) Call(args []interface{}) []interface{} {
out0 := c.fn(args[0].(typex.X), args[1].(typex.Y))
return []interface{}{out0}
}
func (c *callerTypex۰XTypex۰YГTypex۰X) Call2x1(arg0, arg1 interface{}) interface{} {
return c.fn(arg0.(typex.X), arg1.(typex.Y))
}
type callerTypex۰XTypex۰YГTypex۰Y struct {
fn func(typex.X, typex.Y) typex.Y
}
func funcMakerTypex۰XTypex۰YГTypex۰Y(fn interface{}) reflectx.Func {
f := fn.(func(typex.X, typex.Y) typex.Y)
return &callerTypex۰XTypex۰YГTypex۰Y{fn: f}
}
func (c *callerTypex۰XTypex۰YГTypex۰Y) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerTypex۰XTypex۰YГTypex۰Y) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerTypex۰XTypex۰YГTypex۰Y) Call(args []interface{}) []interface{} {
out0 := c.fn(args[0].(typex.X), args[1].(typex.Y))
return []interface{}{out0}
}
func (c *callerTypex۰XTypex۰YГTypex۰Y) Call2x1(arg0, arg1 interface{}) interface{} {
return c.fn(arg0.(typex.X), arg1.(typex.Y))
}
type callerTypex۰XTypex۰YГTypex۰YTypex۰X struct {
fn func(typex.X, typex.Y) (typex.Y, typex.X)
}
func funcMakerTypex۰XTypex۰YГTypex۰YTypex۰X(fn interface{}) reflectx.Func {
f := fn.(func(typex.X, typex.Y) (typex.Y, typex.X))
return &callerTypex۰XTypex۰YГTypex۰YTypex۰X{fn: f}
}
func (c *callerTypex۰XTypex۰YГTypex۰YTypex۰X) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerTypex۰XTypex۰YГTypex۰YTypex۰X) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerTypex۰XTypex۰YГTypex۰YTypex۰X) Call(args []interface{}) []interface{} {
out0, out1 := c.fn(args[0].(typex.X), args[1].(typex.Y))
return []interface{}{out0, out1}
}
func (c *callerTypex۰XTypex۰YГTypex۰YTypex۰X) Call2x2(arg0, arg1 interface{}) (interface{}, interface{}) {
return c.fn(arg0.(typex.X), arg1.(typex.Y))
}
type emitNative struct {
n exec.ElementProcessor
fn interface{}
ctx context.Context
ws []typex.Window
et typex.EventTime
value exec.FullValue
}
func (e *emitNative) Init(ctx context.Context, ws []typex.Window, et typex.EventTime) error {
e.ctx = ctx
e.ws = ws
e.et = et
return nil
}
func (e *emitNative) Value() interface{} {
return e.fn
}
func emitMakerTypex۰T(n exec.ElementProcessor) exec.ReusableEmitter {
ret := &emitNative{n: n}
ret.fn = ret.invokeTypex۰T
return ret
}
func (e *emitNative) invokeTypex۰T(val typex.T) {
e.value = exec.FullValue{Windows: e.ws, Timestamp: e.et, Elm: val}
if err := e.n.ProcessElement(e.ctx, &e.value); err != nil {
panic(err)
}
}
// DO NOT MODIFY: GENERATED CODE