index

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const LocationSize = 8 + 8 + 4 + TrailerSize

LocationSize is the physical storage of a single item (8 for the key, 8 for the wal offset, 4 for the len)

View Source
const TrailerSize = 4

Variables

This section is empty.

Functions

func ReadTrailers added in v0.9.0

func ReadTrailers(dir string, fn func(consumerName string, trailer Trailer)) error

func WriteIndex

func WriteIndex(idx *Index, path string) error

WriteIndex is a convenience function to write the contents of `idx` to `path`.

Types

type Index

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

Index is an in-memory representation of the batch index as b-tree structure.

func FromVlog

func FromVlog(log *vlog.Log) (*Index, error)

FromVlog produces an index from the data in the value log. It's main use is to re-generate the index in case the index file is damaged or broken in some way. The resulting index is likely not the same as before, but will include items that were popped already.

func Load

func Load(path string) (*Index, error)

func (*Index) Copy added in v0.9.0

func (i *Index) Copy() *Index

func (*Index) Delete

func (i *Index) Delete(key item.Key) (loc item.Location)

func (*Index) Iter

func (i *Index) Iter() Iter

func (*Index) Len

func (i *Index) Len() item.Off

Len returns the number of items in the WAL. (Not the number of locations or batches!)

func (*Index) NEntries

func (i *Index) NEntries() item.Off

NEntries returns the number of entries in the index. This is not the same Len() as a deleted item is also inserted into the index.

func (*Index) Set

func (i *Index) Set(loc item.Location) (item.Location, int)

func (*Index) Trailer

func (i *Index) Trailer() Trailer

type Iter

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

func (*Iter) Next

func (i *Iter) Next() bool

func (*Iter) Value

func (i *Iter) Value() item.Location

type Reader

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

Reader gives access to a single index on disk

func NewReader

func NewReader(r io.Reader) *Reader

func (*Reader) Err

func (fi *Reader) Err() error

func (*Reader) Next

func (fi *Reader) Next(loc *item.Location) bool

type Trailer

type Trailer struct {
	TotalEntries item.Off
}

func ReadTrailer

func ReadTrailer(path string) (Trailer, error)

ReadTrailer reads the trailer of the index log. It contains the number of entries in the index.

type Writer

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

func NewWriter

func NewWriter(path string, sync bool) (*Writer, error)

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Push

func (w *Writer) Push(loc item.Location, trailer Trailer) error

func (*Writer) Sync

func (w *Writer) Sync(force bool) error

Jump to

Keyboard shortcuts

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