示例#1
0
文件: data.go 项目: ngaut/logbase
// Delete all zapmap records associated with the given logfile number.
func (zmap *Zapmap) Purge(fnum LBUINT, debug *gubed.Logger) {
	debug.Basic("Purge zapmap of logfile %d entries", fnum)
	for key, zrecs := range zmap.zapmap {
		var newzrecs []*ZapRecord // Make a new list to replace old
		for _, zrec := range zrecs {
			if zrec.fnum != fnum {
				newzrecs = append(newzrecs, zrec)
			} else {
				debug.Fine("Deleting %q%s from zapmap", key, zrec.String())
			}
		}
		if len(newzrecs) == 0 {
			zmap.Delete(key)
		} else {
			zmap.Put(key, newzrecs)
		}
	}
	return
}