Documentation ¶
Index ¶
- Constants
- Variables
- type Pager
- func (p *Pager) Alloc(n int) (uint64, error)
- func (p *Pager) Close() error
- func (p *Pager) Count() uint64
- func (p *Pager) Free(n int) error
- func (p *Pager) Marshal(id uint64, v encoding.BinaryMarshaler) error
- func (p *Pager) PageSize() int
- func (p *Pager) Read(id uint64) ([]byte, error)
- func (p *Pager) ReadAt(dst []byte, offset uint64) error
- func (p *Pager) ReadOnly() bool
- func (p *Pager) Remove()
- func (p *Pager) Stats() Stats
- func (p *Pager) String() string
- func (p *Pager) Unmarshal(id uint64, into encoding.BinaryUnmarshaler) error
- func (p *Pager) Write(id uint64, d []byte) error
- func (p *Pager) WriteAt(src []byte, offset uint64) error
- type RandomAccessFile
- type Stats
Constants ¶
const InMemoryFileName = ":memory:"
InMemoryFileName can be passed to Open() to create a pager for an ephemeral in-memory file.
Variables ¶
var ErrReadOnly = errors.New("read-only")
ErrReadOnly is returned when a write operation is attempted on a read-only pager instance.
Functions ¶
This section is empty.
Types ¶
type Pager ¶
type Pager struct {
// contains filtered or unexported fields
}
Pager provides facilities for paged I/O on file-like objects with random access. If the underlying file is os.File type, memory mapping will be enabled when file size is non-zero.
func Open ¶
Open opens the named file and returns a pager instance for it. If the file doesn't exist, it will be created if not in read-only mode.
func (*Pager) Alloc ¶
Alloc allocates 'n' new sequential pages and returns the id of the first page in sequence.
func (*Pager) Count ¶
Count returns the number of pages in the underlying file. Returns error if the file is closed.
func (*Pager) Marshal ¶
func (p *Pager) Marshal(id uint64, v encoding.BinaryMarshaler) error
Marshal writes the marshaled value of 'v' into page with given id.
func (*Pager) Read ¶
Read reads one page of data from the underlying file or mmapped region if enabled.
func (*Pager) Unmarshal ¶
func (p *Pager) Unmarshal(id uint64, into encoding.BinaryUnmarshaler) error
Unmarshal reads the page with given id and unmarshals the page data using 'into' and 'slot'.