Skip to content

Commit

Permalink
parquet write performance fix
Browse files Browse the repository at this point in the history
  • Loading branch information
k-anshul committed Jun 24, 2024
1 parent 740889f commit e234e04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions go/arrow/compute/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package compute
import (
"fmt"
"io"
"math"
"time"

"github.com/apache/arrow/go/v14/arrow"
Expand All @@ -30,6 +29,7 @@ import (
"github.com/apache/arrow/go/v14/arrow/compute/internal/kernels"
"github.com/apache/arrow/go/v14/arrow/internal/debug"
"github.com/apache/arrow/go/v14/arrow/memory"
"github.com/apache/arrow/go/v14/internal/utils"
"golang.org/x/xerrors"
)

Expand All @@ -43,9 +43,9 @@ func (b *bufferWriteSeeker) Reserve(nbytes int) {
if b.buf == nil {
b.buf = memory.NewResizableBuffer(b.mem)
}
newCap := int(math.Max(float64(b.buf.Cap()), 256))
newCap := utils.MaxInt(b.buf.Cap(), 256)
for newCap < b.pos+nbytes {
newCap = bitutil.NextPowerOf2(newCap)
newCap = bitutil.NextPowerOf2(b.pos + nbytes)
}
b.buf.Reserve(newCap)
}
Expand Down
10 changes: 5 additions & 5 deletions go/parquet/internal/encoding/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ func (b *PooledBufferWriter) Reserve(nbytes int) {
b.buf = bufferPool.Get().(*memory.Buffer)
}

newCap := utils.MaxInt(b.buf.Cap()+b.offset, 256)
newCap := utils.MaxInt(b.buf.Cap(), 256)
for newCap < b.pos+nbytes {
newCap = bitutil.NextPowerOf2(newCap)
newCap = bitutil.NextPowerOf2(b.pos + nbytes)
}
b.buf.Reserve(newCap)
}
Expand Down Expand Up @@ -375,9 +375,9 @@ func (b *BufferWriter) Reserve(nbytes int) {
if b.buffer == nil {
b.buffer = memory.NewResizableBuffer(b.mem)
}
newCap := utils.MaxInt(b.buffer.Cap()+b.offset, 256)
for newCap < b.pos+nbytes+b.offset {
newCap = bitutil.NextPowerOf2(newCap)
newCap := utils.MaxInt(b.buffer.Cap(), 256)
for newCap < b.pos+nbytes {
newCap = bitutil.NextPowerOf2(b.pos + nbytes)
}
b.buffer.Reserve(newCap)
}
Expand Down

0 comments on commit e234e04

Please sign in to comment.