forked from TrueCloudLab/frostfs-node
[#1226] blobovniczatree: Drop leaf width limitation
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
40c9ddb6ba
commit
78b1d9b18d
10 changed files with 50 additions and 55 deletions
|
@ -3,6 +3,7 @@ package blobovniczatree
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -81,12 +82,8 @@ func NewBlobovniczaTree(ctx context.Context, opts ...Option) (blz *Blobovniczas)
|
|||
opts[i](&blz.cfg)
|
||||
}
|
||||
|
||||
if blz.blzLeafWidth == 0 {
|
||||
blz.blzLeafWidth = blz.blzShallowWidth
|
||||
}
|
||||
|
||||
blz.commondbManager = newDBManager(blz.rootPath, blz.blzOpts, blz.readOnly, blz.metrics.Blobovnicza(), blz.log)
|
||||
blz.activeDBManager = newActiveDBManager(blz.commondbManager, blz.blzLeafWidth)
|
||||
blz.activeDBManager = newActiveDBManager(blz.commondbManager, blz.rootPath)
|
||||
blz.dbCache = newDBCache(ctx, blz.openedCacheSize,
|
||||
blz.openedCacheTTL, blz.openedCacheExpInterval, blz.commondbManager)
|
||||
blz.deleteProtectedObjects = newAddressMap()
|
||||
|
@ -124,6 +121,29 @@ func u64FromHexString(str string) uint64 {
|
|||
return v
|
||||
}
|
||||
|
||||
func getBlobovniczaMaxIndex(directory string) (bool, uint64, error) {
|
||||
entries, err := os.ReadDir(directory)
|
||||
if os.IsNotExist(err) { // non initialized tree
|
||||
return false, 0, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, 0, err
|
||||
}
|
||||
if len(entries) == 0 {
|
||||
return false, 0, nil
|
||||
}
|
||||
var hasDBs bool
|
||||
var maxIdx uint64
|
||||
for _, e := range entries {
|
||||
if e.IsDir() {
|
||||
continue
|
||||
}
|
||||
hasDBs = true
|
||||
maxIdx = max(u64FromHexString(e.Name()), maxIdx)
|
||||
}
|
||||
return hasDBs, maxIdx, nil
|
||||
}
|
||||
|
||||
// Type is blobovniczatree storage type used in logs and configuration.
|
||||
const Type = "blobovnicza"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue