blockfile

package
v0.0.0-...-371cdc4 Latest Latest
Warning

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

Go to latest
Published: May 15, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockAllocator

type BlockAllocator interface {
	GetBlockSize() int
	GetMetaDataSize() int
	GetNumBlocks() (BlockIndex, error)
	GetCache() *blockcache.BlockCache

	Close() error

	Allocate(tag interface{}) (BlockIndex, error)
	Free(index BlockIndex) error
	Read(index BlockIndex, buf []byte) ([]byte, error)
	ReadAt(index BlockIndex, off, sz int, buf []byte) ([]byte, error)
	Write(tag interface{}, index BlockIndex, buf []byte) error
	WriteAt(tag interface{}, index BlockIndex, off int, buf []byte) error
	SyncTag(tag interface{}) error
	AccessBlock(tag interface{}, index BlockIndex, accessFunc func(data []byte) (modified bool, err error)) error
	AccessBlockMeta(index BlockIndex, accessFunc func(meta []byte) (modified bool, err error)) error
	IsBlockReadOnly(index BlockIndex) bool
}

type BlockFile

type BlockFile struct {
	MetaDataSize int
	Cache        *blockcache.BlockCache
	File         *os.File

	// Number of blocks to "pre-allocate" upon initialization. These blocks will
	// be numbered 1, 2, ..., `PreAllocatedBlocks`. Note that 0 is always a
	// special block used internally and should never be used.
	PreAllocatedBlocks BlockIndex
	// contains filtered or unexported fields
}

func (*BlockFile) AccessBlock

func (bf *BlockFile) AccessBlock(tag interface{}, index BlockIndex, accessFunc func(data []byte) (bool, error)) error

func (*BlockFile) AccessBlockMeta

func (bf *BlockFile) AccessBlockMeta(index BlockIndex, accessFunc func(meta []byte) (bool, error)) error

func (*BlockFile) Allocate

func (bf *BlockFile) Allocate(tag interface{}) (BlockIndex, error)

Allocate a new block and returns the index. The index is a positive int64 that will never exceed the maximum number of simultaneously allocated blocks.

func (*BlockFile) Close

func (bf *BlockFile) Close() error

Closes the underlying file handle.

func (*BlockFile) FlushBlock

func (bf *BlockFile) FlushBlock(ikey interface{}, tag interface{}, buf []byte) (interface{}, error)

func (*BlockFile) Free

func (bf *BlockFile) Free(index BlockIndex) error

Free a block and allow it to be allocated in the future.

func (*BlockFile) GetBlockSize

func (bf *BlockFile) GetBlockSize() int

func (*BlockFile) GetCache

func (bf *BlockFile) GetCache() *blockcache.BlockCache

func (*BlockFile) GetMetaDataSize

func (bf *BlockFile) GetMetaDataSize() int

func (*BlockFile) GetNumBlocks

func (bf *BlockFile) GetNumBlocks() (BlockIndex, error)

func (*BlockFile) Init

func (bf *BlockFile) Init()

func (*BlockFile) IsBlockReadOnly

func (bf *BlockFile) IsBlockReadOnly(index BlockIndex) bool

func (*BlockFile) Open

func (bf *BlockFile) Open(path string, perm os.FileMode) error

Opens the passed blockfile, creating it if necessary using `perm` permissions.

func (*BlockFile) Read

func (bf *BlockFile) Read(index BlockIndex, buf []byte) ([]byte, error)

Read an entire block into the passed buffer. If the buffer is not large enough (or nil) a new array will be allocated and returned.

func (*BlockFile) ReadAt

func (bf *BlockFile) ReadAt(index BlockIndex, off, sz int, buf []byte) ([]byte, error)

Read part of a block into the passed buffer. If the buffer is not large enough (or nil) a new array will be allocated and returned.

func (*BlockFile) SyncTag

func (bf *BlockFile) SyncTag(tag interface{}) error

func (*BlockFile) Write

func (bf *BlockFile) Write(tag interface{}, index BlockIndex, buf []byte) error

Write an entire block to the block file. buf must be exactly bf.BlockSize in length.

func (*BlockFile) WriteAt

func (bf *BlockFile) WriteAt(tag interface{}, index BlockIndex, off int, buf []byte) error

Write part of a block to the block file.

type BlockIndex

type BlockIndex = int64

func Duplicate

func Duplicate(tag interface{}, bf BlockAllocator, index BlockIndex, onlyIfReadOnly bool) (BlockIndex, error)

type BlockOverlayAllocator

type BlockOverlayAllocator struct {
	// contains filtered or unexported fields
}

func (*BlockOverlayAllocator) AccessBlock

func (bf *BlockOverlayAllocator) AccessBlock(tag interface{}, index BlockIndex, accessFunc func(data []byte) (modified bool, err error)) error

func (*BlockOverlayAllocator) AccessBlockMeta

func (bf *BlockOverlayAllocator) AccessBlockMeta(index BlockIndex, accessFunc func(meta []byte) (modified bool, err error)) error

func (*BlockOverlayAllocator) Allocate

func (bf *BlockOverlayAllocator) Allocate(tag interface{}) (BlockIndex, error)

func (*BlockOverlayAllocator) Close

func (bf *BlockOverlayAllocator) Close() error

func (*BlockOverlayAllocator) Free

func (bf *BlockOverlayAllocator) Free(index BlockIndex) error

func (*BlockOverlayAllocator) GetBlockSize

func (bf *BlockOverlayAllocator) GetBlockSize() int

func (*BlockOverlayAllocator) GetCache

func (*BlockOverlayAllocator) GetMetaDataSize

func (bf *BlockOverlayAllocator) GetMetaDataSize() int

func (*BlockOverlayAllocator) GetNumBlocks

func (bf *BlockOverlayAllocator) GetNumBlocks() (BlockIndex, error)

func (*BlockOverlayAllocator) Init

func (bf *BlockOverlayAllocator) Init(roAllocator, wrAllocator BlockAllocator) error

func (*BlockOverlayAllocator) IsBlockReadOnly

func (bf *BlockOverlayAllocator) IsBlockReadOnly(index BlockIndex) bool

func (*BlockOverlayAllocator) Read

func (bf *BlockOverlayAllocator) Read(index BlockIndex, buf []byte) ([]byte, error)

func (*BlockOverlayAllocator) ReadAt

func (bf *BlockOverlayAllocator) ReadAt(index BlockIndex, off, sz int, buf []byte) ([]byte, error)

func (*BlockOverlayAllocator) SyncTag

func (bf *BlockOverlayAllocator) SyncTag(tag interface{}) error

func (*BlockOverlayAllocator) Write

func (bf *BlockOverlayAllocator) Write(tag interface{}, index BlockIndex, buf []byte) error

func (*BlockOverlayAllocator) WriteAt

func (bf *BlockOverlayAllocator) WriteAt(tag interface{}, index BlockIndex, off int, buf []byte) error

Jump to

Keyboard shortcuts

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