binaryrow

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package binaryrow decodes Paimon's compact BinaryRow binary format.

Wire format (matches Java org.apache.paimon.data.BinaryRow):

[4 bytes big-endian: arity]
[null_bits_size bytes: header + per-field null flags]
  byte 0 = RowKind (0=INSERT,1=UPDATE_BEFORE,2=UPDATE_AFTER,3=DELETE)
  bits 8+: one null flag per field (bit set = null)
[arity * 8 bytes: fixed-size slots]
  fixed types stored inline; variable-length types store pointer
[variable-length data region]

String/bytes slot encoding:

inline (len <= 7): data in bytes 0–6 of slot, byte 7 = 0x80 | len
heap   (len >  7): int64 little-endian = (offset << 32) | length

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b *BinaryRow, fields []schema.DataField) int

Compare compares two BinaryRows field-by-field using the provided key fields (which must correspond to positions 0..len(fields)-1 in each row). Returns -1, 0, or +1. Nulls sort before non-nulls.

func GetField

func GetField(r *BinaryRow, i int, typeTag string) (interface{}, error)

GetField decodes field i as an interface{} based on the provided type tag. typeTag values match Paimon type names (uppercase), e.g. "INT", "BIGINT", "STRING", etc. For DECIMAL pass "DECIMAL:precision:scale" (handled by caller mapping — use typed methods directly for precision/scale control).

func NullBitsSize

func NullBitsSize(arity int) int

NullBitsSize returns the number of bytes occupied by the header + null bit-set.

Types

type BinaryRow

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

BinaryRow holds raw Paimon binary row bytes and decodes fields lazily.

func New

func New(data []byte) (*BinaryRow, error)

New wraps raw BinaryRow bytes (including the 4-byte arity prefix).

func (*BinaryRow) Arity

func (r *BinaryRow) Arity() int

Arity returns the number of fields.

func (*BinaryRow) Bytes

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

Bytes returns the raw bytes of the BinaryRow (including the 4-byte arity prefix). The returned slice shares the underlying array; do not modify it.

func (*BinaryRow) GetBool

func (r *BinaryRow) GetBool(i int) (bool, error)

GetBool decodes a BOOLEAN field.

func (*BinaryRow) GetBytes

func (r *BinaryRow) GetBytes(i int) ([]byte, error)

GetBytes decodes a BINARY/VARBINARY/BYTES field (inline or heap).

func (*BinaryRow) GetDate

func (r *BinaryRow) GetDate(i int) (time.Time, error)

GetDate decodes a DATE field (stored as int32 days since epoch).

func (*BinaryRow) GetDecimal

func (r *BinaryRow) GetDecimal(i int, precision, scale int) (*big.Rat, error)

GetDecimal decodes a DECIMAL field. Paimon stores decimals unscaled as a 16-byte big-endian two's-complement integer in the heap. For precision <= 18, it is stored inline as int64 little-endian.

func (*BinaryRow) GetFloat32

func (r *BinaryRow) GetFloat32(i int) (float32, error)

GetFloat32 decodes a FLOAT field.

func (*BinaryRow) GetFloat64

func (r *BinaryRow) GetFloat64(i int) (float64, error)

GetFloat64 decodes a DOUBLE field.

func (*BinaryRow) GetInt8

func (r *BinaryRow) GetInt8(i int) (int8, error)

GetInt8 decodes a TINYINT field.

func (*BinaryRow) GetInt16

func (r *BinaryRow) GetInt16(i int) (int16, error)

GetInt16 decodes a SMALLINT field.

func (*BinaryRow) GetInt32

func (r *BinaryRow) GetInt32(i int) (int32, error)

GetInt32 decodes an INT/INTEGER field.

func (*BinaryRow) GetInt64

func (r *BinaryRow) GetInt64(i int) (int64, error)

GetInt64 decodes a BIGINT field.

func (*BinaryRow) GetString

func (r *BinaryRow) GetString(i int) (string, error)

GetString decodes a STRING/CHAR/VARCHAR field (inline or heap).

func (*BinaryRow) GetTimestampMillis

func (r *BinaryRow) GetTimestampMillis(i int) (time.Time, error)

GetTimestampMillis decodes a TIMESTAMP field (stored as epoch millis int64).

func (*BinaryRow) GetTimestampNanos

func (r *BinaryRow) GetTimestampNanos(i int) (time.Time, error)

GetTimestampNanos decodes a TIMESTAMP(p>=7) field. Paimon stores these as two int32 values: millis in the lower 4 bytes, nanos-of-millis adjustment in upper 4.

func (*BinaryRow) IsNull

func (r *BinaryRow) IsNull(i int) bool

IsNull returns true if field i is null.

func (*BinaryRow) RowKind

func (r *BinaryRow) RowKind() RowKind

RowKind returns the row kind encoded in the first byte of the bit-set.

type RowKind

type RowKind byte

RowKind mirrors Paimon's RowKind enum.

const (
	Insert       RowKind = 0
	UpdateBefore RowKind = 1
	UpdateAfter  RowKind = 2
	Delete       RowKind = 3
)

Jump to

Keyboard shortcuts

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