Esempio n. 1
0
func (md *mdRelation) NBlocks() (system.BlockNumber, error) {
	relpath := system.RelPath(md.node)

	fi, err := os.Stat(relpath)
	if err != nil {
		return 0, err
	}
	return system.BlockNumber(fi.Size() / int64(system.BlockSize)), nil
}
Esempio n. 2
0
func (rel *HeapRelation) GetNumberOfBlocks() (system.BlockNumber, error) {
	relpath := system.RelPath(rel.RelNode)
	fi, err := os.Stat(relpath)
	if err != nil {
		return 0, err
	}
	size := fi.Size()
	if size%system.BlockSize != 0 {
		return 0, fmt.Errorf("size of %s = %d is not module BlockSize", size, relpath)
	}

	return system.BlockNumber(size / system.BlockSize), nil
}
Esempio n. 3
0
func (md *mdRelation) openFile() error {
	// TODO: do we care concurrency?
	if md.file == nil {
		relpath := system.RelPath(md.node)
		file, err := os.OpenFile(relpath, os.O_RDWR, 0600)
		if err != nil {
			md.file = nil
			return err
		}
		md.file = file
	}

	return nil
}