recordsetcompare

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package recordsetcompare provides a deterministic, pure comparison of two policy-filtered recordsets. It has no dependency on the schema comparator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(left, right apicontract.Recordset, leftReceipt, rightReceipt apicontract.CompareSideReceipt, options Options) (apicontract.CompareResult, error)

func CompareOrdered added in v0.36.0

func CompareOrdered(left, right OrderedRecordset, leftReceipt, rightReceipt apicontract.CompareSideReceipt, options Options) (apicontract.CompareResult, error)

CompareOrdered compares two streams that are already strictly ordered by Options.Key using CompareTypedKeys. Alignment delegates to DALgo recordops.DiffFunc, which advances the cursor(s) at the smallest key and retains one record per input.

func CompareTypedKeys added in v0.36.0

func CompareTypedKeys(left, right []apicontract.TypedValue) (int, error)

CompareTypedKeys exposes the apicontract portable natural key order from the comparison package for ordered-row producers.

func TypedKeySortKey added in v0.36.0

func TypedKeySortKey(values []apicontract.TypedValue) (string, error)

TypedKeySortKey exposes the canonical binary-sortable key encoding used by CompareOrdered and comparison-cache pagination.

Types

type ComparedRecord added in v0.36.0

type ComparedRecord struct {
	Ordinal uint64
	SortKey string
	State   RecordState
	Key     []apicontract.TypedValue
	Row     []apicontract.TypedValue
	Deltas  []RecordDelta
}

ComparedRecord is the neutral per-key stream event exposed to consumers that need more than the bounded API result. Row contains the full shared-visible row once: the matched/added/removed row, or the left baseline for changed. Deltas is populated only for changed rows and contains right-side values.

type Options

type Options struct {
	Key                []string
	DistributionColumn string
	Limit              int
	Observer           RecordObserver
}

type OrderedRecordset added in v0.36.0

type OrderedRecordset struct {
	Columns []apicontract.Column
	Rows    OrderedRows
}

OrderedRecordset carries stable column metadata and an already key-ordered row stream. Unlike apicontract.Recordset, it need not materialize every row.

type OrderedRows added in v0.36.0

type OrderedRows = iter.Seq2[[]apicontract.TypedValue, error]

OrderedRows is a single-use stream of rows ordered strictly by Options.Key using CompareTypedKeys (or equivalently TypedKeySortKey under binary collation). A source can release resources with defer: DALgo recordops stops both inputs when comparison completes or aborts.

type RecordDelta added in v0.36.0

type RecordDelta struct {
	Column string
	Value  apicontract.TypedValue
	Absent bool
}

RecordDelta is one right-side change relative to ComparedRecord.Row. Absent is structurally distinct from a present null value.

type RecordObserver added in v0.36.0

type RecordObserver func(ComparedRecord) error

RecordObserver receives every aligned, post-policy shared-visible record in deterministic key order. It runs synchronously; returning an error aborts comparison and closes both input streams so a caller can roll back its sink.

type RecordState added in v0.36.0

type RecordState string

RecordState classifies one aligned key from left (baseline) to right (candidate).

const (
	RecordMatched RecordState = "matched"
	RecordAdded   RecordState = "added"
	RecordRemoved RecordState = "removed"
	RecordChanged RecordState = "changed"
)

Jump to

Keyboard shortcuts

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