commit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Next

func Next() uint64

Next returns the next commit ID

Types

type Buffer

type Buffer struct {
	Column string // The column for the queue
	// contains filtered or unexported fields
}

Buffer represents a buffer of delta operations.

func NewBuffer

func NewBuffer(capacity int) *Buffer

NewBuffer creates a new queue to store individual operations.

func (*Buffer) AddFloat32

func (b *Buffer) AddFloat32(idx uint32, value float32)

AddFloat32 appends an addition of int32 value.

func (*Buffer) AddFloat64

func (b *Buffer) AddFloat64(idx uint32, value float64)

AddFloat64 appends a float64 value.

func (*Buffer) AddInt

func (b *Buffer) AddInt(idx uint32, value int)

AddInt appends an addition of int64 value.

func (*Buffer) AddInt16

func (b *Buffer) AddInt16(idx uint32, value int16)

AddInt16 appends an addition of int16 value.

func (*Buffer) AddInt32

func (b *Buffer) AddInt32(idx uint32, value int32)

AddInt32 appends an addition of int32 value.

func (*Buffer) AddInt64

func (b *Buffer) AddInt64(idx uint32, value int64)

AddInt64 appends an addition of int64 value.

func (*Buffer) AddNumber

func (b *Buffer) AddNumber(idx uint32, value float64)

AddNumber appends an addition of float64 value.

func (*Buffer) AddUint

func (b *Buffer) AddUint(idx uint32, value uint)

AddUint appends an addition of uint64 value.

func (*Buffer) AddUint16

func (b *Buffer) AddUint16(idx uint32, value uint16)

AddUint16 appends an addition of uint16 value.

func (*Buffer) AddUint32

func (b *Buffer) AddUint32(idx uint32, value uint32)

AddUint32 appends an addition of uint32 value.

func (*Buffer) AddUint64

func (b *Buffer) AddUint64(idx uint32, value uint64)

AddUint64 appends an addition of uint64 value.

func (*Buffer) Clone

func (b *Buffer) Clone() *Buffer

Clone clones the buffer

func (*Buffer) IsEmpty

func (b *Buffer) IsEmpty() bool

IsEmpty returns whether the buffer is empty or not.

func (*Buffer) PutAny

func (b *Buffer) PutAny(op OpType, idx uint32, value interface{})

PutAny appends a supported value onto the buffer.

func (*Buffer) PutBitmap

func (b *Buffer) PutBitmap(op OpType, chunk Chunk, value bitmap.Bitmap)

PutBitmap iterates over the bitmap values and appends an operation for each bit set to one

func (*Buffer) PutBool

func (b *Buffer) PutBool(idx uint32, value bool)

PutBool appends a boolean value.

func (*Buffer) PutBytes

func (b *Buffer) PutBytes(op OpType, idx uint32, value []byte)

PutBytes appends a binary value.

func (*Buffer) PutFloat32

func (b *Buffer) PutFloat32(idx uint32, value float32)

PutFloat32 appends an int32 value.

func (*Buffer) PutFloat64

func (b *Buffer) PutFloat64(idx uint32, value float64)

PutFloat64 appends a float64 value.

func (*Buffer) PutInt

func (b *Buffer) PutInt(idx uint32, value int)

PutInt appends a int64 value.

func (*Buffer) PutInt16

func (b *Buffer) PutInt16(idx uint32, value int16)

PutInt16 appends an int16 value.

func (*Buffer) PutInt32

func (b *Buffer) PutInt32(idx uint32, value int32)

PutInt32 appends an int32 value.

func (*Buffer) PutInt64

func (b *Buffer) PutInt64(idx uint32, value int64)

PutInt64 appends an int64 value.

func (*Buffer) PutNumber

func (b *Buffer) PutNumber(idx uint32, value float64)

PutNumber appends a float64 value.

func (*Buffer) PutOperation

func (b *Buffer) PutOperation(op OpType, idx uint32)

PutOperation appends an operation type without a value.

func (*Buffer) PutString

func (b *Buffer) PutString(op OpType, idx uint32, value string)

PutString appends a string value.

func (*Buffer) PutUint

func (b *Buffer) PutUint(idx uint32, value uint)

PutUint appends a uint64 value.

func (*Buffer) PutUint16

func (b *Buffer) PutUint16(idx uint32, value uint16)

PutUint16 appends an uint16 value.

func (*Buffer) PutUint32

func (b *Buffer) PutUint32(idx uint32, value uint32)

PutUint32 appends an uint32 value.

func (*Buffer) PutUint64

func (b *Buffer) PutUint64(idx uint32, value uint64)

PutUint64 appends an uint64 value.

func (*Buffer) RangeChunks

func (b *Buffer) RangeChunks(fn func(chunk Chunk))

Range iterates over the chunks present in the buffer

func (*Buffer) ReadFrom

func (b *Buffer) ReadFrom(src io.Reader) (int64, error)

ReadFrom reads data from r until EOF or error. The return value n is the number of bytes read. Any error except EOF encountered during the read is also returned.

func (*Buffer) Reset

func (b *Buffer) Reset(column string)

Reset resets the queue so it can be reused.

func (*Buffer) WriteTo

func (b *Buffer) WriteTo(dst io.Writer) (int64, error)

WriteTo writes data to w until there's no more data to write or when an error occurs. The return value n is the number of bytes written. Any error encountered during the write is also returned.

type Channel

type Channel chan Commit

Channel represents an impementation of a commit writer that simply sends each commit into the channel.

func (Channel) Append

func (w Channel) Append(commit Commit) error

Append clones the commit and writes it into the logger

type Chunk

type Chunk uint32

Chunk represents a chunk number

func ChunkAt

func ChunkAt(index uint32) Chunk

ChunkAt returns the chunk number at a given index

func (Chunk) Max

func (c Chunk) Max() uint32

Max returns the max offset at which the chunk should be ending

func (Chunk) Min

func (c Chunk) Min() uint32

Min returns the min offset at which the chunk should be starting

func (Chunk) OfBitmap

func (c Chunk) OfBitmap(v bitmap.Bitmap) bitmap.Bitmap

OfBitmap computes a chunk for a given bitmap

func (Chunk) Range

func (c Chunk) Range(v bitmap.Bitmap, fn func(idx uint32))

Range iterates over a chunk given a bitmap

type Commit

type Commit struct {
	ID      uint64    // The commit ID
	Chunk   Chunk     // The chunk number
	Updates []*Buffer // The update buffers
}

Commit represents an individual transaction commit. If multiple chunks are committed in the same transaction, it would result in multiple commits per transaction.

func (*Commit) Clone

func (c *Commit) Clone() (clone Commit)

Clone clones a commit into a new one

func (*Commit) ReadFrom

func (c *Commit) ReadFrom(src io.Reader) (int64, error)

ReadFrom reads data from r until EOF or error. The return value n is the number of bytes read. Any error except EOF encountered during the read is also returned.

func (*Commit) WriteTo

func (c *Commit) WriteTo(dst io.Writer) (int64, error)

WriteTo writes data to w until there's no more data to write or when an error occurs. The return value n is the number of bytes written. Any error encountered during the write is also returned.

type Log

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

Log represents a commit log that can be used to write the changes to the collection during a snapshot. It also supports reading a commit log back.

func Open

func Open(source io.Reader) *Log

Open opens a commit log stream for both read and write.

func OpenFile

func OpenFile(filename string) (*Log, error)

OpenFile opens a specified commit log file in a read/write mode. If the file does not exist, it will create it.

func OpenTemp

func OpenTemp() (*Log, error)

OpenTemp opens a temporary commit log file with read/write permissions

func (*Log) Append

func (l *Log) Append(commit Commit) (err error)

Append writes the commit into the log destination

func (*Log) Close

func (l *Log) Close() (err error)

Close closes the source log file.

func (*Log) Copy

func (l *Log) Copy(dst io.Writer) error

Copy copies the contents of the log into the destination writer.

func (*Log) Name

func (l *Log) Name() (name string)

Name calls the corresponding Name() method on the underlying source

func (*Log) Range

func (l *Log) Range(fn func(Commit) error) error

Range iterates over all the commits in the log and calls the provided callback function on each of them. If the callback returns an error, the iteration will stop.

type Logger

type Logger interface {
	Append(commit Commit) error
}

Logger represents a contract that a commit logger must implement

type OpType

type OpType uint8

OpType represents a type of an operation.

const (
	Delete   OpType = 0 // Delete deletes an entire row or a set of rows
	Insert   OpType = 1 // Insert inserts a new row or a set of rows
	PutFalse OpType = 0 // PutFalse is a combination of Put+False for boolean values
	PutTrue  OpType = 2 // PutTrue is a combination of Put+True for boolean values
	Put      OpType = 2 // Put stores a value regardless of a previous value
	Add      OpType = 3 // Add increments the current stored value by the amount
)

Various update operations supported.

type Reader

type Reader struct {
	Type OpType // The current operation type

	Offset int32 // The current offset
	// contains filtered or unexported fields
}

Reader represnts a commit log reader (iterator).

func NewReader

func NewReader() *Reader

NewReader creates a new reader for a commit log.

func (*Reader) AddToFloat32

func (r *Reader) AddToFloat32(value float32) float32

AddToFloat32 adds and swaps a float32 value with a new one.

func (*Reader) AddToFloat64

func (r *Reader) AddToFloat64(value float64) float64

AddToFloat64 adds and swaps a float64 value with a new one.

func (*Reader) AddToInt

func (r *Reader) AddToInt(value int) int

AddToInt adds and swaps a int value with a new one.

func (*Reader) AddToInt16

func (r *Reader) AddToInt16(value int16) int16

AddToInt16 adds and swaps a int16 value with a new one.

func (*Reader) AddToInt32

func (r *Reader) AddToInt32(value int32) int32

AddToInt32 adds and swaps a int32 value with a new one.

func (*Reader) AddToInt64

func (r *Reader) AddToInt64(value int64) int64

AddToInt64 adds and swaps a int64 value with a new one.

func (*Reader) AddToUint

func (r *Reader) AddToUint(value uint) uint

AddToUint adds and swaps a uint value with a new one.

func (*Reader) AddToUint16

func (r *Reader) AddToUint16(value uint16) uint16

AddToUint16 adds and swaps a uint16 value with a new one.

func (*Reader) AddToUint32

func (r *Reader) AddToUint32(value uint32) uint32

AddToUint32 adds and swaps a uint32 value with a new one.

func (*Reader) AddToUint64

func (r *Reader) AddToUint64(value uint64) uint64

AddToUint64 adds and swaps a uint64 value with a new one.

func (*Reader) Bool

func (r *Reader) Bool() bool

Bool reads a boolean value.

func (*Reader) Bytes

func (r *Reader) Bytes() []byte

Bytes reads a binary value.

func (*Reader) Float

func (r *Reader) Float() float64

Float reads a floating-point value of any size.

func (*Reader) Float32

func (r *Reader) Float32() float32

Float32 reads a float32 value.

func (*Reader) Float64

func (r *Reader) Float64() float64

Float64 reads a float64 value.

func (*Reader) Index

func (r *Reader) Index() uint32

Index returns the current index of the reader.

func (*Reader) IndexAtChunk

func (r *Reader) IndexAtChunk() uint32

IndexAtChunk returns the current index assuming chunk starts at 0.

func (*Reader) Int

func (r *Reader) Int() int

Int reads a int value of any size.

func (*Reader) Int16

func (r *Reader) Int16() int16

Int16 reads a uint16 value.

func (*Reader) Int32

func (r *Reader) Int32() int32

Int32 reads a uint32 value.

func (*Reader) Int64

func (r *Reader) Int64() int64

Int64 reads a uint64 value.

func (*Reader) Next

func (r *Reader) Next() bool

Next reads the current operation and returns false if there is no more operations in the log.

func (*Reader) Number

func (r *Reader) Number() float64

Number reads a float64 value. This is used for codegen, equivalent to Float64().

func (*Reader) Range

func (r *Reader) Range(buf *Buffer, chunk Chunk, fn func(*Reader))

Range iterates over parts of the buffer which match the specified chunk.

func (*Reader) Rewind

func (r *Reader) Rewind()

Rewind rewinds the reader back to zero.

func (*Reader) Seek

func (r *Reader) Seek(b *Buffer)

Seek resets the reader so it can be reused.

func (*Reader) String

func (r *Reader) String() string

String reads a string value.

func (*Reader) SwapBool

func (r *Reader) SwapBool(b bool)

SwapBool swaps a boolean value with a new one.

func (*Reader) SwapFloat32

func (r *Reader) SwapFloat32(v float32)

SwapFloat32 swaps a float32 value with a new one.

func (*Reader) SwapFloat64

func (r *Reader) SwapFloat64(v float64)

SwapFloat64 swaps a float64 value with a new one.

func (*Reader) SwapInt

func (r *Reader) SwapInt(v int)

SwapInt swaps a uint64 value with a new one.

func (*Reader) SwapInt16

func (r *Reader) SwapInt16(v int16)

SwapInt16 swaps a uint16 value with a new one.

func (*Reader) SwapInt32

func (r *Reader) SwapInt32(v int32)

SwapInt32 swaps a uint32 value with a new one.

func (*Reader) SwapInt64

func (r *Reader) SwapInt64(v int64)

SwapInt64 swaps a uint64 value with a new one.

func (*Reader) SwapUint

func (r *Reader) SwapUint(v uint)

SwapUint swaps a uint64 value with a new one.

func (*Reader) SwapUint16

func (r *Reader) SwapUint16(v uint16)

SwapUint16 swaps a uint16 value with a new one.

func (*Reader) SwapUint32

func (r *Reader) SwapUint32(v uint32)

SwapUint32 swaps a uint32 value with a new one.

func (*Reader) SwapUint64

func (r *Reader) SwapUint64(v uint64)

SwapUint64 swaps a uint64 value with a new one.

func (*Reader) Uint

func (r *Reader) Uint() uint

Uint reads a uint value of any size.

func (*Reader) Uint16

func (r *Reader) Uint16() uint16

Uint16 reads a uint16 value.

func (*Reader) Uint32

func (r *Reader) Uint32() uint32

Uint32 reads a uint32 value.

func (*Reader) Uint64

func (r *Reader) Uint64() uint64

Uint64 reads a uint64 value.

Jump to

Keyboard shortcuts

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