Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-41159: [Go][Parquet] Improvement Parquet BitWriter WriteVlqInt Performance #41160

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions go/parquet/internal/utils/bit_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ func TestBitWriter(t *testing.T) {

assert.Equal(t, byte(0xAA), buf[0])
assert.Equal(t, byte(0xCC), buf[1])

for i := 0; i < 3; i++ {
assert.True(t, bw.WriteVlqInt(uint64(i)))
}
assert.Equal(t, byte(0xAA), buf[0])
assert.Equal(t, byte(0xCC), buf[1])
assert.Equal(t, byte(0), buf[2])
assert.Equal(t, byte(1), buf[3])
assert.Equal(t, byte(2), buf[4])
}

func TestBitReader(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions go/parquet/internal/utils/bit_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type BitWriter struct {
byteoffset int
bitoffset uint
raw [8]byte
buf [binary.MaxVarintLen64]byte
}

// NewBitWriter initializes a new bit writer to write to the passed in interface
Expand Down Expand Up @@ -163,9 +164,8 @@ func (b *BitWriter) WriteAligned(val uint64, nbytes int) bool {
// without buffering.
func (b *BitWriter) WriteVlqInt(v uint64) bool {
b.Flush(true)
var buf [binary.MaxVarintLen64]byte
nbytes := binary.PutUvarint(buf[:], v)
if _, err := b.wr.WriteAt(buf[:nbytes], int64(b.byteoffset)); err != nil {
nbytes := binary.PutUvarint(b.buf[:], v)
if _, err := b.wr.WriteAt(b.buf[:nbytes], int64(b.byteoffset)); err != nil {
log.Println(err)
return false
}
Expand Down
Loading