Skip to content

Commit

Permalink
slicer: Reduce memory costs for payload buffering (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
cthulhu-rider authored Jan 30, 2024
2 parents aa98011 + 2edbc4b commit 03ed6db
Show file tree
Hide file tree
Showing 4 changed files with 470 additions and 88 deletions.
14 changes: 14 additions & 0 deletions object/slicer/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ type Options struct {

sessionToken *session.Object
bearerToken *bearer.Token

payloadSizeFixed bool
payloadSize uint64
}

// SetObjectPayloadLimit specifies data size limit for produced physically
Expand Down Expand Up @@ -61,6 +64,17 @@ func (x *Options) SetPayloadBuffer(payloadBuffer []byte) {
x.payloadBuffer = payloadBuffer
}

// SetPayloadSize allows to specify object's payload size known in advance. If
// set, reading functions will read at least size bytes while writing functions
// will expect exactly size bytes.
//
// If the size is known, the option is recommended as it improves the
// performance of the application using the [Slicer].
func (x *Options) SetPayloadSize(size uint64) {
x.payloadSizeFixed = true
x.payloadSize = size
}

// ObjectPayloadLimit returns required max object size.
func (x *Options) ObjectPayloadLimit() uint64 {
return x.objectPayloadLimit
Expand Down
Loading

0 comments on commit 03ed6db

Please sign in to comment.