forked from TrueCloudLab/frostfs-node
[#1377] oid, cid: Upgrade SDK package
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f65898a354
commit
f15e6e888f
118 changed files with 1455 additions and 886 deletions
|
@ -113,7 +113,7 @@ func (c *testStorage) searchObjects(exec *execCtx, _ clientcore.NodeInfo) ([]oid
|
|||
return v.ids, v.err
|
||||
}
|
||||
|
||||
func (c *testStorage) addResult(addr *cid.ID, ids []oidSDK.ID, err error) {
|
||||
func (c *testStorage) addResult(addr cid.ID, ids []oidSDK.ID, err error) {
|
||||
c.items[addr.String()] = idsErr{
|
||||
ids: ids,
|
||||
err: err,
|
||||
|
@ -146,9 +146,9 @@ func TestGetLocalOnly(t *testing.T) {
|
|||
return svc
|
||||
}
|
||||
|
||||
newPrm := func(cid *cid.ID, w IDListWriter) Prm {
|
||||
newPrm := func(cnr cid.ID, w IDListWriter) Prm {
|
||||
p := Prm{}
|
||||
p.WithContainerID(cid)
|
||||
p.WithContainerID(&cnr)
|
||||
p.SetWriter(w)
|
||||
p.common = new(util.CommonPrm).WithLocalOnly(true)
|
||||
|
||||
|
@ -159,12 +159,12 @@ func TestGetLocalOnly(t *testing.T) {
|
|||
storage := newTestStorage()
|
||||
svc := newSvc(storage)
|
||||
|
||||
cid := cidtest.ID()
|
||||
cnr := cidtest.ID()
|
||||
ids := generateIDs(10)
|
||||
storage.addResult(cid, ids, nil)
|
||||
storage.addResult(cnr, ids, nil)
|
||||
|
||||
w := new(simpleIDWriter)
|
||||
p := newPrm(cid, w)
|
||||
p := newPrm(cnr, w)
|
||||
|
||||
err := svc.Search(ctx, p)
|
||||
require.NoError(t, err)
|
||||
|
@ -175,12 +175,12 @@ func TestGetLocalOnly(t *testing.T) {
|
|||
storage := newTestStorage()
|
||||
svc := newSvc(storage)
|
||||
|
||||
cid := cidtest.ID()
|
||||
cnr := cidtest.ID()
|
||||
testErr := errors.New("any error")
|
||||
storage.addResult(cid, nil, testErr)
|
||||
storage.addResult(cnr, nil, testErr)
|
||||
|
||||
w := new(simpleIDWriter)
|
||||
p := newPrm(cid, w)
|
||||
p := newPrm(cnr, w)
|
||||
|
||||
err := svc.Search(ctx, p)
|
||||
require.ErrorIs(t, err, testErr)
|
||||
|
@ -256,9 +256,9 @@ func TestGetRemoteSmall(t *testing.T) {
|
|||
return svc
|
||||
}
|
||||
|
||||
newPrm := func(id *cid.ID, w IDListWriter) Prm {
|
||||
newPrm := func(id cid.ID, w IDListWriter) Prm {
|
||||
p := Prm{}
|
||||
p.WithContainerID(id)
|
||||
p.WithContainerID(&id)
|
||||
p.SetWriter(w)
|
||||
p.common = new(util.CommonPrm).WithLocalOnly(false)
|
||||
|
||||
|
@ -380,7 +380,7 @@ func TestGetFromPastEpoch(t *testing.T) {
|
|||
w := new(simpleIDWriter)
|
||||
|
||||
p := Prm{}
|
||||
p.WithContainerID(cid)
|
||||
p.WithContainerID(&cid)
|
||||
p.SetWriter(w)
|
||||
|
||||
commonPrm := new(util.CommonPrm)
|
||||
|
|
|
@ -127,15 +127,15 @@ func idsFromAddresses(addrs []*addressSDK.Address) []oidSDK.ID {
|
|||
ids := make([]oidSDK.ID, len(addrs))
|
||||
|
||||
for i := range addrs {
|
||||
ids[i] = *addrs[i].ObjectID()
|
||||
ids[i], _ = addrs[i].ObjectID()
|
||||
}
|
||||
|
||||
return ids
|
||||
}
|
||||
|
||||
func (e *traverseGeneratorWrapper) generateTraverser(cid *cid.ID, epoch uint64) (*placement.Traverser, error) {
|
||||
func (e *traverseGeneratorWrapper) generateTraverser(cnr *cid.ID, epoch uint64) (*placement.Traverser, error) {
|
||||
a := addressSDK.NewAddress()
|
||||
a.SetContainerID(cid)
|
||||
a.SetContainerID(*cnr)
|
||||
|
||||
return (*util.TraverserGenerator)(e).GenerateTraverser(a, epoch)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func (s *streamWriter) WriteIDs(ids []oidSDK.ID) error {
|
|||
idsV2 := make([]refs.ObjectID, len(ids))
|
||||
|
||||
for i := range ids {
|
||||
idsV2[i] = *ids[i].ToV2()
|
||||
ids[i].WriteToV2(&idsV2[i])
|
||||
}
|
||||
|
||||
body.SetIDList(idsV2)
|
||||
|
|
|
@ -23,6 +23,20 @@ import (
|
|||
)
|
||||
|
||||
func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStream) (*searchsvc.Prm, error) {
|
||||
body := req.GetBody()
|
||||
|
||||
cnrV2 := body.GetContainerID()
|
||||
if cnrV2 == nil {
|
||||
return nil, errors.New("missing container ID")
|
||||
}
|
||||
|
||||
var id cid.ID
|
||||
|
||||
err := id.ReadFromV2(*cnrV2)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid container ID: %w", err)
|
||||
}
|
||||
|
||||
meta := req.GetMetaHeader()
|
||||
|
||||
commonPrm, err := util.CommonPrmFromV2(req)
|
||||
|
@ -103,8 +117,15 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
|
|||
}
|
||||
|
||||
chunk := resp.GetBody().GetIDList()
|
||||
var id oidSDK.ID
|
||||
|
||||
for i := range chunk {
|
||||
searchResult = append(searchResult, *oidSDK.NewIDFromV2(&chunk[i]))
|
||||
err = id.ReadFromV2(chunk[i])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid object ID: %w", err)
|
||||
}
|
||||
|
||||
searchResult = append(searchResult, id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,8 +133,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
|
|||
}))
|
||||
}
|
||||
|
||||
body := req.GetBody()
|
||||
p.WithContainerID(cid.NewFromV2(body.GetContainerID()))
|
||||
p.WithContainerID(&id)
|
||||
p.WithSearchFilters(object.NewSearchFiltersFromV2(body.GetFilters()))
|
||||
|
||||
return p, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue