offset2

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT Imports: 12 Imported by: 3

Documentation

Overview

Package offset2 implements a margaret log as persisted sequence of data across multiple files.

Format Defintion

A log consists of three files: data, ofst and jrnl.

* data: a list of length-prefixed data chunks, size is a uint64 (size++[size]byte).

* ofst: a list of uint64, representing entry offsets in 'data'

* jrnl keeps track of the current sequence number, see checkJournal() for more

To read entry 5 in `data`, you follow these steps:

1. Seek to 5*(sizeof(uint64)=8)=40 in `ofset` and read the uint64 representing the offset in `data`

2. Seek to that offset in `data`, read the length-prefix (the uint64 for the size of the entry)

3. Finally, read that amount of data, which is your entry

All uint64's are encoded in BigEndian.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LockSink

func LockSink(sink luigi.Sink) luigi.Sink

Types

type OffsetLog added in v0.4.1

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

func Open

func Open(name string, cdc margaret.Codec) (*OffsetLog, error)

Open returns a the offset log in the directory at `name`. If it is empty or does not exist, a new log will be created.

func (*OffsetLog) Append added in v0.4.1

func (log *OffsetLog) Append(v interface{}) (int64, error)

func (*OffsetLog) Changes added in v0.4.1

func (log *OffsetLog) Changes() luigi.Observable

func (*OffsetLog) CheckConsistency added in v0.4.1

func (log *OffsetLog) CheckConsistency() error

CheckConsistency is an fsck for the offset log.

func (*OffsetLog) Close added in v0.4.1

func (log *OffsetLog) Close() error

func (*OffsetLog) FileName added in v0.4.1

func (log *OffsetLog) FileName() string

func (*OffsetLog) Get added in v0.4.1

func (log *OffsetLog) Get(seq int64) (interface{}, error)

func (*OffsetLog) Null added in v0.4.1

func (log *OffsetLog) Null(seq int64) error

Null overwrites the entry at seq with zeros updating is kinda odd in append-only but in some cases you still might want to redact entries

func (*OffsetLog) Query added in v0.4.1

func (log *OffsetLog) Query(specs ...margaret.QuerySpec) (luigi.Source, error)

func (*OffsetLog) Replace added in v0.4.1

func (log *OffsetLog) Replace(seq int64, data []byte) error

Replace overwrites the seq entry with data. data has to be smaller then the current entry.

func (*OffsetLog) Seq added in v0.4.1

func (log *OffsetLog) Seq() int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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