-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Expand file tree
/
Copy pathbeam.shims.go
More file actions
347 lines (280 loc) · 9.87 KB
/
beam.shims.go
File metadata and controls
347 lines (280 loc) · 9.87 KB
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
// 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/sdf"
"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((*T)(nil)).Elem())
schema.RegisterType(reflect.TypeOf((*T)(nil)).Elem())
runtime.RegisterType(reflect.TypeOf((*X)(nil)).Elem())
schema.RegisterType(reflect.TypeOf((*X)(nil)).Elem())
runtime.RegisterType(reflect.TypeOf((*Y)(nil)).Elem())
schema.RegisterType(reflect.TypeOf((*Y)(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.RegisterFunc(reflect.TypeOf((*func(reflect.Type, []byte) (T, error))(nil)).Elem(), funcMakerReflect۰TypeSliceOfByteГTError)
reflectx.RegisterFunc(reflect.TypeOf((*func(reflect.Type, T) ([]byte, error))(nil)).Elem(), funcMakerReflect۰TypeTГSliceOfByteError)
reflectx.RegisterFunc(reflect.TypeOf((*func([]T, func(T)))(nil)).Elem(), funcMakerSliceOfTEmitTГ)
reflectx.RegisterFunc(reflect.TypeOf((*func(string, reflect.Type, []byte) reflectx.Func)(nil)).Elem(), funcMakerStringReflect۰TypeSliceOfByteГReflectx۰Func)
reflectx.RegisterFunc(reflect.TypeOf((*func(T) (int, T))(nil)).Elem(), funcMakerTГIntT)
reflectx.RegisterFunc(reflect.TypeOf((*func(T) ([]byte, error))(nil)).Elem(), funcMakerTГSliceOfByteError)
reflectx.RegisterFunc(reflect.TypeOf((*func(X, Y) X)(nil)).Elem(), funcMakerXYГX)
reflectx.RegisterFunc(reflect.TypeOf((*func(X, Y) Y)(nil)).Elem(), funcMakerXYГY)
reflectx.RegisterFunc(reflect.TypeOf((*func(X, Y) (Y, X))(nil)).Elem(), funcMakerXYГYX)
exec.RegisterEmitter(reflect.TypeOf((*func(T))(nil)).Elem(), emitMakerT)
}
type callerReflect۰TypeSliceOfByteГTError struct {
fn func(reflect.Type, []byte) (T, error)
}
func funcMakerReflect۰TypeSliceOfByteГTError(fn any) reflectx.Func {
f := fn.(func(reflect.Type, []byte) (T, error))
return &callerReflect۰TypeSliceOfByteГTError{fn: f}
}
func (c *callerReflect۰TypeSliceOfByteГTError) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerReflect۰TypeSliceOfByteГTError) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerReflect۰TypeSliceOfByteГTError) Call(args []any) []any {
out0, out1 := c.fn(args[0].(reflect.Type), args[1].([]byte))
return []any{out0, out1}
}
func (c *callerReflect۰TypeSliceOfByteГTError) Call2x2(arg0, arg1 any) (any, any) {
return c.fn(arg0.(reflect.Type), arg1.([]byte))
}
type callerReflect۰TypeTГSliceOfByteError struct {
fn func(reflect.Type, T) ([]byte, error)
}
func funcMakerReflect۰TypeTГSliceOfByteError(fn any) reflectx.Func {
f := fn.(func(reflect.Type, T) ([]byte, error))
return &callerReflect۰TypeTГSliceOfByteError{fn: f}
}
func (c *callerReflect۰TypeTГSliceOfByteError) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerReflect۰TypeTГSliceOfByteError) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerReflect۰TypeTГSliceOfByteError) Call(args []any) []any {
out0, out1 := c.fn(args[0].(reflect.Type), args[1].(T))
return []any{out0, out1}
}
func (c *callerReflect۰TypeTГSliceOfByteError) Call2x2(arg0, arg1 any) (any, any) {
return c.fn(arg0.(reflect.Type), arg1.(T))
}
type callerSliceOfTEmitTГ struct {
fn func([]T, func(T))
}
func funcMakerSliceOfTEmitTГ(fn any) reflectx.Func {
f := fn.(func([]T, func(T)))
return &callerSliceOfTEmitTГ{fn: f}
}
func (c *callerSliceOfTEmitTГ) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerSliceOfTEmitTГ) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerSliceOfTEmitTГ) Call(args []any) []any {
c.fn(args[0].([]T), args[1].(func(T)))
return []any{}
}
func (c *callerSliceOfTEmitTГ) Call2x0(arg0, arg1 any) {
c.fn(arg0.([]T), arg1.(func(T)))
}
type callerStringReflect۰TypeSliceOfByteГReflectx۰Func struct {
fn func(string, reflect.Type, []byte) reflectx.Func
}
func funcMakerStringReflect۰TypeSliceOfByteГReflectx۰Func(fn any) 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 []any) []any {
out0 := c.fn(args[0].(string), args[1].(reflect.Type), args[2].([]byte))
return []any{out0}
}
func (c *callerStringReflect۰TypeSliceOfByteГReflectx۰Func) Call3x1(arg0, arg1, arg2 any) any {
return c.fn(arg0.(string), arg1.(reflect.Type), arg2.([]byte))
}
type callerTГIntT struct {
fn func(T) (int, T)
}
func funcMakerTГIntT(fn any) reflectx.Func {
f := fn.(func(T) (int, T))
return &callerTГIntT{fn: f}
}
func (c *callerTГIntT) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerTГIntT) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerTГIntT) Call(args []any) []any {
out0, out1 := c.fn(args[0].(T))
return []any{out0, out1}
}
func (c *callerTГIntT) Call1x2(arg0 any) (any, any) {
return c.fn(arg0.(T))
}
type callerTГSliceOfByteError struct {
fn func(T) ([]byte, error)
}
func funcMakerTГSliceOfByteError(fn any) reflectx.Func {
f := fn.(func(T) ([]byte, error))
return &callerTГSliceOfByteError{fn: f}
}
func (c *callerTГSliceOfByteError) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerTГSliceOfByteError) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerTГSliceOfByteError) Call(args []any) []any {
out0, out1 := c.fn(args[0].(T))
return []any{out0, out1}
}
func (c *callerTГSliceOfByteError) Call1x2(arg0 any) (any, any) {
return c.fn(arg0.(T))
}
type callerXYГX struct {
fn func(X, Y) X
}
func funcMakerXYГX(fn any) reflectx.Func {
f := fn.(func(X, Y) X)
return &callerXYГX{fn: f}
}
func (c *callerXYГX) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerXYГX) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerXYГX) Call(args []any) []any {
out0 := c.fn(args[0].(X), args[1].(Y))
return []any{out0}
}
func (c *callerXYГX) Call2x1(arg0, arg1 any) any {
return c.fn(arg0.(X), arg1.(Y))
}
type callerXYГY struct {
fn func(X, Y) Y
}
func funcMakerXYГY(fn any) reflectx.Func {
f := fn.(func(X, Y) Y)
return &callerXYГY{fn: f}
}
func (c *callerXYГY) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerXYГY) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerXYГY) Call(args []any) []any {
out0 := c.fn(args[0].(X), args[1].(Y))
return []any{out0}
}
func (c *callerXYГY) Call2x1(arg0, arg1 any) any {
return c.fn(arg0.(X), arg1.(Y))
}
type callerXYГYX struct {
fn func(X, Y) (Y, X)
}
func funcMakerXYГYX(fn any) reflectx.Func {
f := fn.(func(X, Y) (Y, X))
return &callerXYГYX{fn: f}
}
func (c *callerXYГYX) Name() string {
return reflectx.FunctionName(c.fn)
}
func (c *callerXYГYX) Type() reflect.Type {
return reflect.TypeOf(c.fn)
}
func (c *callerXYГYX) Call(args []any) []any {
out0, out1 := c.fn(args[0].(X), args[1].(Y))
return []any{out0, out1}
}
func (c *callerXYГYX) Call2x2(arg0, arg1 any) (any, any) {
return c.fn(arg0.(X), arg1.(Y))
}
type emitNative struct {
n exec.ElementProcessor
fn any
est *sdf.WatermarkEstimator
ctx context.Context
pn typex.PaneInfo
ws []typex.Window
et typex.EventTime
value exec.FullValue
}
func (e *emitNative) Init(ctx context.Context, pn typex.PaneInfo, ws []typex.Window, et typex.EventTime) error {
e.ctx = ctx
e.pn = pn
e.ws = ws
e.et = et
return nil
}
func (e *emitNative) Value() any {
return e.fn
}
func (e *emitNative) AttachEstimator(est *sdf.WatermarkEstimator) {
e.est = est
}
func emitMakerT(n exec.ElementProcessor) exec.ReusableEmitter {
ret := &emitNative{n: n}
ret.fn = ret.invokeT
return ret
}
func (e *emitNative) invokeT(val T) {
e.value = exec.FullValue{Pane: e.pn, Windows: e.ws, Timestamp: e.et, Elm: val}
if e.est != nil {
(*e.est).(sdf.TimestampObservingEstimator).ObserveTimestamp(e.et.ToTime())
}
if err := e.n.ProcessElement(e.ctx, &e.value); err != nil {
panic(err)
}
}
// DO NOT MODIFY: GENERATED CODE