Skip to content

Commit

Permalink
[Go][Parquet] unpack32Avx2 returns 0 if n is equal to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
don4get committed Aug 9, 2024
1 parent 8e034c7 commit 1af4ee9
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 @@ -39,6 +39,10 @@ func unpack32Avx2(in io.Reader, out []uint32, nbits int) int {

n := batch * nbits / 8

if n == 0 {
return 0
}

buffer := bufferPool.Get().(*bytes.Buffer)
defer bufferPool.Put(buffer)
buffer.Reset()
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 1af4ee9

Please sign in to comment.