schemacmp

package
v3.1.0-beta.2+incompat... Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMsgTypeMismatch           = "type mismatch (%T vs %T)"
	ErrMsgTupleLengthMismatch    = "tuple length mismatch (%d vs %d)"
	ErrMsgDistinctSingletons     = "distinct singletons (%v vs %v)"
	ErrMsgAtTupleIndex           = "at tuple index %d: %v"
	ErrMsgAtMapKey               = "at map key %q: %v"
	ErrMsgNonInclusiveBitSets    = "non-inclusive bit sets (%#x vs %#x)"
	ErrMsgContradictingOrders    = "combining contradicting orders (%d && %d)"
	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 Type

func Type(ft *types.FieldType) typ

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() interface{}

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() interface{}

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() interface{}

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 []interface{}
}

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() interface{}

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() interface{}

Unwrap implements Lattice.

type Lattice

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

	// 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 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 interface{}) 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 interface{}) 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() interface{}

Unwrap implements Lattice.

type Table

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

func Encode

func Encode(ti *model.TableInfo) Table

func (Table) Compare

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

func (Table) Join

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

func (Table) Restore

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

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() interface{}

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() interface{}

Unwrap implements Lattice.

Jump to

Keyboard shortcuts

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