Commit cb6b33a9 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4495707b
...@@ -546,8 +546,7 @@ func (r *Root) zhandle1(zevent zodb.WatchEvent) { ...@@ -546,8 +546,7 @@ func (r *Root) zhandle1(zevent zodb.WatchEvent) {
defer r.head.zconnMu.Unlock() defer r.head.zconnMu.Unlock()
zhead := r.head.zconn zhead := r.head.zconn
//toinvalidate := map[*ZBigFile]SetI64{} // {} zfile -> set(#blk) toinvalidate := map[*BigFile]SetI64{} // {} file -> set(#blk)
toinvalidate := map[*BigFile]SetI64{} // {} zfile -> set(#blk)
// zevent = (tid^, []oid) // zevent = (tid^, []oid)
for _, oid := range zevent.Changev { for _, oid := range zevent.Changev {
...@@ -567,14 +566,17 @@ func (r *Root) zhandle1(zevent zodb.WatchEvent) { ...@@ -567,14 +566,17 @@ func (r *Root) zhandle1(zevent zodb.WatchEvent) {
// XXX -> δBTree // XXX -> δBTree
case zBlk: // ZBlk* case zBlk: // ZBlk*
// XXX locking ? // blkBoundTo locking: no other bindZFile are running,
for zfile, objWhere := range obj.inzfile { // 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] blkmap, ok := toinvalidate[zfile]
if !ok { if !ok {
blkmap = SetI64{} blkmap = SetI64{}
toinvalidate[zfile] = blkmap toinvalidate[zfile] = blkmap
} }
blkmap.Update(objWhere) blkmap.Update(objBlk)
} }
case *ZBigFile: case *ZBigFile:
......
...@@ -69,16 +69,24 @@ type zBlk interface { ...@@ -69,16 +69,24 @@ type zBlk interface {
// A ZBlk may be bound to several blocks inside one file, and to // A ZBlk may be bound to several blocks inside one file, and to
// several files. // 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. // 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. // XXX link to overview.
bindZFile(zfile *ZBigFile, blk int64) bindZFile(zfile *ZBigFile, blk int64)
// XXX unbindZFile // XXX unbindZFile
// XXX zfile -> bind map for it // 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 // module of Wendelin ZODB py objects
...@@ -91,14 +99,14 @@ const zwendelin = "wendelin.bigfile.file_zodb" ...@@ -91,14 +99,14 @@ const zwendelin = "wendelin.bigfile.file_zodb"
// 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 {
mu sync.Mutex bindMu sync.Mutex // used only for binding to support multiple loaders
inzfile map[*ZBigFile]SetI64 // {} zfile -> set(#blk) inzfile map[*ZBigFile]SetI64 // {} zfile -> set(#blk)
} }
// bindZFile implements zBlk. // bindZFile implements zBlk.
func (zb *zBlkBase) bindZFile(zfile *ZBigFile, blk int64) { func (zb *zBlkBase) bindZFile(zfile *ZBigFile, blk int64) {
zb.mu.Lock() zb.bindMu.Lock()
defer zb.mu.Unlock() defer zb.bindMu.Unlock()
blkmap, ok := zb.inzfile[zfile] blkmap, ok := zb.inzfile[zfile]
if !ok { if !ok {
...@@ -111,6 +119,11 @@ func (zb *zBlkBase) bindZFile(zfile *ZBigFile, blk int64) { ...@@ -111,6 +119,11 @@ func (zb *zBlkBase) bindZFile(zfile *ZBigFile, blk int64) {
blkmap.Add(blk) blkmap.Add(blk)
} }
// blkBoundTo implementss zBlk.
func (zb *zBlkBase) blkBoundTo() map[*ZBigFile]SetI64 {
return zb.inzfile
}
// ---- ZBlk0 ---- // ---- ZBlk0 ----
// ZBlk0 mimics ZBlk0 from python. // 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