[#2175] blobovniczatree: Make function parameters more descriptive
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
b4e90cdf51
commit
c1cf418956
1 changed files with 13 additions and 13 deletions
|
@ -130,19 +130,19 @@ func NewBlobovniczaTree(opts ...Option) (blz *Blobovniczas) {
|
||||||
// activates and returns activated blobovnicza of p-level (dir).
|
// activates and returns activated blobovnicza of p-level (dir).
|
||||||
//
|
//
|
||||||
// returns error if blobvnicza could not be activated.
|
// returns error if blobvnicza could not be activated.
|
||||||
func (b *Blobovniczas) getActivated(p string) (blobovniczaWithIndex, error) {
|
func (b *Blobovniczas) getActivated(lvlPath string) (blobovniczaWithIndex, error) {
|
||||||
return b.updateAndGet(p, nil)
|
return b.updateAndGet(lvlPath, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// updates active blobovnicza of p-level (dir).
|
// updates active blobovnicza of p-level (dir).
|
||||||
//
|
//
|
||||||
// if current active blobovnicza's index is not old, it remains unchanged.
|
// if current active blobovnicza's index is not old, it remains unchanged.
|
||||||
func (b *Blobovniczas) updateActive(p string, old *uint64) error {
|
func (b *Blobovniczas) updateActive(lvlPath string, old *uint64) error {
|
||||||
b.log.Debug("updating active blobovnicza...", zap.String("path", p))
|
b.log.Debug("updating active blobovnicza...", zap.String("path", lvlPath))
|
||||||
|
|
||||||
_, err := b.updateAndGet(p, old)
|
_, err := b.updateAndGet(lvlPath, old)
|
||||||
|
|
||||||
b.log.Debug("active blobovnicza successfully updated", zap.String("path", p))
|
b.log.Debug("active blobovnicza successfully updated", zap.String("path", lvlPath))
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -150,9 +150,9 @@ func (b *Blobovniczas) updateActive(p string, old *uint64) error {
|
||||||
// updates and returns active blobovnicza of p-level (dir).
|
// updates and returns active blobovnicza of p-level (dir).
|
||||||
//
|
//
|
||||||
// if current active blobovnicza's index is not old, it is returned unchanged.
|
// if current active blobovnicza's index is not old, it is returned unchanged.
|
||||||
func (b *Blobovniczas) updateAndGet(p string, old *uint64) (blobovniczaWithIndex, error) {
|
func (b *Blobovniczas) updateAndGet(lvlPath string, old *uint64) (blobovniczaWithIndex, error) {
|
||||||
b.activeMtx.RLock()
|
b.activeMtx.RLock()
|
||||||
active, ok := b.active[p]
|
active, ok := b.active[lvlPath]
|
||||||
b.activeMtx.RUnlock()
|
b.activeMtx.RUnlock()
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -172,7 +172,7 @@ func (b *Blobovniczas) updateAndGet(p string, old *uint64) (blobovniczaWithIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
if active.blz, err = b.openBlobovnicza(filepath.Join(p, u64ToHexString(active.ind))); err != nil {
|
if active.blz, err = b.openBlobovnicza(filepath.Join(lvlPath, u64ToHexString(active.ind))); err != nil {
|
||||||
return active, err
|
return active, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ func (b *Blobovniczas) updateAndGet(p string, old *uint64) (blobovniczaWithIndex
|
||||||
defer b.activeMtx.Unlock()
|
defer b.activeMtx.Unlock()
|
||||||
|
|
||||||
// check 2nd time to find out if it blobovnicza was activated while thread was locked
|
// check 2nd time to find out if it blobovnicza was activated while thread was locked
|
||||||
tryActive, ok := b.active[p]
|
tryActive, ok := b.active[lvlPath]
|
||||||
if ok && tryActive.blz == active.blz {
|
if ok && tryActive.blz == active.blz {
|
||||||
return tryActive, nil
|
return tryActive, nil
|
||||||
}
|
}
|
||||||
|
@ -188,13 +188,13 @@ func (b *Blobovniczas) updateAndGet(p string, old *uint64) (blobovniczaWithIndex
|
||||||
// Remove from opened cache (active blobovnicza should always be opened).
|
// Remove from opened cache (active blobovnicza should always be opened).
|
||||||
// Because `onEvict` callback is called in `Remove`, we need to update
|
// Because `onEvict` callback is called in `Remove`, we need to update
|
||||||
// active map beforehand.
|
// active map beforehand.
|
||||||
b.active[p] = active
|
b.active[lvlPath] = active
|
||||||
|
|
||||||
activePath := filepath.Join(p, u64ToHexString(active.ind))
|
activePath := filepath.Join(lvlPath, u64ToHexString(active.ind))
|
||||||
b.lruMtx.Lock()
|
b.lruMtx.Lock()
|
||||||
b.opened.Remove(activePath)
|
b.opened.Remove(activePath)
|
||||||
if ok {
|
if ok {
|
||||||
b.opened.Add(filepath.Join(p, u64ToHexString(tryActive.ind)), tryActive.blz)
|
b.opened.Add(filepath.Join(lvlPath, u64ToHexString(tryActive.ind)), tryActive.blz)
|
||||||
}
|
}
|
||||||
b.lruMtx.Unlock()
|
b.lruMtx.Unlock()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue