page

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloseFunc

type CloseFunc func(f *os.File, mappedBytes []byte) error

CloseFunc defines the way to release underlying bytes. This makes it easy to use normal non-mmapped bytes for test.

var MMapCloseFunc CloseFunc = fileutil.Unmap

MMapCloseFunc defines the way to release mmaped bytes.

type Factory

type Factory interface {
	io.Closer
	// AcquirePage acquires a mapped page with specific index from the factory
	AcquirePage(index int64) (MappedPage, error)
	// GetPage returns a mapped page with specific index
	GetPage(index int64) (MappedPage, bool)
	// TruncatePages truncates expired page by index(page id).
	TruncatePages(index int64)
	// Size returns the total page size
	Size() int64
}

Factory represents mapped page manage factory

func NewFactory

func NewFactory(path string, pageSize int) (fct Factory, err error)

NewFactory creates page factory based on page size

type MappedPage

type MappedPage interface {
	// FilePath returns mapped filePath
	FilePath() string
	// WriteBytes writes bytes data into buffer
	WriteBytes(data []byte, offset int)
	// ReadBytes reads bytes data from buffer
	ReadBytes(offset, length int) []byte
	// PutUint64 puts uint64 into buffer
	PutUint64(value uint64, offset int)
	// ReadUint64 reads uint64 from buffer
	ReadUint64(offset int) uint64
	// PutUint32 puts uint32 into buffer
	PutUint32(value uint32, offset int)
	// ReadUint32 reads uint32 from buffer
	ReadUint32(offset int) uint32
	// PutUint8 puts uint8 into buffer
	PutUint8(value uint8, offset int)
	// ReadUint8 reads uint8 from buffer
	ReadUint8(offset int) uint8
	// Sync syncs page to persist storage
	Sync() error
	// Close releases underlying bytes
	Close() error
	// Closed returns if the mmap bytes is closed
	Closed() bool
	// Size returns the size of underlying bytes
	Size() int
}

MappedPage represents a holder for mmap bytes, one MappedPage corresponds to a mapped file.

func NewMappedPage

func NewMappedPage(fileName string, size int) (MappedPage, error)

NewMappedPage returns a new MappedPage wrapping the give bytes.

type SyncFunc

type SyncFunc func(mappedBytes []byte) error

SyncFunc defines the way to flush bytes to storage. This makes it easy to use normal non-mmapped bytes for test.

var MMapSyncFunc SyncFunc = fileutil.Sync

MMapSyncFunc defines the way to flush mmaped bytes.

Jump to

Keyboard shortcuts

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