func (block *Block) Release() { if block.dirty { n, err := block.cache.f.WriteAt(block.Buf[:], block.id<<blockShift) bug.Err(err) bug.Assert(n == blockSize) } }
func (kv *Kv) Put(key, val Bytes) { var block *Block if kv.rootId == 0 { block = kv.cache.newLeaf() } else { block = kv.cache.Get(kv.rootId) } head := getHead(block) bug.Assert(head.leaf) kv.key = key kv.val = val }
func (cache *Cache) Get(blknum int64) *Block { var block Block n, err := cache.f.ReadAt(block.Buf[:], blknum<<blockShift) if err == io.EOF { n = blockSize err = nil } bug.Err(err) bug.Assert(n == blockSize) block.id = blknum block.cache = cache return &block }