block

package
v0.0.0-...-3f4335e Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Header Header
	Stats  Stats
	Data   []byte
	// contains filtered or unexported fields
}

Block represents a single columnar block on disk. Layout: Header Stats [Data]

func NewBlock

func NewBlock() *Block

NewBlock creates a new empty block

func (*Block) Add

func (b *Block) Add(key, value []byte) error

Add adds a key-value pair to the block

func (*Block) Count

func (b *Block) Count() int

Count returns the number of key-value pairs in the block

func (*Block) Decode

func (b *Block) Decode(r io.Reader) error

Decode reads a block from the given reader.

func (*Block) Encode

func (b *Block) Encode(w io.Writer) error

Encode writes the block to the given writer.

func (*Block) Finalize

func (b *Block) Finalize() error

Finalize prepares the block for writing to disk

func (*Block) Get

func (b *Block) Get(key []byte) ([]byte, error)

Get retrieves a value for a key from the block

func (*Block) ID

func (b *Block) ID() string

ID returns the unique identifier for the block

func (*Block) MaxKey

func (b *Block) MaxKey() string

MaxKey returns the maximum key in the block

func (*Block) MinKey

func (b *Block) MinKey() string

MinKey returns the minimum key in the block

func (*Block) Reader

func (b *Block) Reader() io.Reader

Reader returns a reader for the block data

func (*Block) Size

func (b *Block) Size() int

Size returns the size of the block in bytes

func (*Block) String

func (b *Block) String() string

String returns a string representation of the block

type CompressionType

type CompressionType uint8

CompressionType defines the compression algorithm used.

const (
	CompressionNone CompressionType = iota
	CompressionLZ4
)

type DataType

type DataType uint8

DataType defines the type of data stored in a column block.

const (
	Int32 DataType = iota
	Int64
	Float32
	Float64
	String
	Bool
)
type Header struct {
	DataType        DataType
	CompressionType CompressionType
	Count           uint32   // Number of values in the block
	RawSizeBytes    uint32   // Size of the data in bytes before compression
	StoredSizeBytes uint32   // Size of the data in bytes after compression
	CreatedAt       int64    // Unix timestamp when the block was created
	BlockID         [32]byte // SHA-256 hash of the block contents
}

Header defines the metadata for a column block. It's a fixed-size structure.

type Stats

type Stats struct {
	Min, Max uint64 // Using uint64 to generically represent min/max for numeric types
	MinKey   []byte // Minimum key in the block
	MaxKey   []byte // Maximum key in the block
}

Stats stores summary statistics for the data in the block. This is used for query optimization (e.g., predicate pushdown).

Jump to

Keyboard shortcuts

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