forked from TrueCloudLab/frostfs-node
[#1418] blobovnicza: Do not use pointers as parameters
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
281befec67
commit
021aa97965
6 changed files with 7 additions and 7 deletions
|
@ -18,7 +18,7 @@ func testPutGet(t *testing.T, blz *Blobovnicza, addr oid.Address, sz uint64, ass
|
||||||
data := make([]byte, sz)
|
data := make([]byte, sz)
|
||||||
rand.Read(data)
|
rand.Read(data)
|
||||||
|
|
||||||
pPut := new(PutPrm)
|
var pPut PutPrm
|
||||||
pPut.SetAddress(addr)
|
pPut.SetAddress(addr)
|
||||||
pPut.SetMarshaledObject(data)
|
pPut.SetMarshaledObject(data)
|
||||||
_, err := blz.Put(pPut)
|
_, err := blz.Put(pPut)
|
||||||
|
@ -143,7 +143,7 @@ func TestIterateObjects(t *testing.T) {
|
||||||
putPrm.SetAddress(oidtest.Address())
|
putPrm.SetAddress(oidtest.Address())
|
||||||
putPrm.SetMarshaledObject(v)
|
putPrm.SetMarshaledObject(v)
|
||||||
|
|
||||||
_, err := blz.Put(&putPrm)
|
_, err := blz.Put(putPrm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ func (p *GetPrm) SetAddress(addr oid.Address) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object returns binary representation of the requested object.
|
// Object returns binary representation of the requested object.
|
||||||
func (p GetRes) Object() []byte {
|
func (p *GetRes) Object() []byte {
|
||||||
return p.obj
|
return p.obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ func TestBlobovniczaIterate(t *testing.T) {
|
||||||
|
|
||||||
data := [][]byte{{0, 1, 2, 3}, {5, 6, 7, 8}}
|
data := [][]byte{{0, 1, 2, 3}, {5, 6, 7, 8}}
|
||||||
addr := oidtest.Address()
|
addr := oidtest.Address()
|
||||||
_, err := b.Put(&PutPrm{addr: addr, objData: data[0]})
|
_, err := b.Put(PutPrm{addr: addr, objData: data[0]})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
require.NoError(t, b.boltDB.Update(func(tx *bbolt.Tx) error {
|
require.NoError(t, b.boltDB.Update(func(tx *bbolt.Tx) error {
|
||||||
|
|
|
@ -47,7 +47,7 @@ func (p *PutPrm) SetMarshaledObject(data []byte) {
|
||||||
// Returns ErrFull if blobovnicza is filled.
|
// Returns ErrFull if blobovnicza is filled.
|
||||||
//
|
//
|
||||||
// Should not be called in read-only configuration.
|
// Should not be called in read-only configuration.
|
||||||
func (b *Blobovnicza) Put(prm *PutPrm) (*PutRes, error) {
|
func (b *Blobovnicza) Put(prm PutPrm) (*PutRes, error) {
|
||||||
sz := uint64(len(prm.objData))
|
sz := uint64(len(prm.objData))
|
||||||
bucketName := bucketForSize(sz)
|
bucketName := bucketForSize(sz)
|
||||||
key := addressKey(prm.addr)
|
key := addressKey(prm.addr)
|
||||||
|
|
|
@ -137,7 +137,7 @@ func indexSlice(number uint64) []uint64 {
|
||||||
//
|
//
|
||||||
// returns error if could not save object in any blobovnicza.
|
// returns error if could not save object in any blobovnicza.
|
||||||
func (b *blobovniczas) put(addr oid.Address, data []byte) (*blobovnicza.ID, error) {
|
func (b *blobovniczas) put(addr oid.Address, data []byte) (*blobovnicza.ID, error) {
|
||||||
prm := new(blobovnicza.PutPrm)
|
var prm blobovnicza.PutPrm
|
||||||
prm.SetAddress(addr)
|
prm.SetAddress(addr)
|
||||||
prm.SetMarshaledObject(data)
|
prm.SetMarshaledObject(data)
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,7 @@ func TestDumpIgnoreErrors(t *testing.T) {
|
||||||
require.NoError(t, os.WriteFile(filepath.Join(bTree, "0", "2"), data, 0))
|
require.NoError(t, os.WriteFile(filepath.Join(bTree, "0", "2"), data, 0))
|
||||||
|
|
||||||
// 2.2. Invalid object in valid blobovnicza.
|
// 2.2. Invalid object in valid blobovnicza.
|
||||||
prm := new(blobovnicza.PutPrm)
|
var prm blobovnicza.PutPrm
|
||||||
prm.SetAddress(oid.Address{})
|
prm.SetAddress(oid.Address{})
|
||||||
prm.SetMarshaledObject(corruptedData)
|
prm.SetMarshaledObject(corruptedData)
|
||||||
b := blobovnicza.New(blobovnicza.WithPath(filepath.Join(bTree, "1", "2")))
|
b := blobovnicza.New(blobovnicza.WithPath(filepath.Join(bTree, "1", "2")))
|
||||||
|
|
Loading…
Reference in a new issue