rowdiff

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rowdiff compares two CSV artifacts as sets of logical rows: A is a source export and B the re-export of the cluster A was imported into. Rows are keyed per catalog, replicas are deduplicated, measure versions are reduced to the newest one (with Options.TopN, the copies of a _top_n_result data point are merged instead, see TopN), and cells are compared as their canonical CSV encoding, with columns aligned by header name. A property is keyed by its entity (group, _name, _id) and only its latest revision is compared (the largest _mod_revision; at an equal revision a tombstone wins over a live copy), with _delete_time compared as live or tombstone only; older revisions are ignored on both sides.

Memory: every deduplicated row of the compared groups of both artifacts is held in memory with its encoded cells. It is meant for test-scale artifacts (integration and e2e), not for production-size exports.

Index

Constants

View Source
const (
	KindMissingInB         = "missing_in_b"
	KindExtraInB           = "extra_in_b"
	KindValueMismatch      = "value_mismatch"
	KindReplicaConflict    = "replica_conflict"
	KindStageCountMismatch = "stage_count_mismatch"
	KindLayoutMismatch     = "layout_mismatch"
)

Diff kinds.

Variables

This section is empty.

Functions

This section is empty.

Types

type CatalogStat

type CatalogStat struct {
	Catalog string
	RowsA   int
	RowsB   int
}

CatalogStat counts the deduplicated rows of one catalog in each artifact; for property it counts entities.

type Diff

type Diff struct {
	Catalog  string
	Group    string
	Resource string
	Key      string
	Kind     string
	Detail   string
}

Diff is one difference between the artifacts. Key is the readable logical key of the row, the stage of a stage_count_mismatch, or empty for a group-level layout_mismatch.

func (Diff) String

func (d Diff) String() string

String renders the diff on one line.

type Options

type Options struct {
	// TopN merges and renders the values of the _top_n_result measure. When it is set, every
	// copy of a data point of that measure is merged and the merged values are compared as
	// rendered; nil compares the measure like any other.
	TopN TopN
	// Groups restricts the comparison to these groups; empty means every group present in A.
	Groups []string
}

Options configures Compare.

type Report

type Report struct {
	// StageCounts maps "catalog/group/stage" to the deduplicated row counts {A, B}; for
	// property, the entity counts.
	StageCounts map[string][2]int
	Diffs       []Diff
	Stats       []CatalogStat
}

Report is the result of Compare.

func Compare

func Compare(dirA, dirB string, opts Options) (*Report, error)

Compare loads the artifacts at dirA and dirB and compares their logical rows.

func (*Report) OK

func (r *Report) OK() bool

OK reports whether the artifacts hold the same logical rows.

func (*Report) Summary

func (r *Report) Summary(maxDiffs int) []string

Summary renders the first maxDiffs diffs, one per line, followed by a "... N more" line when there are more; a negative maxDiffs renders every diff.

type TopN

type TopN interface {
	// MergeTopNResults combines two stored values of one data point the way a query does.
	MergeTopNResults(entity []*modelv1.TagValue, timestamp, leftVersion, rightVersion int64, left, right []byte) ([]byte, error)
	// RenderTopNResult renders a value so that equal results render equally, whatever the
	// order of their tied items.
	RenderTopNResult(entity []*modelv1.TagValue, value []byte) (string, error)
}

TopN merges and renders the values of the _top_n_result measure. A data point of it is stored as one partial result per source shard and version, which a query merges, and an import may route those copies into one shard, where a part merge combines them and may reorder tied items. rowdiff cannot decode the engine encoding itself: that needs banyand/measure.

Jump to

Keyboard shortcuts

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