Commit cb6b33a9 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4495707b
......@@ -546,8 +546,7 @@ func (r *Root) zhandle1(zevent zodb.WatchEvent) {
defer r.head.zconnMu.Unlock()
zhead := r.head.zconn
//toinvalidate := map[*ZBigFile]SetI64{} // {} zfile -> set(#blk)
toinvalidate := map[*BigFile]SetI64{} // {} zfile -> set(#blk)
toinvalidate := map[*BigFile]SetI64{} // {} file -> set(#blk)
// zevent = (tid^, []oid)
for _, oid := range zevent.Changev {
......@@ -567,14 +566,17 @@ func (r *Root) zhandle1(zevent zodb.WatchEvent) {
// XXX -> δBTree
case zBlk: // ZBlk*
// XXX locking ?
for zfile, objWhere := range obj.inzfile {
// blkBoundTo locking: no other bindZFile are running,
// since we write-locked head.zconnMu and bindZFile is
// run when loading objects - thus when head.zconnMu is
// read-locked.
for zfile, objBlk := range obj.blkBoundTo() {
blkmap, ok := toinvalidate[zfile]
if !ok {
blkmap = SetI64{}
toinvalidate[zfile] = blkmap
}
blkmap.Update(objWhere)
blkmap.Update(objBlk)
}
case *ZBigFile:
......
......@@ -69,16 +69,24 @@ type zBlk interface {
// A ZBlk may be bound to several blocks inside one file, and to
// several files.
//
// XXX the information is preserved even when ZBlk comes to ghost
// The information is preserved even when ZBlk comes to ghost
// state, but is lost if ZBlk is garbage collected.
//
// bindZFile is safe for concurrent access.
// it is safe to call multiple bindZFile simultaneously.
// it is not safe to call bindZFile and boundTo simultaneously.
//
// XXX link to overview.
bindZFile(zfile *ZBigFile, blk int64)
// XXX unbindZFile
// XXX zfile -> bind map for it
// blkBoundTo returns ZBlk association with zfile(s)/#blk(s).
//
// The association returned is that was previously set by bindZFile.
//
// blkBoundTo must not be called simultaneously wrt bindZFile.
blkBoundTo() map[*ZBigFile]SetI64
}
// module of Wendelin ZODB py objects
......@@ -91,14 +99,14 @@ const zwendelin = "wendelin.bigfile.file_zodb"
// The data stored by zBlkBase is transient - it is _not_ included into
// persistent state.
type zBlkBase struct {
mu sync.Mutex
bindMu sync.Mutex // used only for binding to support multiple loaders
inzfile map[*ZBigFile]SetI64 // {} zfile -> set(#blk)
}
// bindZFile implements zBlk.
func (zb *zBlkBase) bindZFile(zfile *ZBigFile, blk int64) {
zb.mu.Lock()
defer zb.mu.Unlock()
zb.bindMu.Lock()
defer zb.bindMu.Unlock()
blkmap, ok := zb.inzfile[zfile]
if !ok {
......@@ -111,6 +119,11 @@ func (zb *zBlkBase) bindZFile(zfile *ZBigFile, blk int64) {
blkmap.Add(blk)
}
// blkBoundTo implementss zBlk.
func (zb *zBlkBase) blkBoundTo() map[*ZBigFile]SetI64 {
return zb.inzfile
}
// ---- ZBlk0 ----
// ZBlk0 mimics ZBlk0 from python.
......
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