Commit be0fed1e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent cb778a7d
...@@ -92,6 +92,9 @@ type zBlk interface { ...@@ -92,6 +92,9 @@ type zBlk interface {
blkBoundTo() map[*BigFile]SetI64 blkBoundTo() map[*BigFile]SetI64
} }
var _ zBlk = (*ZBlk0)(nil)
var _ zBlk = (*ZBlk1)(nil)
// ---- zBlkBase ---- // ---- zBlkBase ----
// zBlkBase provides common functionality to implement ZBlk* -> zfile, #blk binding. // zBlkBase provides common functionality to implement ZBlk* -> zfile, #blk binding.
...@@ -99,29 +102,29 @@ type zBlk interface { ...@@ -99,29 +102,29 @@ type zBlk interface {
// The data stored by zBlkBase is transient - it is _not_ included into // The data stored by zBlkBase is transient - it is _not_ included into
// persistent state. // persistent state.
type zBlkBase struct { type zBlkBase struct {
bindMu sync.Mutex // used only for binding to support multiple loaders bindMu sync.Mutex // used only for binding to support multiple loaders
inzfile map[*ZBigFile]SetI64 // {} zfile -> set(#blk) infile map[*BigFile]SetI64 // {} zfile -> set(#blk)
} }
// bindZFile implements zBlk. // bindFile implements zBlk.
func (zb *zBlkBase) bindZFile(zfile *ZBigFile, blk int64) { func (zb *zBlkBase) bindFile(file *BigFile, blk int64) {
zb.bindMu.Lock() zb.bindMu.Lock()
defer zb.bindMu.Unlock() defer zb.bindMu.Unlock()
blkmap, ok := zb.inzfile[zfile] blkmap, ok := zb.infile[file]
if !ok { if !ok {
blkmap = make(SetI64, 1) blkmap = make(SetI64, 1)
if zb.inzfile == nil { if zb.infile == nil {
zb.inzfile = make(map[*ZBigFile]SetI64) zb.infile = make(map[*BigFile]SetI64)
} }
zb.inzfile[zfile] = blkmap zb.infile[file] = blkmap
} }
blkmap.Add(blk) blkmap.Add(blk)
} }
// blkBoundTo implementss zBlk. // blkBoundTo implementss zBlk.
func (zb *zBlkBase) blkBoundTo() map[*ZBigFile]SetI64 { func (zb *zBlkBase) blkBoundTo() map[*BigFile]SetI64 {
return zb.inzfile return zb.infile
} }
// ---- ZBlk0 ---- // ---- ZBlk0 ----
...@@ -172,7 +175,6 @@ func (zb *ZBlk0) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) { ...@@ -172,7 +175,6 @@ func (zb *ZBlk0) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
// ZData mimics ZData from python. // ZData mimics ZData from python.
type ZData struct { type ZData struct {
zBlkBase // XXX -> ZBlk1, not here?
zodb.Persistent zodb.Persistent
// XXX py source uses bytes(buf) but on python2 it still results in str // XXX py source uses bytes(buf) but on python2 it still results in str
...@@ -202,6 +204,7 @@ func (zd *zDataState) PySetState(pystate interface{}) error { ...@@ -202,6 +204,7 @@ func (zd *zDataState) PySetState(pystate interface{}) error {
// ZBlk1 mimics ZBlk1 from python. // ZBlk1 mimics ZBlk1 from python.
type ZBlk1 struct { type ZBlk1 struct {
zBlkBase
zodb.Persistent zodb.Persistent
chunktab *btree.IOBTree // {} offset -> ZData(chunk) chunktab *btree.IOBTree // {} offset -> ZData(chunk)
......
...@@ -91,7 +91,7 @@ type ΔBtail struct { ...@@ -91,7 +91,7 @@ type ΔBtail struct {
δRtail []ΔRoots // which BTree were changed; Noted only by keys ∈ tracket subset δRtail []ΔRoots // which BTree were changed; Noted only by keys ∈ tracket subset
byRoot map[*Tree]*ΔTreeTail // root -> k/v change history; only for keys ∈ tracket subset byRoot map[*Tree]*ΔTreeTail // root -> k/v change history; only for keys ∈ tracket subset
// XXX or ask client provide db on every call? // XXX or ask client to provide db on every call?
db *zodb.DB // to open connections to load new/old tree|buckets db *zodb.DB // to open connections to load new/old tree|buckets
// tracked index: BTree|Bucket -> top tree element. // tracked index: BTree|Bucket -> top tree element.
......
...@@ -153,6 +153,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) ΔF { ...@@ -153,6 +153,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) ΔF {
// take zblk changes into account // take zblk changes into account
for _, oid := range δZ.Changev { for _, oid := range δZ.Changev {
// XXX cache lock/unlock // XXX cache lock/unlock
var zcache *zodb.LiveCache // XXX stub
obj := zcache.Get(oid) obj := zcache.Get(oid)
if obj == nil { if obj == nil {
//fmt.Printf("%s: not in cache\n", oid) //fmt.Printf("%s: not in cache\n", oid)
......
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