Commit 3baa5b34 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4ec86803
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
package main package main
// ZBlk* + ZBigFile loading // ZBlk* + ZBigFile loading
// module: "wendelin.bigfile.file_zodb" // module: "wendelin.bigfile.file_zodb"
// //
// ZBigFile // ZBigFile
...@@ -44,13 +43,13 @@ import ( ...@@ -44,13 +43,13 @@ import (
"sync" "sync"
"syscall" "syscall"
"github.com/johncgriffin/overflow"
pickle "github.com/kisielk/og-rek"
"lab.nexedi.com/kirr/go123/mem" "lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xsync" "lab.nexedi.com/kirr/go123/xsync"
"lab.nexedi.com/kirr/neo/go/zodb" "lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree" "lab.nexedi.com/kirr/neo/go/zodb/btree"
pickle "github.com/kisielk/og-rek"
"github.com/johncgriffin/overflow"
"lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/pycompat" "lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/pycompat"
) )
...@@ -308,7 +307,7 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err ...@@ -308,7 +307,7 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err
// glue all chunks from chunktab // glue all chunks from chunktab
offv := make([]int32, 0, len(chunktab)) // ↑ offv := make([]int32, 0, len(chunktab)) // ↑
for off := range(chunktab) { for off := range chunktab {
offv = append(offv, off) offv = append(offv, off)
} }
sort.Slice(offv, func(i, j int) bool { sort.Slice(offv, func(i, j int) bool {
...@@ -319,7 +318,7 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err ...@@ -319,7 +318,7 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err
//fmt.Printf("offv: %v\n", offv) //fmt.Printf("offv: %v\n", offv)
// find out whole blk len via inspecting tail chunk // find out whole blk len via inspecting tail chunk
tailStart := offv[len(offv)-1] tailStart := offv[len(offv)-1]
tailChunk := chunktab[tailStart] tailChunk := chunktab[tailStart]
blklen, ok := overflow.Add32(tailStart, int32(len(tailChunk.data))) blklen, ok := overflow.Add32(tailStart, int32(len(tailChunk.data)))
...@@ -327,15 +326,15 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err ...@@ -327,15 +326,15 @@ func (zb *ZBlk1) loadBlkData(ctx context.Context) (_ []byte, _ zodb.Tid, err err
return nil, 0, fmt.Errorf("invalid data: blklen overflow") return nil, 0, fmt.Errorf("invalid data: blklen overflow")
} }
// whole buffer initialized as 0 + tail_chunk // whole buffer initialized as 0 + tail_chunk
blkdata := make([]byte, blklen) blkdata := make([]byte, blklen)
copy(blkdata[tailStart:], tailChunk.data) copy(blkdata[tailStart:], tailChunk.data)
// go through all chunks besides tail and extract them // go through all chunks besides tail and extract them
stop := int32(0) stop := int32(0)
for _, start := range offv[:len(offv)-1] { for _, start := range offv[:len(offv)-1] {
chunk := chunktab[start] chunk := chunktab[start]
if !(start >= stop) { // verify chunks don't overlap if !(start >= stop) { // verify chunks don't overlap
return nil, 0, fmt.Errorf("invalid data: chunks overlap") return nil, 0, fmt.Errorf("invalid data: chunks overlap")
} }
stop, ok = overflow.Add32(start, int32(len(chunk.data))) stop, ok = overflow.Add32(start, int32(len(chunk.data)))
...@@ -356,13 +355,12 @@ type ZBigFile struct { ...@@ -356,13 +355,12 @@ type ZBigFile struct {
zodb.Persistent zodb.Persistent
// state: (.blksize, .blktab) // state: (.blksize, .blktab)
blksize int64 blksize int64
blktab *btree.LOBTree // {} blk -> ZBlk*(blkdata) blktab *btree.LOBTree // {} blk -> ZBlk*(blkdata)
} }
type zBigFileState ZBigFile // hide state methods from public API type zBigFileState ZBigFile // hide state methods from public API
// DropState implements zodb.Ghostable. // DropState implements zodb.Ghostable.
func (bf *zBigFileState) DropState() { func (bf *zBigFileState) DropState() {
bf.blksize = 0 bf.blksize = 0
......
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