示例#1
0
文件: block.go 项目: taysom/va
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)
	}
}
示例#2
0
文件: block.go 项目: taysom/va
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
}
示例#3
0
文件: block.go 项目: taysom/va
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
}