gsfaprimary

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: AGPL-3.0, Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrimaryVersion is stored in the header data to indicate how to interpret
	// primary data.
	PrimaryVersion = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GsfaPrimary

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

A primary storage that is multihash aware.

func Open

func Open(path string, freeList *freelist.FreeList, fileCache *filecache.FileCache, maxFileSize uint32) (*GsfaPrimary, error)

Open opens the gsfa primary storage file. The primary is created if there is no existing primary at the specified path. If there is an older version primary, then it is automatically upgraded.

func (*GsfaPrimary) Close

func (mp *GsfaPrimary) Close() error

Close calls Flush to write work and data to the primary file, and then closes the file.

func (*GsfaPrimary) FileSize

func (cp *GsfaPrimary) FileSize() uint32

func (*GsfaPrimary) Flush

func (cp *GsfaPrimary) Flush() (types.Work, error)

Flush writes outstanding work and buffered data to the primary file.

func (*GsfaPrimary) Get

func (cp *GsfaPrimary) Get(blk types.Block) ([]byte, []byte, error)

func (*GsfaPrimary) GetIndexKey

func (cp *GsfaPrimary) GetIndexKey(blk types.Block) ([]byte, error)

func (*GsfaPrimary) IndexKey

func (cp *GsfaPrimary) IndexKey(key []byte) ([]byte, error)

func (*GsfaPrimary) Iter

func (*GsfaPrimary) NewIndexRemapper

func (mp *GsfaPrimary) NewIndexRemapper() (*IndexRemapper, error)

func (*GsfaPrimary) OutstandingWork

func (cp *GsfaPrimary) OutstandingWork() types.Work

func (*GsfaPrimary) Overwrite

func (cp *GsfaPrimary) Overwrite(blk types.Block, key []byte, value []byte) error

func (*GsfaPrimary) Put

func (cp *GsfaPrimary) Put(key []byte, value []byte) (types.Block, error)

Put adds a new pending blockRecord to the pool and returns a Block that contains the location that the block will occupy in the primary. The returned primary location must be an absolute position across all primary files.

func (*GsfaPrimary) StorageSize

func (cp *GsfaPrimary) StorageSize() (int64, error)

StorageSize returns bytes of storage used by the primary files.

func (*GsfaPrimary) Sync

func (mp *GsfaPrimary) Sync() error

Sync commits the contents of the primary file to disk. Flush should be called before calling Sync.

type Header struct {
	// A version number in case we change the header
	Version int
	// MaxFileSize is the size limit of each index file. This cannot be greater
	// than 4GiB.
	MaxFileSize uint32
	// First index file number
	FirstFile uint32
}

Header contains information about the primary. This is actually stored in a separate ".info" file, but is the first file read when the index is opened.

type IndexRemapper

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

func (*IndexRemapper) FileSize

func (ir *IndexRemapper) FileSize() uint32

func (*IndexRemapper) RemapOffset

func (ir *IndexRemapper) RemapOffset(pos types.Position) (types.Position, error)

type Iterator

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

func NewIterator

func NewIterator(basePath string, fileNum uint32) *Iterator

func (*Iterator) Close

func (iter *Iterator) Close() error

func (*Iterator) Next

func (iter *Iterator) Next() ([]byte, []byte, error)

type Pubkey

type Pubkey []byte

Jump to

Keyboard shortcuts

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