schemacmp

package
v1.1.0-beta.0...-d5b6b69 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrMsgTypeMismatch is the error message for type mismatch.
	ErrMsgTypeMismatch = "type mismatch (%T vs %T)"
	// ErrMsgTupleLengthMismatch is the error message for tuple length mismatch.
	ErrMsgTupleLengthMismatch = "tuple length mismatch (%d vs %d)"
	// ErrMsgDistinctSingletons is the error message for distinct singletons.
	ErrMsgDistinctSingletons = "distinct singletons (%v vs %v)"
	// ErrMsgIncompatibleType is the error message for incompatible type.
	ErrMsgIncompatibleType = "incompatible mysql type (%v vs %v)"
	// ErrMsgAtTupleIndex is the error message for at tuple index.
	ErrMsgAtTupleIndex = "at tuple index %d: %v"
	// ErrMsgAtMapKey is the error message for at map key.
	ErrMsgAtMapKey = "at map key %q: %v"
	// ErrMsgNonInclusiveBitSets is the error message for non-inclusive bit sets.
	ErrMsgNonInclusiveBitSets = "non-inclusive bit sets (%#x vs %#x)"
	// ErrMsgContradictingOrders is the error message for contradicting orders.
	ErrMsgContradictingOrders = "combining contradicting orders (%d && %d)"
	// ErrMsgStringListElemMismatch is the error message for string list elem mismatch.
	ErrMsgStringListElemMismatch = "at string list index %d: distinct values (%q vs %q)"
)
View Source
const (
	ErrMsgAutoTypeWithoutKey = "auto type but not defined as a key"
)

Please ensure this list is synchronized with the order of Tuple{} in encodeFieldTypeToLattice().

Variables

This section is empty.

Functions

func CombineCompareResult

func CombineCompareResult(x int, y int) (int, error)

CombineCompareResult combines two comparison results.

func DecodeColumnFieldTypes

func DecodeColumnFieldTypes(t Table) map[string]*types.FieldType

DecodeColumnFieldTypes is used to decode column field types from Lattice.

func Type

func Type(ft *types.FieldType) typ

Type is to create type.

Types

type BitSet

type BitSet uint

BitSet is a set of bits where `a < b` iff `a` is a subset of `b`.

func (BitSet) Compare

func (a BitSet) Compare(other Lattice) (int, error)

Compare implements Lattice.

func (BitSet) Join

func (a BitSet) Join(other Lattice) (Lattice, error)

Join implements Lattice.

func (BitSet) Unwrap

func (a BitSet) Unwrap() any

Unwrap implements Lattice.

type Bool

type Bool bool

Bool is a boolean implementing Lattice where `false < true`.

func (Bool) Compare

func (a Bool) Compare(other Lattice) (int, error)

Compare implements Lattice.

func (Bool) Join

func (a Bool) Join(other Lattice) (Lattice, error)

Join implements Lattice

func (Bool) Unwrap

func (a Bool) Unwrap() any

Unwrap implements Lattice

type Byte

type Byte byte

Byte is a byte implementing Lattice.

func (Byte) Compare

func (a Byte) Compare(other Lattice) (int, error)

Compare implements Lattice.

func (Byte) Join

func (a Byte) Join(other Lattice) (Lattice, error)

Join implements Lattice.

func (Byte) Unwrap

func (a Byte) Unwrap() any

Unwrap implements Lattice.

type Equality

type Equality interface {
	// Equals returns true if this instance should be equal to another object.
	Equals(other Equality) bool
}

Equality allows custom equality.

type IncompatibleError

type IncompatibleError struct {
	Msg  string
	Args []any
}

IncompatibleError is the error type for incompatible schema.

func (*IncompatibleError) Error

func (e *IncompatibleError) Error() string

type Int

type Int int

Int is an int implementing Lattice.

func (Int) Compare

func (a Int) Compare(other Lattice) (int, error)

Compare implements Lattice.

func (Int) Join

func (a Int) Join(other Lattice) (Lattice, error)

Join implements Lattice.

func (Int) Unwrap

func (a Int) Unwrap() any

Unwrap implements Lattice.

type Int64

type Int64 int64

Int64 is an int64 implementing Lattice.

func (Int64) Compare

func (a Int64) Compare(other Lattice) (int, error)

Compare implements Lattice.

func (Int64) Join

func (a Int64) Join(other Lattice) (Lattice, error)

Join implements Lattice.

func (Int64) Unwrap

func (a Int64) Unwrap() any

Unwrap implements Lattice.

type Lattice

type Lattice interface {
	// Unwrap returns the underlying object supporting the lattice. This
	// operation is deep.
	Unwrap() any

	// Compare this instance with another instance.
	//
	// Returns -1 if `self < other`, 0 if `self == other`, 1 if `self > other`.
	// Returns `IncompatibleError` if the two instances are not ordered.
	Compare(other Lattice) (int, error)

	// Join finds the "least upper bound" of two Lattice instances. The result
	// is `>=` both inputs. Returns an error if the join does not exist.
	Join(other Lattice) (Lattice, error)
}

Lattice is implemented for types which forms a join-semilattice.

func EqualitySingleton

func EqualitySingleton(value Equality) Lattice

EqualitySingleton wraps an unordered value with equality defined by custom code instead of the `==` operator.

func FieldTp

func FieldTp(value byte) Lattice

FieldTp is used for the column field type (`github.com/pingcap/tidb/pkg/parser/types.FieldType.Tp`).

func Map

func Map(lm LatticeMap) Lattice

Map wraps a LatticeMap instance into a Lattice.

func Maybe

func Maybe(inner Lattice) Lattice

Maybe includes `nil` as the universal lower bound of the original Lattice.

func MaybeSingletonInterface

func MaybeSingletonInterface(value any) Lattice

MaybeSingletonInterface is a convenient function calling `Maybe(Singleton(value))`.

func MaybeSingletonString

func MaybeSingletonString(s string) Lattice

MaybeSingletonString is a convenient function calling `Maybe(Singleton(s))`.

func Singleton

func Singleton(value any) Lattice

Singleton wraps an unordered value. Distinct instances of Singleton are incompatible.

type LatticeMap

type LatticeMap interface {
	// New creates an empty LatticeMap of the same type as the receiver.
	New() LatticeMap

	// Insert inserts a key-value pair into the map.
	Insert(key string, value Lattice)

	// Get obtains the Lattice object at the given key. Returns nil if the key
	// does not exist.
	Get(key string) Lattice

	// ForEach iterates the map.
	ForEach(func(key string, value Lattice) error) error

	// CompareWithNil returns the comparison result when the value is compared
	// with a non-existing entry.
	CompareWithNil(value Lattice) (int, error)

	// JoinWithNil returns the result when the value is joined with a
	// non-existing entry. If the joined result should be non-existing, this
	// method should return nil, nil.
	JoinWithNil(value Lattice) (Lattice, error)

	// ShouldDeleteIncompatibleJoin returns true if two incompatible entries
	// should be deleted instead of propagating the error.
	ShouldDeleteIncompatibleJoin() bool
}

LatticeMap is a map of Lattice objects keyed by strings.

type StringList

type StringList []string

StringList is a list of string where `a <= b` iff `a == b[:len(a)]`.

func (StringList) Compare

func (a StringList) Compare(other Lattice) (int, error)

Compare implements Lattice.

func (StringList) Join

func (a StringList) Join(other Lattice) (Lattice, error)

Join implements Lattice.

func (StringList) Unwrap

func (a StringList) Unwrap() any

Unwrap implements Lattice.

type Table

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

Table is a table in the database.

func Encode

func Encode(ti *model.TableInfo) Table

Encode is used to encode a Table.

func (Table) Compare

func (t Table) Compare(other Table) (int, error)

Compare is the implementation of Lattice interface.

func (Table) Join

func (t Table) Join(other Table) (Table, error)

Join is a helper function to join two tables.

func (Table) Restore

func (t Table) Restore(ctx *format.RestoreCtx, tableName string)

Restore is for debug use only.

func (Table) String

func (t Table) String() string

type Tuple

type Tuple []Lattice

Tuple of Lattice instances. Given two Tuples `a` and `b`, we define `a <= b` iff `a[i] <= b[i]` for all `i`.

func (Tuple) Compare

func (a Tuple) Compare(other Lattice) (int, error)

Compare implements Lattice.

func (Tuple) Join

func (a Tuple) Join(other Lattice) (Lattice, error)

Join implements Lattice

func (Tuple) Unwrap

func (a Tuple) Unwrap() any

Unwrap implements Lattice. The returned type is a `[]interface{}`.

type Uint

type Uint uint

Uint is a uint implementing Lattice.

func (Uint) Compare

func (a Uint) Compare(other Lattice) (int, error)

Compare implements Lattice.

func (Uint) Join

func (a Uint) Join(other Lattice) (Lattice, error)

Join implements Lattice.

func (Uint) Unwrap

func (a Uint) Unwrap() any

Unwrap implements Lattice.

Jump to

Keyboard shortcuts

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