schema

package
v0.40.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 16 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// DocNameTag is the tag of the name column in the docs table
	DocNameTag = iota + SystemTableReservedMin + uint64(5)
	// DocTextTag is the tag of the text column in the docs table
	DocTextTag
)

Tags for dolt_docs table for info on unaligned constant: https://github.com/dolthub/dolt/pull/663

View Source
const (
	HistoryCommitterTag = iota + SystemTableReservedMin + uint64(1000)
	HistoryCommitHashTag
	HistoryCommitDateTag
)

Tags for dolt_history_ table

View Source
const (
	DiffCommitTag = iota + SystemTableReservedMin + uint64(2000)
	DiffCommitDateTag
	DiffTypeTag
)

Tags for dolt_diff_ table

View Source
const (
	// QueryCatalogIdTag is the tag of the id column in the query catalog table
	QueryCatalogIdTag = iota + SystemTableReservedMin + uint64(3005)
	// QueryCatalogOrderTag is the tag of the column containing the sort order in the query catalog table
	QueryCatalogOrderTag
	// QueryCatalogNameTag is the tag of the column containing the name of the query in the query catalog table
	QueryCatalogNameTag
	// QueryCatalogQueryTag is the tag of the column containing the query in the query catalog table
	QueryCatalogQueryTag
	// QueryCatalogDescriptionTag is the tag of the column containing the query description in the query catalog table
	QueryCatalogDescriptionTag
)

Tags for dolt_query_catalog table for info on unaligned constant: https://github.com/dolthub/dolt/pull/663

View Source
const (
	DoltSchemasIdTag = iota + SystemTableReservedMin + uint64(4007)
	DoltSchemasTypeTag
	DoltSchemasNameTag
	DoltSchemasFragmentTag
	DoltSchemasExtraTag
)

Tags for dolt_schemas table for info on unaligned constant: https://github.com/dolthub/dolt/pull/663

View Source
const (
	KeylessRowIdTag = iota + SystemTableReservedMin + uint64(5000)
	KeylessRowCardinalityTag
)

Tags for hidden columns in keyless rows

View Source
const (
	DoltProceduresNameTag = iota + SystemTableReservedMin + uint64(6000)
	DoltProceduresCreateStmtTag
	DoltProceduresCreatedAtTag
	DoltProceduresModifiedAtTag
)

Tags for the dolt_procedures table

View Source
const (
	DoltConstraintViolationsTypeTag = 0
	DoltConstraintViolationsInfoTag = math.MaxUint64
)
View Source
const InvalidTag uint64 = math.MaxUint64

InvalidTag is used as an invalid tag

View Source
const (
	NotNullConstraintType = "not_null"
)
View Source
const (
	// ReservedTagMin is the start of a range of tags which the user should not be able to use in their schemas.
	ReservedTagMin uint64 = 1 << 50
)
View Source
const (
	// SystemTableReservedMin defines the lower bound of the tag space reserved for system tables
	SystemTableReservedMin uint64 = ReservedTagMin << 1
)

Variables

View Source
var (
	// KindToLwrStr maps a noms kind to the kinds lowercased name
	KindToLwrStr = make(map[types.NomsKind]string)

	// LwrStrToKind maps a lowercase string to the noms kind it is referring to
	LwrStrToKind = make(map[string]types.NomsKind)
)
View Source
var EmptyColColl = &ColCollection{
	[]Column{},
	[]uint64{},
	[]uint64{},
	map[uint64]Column{},
	map[string]Column{},
	map[string]Column{},
	map[uint64]int{},
}
View Source
var EmptySchema = &schemaImpl{
	pkCols:          EmptyColColl,
	nonPKCols:       EmptyColColl,
	allCols:         EmptyColColl,
	indexCollection: NewIndexCollection(nil, nil),
}

EmptySchema is an instance of a schema with no columns.

View Source
var ErrColNameCollision = errors.New("two different columns with the same name exist")

ErrColNameCollision is an error that is returned when two columns within a ColCollection have the same name but a different type or tag

View Source
var ErrColNotFound = errors.New("column not found")

ErrColNotFound is an error that is returned when attempting an operation on a column that does not exist

View Source
var ErrColTagCollision = errors.New("two different columns with the same tag")

ErrColTagCollision is an error that is returned when two columns within a ColCollection have the same tag but a different name or type

View Source
var ErrInvalidPkOrdinals = errors.New("incorrect number of primary key ordinals")
View Source
var ErrMultipleNotNullConstraints = errors.New("multiple not null constraints on same column")
View Source
var ErrNoPrimaryKeyColumns = errors.New("no primary key columns")

ErrNoPrimaryKeyColumns is an error that is returned when no primary key columns are found

View Source
var ErrNonAutoIncType = errors.New("column type cannot be auto incremented")
View Source
var ErrUsingSpatialKey = errors.NewKind("can't use Spatial Types as Primary Key for table %s")
View Source
var FeatureFlagKeylessSchema = true
View Source
var (
	// InvalidCol is a Column instance that is returned when there is nothing to return and can be tested against.
	InvalidCol = Column{
		"invalid",
		InvalidTag,
		types.NullKind,
		false,
		typeinfo.UnknownType,
		"",
		false,
		"",
		nil,
	}
)

Functions

func ArePrimaryKeySetsDiffable

func ArePrimaryKeySetsDiffable(fromSch, toSch Schema) bool

ArePrimaryKeySetsDiffable checks if two schemas are diffable. Assumes the passed in schema are from the same table between commits.

func AutoGenerateTag

func AutoGenerateTag(existingTags *set.Uint64Set, tableName string, existingColKinds []types.NomsKind, newColName string, newColKind types.NomsKind) uint64

AutoGenerateTag generates a random tag that doesn't exist in the provided SuperSchema. It uses a deterministic random number generator that is seeded with the NomsKinds of any existing columns in the schema and the NomsKind of the column being added to the schema. Deterministic tag generation means that branches and repositories that perform the same sequence of mutations to a database will get equivalent databases as a result. DETERMINISTIC MUTATION IS A CRITICAL INVARIANT TO MAINTAINING COMPATIBILITY BETWEEN REPOSITORIES. DO NOT ALTER THIS METHOD.

func ColCollsAreCompatible

func ColCollsAreCompatible(cc1, cc2 *ColCollection) bool

ColCollsAreCompatible determines whether two ColCollections are compatible with each other. Compatible columns have the same tags and storage types, but may have different names, constraints or SQL type parameters.

func ColCollsAreEqual

func ColCollsAreEqual(cc1, cc2 *ColCollection) bool

ColCollsAreEqual determines whether two ColCollections are equal.

func ColConstraintsAreEqual

func ColConstraintsAreEqual(a, b []ColConstraint) bool

ColConstraintsAreEqual validates two ColConstraint slices are identical.

func ErrTagPrevUsed

func ErrTagPrevUsed(tag uint64, newColName, tableName string) error

func ExtractAllColNames

func ExtractAllColNames(sch Schema) (map[uint64]string, error)

ExtractAllColNames returns a map of tag to column name, with one map entry for every column in the schema.

func HasAutoIncrement

func HasAutoIncrement(sch Schema) (ok bool)

func IndexOfConstraint

func IndexOfConstraint(constraints []ColConstraint, constraintType string) int

IndexOfConstraint returns the index in the supplied slice of the first constraint of matching type. If none are found then -1 is returned

func IsColSpatialType

func IsColSpatialType(c Column) bool

IsColSpatialType is a utility function that checks if a single column is using a spatial type by comparing typeinfos

func IsKeyless

func IsKeyless(sch Schema) bool

func IsUsingSpatialColAsKey

func IsUsingSpatialColAsKey(sch Schema) bool

IsUsingSpatialColAsKey is a utility function that checks for any spatial types being used as a primary key

func NewCheck

func NewCheck(name, expression string, enforced bool) check

func NomsKindsFromSchema

func NomsKindsFromSchema(sch Schema) []types.NomsKind

func SchemasAreEqual

func SchemasAreEqual(sch1, sch2 Schema) bool

SchemasAreEqual tests equality of two schemas.

func ValidateColumnConstraints

func ValidateColumnConstraints(allCols *ColCollection) error

ValidateColumnConstraints removes any duplicate NOT NULL column constraints from schemas.

func ValidateForInsert

func ValidateForInsert(allCols *ColCollection) error

ValidateForInsert returns an error if the given schema cannot be written to the dolt database.

func VerifyInSchema

func VerifyInSchema(inSch, outSch Schema) (bool, error)

TODO: this function never returns an error VerifyInSchema tests that the incoming schema matches the schema from the original table based on the presence of the column name in the original schema.

Types

type Check

type Check interface {
	Name() string
	Expression() string
	Enforced() bool
}

type CheckCollection

type CheckCollection interface {
	// AddCheck adds a check to this collection and returns it
	AddCheck(name, expression string, enforce bool) (Check, error)
	// DropCheck removes the check with the name given
	DropCheck(name string) error
	// AllChecks returns all the checks in the collection
	AllChecks() []Check
	// Count returns the size of the collection
	Count() int
}

CheckCollection is the set of `check` constraints on a table's schema

func NewCheckCollection

func NewCheckCollection() CheckCollection

type ColCollection

type ColCollection struct {

	// Tags is a list of all the tags in the ColCollection in their original order.
	Tags []uint64
	// SortedTags is a list of all the tags in the ColCollection in sorted order.
	SortedTags []uint64
	// TagToCol is a map of tag to column
	TagToCol map[uint64]Column
	// NameToCol is a map from name to column
	NameToCol map[string]Column
	// LowerNameToCol is a map from lower-cased name to column
	LowerNameToCol map[string]Column
	// TagToIdx is a map from a tag to the column index
	TagToIdx map[uint64]int
	// contains filtered or unexported fields
}

ColCollection is a collection of columns. As a stand-alone collection, all columns in the collection must have unique tags. To be instantiated as a schema for writing to the database, names must also be unique. See schema.ValidateForInsert for details.

func ColCollUnion

func ColCollUnion(colColls ...*ColCollection) (*ColCollection, error)

func ColCollectionSetDifference

func ColCollectionSetDifference(leftCC, rightCC *ColCollection) (d *ColCollection)

ColCollectionSetDifference returns the set difference leftCC - rightCC.

func FilterColCollection

func FilterColCollection(cc *ColCollection, cb func(col Column) bool) *ColCollection

FilterColCollection applies a boolean function to column in a ColCollection, it creates a new ColCollection from the set of columns for which the function returned true.

func MapColCollection

func MapColCollection(cc *ColCollection, cb func(col Column) Column) *ColCollection

MapColCollection applies a function to each column in a ColCollection and creates a new ColCollection from the results.

func NewColCollection

func NewColCollection(cols ...Column) *ColCollection

NewColCollection creates a new collection from a list of columns. If any columns have the same tag, by-tag lookups in this collection will not function correctly. If any columns have the same name, by-name lookups from this collection will not function correctly. If any columns have the same case-insensitive name, case-insensitive lookups will be unable to return the correct column in all cases. For this collection to be used as a Dolt schema, it must pass schema.ValidateForInsert.

func (*ColCollection) Append

func (cc *ColCollection) Append(cols ...Column) *ColCollection

Append returns a new collection with the additional columns appended

func (*ColCollection) AppendColl

func (cc *ColCollection) AppendColl(colColl *ColCollection) *ColCollection

AppendColl returns a new collection with the additional ColCollection's columns appended

func (*ColCollection) GetAtIndex

func (cc *ColCollection) GetAtIndex(i int) Column

func (*ColCollection) GetByIndex

func (cc *ColCollection) GetByIndex(idx int) Column

GetByIndex returns a column with a given index

func (*ColCollection) GetByName

func (cc *ColCollection) GetByName(name string) (Column, bool)

GetByName takes the name of a column and returns the column and true if found. Otherwise InvalidCol and false are returned.

func (*ColCollection) GetByNameCaseInsensitive

func (cc *ColCollection) GetByNameCaseInsensitive(name string) (Column, bool)

GetByNameCaseInensitive takes the name of a column and returns the column and true if there is a column with that name ignoring case. Otherwise InvalidCol and false are returned. If multiple columns have the same case-insensitive name, the first declared one is returned.

func (*ColCollection) GetByTag

func (cc *ColCollection) GetByTag(tag uint64) (Column, bool)

GetByTag takes a tag and returns the corresponding column and true if found, otherwise InvalidCol and false are returned

func (*ColCollection) GetColumnNames

func (cc *ColCollection) GetColumnNames() []string

GetColumnNames returns a list of names of the columns.

func (*ColCollection) GetColumns

func (cc *ColCollection) GetColumns() []Column

GetColumns returns the underlying list of columns. The list returned is a copy.

func (*ColCollection) IndexOf

func (cc *ColCollection) IndexOf(colName string) int

IndexOf returns the index of the column with the name given (case-insensitive) or -1 if it's not found

func (*ColCollection) Iter

func (cc *ColCollection) Iter(cb func(tag uint64, col Column) (stop bool, err error)) error

Iter iterates over all the columns in the supplied ordering

func (*ColCollection) IterInSortedOrder

func (cc *ColCollection) IterInSortedOrder(cb func(tag uint64, col Column) (stop bool))

IterInSortOrder iterates over all the columns from lowest tag to highest tag.

func (*ColCollection) Size

func (cc *ColCollection) Size() int

Size returns the number of columns in the collection.

type ColConstraint

type ColConstraint interface {
	// SatisfiesConstraint takes in a value and returns true if the value satisfies the constraint
	SatisfiesConstraint(value types.Value) bool

	// GetConstraintType returns a string representation of the type of constraint.  This is used for serialization and
	// deserialization of constraints (see ColConstraintFromTypeAndParams).
	GetConstraintType() string

	// GetConstraintParams returns a map[string]string containing the constraints parameters.  This is used for
	// serialization and deserialization of constraints, and a deserialized constraint must be able to reproduce the same
	// behavior based on the parameters in this map (See ColConstraintFromTypeAndParams).
	GetConstraintParams() map[string]string

	// Stringer results are used to inform users of the constraint's properties.
	fmt.Stringer
}

ColConstraint is an interface used for evaluating whether a columns value is valid

func ColConstraintFromTypeAndParams

func ColConstraintFromTypeAndParams(colCnstType string, params map[string]string) ColConstraint

ColConstraintFromTypeAndParams takes in a string representing the type of the constraint and a map of parameters that can be used to determine the behavior of the constraint. An example might be a constraint which validated a value is in a given range. For this the constraint type might by "in_range_constraint", and the parameters might be {"min": -10, "max": 10}

type Column

type Column struct {
	// Name is the name of the column
	Name string

	// Tag should be unique per versioned schema and allows
	Tag uint64

	// Kind is the types.NomsKind that values of this column will be
	Kind types.NomsKind

	// IsPartOfPK says whether this column is part of the primary key
	IsPartOfPK bool

	// TypeInfo states the type of this column.
	TypeInfo typeinfo.TypeInfo

	// Default is the default value of this column. This is the string representation of a sql.Expression.
	Default string

	// AutoIncrement says whether this column auto increments.
	AutoIncrement bool

	// Comment is the comment for this column.
	Comment string

	// Constraints are rules that can be checked on each column to say if the columns value is valid
	Constraints []ColConstraint
}

Column is a structure containing information about a column in a row in a table.

func ColFromName

func ColFromName(sch Schema, name string) (Column, bool)

ColFromName returns a schema.Column from a schema from it's name

func ColFromTag

func ColFromTag(sch Schema, tag uint64) (Column, bool)

ColFromTag returns a schema.Column from a schema and a tag

func GetSharedCols

func GetSharedCols(schema Schema, cmpNames []string, cmpKinds []types.NomsKind) []Column

GetSharedCols return all columns in the schema that match the names and types given, which are parallel arrays specifying columns to match.

func NewColumn

func NewColumn(name string, tag uint64, kind types.NomsKind, partOfPK bool, constraints ...ColConstraint) Column

NewColumn creates a Column instance with the default type info for the NomsKind

func NewColumnWithTypeInfo

func NewColumnWithTypeInfo(name string, tag uint64, typeInfo typeinfo.TypeInfo, partOfPK bool, defaultVal string, autoIncrement bool, comment string, constraints ...ColConstraint) (Column, error)

NewColumnWithTypeInfo creates a Column instance with the given type info.

func (Column) Compatible

func (c Column) Compatible(other Column) bool

Compatible tests compatibility between two columns. Compatible columns have the same tag and can store the same kinds of values at the storage layer, but may have different constraints or type parameters.

func (Column) Equals

func (c Column) Equals(other Column) bool

Equals tests equality between two columns.

func (Column) IsNullable

func (c Column) IsNullable() bool

IsNullable returns whether the column can be set to a null value.

func (Column) KindString

func (c Column) KindString() string

KindString returns the string representation of the NomsKind stored in the column.

type ColumnOrder

type ColumnOrder struct {
	First       bool   // True if this column should come first
	AfterColumn string // Set to the name of the column after which this column should appear
}

ColumnOrder is used in ALTER TABLE statements to change the order of inserted / modified columns.

type Index

type Index interface {
	// AllTags returns the tags of the columns in the entire index, including the primary keys.
	// If we imagined a dolt index as being a standard dolt table, then the tags would represent the schema columns.
	AllTags() []uint64
	// ColumnNames returns the names of the columns in the index.
	ColumnNames() []string
	// Comment returns the comment that was provided upon index creation.
	Comment() string
	// Count returns the number of indexed columns in this index.
	Count() int
	// DeepEquals returns whether this Index is equivalent to another. This function is similar to Equals, however it
	// does take the table's primary keys into consideration.
	DeepEquals(other Index) bool
	// Equals returns whether this Index is equivalent to another. This does not check for column names, thus those may
	// be renamed and the index equivalence will be preserved. It also does not depend on the table's primary keys.
	Equals(other Index) bool
	// GetColumn returns the column for the given tag and whether the column was found or not.
	GetColumn(tag uint64) (Column, bool)
	// IndexedColumnTags returns the tags of the columns in the index.
	IndexedColumnTags() []uint64
	// IsUnique returns whether the given index has the UNIQUE constraint.
	IsUnique() bool
	// IsUserDefined returns whether the given index was created by a user or automatically generated.
	IsUserDefined() bool
	// Name returns the name of the index.
	Name() string
	// PrimaryKeyTags returns the primary keys of the indexed table, in the order that they're stored for that table.
	PrimaryKeyTags() []uint64
	// Schema returns the schema for the internal index map. Can be used for table operations.
	Schema() Schema
	// ToTableTuple returns a tuple that may be used to retrieve the original row from the indexed table when given
	// a full index key (and not a partial index key).
	ToTableTuple(ctx context.Context, fullKey types.Tuple, format *types.NomsBinFormat) (types.Tuple, error)
	// VerifyMap returns whether the given map iterator contains all valid keys and values for this index.
	VerifyMap(ctx context.Context, iter types.MapIterator, nbf *types.NomsBinFormat) error
}

func NewIndex

func NewIndex(name string, tags, allTags []uint64, indexColl *indexCollectionImpl, props IndexProperties) Index

type IndexCollection

type IndexCollection interface {
	// AddIndex adds the given index, overwriting any current indexes with the same name or columns.
	// It does not perform any kind of checking, and is intended for schema modifications.
	AddIndex(indexes ...Index)
	// AddIndexByColNames adds an index with the given name and columns (in index order).
	AddIndexByColNames(indexName string, cols []string, props IndexProperties) (Index, error)
	// AddIndexByColTags adds an index with the given name and column tags (in index order).
	AddIndexByColTags(indexName string, tags []uint64, props IndexProperties) (Index, error)
	// todo: this method is trash, clean up this interface
	UnsafeAddIndexByColTags(indexName string, tags []uint64, props IndexProperties) (Index, error)
	// AllIndexes returns a slice containing all of the indexes in this collection.
	AllIndexes() []Index
	// Contains returns whether the given index name already exists for this table.
	Contains(indexName string) bool
	// Count returns the number of indexes in this collection.
	Count() int
	// Equals returns whether this index collection is equivalent to another. Indexes are compared by everything except
	// for their name, the names of all columns, and anything relating to the parent table's primary keys.
	Equals(other IndexCollection) bool
	// GetByName returns the index with the given name, or nil if it does not exist.
	GetByName(indexName string) Index
	// GetByName returns the index with a matching case-insensitive name, the bool return value indicates if a match was found.
	GetByNameCaseInsensitive(indexName string) (Index, bool)
	// GetIndexByColumnNames returns whether the collection contains an index that has this exact collection and ordering of columns.
	GetIndexByColumnNames(cols ...string) (Index, bool)
	// GetIndexByTags returns whether the collection contains an index that has this exact collection and ordering of columns.
	GetIndexByTags(tags ...uint64) (Index, bool)
	// IndexesWithColumn returns all indexes that index the given column.
	IndexesWithColumn(columnName string) []Index
	// IndexesWithTag returns all indexes that index the given tag.
	IndexesWithTag(tag uint64) []Index
	// Iter iterated over the indexes in the collection, calling the cb function on each.
	Iter(cb func(index Index) (stop bool, err error)) error
	// Merge adds the given index if it does not already exist. Indexed columns are referenced by column name,
	// rather than by tag number, which allows an index from a different table to be added as long as they have matching
	// column names. If an index with the same name or column structure already exists, or the index contains different
	// columns, then it is skipped.
	Merge(indexes ...Index)
	// RemoveIndex removes an index from the table metadata.
	RemoveIndex(indexName string) (Index, error)
	// RenameIndex renames an index in the table metadata.
	RenameIndex(oldName, newName string) (Index, error)
	//SetPks changes the pks or pk ordinals
	SetPks([]uint64) error
}

func NewIndexCollection

func NewIndexCollection(cols *ColCollection, pkCols *ColCollection) IndexCollection

type IndexProperties

type IndexProperties struct {
	IsUnique      bool
	IsUserDefined bool
	Comment       string
}

type NotNullConstraint

type NotNullConstraint struct{}

NotNullConstraint validates that a value is not null. It does not restrict 0 length strings, or 0 valued ints, or anything other than non nil values

func (NotNullConstraint) GetConstraintParams

func (nnc NotNullConstraint) GetConstraintParams() map[string]string

GetConstraintParams returns nil as this constraint does not require any parameters.

func (NotNullConstraint) GetConstraintType

func (nnc NotNullConstraint) GetConstraintType() string

GetConstraintType returns "not_null"

func (NotNullConstraint) SatisfiesConstraint

func (nnc NotNullConstraint) SatisfiesConstraint(value types.Value) bool

SatisfiesConstraint returns true if value is not nil and not types.NullValue

func (NotNullConstraint) String

func (nnc NotNullConstraint) String() string

String returns a useful description of the constraint

type Schema

type Schema interface {
	// GetPKCols gets the collection of columns which make the primary key.
	GetPKCols() *ColCollection

	// GetNonPKCols gets the collection of columns which are not part of the primary key.
	GetNonPKCols() *ColCollection

	// GetAllCols gets the collection of all columns (pk and non-pk)
	GetAllCols() *ColCollection

	// Indexes returns a collection of all indexes on the table that this schema belongs to.
	Indexes() IndexCollection

	// Checks returns a collection of all check constraints on the table that this schema belongs to.
	Checks() CheckCollection

	// GetPkOrdinals returns a slice of the primary key ordering indexes relative to the schema column ordering
	GetPkOrdinals() []int

	// SetPkOrdinals specifies a primary key column ordering
	SetPkOrdinals([]int) error

	// AddColumn adds a column to this schema in the order given and returns the resulting Schema.
	// The new column cannot be a primary key. To alter primary keys, create a new schema with those keys.
	AddColumn(column Column, order *ColumnOrder) (Schema, error)
}

Schema is an interface for retrieving the columns that make up a schema

func Adapt

func Adapt(from, to Schema) (Schema, error)

Adapt adapts the |from| schema to the |to| schema, applying all the necessary metadata (foreign keys, constraints, etc) present in |from| to |to| and returning the result.

func MustSchemaFromCols

func MustSchemaFromCols(typedColColl *ColCollection) Schema

func SchemaFromColCollections

func SchemaFromColCollections(allCols, pkColColl, nonPKColColl *ColCollection) Schema

func SchemaFromCols

func SchemaFromCols(allCols *ColCollection) (Schema, error)

SchemaFromCols creates a Schema from a collection of columns

func SchemaFromPKAndNonPKCols

func SchemaFromPKAndNonPKCols(pkCols, nonPKCols *ColCollection) (Schema, error)

SchemaFromPKAndNonPKCols creates a Schema from a collection of the key columns, and the non-key columns.

func UnkeyedSchemaFromCols

func UnkeyedSchemaFromCols(allCols *ColCollection) Schema

UnkeyedSchemaFromCols creates a schema without any primary keys to be used for displaying to users, tests, etc. Such unkeyed schemas are not suitable to be inserted into storage.

type SuperSchema

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

SuperSchema is the union of all Schemas over the history of a table the tagNames map tracks all names corresponding to a column tag

func NewSuperSchema

func NewSuperSchema(schemas ...Schema) (*SuperSchema, error)

NewSuperSchema creates a SuperSchema from the columns of schemas.

func SuperSchemaUnion

func SuperSchemaUnion(superSchemas ...*SuperSchema) (*SuperSchema, error)

SuperSchemaUnion combines multiple SuperSchemas.

func UnmarshalSuperSchema

func UnmarshalSuperSchema(allCols *ColCollection, tagNames map[uint64][]string) *SuperSchema

UnmarshalSuperSchema creates a SuperSchema, it is only used by the encoding package.

func (*SuperSchema) AddColumn

func (ss *SuperSchema) AddColumn(col Column) (err error)

AddColumn adds a column and its name to the SuperSchema

func (*SuperSchema) AddSchemas

func (ss *SuperSchema) AddSchemas(schemas ...Schema) error

AddSchemas adds all names and columns of each schema to the SuperSchema

func (*SuperSchema) AllColumnNames

func (ss *SuperSchema) AllColumnNames(tag uint64) []string

AllColumnNames returns all names of the column corresponding to tag

func (*SuperSchema) AllTags

func (ss *SuperSchema) AllTags() []uint64

AllTags returns a slice of all tags contained in the SuperSchema

func (*SuperSchema) Equals

func (ss *SuperSchema) Equals(oss *SuperSchema) bool

Equals returns true iff the SuperSchemas have the same ColCollections and tagNames maps

func (*SuperSchema) GenerateColCollection

func (ss *SuperSchema) GenerateColCollection() (*ColCollection, error)

GenerateColCollection creates a ColCollection from all the columns in the SuperSchema. Each column is assigned its latest name from its name history.

func (*SuperSchema) GenerateSchema

func (ss *SuperSchema) GenerateSchema() (Schema, error)

GenerateSchema creates a Schema from all the columns in the SuperSchema. Each column is assigned its latest name from its name history.

func (*SuperSchema) GetByTag

func (ss *SuperSchema) GetByTag(tag uint64) (Column, bool)

GetByTag returns the corresponding column and true if found, returns InvalidCol and false otherwise

func (*SuperSchema) Iter

func (ss *SuperSchema) Iter(cb func(tag uint64, col Column) (stop bool, err error)) error

Iter processes each column in the SuperSchema with the specified function

func (*SuperSchema) LatestColumnName

func (ss *SuperSchema) LatestColumnName(tag uint64) string

LatestColumnName returns the latest name of the column corresponding to tag

func (*SuperSchema) NameMapForSchema

func (ss *SuperSchema) NameMapForSchema(sch Schema) (map[string]string, error)

NameMapForSchema creates a field name mapping needed to construct a rowconv.RowConverter sch columns are mapped by tag to the corresponding SuperSchema columns

func (*SuperSchema) Size

func (ss *SuperSchema) Size() int

Size returns the number of columns in the SuperSchema

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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