mhprimary

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: Apache-2.0, MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

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

	SizePrefix = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

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 added in v0.3.0

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

func (*IndexRemapper) FileSize added in v0.3.0

func (ir *IndexRemapper) FileSize() uint32

func (*IndexRemapper) RemapOffset added in v0.3.0

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

type Iterator added in v0.3.0

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

func NewIterator added in v0.3.0

func NewIterator(basePath string, fileNum uint32) *Iterator

func (*Iterator) Close added in v0.3.0

func (iter *Iterator) Close() error

func (*Iterator) Next added in v0.3.0

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

type MultihashPrimary

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

A primary storage that is multihash aware.

func Open added in v0.2.0

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

Open opens the multihash 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 (*MultihashPrimary) Close

func (mp *MultihashPrimary) Close() error

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

func (*MultihashPrimary) FileSize added in v0.3.0

func (cp *MultihashPrimary) FileSize() uint32

func (*MultihashPrimary) Flush

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

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

func (*MultihashPrimary) GC added in v0.3.0

func (mp *MultihashPrimary) GC(ctx context.Context, lowUsePercent int64) (int64, error)

func (*MultihashPrimary) Get

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

func (*MultihashPrimary) GetIndexKey

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

func (*MultihashPrimary) IndexKey

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

func (*MultihashPrimary) Iter

func (*MultihashPrimary) NewIndexRemapper added in v0.3.0

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

func (*MultihashPrimary) OutstandingWork

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

func (*MultihashPrimary) Put

func (cp *MultihashPrimary) 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 (*MultihashPrimary) StartGC added in v0.3.0

func (mp *MultihashPrimary) StartGC(freeList *freelist.FreeList, interval, timeLimit time.Duration, updateIndex UpdateIndexFunc)

func (*MultihashPrimary) StorageSize added in v0.2.0

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

StorageSize returns bytes of storage used by the primary files.

func (*MultihashPrimary) Sync

func (mp *MultihashPrimary) Sync() error

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

type UpdateIndexFunc added in v0.3.0

type UpdateIndexFunc func([]byte, types.Block) error

Jump to

Keyboard shortcuts

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