Skip to content

Commit

Permalink
*: Remove multipart object re-slicing
Browse files Browse the repository at this point in the history
Closes #843.

Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
  • Loading branch information
smallhive committed Feb 29, 2024
1 parent b447c8c commit 2475643
Show file tree
Hide file tree
Showing 11 changed files with 540 additions and 51 deletions.
7 changes: 7 additions & 0 deletions api/data/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ type PartInfo struct {
Created time.Time
// Server creation time.
ServerCreated time.Time

// MultipartHash contains internal state of the [hash.Hash] to calculate whole object payload hash.
MultipartHash []byte
// HomoHash contains internal state of the [hash.Hash] to calculate whole object homomorphic payload hash.
HomoHash []byte
// Elements contain [oid.ID] object list for the current part.
Elements []string
}

// ToHeaderString form short part representation to use in S3-Completed-Parts header.
Expand Down
9 changes: 9 additions & 0 deletions api/layer/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/url"
"strconv"
"strings"
"sync"
"time"

"github.com/nats-io/nats.go"
Expand Down Expand Up @@ -50,6 +51,7 @@ type (
ncontroller EventListener
cache *Cache
treeService TreeService
buffers *sync.Pool
}

Config struct {
Expand Down Expand Up @@ -266,13 +268,20 @@ func (f MsgHandlerFunc) HandleMessage(ctx context.Context, msg *nats.Msg) error
// NewLayer creates an instance of a layer. It checks credentials
// and establishes gRPC connection with the node.
func NewLayer(log *zap.Logger, neoFS NeoFS, config *Config) Client {
buffers := sync.Pool{}
buffers.New = func() any {
b := make([]byte, neoFS.MaxObjectSize())
return &b
}

return &layer{
neoFS: neoFS,
log: log,
anonymous: config.Anonymous,
resolver: config.Resolver,
cache: NewCache(config.Caches),
treeService: config.TreeService,
buffers: &buffers,
}
}

Expand Down
Loading

0 comments on commit 2475643

Please sign in to comment.