row

package
v0.0.0-...-892de5e Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRowNotValid = errors.New("invalid row for current schema")

Functions

func AreEqual

func AreEqual(row1, row2 Row, sch schema.Schema) bool

func GetFieldByName

func GetFieldByName(colName string, r Row, sch schema.Schema) (types.Value, bool)

func GetFieldByNameWithDefault

func GetFieldByNameWithDefault(colName string, defVal types.Value, r Row, sch schema.Schema) types.Value

func GetInvalidCol

func GetInvalidCol(r Row, sch schema.Schema) (*schema.Column, error)

GetInvalidCol returns the first column in the schema that fails a constraint, or nil if none do.

func GetInvalidConstraint

func GetInvalidConstraint(r Row, sch schema.Schema) (*schema.Column, schema.ColConstraint, error)

GetInvalidConstraint returns the failed constraint for the row given (previously identified by IsValid) along with the column with that constraint. Note that if there is a problem with the row besides the constraint, the constraint return value will be nil.

func IsEmpty

func IsEmpty(r Row) (b bool)

func IsValid

func IsValid(r Row, sch schema.Schema) (bool, error)

IsValid returns whether the row given matches the types and satisfies all the constraints of the schema given.

Types

type Row

type Row interface {
	// Returns the noms map key for this row, using the schema provided.
	NomsMapKey(sch schema.Schema) types.LesserValuable

	// Returns the noms map value for this row, using the schema provided.
	NomsMapValue(sch schema.Schema) types.Valuable

	// Iterates over all the columns in the row. Columns that have no value set will not be visited.
	IterCols(cb func(tag uint64, val types.Value) (stop bool, err error)) (bool, error)

	// Iterates over all columns in the schema, using the value for the row. Columns that have no value set in this row
	// will still be visited, and receive a nil value.
	IterSchema(sch schema.Schema, cb func(tag uint64, val types.Value) (stop bool, err error)) (bool, error)

	// Returns the value for the column with the tag given, and a success bool. The value will be null if the row
	// doesn't contain a value for that tag.
	GetColVal(tag uint64) (types.Value, bool)

	// Sets a value for the column with the tag given, returning a new row with the update.
	SetColVal(tag uint64, val types.Value, sch schema.Schema) (Row, error)

	// ReduceToIndex reduces a row to only the columns contained in an index, including the parent table's primary
	// keys. Only the column tags that are in the index will be included in the reduced row. The full index does not
	// have to be matched.
	ReduceToIndex(idx schema.Index) (Row, error)

	// ReduceToIndexPartialKey reduces a row to only the columns contained in an index, not including the parent table's
	// primary keys. The Tuple is then returned, allowing all matching rows on an index to be found.
	ReduceToIndexPartialKey(idx schema.Index) (types.Tuple, error)

	Format() *types.NomsBinFormat
}

func FromNoms

func FromNoms(sch schema.Schema, nomsKey, nomsVal types.Tuple) (Row, error)

func New

func New(nbf *types.NomsBinFormat, sch schema.Schema, colVals TaggedValues) (Row, error)

type RowFormatFunc

type RowFormatFunc func(ctx context.Context, r Row, sch schema.Schema) string

func FieldSeparatedFmt

func FieldSeparatedFmt(delim rune) RowFormatFunc

type TaggedValues

type TaggedValues map[uint64]types.Value

func GetTaggedVals

func GetTaggedVals(row Row) (TaggedValues, error)

func ParseTaggedValues

func ParseTaggedValues(tpl types.Tuple) (TaggedValues, error)

func (TaggedValues) Get

func (tt TaggedValues) Get(tag uint64) (types.Value, bool)

func (TaggedValues) GetWithDefault

func (tt TaggedValues) GetWithDefault(tag uint64, def types.Value) types.Value

func (TaggedValues) Iter

func (tt TaggedValues) Iter(cb func(tag uint64, val types.Value) (stop bool, err error)) (bool, error)

func (TaggedValues) NomsTupleForNonPKCols

func (tt TaggedValues) NomsTupleForNonPKCols(nbf *types.NomsBinFormat, nonPKCols *schema.ColCollection) TupleVals

func (TaggedValues) NomsTupleForPKCols

func (tt TaggedValues) NomsTupleForPKCols(nbf *types.NomsBinFormat, pkCols *schema.ColCollection) TupleVals

func (TaggedValues) Set

func (tt TaggedValues) Set(tag uint64, val types.Value) TaggedValues

func (TaggedValues) String

func (tt TaggedValues) String() string

type TupleVals

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

func (TupleVals) Kind

func (tvs TupleVals) Kind() types.NomsKind

func (TupleVals) Less

func (tvs TupleVals) Less(nbf *types.NomsBinFormat, other types.LesserValuable) (bool, error)

func (TupleVals) Value

func (tvs TupleVals) Value(ctx context.Context) (types.Value, error)

Jump to

Keyboard shortcuts

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