forked from TrueCloudLab/frostfs-node
[#423] *: Use hrw.StringHash() where possible
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
cd92d8a9e7
commit
41ab4d070e
5 changed files with 6 additions and 6 deletions
|
@ -216,7 +216,7 @@ func addressHash(addr *oid.Address, path string) uint64 {
|
||||||
a = addr.EncodeToString()
|
a = addr.EncodeToString()
|
||||||
}
|
}
|
||||||
|
|
||||||
return hrw.Hash([]byte(a + path))
|
return hrw.StringHash(a + path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// converts uint64 to hex string.
|
// converts uint64 to hex string.
|
||||||
|
|
|
@ -101,7 +101,7 @@ func (te *testEngineWrapper) setInitializedShards(t testing.TB, shards ...*shard
|
||||||
errorCount: new(atomic.Uint32),
|
errorCount: new(atomic.Uint32),
|
||||||
Shard: s,
|
Shard: s,
|
||||||
},
|
},
|
||||||
hash: hrw.Hash([]byte(s.ID().String())),
|
hash: hrw.StringHash(s.ID().String()),
|
||||||
}
|
}
|
||||||
te.engine.shardPools[s.ID().String()] = pool
|
te.engine.shardPools[s.ID().String()] = pool
|
||||||
te.shardIDs = append(te.shardIDs, s.ID())
|
te.shardIDs = append(te.shardIDs, s.ID())
|
||||||
|
|
|
@ -373,7 +373,7 @@ func (e *StorageEngine) evacuateObjects(ctx context.Context, sh *shard.Shard, to
|
||||||
|
|
||||||
func (e *StorageEngine) tryEvacuateObjectLocal(ctx context.Context, addr oid.Address, object *objectSDK.Object, sh *shard.Shard,
|
func (e *StorageEngine) tryEvacuateObjectLocal(ctx context.Context, addr oid.Address, object *objectSDK.Object, sh *shard.Shard,
|
||||||
shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard, res *EvacuateShardRes) (bool, error) {
|
shards []pooledShard, weights []float64, shardsToEvacuate map[string]*shard.Shard, res *EvacuateShardRes) (bool, error) {
|
||||||
hrw.SortHasherSliceByWeightValue(shards, weights, hrw.Hash([]byte(addr.EncodeToString())))
|
hrw.SortHasherSliceByWeightValue(shards, weights, hrw.StringHash(addr.EncodeToString()))
|
||||||
for j := range shards {
|
for j := range shards {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
|
|
@ -110,7 +110,7 @@ func (e *StorageEngine) removeObjects(ctx context.Context, ch <-chan oid.Address
|
||||||
}
|
}
|
||||||
|
|
||||||
for addr := range ch {
|
for addr := range ch {
|
||||||
h := hrw.Hash([]byte(addr.EncodeToString()))
|
h := hrw.StringHash(addr.EncodeToString())
|
||||||
shards := sortShardsByWeight(shards, h)
|
shards := sortShardsByWeight(shards, h)
|
||||||
found := false
|
found := false
|
||||||
for i := range shards {
|
for i := range shards {
|
||||||
|
|
|
@ -162,7 +162,7 @@ func (e *StorageEngine) addShard(sh *shard.Shard) error {
|
||||||
errorCount: new(atomic.Uint32),
|
errorCount: new(atomic.Uint32),
|
||||||
Shard: sh,
|
Shard: sh,
|
||||||
},
|
},
|
||||||
hash: hrw.Hash([]byte(strID)),
|
hash: hrw.StringHash(strID),
|
||||||
}
|
}
|
||||||
|
|
||||||
e.shardPools[strID] = pool
|
e.shardPools[strID] = pool
|
||||||
|
@ -237,7 +237,7 @@ func (e *StorageEngine) sortShardsByWeight(objAddr interface{ EncodeToString() s
|
||||||
e.mtx.RLock()
|
e.mtx.RLock()
|
||||||
defer e.mtx.RUnlock()
|
defer e.mtx.RUnlock()
|
||||||
|
|
||||||
h := hrw.Hash([]byte(objAddr.EncodeToString()))
|
h := hrw.StringHash(objAddr.EncodeToString())
|
||||||
shards := make([]hashedShard, 0, len(e.shards))
|
shards := make([]hashedShard, 0, len(e.shards))
|
||||||
for _, sh := range e.shards {
|
for _, sh := range e.shards {
|
||||||
shards = append(shards, hashedShard(sh))
|
shards = append(shards, hashedShard(sh))
|
||||||
|
|
Loading…
Reference in a new issue