Skip to content

Commit

Permalink
[Go][Parquet] unpack32Avx2 returns 0 if its buffer is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
don4get committed Aug 8, 2024
1 parent 8e034c7 commit 4d97086
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions go/parquet/internal/utils/bit_packing_avx2_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func unpack32Avx2(in io.Reader, out []uint32, nbits int) int {
buffer.Grow(n)
io.CopyN(buffer, in, int64(n))

if buffer.Len() == 0 {
return 0
}

var (
input = unsafe.Pointer(&buffer.Bytes()[0])
output = unsafe.Pointer(&out[0])
Expand Down
20 changes: 16 additions & 4 deletions go/parquet/pqarrow/file_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,28 @@ func TestReadParquetFile(t *testing.T) {
}()

arrowRdr, err := pqarrow.NewFileReader(rdr, pqarrow.ArrowReadProperties{
Parallel: false,
Parallel: true,
BatchSize: 0,
}, mem)
if err != nil {
t.Errorf("unexpected error: %v", err)
}

_, err = arrowRdr.ReadTable(ctx)
table, err := arrowRdr.ReadTable(ctx)
defer table.Release()

if err == nil {
t.Errorf("expected error: %v", err)
if err != nil {
t.Errorf("unexpected error: %v", err)
}

assert.Equal(t, table.NumCols(), int64(1))
assert.Equal(t, table.NumRows(), int64(21186))

for i := 0; i < int(table.NumCols()); i++ {
col := table.Column(i)
assert.Equal(t, col.Len(), int(table.NumRows()))
for j := 0; j < col.Len(); j++ {
assert.Equal(t, col.Data().Chunk(0).(*array.Uint16).Value(j), uint16(0))
}
}
}

0 comments on commit 4d97086

Please sign in to comment.