Skip to content

Commit

Permalink
Remove re-slicing for multipart (#931)
Browse files Browse the repository at this point in the history
Closes #843
  • Loading branch information
roman-khimov authored Mar 26, 2024
2 parents 4717bd8 + 127dd3e commit 20f55c4
Show file tree
Hide file tree
Showing 15 changed files with 878 additions and 115 deletions.
8 changes: 8 additions & 0 deletions api/data/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type MultipartInfo struct {
Created time.Time
Meta map[string]string
CopiesNumber uint32
SplitID string
}

// PartInfo is upload information about part.
Expand All @@ -89,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 []oid.ID
}

// ToHeaderString form short part representation to use in S3-Completed-Parts header.
Expand Down
3 changes: 1 addition & 2 deletions api/handler/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/json"
"encoding/xml"
"errors"
stderrors "errors"
"fmt"
"net/http"
"sort"
Expand Down Expand Up @@ -1464,7 +1463,7 @@ func bucketACLToTable(acp *AccessControlPolicy) (*eacl.Table, error) {

for _, grant := range acp.AccessControlList {
if !isValidGrant(grant) {
return nil, stderrors.New("unsupported grantee")
return nil, errors.New("unsupported grantee")
}
if grant.Grantee.ID == acp.Owner.ID {
found = true
Expand Down
8 changes: 4 additions & 4 deletions api/handler/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ func prepareHandlerContext(t *testing.T) *handlerContext {
require.NoError(t, err)
anonSigner := user.NewAutoIDSignerRFC6979(anonKey.PrivateKey)

signer := user.NewAutoIDSignerRFC6979(key.PrivateKey)
owner := signer.UserID()

l := zap.NewExample()
tp := layer.NewTestNeoFS()
tp := layer.NewTestNeoFS(signer)

testResolver := &contResolver{layer: tp}

signer := user.NewAutoIDSignerRFC6979(key.PrivateKey)
owner := signer.UserID()

layerCfg := &layer.Config{
Caches: layer.DefaultCachesConfigs(zap.NewExample()),
GateKey: key,
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 20f55c4

Please sign in to comment.