schema

package
v0.0.0-...-8d73f87 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const MetaTableName = "__schema__"

Meta Table Name

View Source
const NAME_VALIDATION_REGEXP = "[A-z0-9_]"
View Source
const SchemaTableName = "__schema__"

Variables

View Source
var CATALOG_KEYS_END = CATALOG_KEYS_PREFIX.Next()
View Source
var CATALOG_KEYS_PREFIX = keys.New("__tables")

System Table Keys

View Source
var ErrDropMetaTable = errors.New("cannot drop meta table")

Custom error for dropping the Meta table.

View Source
var ErrNilColumns = errors.New("nil columns passed into NewTable")
View Source
var MetaTable = &Table{
	Name: MetaTableName,
	Columns: []*Column{
		{
			Name:     "name",
			DataType: STRING,
		},
	},
	PrimaryKey: []string{"name"},
}
View Source
var ReservedInternalKeyName = "___zkey"

Functions

This section is empty.

Types

type Column

type Column struct {
	Name     string
	DataType DataType
}

func NewColumn

func NewColumn(name string, tokenType scanner.TokenType) (*Column, error)

NewColumn is a utility function which turns a name and a scanned token into a schema column.

func (*Column) Equal

func (c *Column) Equal(o *Column) bool

type DataType

type DataType int
const (
	UNKNOWN DataType = iota
	STRING
	NUMBER
	BOOLEAN
)

func GetDataType

func GetDataType(tokenType scanner.TokenType) (DataType, error)

func (DataType) String

func (i DataType) String() string

type Manager

type Manager struct {
	Schema *Schema
	Store  kv.Store
}

Manager is responsible for holding the entire schema as well as keeping it in sync with the underlying data store.

func (*Manager) AddTable

func (m *Manager) AddTable(t *Table) error

func (*Manager) DropTable

func (m *Manager) DropTable(t *Table) error

func (*Manager) LoadSchema

func (m *Manager) LoadSchema() error

func (*Manager) NewManager

func (m *Manager) NewManager(store kv.Store) (*Manager, error)

type Schema

type Schema struct {
	Tables map[string]*Table
}

func NewSchema

func NewSchema() *Schema

func SchemaFromBytes

func SchemaFromBytes(tablesBytes [][]byte) (*Schema, error)

func (*Schema) AddTable

func (s *Schema) AddTable(t *Table) error

func (*Schema) DropTable

func (s *Schema) DropTable(key string) error

func (*Schema) GetTable

func (s *Schema) GetTable(key string) (*Table, error)

type Table

type Table struct {
	Name       string
	Columns    []*Column
	PrimaryKey []string
}

func NewTable

func NewTable(name string, columns []*Column, pkey []string) (*Table, error)

func NewTableFromBytes

func NewTableFromBytes(tableBytes []byte) (*Table, error)

func (*Table) AddColumn

func (t *Table) AddColumn(name string, tokenType scanner.TokenType) error

func (*Table) Equal

func (t *Table) Equal(other *Table) bool

func (*Table) GetColumn

func (t *Table) GetColumn(name string) *Column

func (*Table) Key

func (t *Table) Key() string

Utility functions for the schema table

func (*Table) Prefix

func (t *Table) Prefix() *keys.Key

func (*Table) PrefixEnd

func (t *Table) PrefixEnd() *keys.Key

func (*Table) Value

func (t *Table) Value() ([]byte, error)

Jump to

Keyboard shortcuts

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