Commit c4e16704 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ca31958e
...@@ -387,8 +387,6 @@ func (δBtail *ΔBtail) Tail() zodb.Tid { return δBtail.δZtail.Tail() } ...@@ -387,8 +387,6 @@ func (δBtail *ΔBtail) Tail() zodb.Tid { return δBtail.δZtail.Tail() }
// All path elements must be Tree except last one which, for non-empty tree, must be Bucket. // All path elements must be Tree except last one which, for non-empty tree, must be Bucket.
// //
// Objects in the path must be with .PJar().At() == .Head() // Objects in the path must be with .PJar().At() == .Head()
//
// XXX put keycov back to come first?
func (δBtail *ΔBtail) Track(nodePath []Node, keycov KeyRange) { func (δBtail *ΔBtail) Track(nodePath []Node, keycov KeyRange) {
head := δBtail.Head() head := δBtail.Head()
for _, node := range nodePath { for _, node := range nodePath {
......
...@@ -417,24 +417,24 @@ func (bf *ZBigFile) BlkSize() int64 { ...@@ -417,24 +417,24 @@ func (bf *ZBigFile) BlkSize() int64 {
// which provides a rough upper-bound estimate for file[blk] revision. // which provides a rough upper-bound estimate for file[blk] revision.
// //
// TODO load into user-provided buf. // TODO load into user-provided buf.
// XXX blkCov -> treeLeafCov ?
func (bf *ZBigFile) LoadBlk(ctx context.Context, blk int64) (_ []byte, treePath []btree.LONode, blkCov btree.LKeyRange, zblk ZBlk, blkRevMax zodb.Tid, err error) { func (bf *ZBigFile) LoadBlk(ctx context.Context, blk int64) (_ []byte, treePath []btree.LONode, blkCov btree.LKeyRange, zblk ZBlk, blkRevMax zodb.Tid, err error) {
defer xerr.Contextf(&err, "bigfile %s: loadblk %d", bf.POid(), blk) defer xerr.Contextf(&err, "bigfile %s: loadblk %d", bf.POid(), blk)
:= btree.LKeyRange{Lo: 0, Hi_: -1} // empty KeyRange
err = bf.PActivate(ctx) err = bf.PActivate(ctx)
if err != nil { if err != nil {
return nil, nil, btree.LKeyRange{}, nil, 0, err return nil, nil, , nil, 0, err
} }
defer bf.PDeactivate() defer bf.PDeactivate()
blkRevMax = 0 blkRevMax = 0
xzblk, ok, err := bf.blktab.VGet(ctx, blk, func(node btree.LONode, keycov btree.LKeyRange) { xzblk, ok, err := bf.blktab.VGet(ctx, blk, func(node btree.LONode, keycov btree.LKeyRange) {
blkCov = keycov // will be set last for leaf
treePath = append(treePath, node) treePath = append(treePath, node)
blkCov = keycov // will be set last for leaf
blkRevMax = tidmax(blkRevMax, node.PSerial()) blkRevMax = tidmax(blkRevMax, node.PSerial())
}) })
if err != nil { if err != nil {
return nil, nil, btree.LKeyRange{}, nil, 0, err return nil, nil, , nil, 0, err
} }
if !ok { if !ok {
return make([]byte, bf.blksize), treePath, blkCov, nil, blkRevMax, nil return make([]byte, bf.blksize), treePath, blkCov, nil, blkRevMax, nil
...@@ -442,18 +442,18 @@ func (bf *ZBigFile) LoadBlk(ctx context.Context, blk int64) (_ []byte, treePath ...@@ -442,18 +442,18 @@ func (bf *ZBigFile) LoadBlk(ctx context.Context, blk int64) (_ []byte, treePath
zblk, err = vZBlk(xzblk) zblk, err = vZBlk(xzblk)
if err != nil { if err != nil {
return nil, nil, btree.LKeyRange{}, nil, 0, err return nil, nil, , nil, 0, err
} }
blkdata, zblkrev, err := zblk.LoadBlkData(ctx) blkdata, zblkrev, err := zblk.LoadBlkData(ctx)
if err != nil { if err != nil {
return nil, nil, btree.LKeyRange{}, nil, 0, err return nil, nil, , nil, 0, err
} }
blkRevMax = tidmax(blkRevMax, zblkrev) blkRevMax = tidmax(blkRevMax, zblkrev)
l := int64(len(blkdata)) l := int64(len(blkdata))
if l > bf.blksize { if l > bf.blksize {
return nil, nil, btree.LKeyRange{}, nil, 0, fmt.Errorf("zblk %s: invalid blk: size = %d (> blksize = %d)", zblk.POid(), l, bf.blksize) return nil, nil, , nil, 0, fmt.Errorf("zblk %s: invalid blk: size = %d (> blksize = %d)", zblk.POid(), l, bf.blksize)
} }
// append trailing \0 to data to reach .blksize // append trailing \0 to data to reach .blksize
...@@ -469,33 +469,33 @@ func (bf *ZBigFile) LoadBlk(ctx context.Context, blk int64) (_ []byte, treePath ...@@ -469,33 +469,33 @@ func (bf *ZBigFile) LoadBlk(ctx context.Context, blk int64) (_ []byte, treePath
// Size returns whole file size. // Size returns whole file size.
// //
// it also returns BTree path scanned to obtain the size. // it also returns BTree path scanned to obtain the size.
// XXX naming leafCov -> blkCov ? func (bf *ZBigFile) Size(ctx context.Context) (_ int64, treePath []btree.LONode, blkCov btree.LKeyRange, err error) {
func (bf *ZBigFile) Size(ctx context.Context) (_ int64, treePath []btree.LONode, leafCov btree.LKeyRange, err error) {
defer xerr.Contextf(&err, "bigfile %s: size", bf.POid()) defer xerr.Contextf(&err, "bigfile %s: size", bf.POid())
:= btree.LKeyRange{Lo: 0, Hi_: -1} // empty KeyRange
err = bf.PActivate(ctx) err = bf.PActivate(ctx)
if err != nil { if err != nil {
return 0, nil, btree.LKeyRange{}, err return 0, nil, , err
} }
defer bf.PDeactivate() defer bf.PDeactivate()
tailblk, ok, err := bf.blktab.VMaxKey(ctx, func(node btree.LONode, keycov btree.LKeyRange) { tailblk, ok, err := bf.blktab.VMaxKey(ctx, func(node btree.LONode, keycov btree.LKeyRange) {
leafCov = keycov // will be set last for leaf
treePath = append(treePath, node) treePath = append(treePath, node)
blkCov = keycov // will be set last for leaf
}) })
if err != nil { if err != nil {
return 0, nil, btree.LKeyRange{}, err return 0, nil, , err
} }
if !ok { if !ok {
return 0, treePath, leafCov, nil return 0, treePath, blkCov, nil
} }
size := (tailblk + 1) * bf.blksize size := (tailblk + 1) * bf.blksize
if size / bf.blksize != tailblk + 1 { if size / bf.blksize != tailblk + 1 {
return 0, nil, btree.LKeyRange{}, syscall.EFBIG // overflow return 0, nil, , syscall.EFBIG // overflow
} }
return size, treePath, leafCov, nil return size, treePath, blkCov, nil
} }
// vZBlk checks and converts xzblk to a ZBlk object. // vZBlk checks and converts xzblk to a ZBlk object.
......
...@@ -195,13 +195,13 @@ func (δFtail *ΔFtail) Tail() zodb.Tid { return δFtail.δBtail.Tail() } ...@@ -195,13 +195,13 @@ func (δFtail *ΔFtail) Tail() zodb.Tid { return δFtail.δBtail.Tail() }
// ---- Track/rebuild/Update/Forget ---- // ---- Track/rebuild/Update/Forget ----
// Track associates file[blkcov]@head with tree path and zblk object. // Track associates file[blk]@head with zblk object and file[blkcov]@head with tree path.
// //
// Path root becomes associated with the file, and the path and zblk object become tracked. // Path root becomes associated with the file, and the path and zblk object become tracked.
// One root can be associated with several files (each provided on different Track calls). // One root can be associated with several files (each provided on different Track calls).
// //
// zblk can be nil, which represents a hole. // zblk can be nil, which represents a hole.
// XXX kill: blk=-1 should be used for tracking after ZBigFile.Size() query (no zblk is accessed at all). // if zblk is nil -> blk is ignored and can be arbitrary.
// //
// Objects in path and zblk must be with .PJar().At() == .head // Objects in path and zblk must be with .PJar().At() == .head
func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, blkcov btree.LKeyRange, zblk ZBlk) { func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, blkcov btree.LKeyRange, zblk ZBlk) {
...@@ -222,9 +222,6 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, bl ...@@ -222,9 +222,6 @@ func (δFtail *ΔFtail) Track(file *ZBigFile, blk int64, path []btree.LONode, bl
// path.at == head is verified by ΔBtail.Track // path.at == head is verified by ΔBtail.Track
foid := file.POid() foid := file.POid()
// if blk == -1 {
// blk = xbtree.KeyMax
// }
δFtail.δBtail.Track(path, blkcov) δFtail.δBtail.Track(path, blkcov)
rootObj := path[0].(*btree.LOBTree) rootObj := path[0].(*btree.LOBTree)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment