paging

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Stream   io.ReadWriteSeeker
	PageSize int64
	Pages    int64
}

File is a page-file over an underlying random-access stream.

func New

func New(s io.ReadWriteSeeker, pageSize int) (*File, error)

New instantiates a new page-file.

func (*File) Alloc

func (f *File) Alloc() (*Page, error)

Alloc allocates a new page at the end of the page-file.

func (*File) Read

func (f *File) Read(index int64) (*Page, error)

Read reads a page at the given index from the page-file.

func (*File) Write

func (f *File) Write(page *Page) error

Write writes a page back to the page-file.

type Memory

type Memory struct {
	Data   []byte
	Cursor int
}

Memory is an in-memory implementation of io.ReadWriteSeeker.

func (*Memory) Read

func (m *Memory) Read(p []byte) (int, error)

Read reads upto len(p) bytes into p from the stream.

func (*Memory) Seek

func (m *Memory) Seek(offset int64, whence int) (int64, error)

Seek sets the offset for the next Read or Write.

func (*Memory) Write

func (m *Memory) Write(p []byte) (int, error)

Write writes upto len(p) bytes from p to the stream.

type Page

type Page struct {
	Data  []byte
	Index int64
}

Page is a sequence of bytes in the page-file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL