commit

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 14 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) 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 any) error

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(op OpType, idx uint32, value float32)

PutFloat32 appends an int32 value.

func (*Buffer) PutFloat64

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

PutFloat64 appends a float64 value.

func (*Buffer) PutInt

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

PutInt appends a int64 value.

func (*Buffer) PutInt16

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

PutInt16 appends an int16 value.

func (*Buffer) PutInt32

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

PutInt32 appends an int32 value.

func (*Buffer) PutInt64

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

PutInt64 appends an int64 value.

func (*Buffer) PutNumber

func (b *Buffer) PutNumber(op OpType, 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(op OpType, idx uint32, value uint)

PutUint appends a uint64 value.

func (*Buffer) PutUint16

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

PutUint16 appends an uint16 value.

func (*Buffer) PutUint32

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

PutUint32 appends an uint32 value.

func (*Buffer) PutUint64

func (b *Buffer) PutUint64(op OpType, 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
	Merge    OpType = 3 // Applies a merge function
	Skip     OpType = 4 // Skips the value
)

Various update operations supported.

func (OpType) String added in v0.2.2

func (o OpType) String() string

String returns a string representation

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) 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) IsDelete added in v0.2.3

func (r *Reader) IsDelete() bool

IsDelete returns true if the current operation is a deletion

func (*Reader) IsUpsert added in v0.2.3

func (r *Reader) IsUpsert() bool

IsUpsert returns true if the current operation is an insert or update

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) bool

SwapBool swaps a boolean value with a new one.

func (*Reader) SwapBytes added in v0.2.0

func (r *Reader) SwapBytes(v []byte) []byte

SwapBytes swaps a binary value with a new one.

func (*Reader) SwapFloat32

func (r *Reader) SwapFloat32(v float32) float32

SwapFloat32 swaps a float32 value with a new one.

func (*Reader) SwapFloat64

func (r *Reader) SwapFloat64(v float64) float64

SwapFloat64 swaps a float64 value with a new one.

func (*Reader) SwapInt

func (r *Reader) SwapInt(v int) int

SwapInt swaps a uint64 value with a new one.

func (*Reader) SwapInt16

func (r *Reader) SwapInt16(v int16) int16

SwapInt16 swaps a uint16 value with a new one.

func (*Reader) SwapInt32

func (r *Reader) SwapInt32(v int32) int32

SwapInt32 swaps a uint32 value with a new one.

func (*Reader) SwapInt64

func (r *Reader) SwapInt64(v int64) int64

SwapInt64 swaps a uint64 value with a new one.

func (*Reader) SwapString added in v0.2.0

func (r *Reader) SwapString(v string) string

SwapString swaps a string value with a new one.

func (*Reader) SwapUint

func (r *Reader) SwapUint(v uint) uint

SwapUint swaps a uint64 value with a new one.

func (*Reader) SwapUint16

func (r *Reader) SwapUint16(v uint16) uint16

SwapUint16 swaps a uint16 value with a new one.

func (*Reader) SwapUint32

func (r *Reader) SwapUint32(v uint32) uint32

SwapUint32 swaps a uint32 value with a new one.

func (*Reader) SwapUint64

func (r *Reader) SwapUint64(v uint64) 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