Commit be0fed1e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent cb778a7d
......@@ -92,6 +92,9 @@ type zBlk interface {
blkBoundTo() map[*BigFile]SetI64
}
var _ zBlk = (*ZBlk0)(nil)
var _ zBlk = (*ZBlk1)(nil)
// ---- zBlkBase ----
// zBlkBase provides common functionality to implement ZBlk* -> zfile, #blk binding.
......@@ -100,28 +103,28 @@ type zBlk interface {
// persistent state.
type zBlkBase struct {
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.
func (zb *zBlkBase) bindZFile(zfile *ZBigFile, blk int64) {
// bindFile implements zBlk.
func (zb *zBlkBase) bindFile(file *BigFile, blk int64) {
zb.bindMu.Lock()
defer zb.bindMu.Unlock()
blkmap, ok := zb.inzfile[zfile]
blkmap, ok := zb.infile[file]
if !ok {
blkmap = make(SetI64, 1)
if zb.inzfile == nil {
zb.inzfile = make(map[*ZBigFile]SetI64)
if zb.infile == nil {
zb.infile = make(map[*BigFile]SetI64)
}
zb.inzfile[zfile] = blkmap
zb.infile[file] = blkmap
}
blkmap.Add(blk)
}
// blkBoundTo implementss zBlk.
func (zb *zBlkBase) blkBoundTo() map[*ZBigFile]SetI64 {
return zb.inzfile
func (zb *zBlkBase) blkBoundTo() map[*BigFile]SetI64 {
return zb.infile
}
// ---- ZBlk0 ----
......@@ -172,7 +175,6 @@ func (zb *ZBlk0) loadBlkData(ctx context.Context) ([]byte, zodb.Tid, error) {
// ZData mimics ZData from python.
type ZData struct {
zBlkBase // XXX -> ZBlk1, not here?
zodb.Persistent
// 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 {
// ZBlk1 mimics ZBlk1 from python.
type ZBlk1 struct {
zBlkBase
zodb.Persistent
chunktab *btree.IOBTree // {} offset -> ZData(chunk)
......
......@@ -91,7 +91,7 @@ type ΔBtail struct {
δ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
// 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
// tracked index: BTree|Bucket -> top tree element.
......
......@@ -153,6 +153,7 @@ func (δFtail *ΔFtail) Update(δZ *zodb.EventCommit) ΔF {
// take zblk changes into account
for _, oid := range δZ.Changev {
// XXX cache lock/unlock
var zcache *zodb.LiveCache // XXX stub
obj := zcache.Get(oid)
if obj == nil {
//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