Patzifist commented on issue #785:
URL: https://github.com/apache/arrow-go/issues/785#issuecomment-4372141552
package main
import (
"context"
"fmt"
"sync"
"testing"
"github.com/apache/arrow-go/v18/arrow"
"github.com/apache/arrow-go/v18/arrow/array"
"github.com/apache/arrow-go/v18/arrow/compute"
"github.com/apache/arrow-go/v18/arrow/memory"
)
func TestReproduceArrowPanicAndScalarError(t *testing.T) {
mem := memory.NewGoAllocator()
ctx := context.Background()
catType := &arrow.FixedSizeBinaryType{ByteWidth: 50}
schema := arrow.NewSchema([]arrow.Field{{Name: "i_category", Type:
catType, Nullable: true}}, nil)
numRows := 1000
b := array.NewFixedSizeBinaryBuilder(mem, catType)
for i := 0; i < numRows; i++ {
buf := make([]byte, 50)
copy(buf, "SPORTS")
b.Append(buf)
}
dataArr := b.NewArray()
defer dataArr.Release()
batch := array.NewRecordBatch(schema, []arrow.Array{dataArr},
int64(numRows))
defer batch.Release()
vBuilder := array.NewFixedSizeBinaryBuilder(mem, catType)
buf := make([]byte, 50)
copy(buf, "SPORTS")
vBuilder.Append(buf)
valueSet := vBuilder.NewArray()
defer valueSet.Release()
opts := compute.SetOptions{
ValueSet: compute.NewDatumWithoutOwning(valueSet),
NullBehavior: compute.NullMatchingMatch,
}
var wg sync.WaitGroup
numWorkers := 40
errChan := make(chan error, numWorkers*100)
for w := 0; w < numWorkers; w++ {
wg.Add(1)
go func() {
defer wg.Done()
for i := 0; i < 50; i++ {
col := batch.Column(0)
col.Retain()
input := compute.NewDatum(col)
mask, err := compute.IsIn(ctx, opts, input)
if err != nil {
errChan <- err
continue
}
batchInput :=
compute.NewDatumWithoutOwning(batch)
_, err = compute.Filter(ctx, batchInput, mask,
*compute.DefaultFilterOptions())
if err != nil {
errChan <- fmt.Errorf("filter err: %w",
err)
}
mask.Release()
}
}()
}
wg.Wait()
close(errChan)
for e := range errChan {
fmt.Printf("Caught: %v\n", e)
}
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]