import "github.com/byte-mug/golibs/filealloc"
This package offers space-management of os.File-like entities.
Each allocation is broken down to a set of simple, atomic steps, so that the file does not get corrupted, if the process or system crashes during an allocation or deallocation.
var EDoubleFree = fmt.Errorf("Warning: Double Free")
-
var EInternalError = fmt.Errorf("Invalid Offset")
-
var EInvalidOffset = fmt.Errorf("Invalid Offset")
-
func LL_getRawSizeForRank(i uint) int
-
type Allocator struct { // contains filtered or unexported fields }
Allocator manages allocation of file blocks within a File.
Allocator methods are not safe for concurrent use by multiple goroutines. Callers must provide their own synchronization whan it's used concurrently by multiple goroutines.
func NewAllocator(f File) (*Allocator, error)
-
func (a *Allocator) Alloc(size int, noGrow bool) (int64, error)
-
func (a *Allocator) ApproxFreeSpace() (total int64)
-
func (a *Allocator) ApproxFreeSpaceFor(minSize int) (total int64)
-
func (a *Allocator) FileSize() int64
-
func (a *Allocator) Free(off int64) error
-
func (a *Allocator) LL_getRanks() [30]int64
-
func (a *Allocator) UsableSize(off int64) (int, error)
-
type File interface { Close() error ReadAt(p []byte, off int64) (n int, err error) Stat() (os.FileInfo, error) Sync() error Truncate(int64) error WriteAt(p []byte, off int64) (n int, err error) }
*os.File
import "encoding/binary"
import "fmt"
import "github.com/byte-mug/golibs/buffer"
import "github.com/byte-mug/golibs/pstruct"
import "os"