encoding

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalRecords

func MarshalRecords(records []*Record) ([]byte, error)

todo: move encoding/decoding to a separate util area? is the index too large? need an io.Reader?

func RecordCount

func RecordCount(b []byte) int

Types

type Appender

type Appender interface {
	Append(ID, []byte) error
	Complete()
	Records() []*Record
	Length() int
}

func NewAppender

func NewAppender(writer io.Writer) Appender

func NewBufferedAppender

func NewBufferedAppender(writer io.Writer, indexDownsample int, totalObjectsEstimate int) Appender

type BlockMeta

type BlockMeta struct {
	Version         string    `json:"format"`
	BlockID         uuid.UUID `json:"blockID"`
	MinID           ID        `json:"minID"`
	MaxID           ID        `json:"maxID"`
	TenantID        string    `json:"tenantID"`
	StartTime       time.Time `json:"startTime"`
	EndTime         time.Time `json:"endTime"`
	TotalObjects    int       `json:"totalObjects"`
	CompactionLevel uint8     `json:"compactionLevel"`
}

func NewBlockMeta

func NewBlockMeta(tenantID string, blockID uuid.UUID) *BlockMeta

func (*BlockMeta) ObjectAdded

func (b *BlockMeta) ObjectAdded(id ID)

type CompactedBlockMeta

type CompactedBlockMeta struct {
	BlockMeta

	CompactedTime time.Time `json:"-"`
}

type Finder

type Finder interface {
	Find(id ID) ([]byte, error)
}

func NewDedupingFinder

func NewDedupingFinder(sortedRecords []*Record, ra io.ReaderAt, combiner ObjectCombiner) Finder

func NewFinder

func NewFinder(sortedRecords []*Record, ra io.ReaderAt) Finder

type ID

type ID []byte

type Iterator

type Iterator interface {
	Next() (ID, []byte, error)
}

func NewBackendIterator

func NewBackendIterator(tenantID string, blockID uuid.UUID, chunkSizeBytes uint32, reader Reader) (Iterator, error)

func NewDedupingIterator

func NewDedupingIterator(iter Iterator, combiner ObjectCombiner) (Iterator, error)

func NewIterator

func NewIterator(reader io.Reader) Iterator

func NewRecordIterator

func NewRecordIterator(r []*Record, ra io.ReaderAt) Iterator

type ObjectCombiner

type ObjectCombiner interface {
	Combine(objA []byte, objB []byte) []byte
}

type Reader

type Reader interface {
	Index(ctx context.Context, blockID uuid.UUID, tenantID string) ([]byte, error)
	Object(ctx context.Context, blockID uuid.UUID, tenantID string, start uint64, buffer []byte) error
}

type Record

type Record struct {
	ID     ID
	Start  uint64
	Length uint32
}

func FindRecord

func FindRecord(id ID, recordBytes []byte) (*Record, error)

binary search the bytes. records are not compressed and ordered

func UnmarshalRecords

func UnmarshalRecords(recordBytes []byte) ([]*Record, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳