[
https://issues.apache.org/jira/browse/BEAM-5421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16619376#comment-16619376
]
Vadym commented on BEAM-5421:
-----------------------------
You are a rockstar for finding time to answer!
Alas, it does not work after registering the function:
{code:java}
package main
import (
"context"
"github.com/apache/beam/sdks/go/pkg/beam"
"github.com/apache/beam/sdks/go/pkg/beam/io/textio"
"github.com/apache/beam/sdks/go/pkg/beam/log"
"github.com/apache/beam/sdks/go/pkg/beam/transforms/filter"
"github.com/apache/beam/sdks/go/pkg/beam/x/beamx"
)
func isShortWord(s string) bool {
return len(s) < 3
}
func init() {
beam.RegisterFunction(isShortWord)
}
func main() {
beam.Init()
ctx := context.Background()
p, s := beam.NewPipelineWithRoot()
words := beam.Create(s, "a", "b", "long", "alsolong")
long := filter.Exclude(s, words, isShortWord)
textio.Write(s, "long.txt", long)
if err := beamx.Run(ctx, p); err != nil {
log.Exitf(ctx, "Failed to execute job: %v", err)
}
}
{code}
Here is the full stack dump:
{{2018/09/18 09:43:50 Pipeline:}}
{{2018/09/18 09:43:50 Nodes: \{1: []uint8/bytes GLO}}}
{{{2: string/bytes GLO}}}
{{{3: string/bytes GLO}}}
{{{4: KV<int,string>/KV<int[varintz],bytes> GLO}}}
{{{5: CoGBK<int,string>/CoGBK<int[varintz],bytes> GLO}}}
{{Edges: 1: Impulse [] -> [Out: []uint8 -> \{1: []uint8/bytes GLO}]}}
{{2: ParDo [In(Main): []uint8 <- \{1: []uint8/bytes GLO}] -> [Out: T -> \{2:
string/bytes GLO}]}}
{{3: ParDo [In(Main): T <- \{2: string/bytes GLO}] -> [Out: T -> \{3:
string/bytes GLO}]}}
{{4: ParDo [In(Main): T <- \{3: string/bytes GLO}] -> [Out: KV<int,T> -> \{4:
KV<int,string>/KV<int[varintz],bytes> GLO}]}}
{{5: CoGBK [In(Main): KV<int,string> <- \{4:
KV<int,string>/KV<int[varintz],bytes> GLO}] -> [Out: CoGBK<int,string> -> \{5:
CoGBK<int,string>/CoGBK<int[varintz],bytes> GLO}]}}
{{6: ParDo [In(Main): CoGBK<int,string> <- \{5:
CoGBK<int,string>/CoGBK<int[varintz],bytes> GLO}] -> []}}
{{2018/09/18 09:43:50 Plan[plan]:}}
{{7: Impulse[0]}}
{{1: ParDo[textio.writeFileFn] Out:[]}}
{{2: CoGBK. Out:1}}
{{3: Inject[0]. Out:2}}
{{4: ParDo[beam.addFixedKeyFn] Out:[3]}}
{{5: ParDo[filter.filterFn] Out:[4]}}
{{6: ParDo[beam.createFn] Out:[5]}}
{{2018/09/18 09:43:50 Failed to execute job: panic: reflect: Call using []uint8
as type string goroutine 1 [running]:}}
{{runtime/debug.Stack(0xc0002d83b8, 0x1865f80, 0xc0002218a0)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/runtime/debug/stack.go:24 +0xa7}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec.callNoPanic.func1(0xc0002d9c30)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/util.go:39
+0x6e}}
{{panic(0x1865f80, 0xc0002218a0)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 +0x1b9}}
{{reflect.Value.call(0x188e7a0, 0x1a1e920, 0x13, 0x19ebfd4, 0x4, 0xc0000cd980,
0x1, 0x1, 0x1, 0x1857340, ...)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/reflect/value.go:377 +0x1435}}
{{reflect.Value.Call(0x188e7a0, 0x1a1e920, 0x13, 0xc0000cd980, 0x1, 0x1,
0x186eb80, 0x1, 0xc000221890)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/reflect/value.go:308 +0xa4}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx.(*reflectFunc).Call(0xc0000ccce0,
0xc000221890, 0x1, 0x1, 0xc000304810, 0x1, 0xc0000cd960)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx/call.go:92
+0x66}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx.(*shimFunc1x1).Call1x1(0xc0002217c0,
0x1857340, 0xc0000cd8e0, 0x1071296, 0x18662c0)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx/calls.go:258
+0x7d}}
{{github.com/apache/beam/sdks/go/pkg/beam/transforms/filter.(*filterFn).ProcessElement(0xc000157920,
0x1857340, 0xc0000cd8e0, 0xc0002217d0)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/transforms/filter/filter.go:86
+0x4c}}
{{reflect.callMethod(0xc000157aa0, 0xc0002d8970)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/reflect/value.go:663 +0x180}}
{{reflect.methodValueCall(0x1857340, 0xc0000cd8e0, 0xc0002217d0, 0xc0000cd900,
0xc0002d8c58, 0x10b5859, 0xc000157a10, 0xc000157aa0, 0xc0000cd900,
0x1800000018, ...)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/reflect/asm_amd64.s:29 +0x33}}
{{reflect.Value.call(0x1883820, 0xc000157aa0, 0x13, 0x19ebfd4, 0x4,
0xc0003047e0, 0x2, 0x2, 0x2, 0x1863e00, ...)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/reflect/value.go:447 +0x449}}
{{reflect.Value.Call(0x1883820, 0xc000157aa0, 0x13, 0xc0003047e0, 0x2, 0x2,
0x0, 0x0, 0x0)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/reflect/value.go:308 +0xa4}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx.(*reflectFunc).Call(0xc0000ccd80,
0xc0000cd7e0, 0x2, 0x2, 0x1857340, 0xc0000cd8e0, 0x1)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx/call.go:92
+0x66}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec.(*invoker).Invoke(0xc00015a600,
0x1aabf40, 0xc000304690, 0x2185c60, 0x1, 0x1, 0x165ed910b7c, 0xc0002d9010,
0xc000221850, 0x1, ...)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/fn.go:150
+0x1d6}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec.(*ParDo).invokeProcessFn(0xc0003025b0,
0x1aabf40, 0xc000304690, 0x2185c60, 0x1, 0x1, 0x165ed910b7c, 0xc0002d9010,
0x1, 0x1003f00, ...)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/pardo.go:261
+0x12b}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec.(*ParDo).ProcessElement(0xc0003025b0,
0x1aabf40, 0xc000304660, 0x1857340, 0xc0000cd8e0, 0x0, 0x0, 0x165ed910b7c,
0x2185c60, 0x1, ...)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/pardo.go:113
+0x552}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/optimized.(*emitNative).invokeTypex_T(0xc0000d0d70,
0x1857340, 0xc0000cd8e0)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/optimized/emitters.go:10041
+0x10f}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/optimized.(*emitNative).invokeTypex_T-fm(0x1857340,
0xc0000cd8e0)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/optimized/emitters.go:10035
+0x3e}}
{{github.com/apache/beam/sdks/go/pkg/beam.(*createFn).ProcessElement(0xc0000ccae0,
0x21b9dd8, 0x0, 0x0, 0xc0002217f0, 0x0, 0x0)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/create.go:102
+0x1f1}}
{{reflect.callMethod(0xc000157740, 0xc0002d93b8)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/reflect/value.go:663 +0x180}}
{{reflect.methodValueCall(0x21b9dd8, 0x0, 0x0, 0xc0002217f0, 0x0, 0x0,
0xc000304750, 0xc0000cd880, 0xc0002d96c0, 0x10b5859, ...)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/reflect/asm_amd64.s:29 +0x33}}
{{reflect.Value.call(0x18a99a0, 0xc000157740, 0x13, 0x19ebfd4, 0x4,
0xc000304720, 0x2, 0x2, 0x2, 0x1863e00, ...)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/reflect/value.go:447 +0x449}}
{{reflect.Value.Call(0x18a99a0, 0xc000157740, 0x13, 0xc000304720, 0x2, 0x2,
0x0, 0x0, 0x0)}}
{{ /usr/local/Cellar/go/1.11/libexec/src/reflect/value.go:308 +0xa4}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx.(*reflectFunc).Call(0xc0000ccc00,
0xc0000cd860, 0x2, 0x2, 0x1857340, 0xc0000cd880, 0x1)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx/call.go:92
+0x66}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec.(*invoker).Invoke(0xc00015a700,
0x1aabf40, 0xc000304660, 0x2185c60, 0x1, 0x1, 0x165ed910b7c, 0xc0002d9a78,
0xc000221810, 0x1, ...)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/fn.go:150
+0x1d6}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec.(*ParDo).invokeProcessFn(0xc000302680,
0x1aabf40, 0xc000304660, 0x2185c60, 0x1, 0x1, 0x165ed910b7c, 0xc0002d9a78,
0x1, 0x0, ...)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/pardo.go:261
+0x12b}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec.(*ParDo).ProcessElement(0xc000302680,
0x1aabf40, 0xc000304540, 0x1857340, 0xc0000cd880, 0x0, 0x0, 0x165ed910b7c,
0x2185c60, 0x1, ...)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/pardo.go:113
+0x552}}
{{github.com/apache/beam/sdks/go/pkg/beam/runners/direct.(*Impulse).Process(0xc000304510,
0x1aabf40, 0xc000304540, 0x0, 0xc0002d9bf0)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/runners/direct/impulse.go:52
+0x146}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec.Root.Process-fm(0x1aabf40,
0xc000304540, 0xc0002d9c30, 0x0)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/plan.go:112
+0x43}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec.callNoPanic(0x1aabf40,
0xc000304540, 0xc0002d9cb0, 0x0, 0x0)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/util.go:42
+0x6c}}
{{github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec.(*Plan).Execute(0xc0002275e0,
0x1aabd00, 0xc000304540, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc000304090, ...)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/core/runtime/exec/plan.go:112
+0x3fa}}
{{github.com/apache/beam/sdks/go/pkg/beam/runners/direct.Execute(0x1aabd00,
0xc0000b8008, 0xc0000c60c0, 0x6, 0xc0001a78f0)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/runners/direct/direct.go:52
+0x2fe}}
{{github.com/apache/beam/sdks/go/pkg/beam.Run(0x1aabd00, 0xc0000b8008,
0x19eda97, 0x6, 0xc0000c60c0, 0xc0000ccf00, 0xc000304090)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/runner.go:50
+0x8e}}
{{github.com/apache/beam/sdks/go/pkg/beam/x/beamx.Run(0x1aabd00, 0xc0000b8008,
0xc0000c60c0, 0x8, 0xc000157ce0)}}
{{
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/x/beamx/run.go:42
+0x57}}
{{main.main()}}
{{
/Users/vadym.tyemirov/Documents/Development/src/algoIO/beam/nyctaxi/scracthpad.go:31
+0x226}}
{{exit status 1}}
> filter.Exclude is panicking
> ---------------------------
>
> Key: BEAM-5421
> URL: https://issues.apache.org/jira/browse/BEAM-5421
> Project: Beam
> Issue Type: Bug
> Components: sdk-go
> Affects Versions: 2.6.0
> Environment: Mac, Linux
> Reporter: Vadym
> Assignee: Robert Burke
> Priority: Major
>
> {code:java}
> package main
> import (
> "context"
> "github.com/apache/beam/sdks/go/pkg/beam"
> "github.com/apache/beam/sdks/go/pkg/beam/io/textio"
> "github.com/apache/beam/sdks/go/pkg/beam/log"
> "github.com/apache/beam/sdks/go/pkg/beam/transforms/filter"
> "github.com/apache/beam/sdks/go/pkg/beam/x/beamx"
> )
> func islongWord(s string) bool {
> return len(s) < 3
> }
> func main() {
> beam.Init()
> ctx := context.Background()
> p, s := beam.NewPipelineWithRoot()
> words := beam.Create(s, "a", "b", "long", "alsolong")
> long := filter.Exclude(s, words, islongWord)
> textio.Write(s, "long.txt", long)
> if err := beamx.Run(ctx, p); err != nil {
> log.Exitf(ctx, "Failed to execute job: %v", err)
> }
> }
> {code}
> The code above fails with the error message:
> {{2018/09/18 15:47:23 Failed to execute job: panic: reflect: Call using
> []uint8 as type string goroutine 1 [running]:}}
>
> The code was taken from Exclude example in the documentation:
> https://godoc.org/github.com/apache/beam/sdks/go/pkg/beam/transforms/filter#Exclude
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)