[
https://issues.apache.org/jira/browse/BEAM-5421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16619568#comment-16619568
]
Vadym commented on BEAM-5421:
-----------------------------
When I tried the short-term solution the way I understood it, it didn't work:
{code:java}
func main() {
beam.Init()
ctx := context.Background()
p, s := beam.NewPipelineWithRoot()
words := beam.Create(s, []uint8("a"), []uint8("b"), []uint8("long"),
[]uint8("alsolong"))
long := filter.Exclude(s, words, func(in []uint8) bool {
return len(string(in)) < 3
})
textio.Write(s, "long.txt", long)
if err := beamx.Run(ctx, p); err != nil {
log.Exitf(ctx, "Failed to execute job: %v", err)
}
}
{code}
Output:
{code:java}
panic: failed to bind {Fn:0xc0002f6860 Param:[{Kind:Context T:context.Context}
{Kind:Value T:int} {Kind:Iter T:func(*string) bool}] Ret:[{Kind:Error
T:error}]} to input [CoGBK<int,[]uint8>]: CoGBK
<int,[]uint8> is not assignable to CoGBK<int,string>
goroutine 1 [running]:
github.com/apache/beam/sdks/go/pkg/beam.MustN(...)
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/util.go:108
github.com/apache/beam/sdks/go/pkg/beam.ParDo0(0xc0002f64c0, 0xc0002fe000,
0x18c61c0, 0xc0002f25f0, 0xc0002eced0, 0x0, 0x0, 0x0)
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/pardo.go:63
+0x1bf
github.com/apache/beam/sdks/go/pkg/beam/io/textio.Write(0xc0002f6020,
0xc0002fe000, 0x19f00e8, 0x8, 0xc0002ecb10)
/Users/vadym.tyemirov/Documents/Development/src/github.com/apache/beam/sdks/go/pkg/beam/io/textio/textio.go:121
+0x1be
main.main()
/Users/vadym.tyemirov/Documents/Development/src/algoIO/beam/nyctaxi/scracthpad.go:27
+0x3af
exit status 2{code}
> 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
> 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)