meta

package
v0.0.0-...-f022186 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package meta handles the database metadata. The metadata is split into two parts - info and schema. Info is the fast changing stats and indexes, that change with every update. Schema is the slow changing columns and indexes that are changed infrequently.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply[U applyable](m *Meta, updates []U)

Apply applies the updates collected by Merge or Persist It is called by state.go Database.Merge/Persist, inside UpdateState.

Types

type Fkey

type Fkey = schema.Fkey

type Info

type Info struct {
	Table   string
	Indexes []*index.Overlay
	Nrows   int
	Size    uint64
	// contains filtered or unexported fields
}

func ReadInfo

func ReadInfo(st *stor.Stor, r *stor.Reader) *Info

func (*Info) Cksum

func (ti *Info) Cksum() uint32

func (*Info) Hash

func (*Info) Hash(key string) uint32

func (*Info) IsTomb

func (ti *Info) IsTomb() bool

func (*Info) Key

func (ti *Info) Key() string

func (*Info) LastMod

func (ti *Info) LastMod() int

func (*Info) SetLastMod

func (ti *Info) SetLastMod(mod int)

func (*Info) StorSize

func (ti *Info) StorSize() int

func (*Info) Write

func (ti *Info) Write(w *stor.Writer)

type InfoHamt

type InfoHamt = hamt.Hamt[string, *Info]

type MergeResult

type MergeResult = index.MergeResult

type MergeUpdate

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

func (MergeUpdate) Apply

func (mu MergeUpdate) Apply(ov *index.Overlay, i int) *index.Overlay

func (MergeUpdate) Table

func (mu MergeUpdate) Table() string

type Meta

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

Meta is the schema and info metadata. See also: schema.go - Schema, info.go - Info

func ReadMeta

func ReadMeta(store *stor.Stor, offSchema, offInfo uint64) *Meta

func (*Meta) AddView

func (m *Meta) AddView(name, def string) *Meta

func (*Meta) AlterCreate

func (m *Meta) AlterCreate(ac *schema.Schema, store *stor.Stor) *Meta

func (*Meta) AlterDrop

func (m *Meta) AlterDrop(ad *schema.Schema) *Meta

func (*Meta) AlterRename

func (m *Meta) AlterRename(table string, from, to []string) *Meta

func (*Meta) CheckAllMerged

func (m *Meta) CheckAllMerged()

func (*Meta) CheckFkeys

func (m *Meta) CheckFkeys(ts *schema.Schema)

CheckFkeys checks the targets of the foreign keys of a table. It panics on error. It is basically a read-only version of createFkeys.

func (*Meta) Cksum

func (m *Meta) Cksum() uint32

func (*Meta) CksumData

func (m *Meta) CksumData() uint32

func (*Meta) Drop

func (m *Meta) Drop(name string) *Meta

Drop removes a table or view

func (*Meta) Ensure

func (m *Meta) Ensure(a *schema.Schema, store *stor.Stor) ([]schema.Index, *Meta)

Ensure returns nil newIdxs if there is nothing more to be done i.e. if there are no new indexes or if there is no data yet.

func (*Meta) ForEachInfo

func (m *Meta) ForEachInfo(fn func(*Info))

func (*Meta) ForEachSchema

func (m *Meta) ForEachSchema(fn func(*Schema))

func (*Meta) ForEachView

func (m *Meta) ForEachView(fn func(name, def string))

func (*Meta) GetRoInfo

func (m *Meta) GetRoInfo(table string) *Info

GetRoInfo returns read-only Info for the table or nil if not found

func (*Meta) GetRoSchema

func (m *Meta) GetRoSchema(table string) *Schema

func (*Meta) GetRwInfo

func (m *Meta) GetRwInfo(table string) *Info

func (*Meta) GetView

func (m *Meta) GetView(name string) string

func (*Meta) LayeredOnto

func (m *Meta) LayeredOnto(latest *Meta) *Meta

LayeredOnto is called by transaction commit inside UpdateState. It layers the mutable ixbuf's from transactions onto the latest/current state and returns a new state. Also, the nrows and size deltas are applied. Note: this does not merge the ixbuf's, that is done later by merge. Nor does it save the changes to disk, that is done later by persist.

func (*Meta) Merge

func (m *Meta) Merge(table string, nmerge int) MergeUpdate

Merge collects the updates which are then applied by Apply. It is called by concur merger. WARNING: must not modify meta.

func (*Meta) Mutable

func (m *Meta) Mutable() *Meta

Mutable returns a mutable copy of a Meta. Used by UpdateTran.

func (*Meta) Offsets

func (m *Meta) Offsets() (schemaOff, infoOff uint64)

func (*Meta) Persist

func (m *Meta) Persist(exec func(func() PersistUpdate))

Persist is called by state.Persist to write the index updates. It collects the new btree roots which are then applied by Apply. WARNING: must not modify meta.

func (*Meta) Put

func (m *Meta) Put(ts *Schema, ti *Info) *Meta

Put is used by Database.LoadedTable and admin schema changes

func (*Meta) PutNew

func (m *Meta) PutNew(ts *Schema, ti *Info, ac *schema.Schema) *Meta

PutNew sets created so drop knows it doesn't need a tombstone

func (*Meta) RenameTable

func (m *Meta) RenameTable(from, to string) *Meta

func (*Meta) ResetClock

func (m *Meta) ResetClock()

func (*Meta) SameSchemaAs

func (m *Meta) SameSchemaAs(m2 *Meta) bool

func (*Meta) TouchIndexes

func (m *Meta) TouchIndexes(table string) *Meta

TouchIndexes is for tests

func (*Meta) TouchTable

func (m *Meta) TouchTable(table string) *Meta

TouchTable is for tests

func (*Meta) Write

func (m *Meta) Write(store *stor.Stor) (schemaOff uint64, infoOff uint64)

type PersistUpdate

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

func (PersistUpdate) Apply

func (pu PersistUpdate) Apply(ov *index.Overlay, i int) *index.Overlay

func (PersistUpdate) Table

func (pu PersistUpdate) Table() string

type SaveResult

type SaveResult = index.SaveResult

type Schema

type Schema struct {
	schema.Schema
	// contains filtered or unexported fields
}

func ReadSchema

func ReadSchema(_ *stor.Stor, r *stor.Reader) *Schema

func (*Schema) Hash

func (*Schema) Hash(key string) uint32

func (*Schema) IsTomb

func (ts *Schema) IsTomb() bool

func (*Schema) Ixspecs

func (ts *Schema) Ixspecs(nold int)

Ixspecs sets up the ixspecs for a table's indexes. In most cases newIdxs will be ts.Indexes.

func (*Schema) Key

func (ts *Schema) Key() string

func (*Schema) LastMod

func (ts *Schema) LastMod() int

func (*Schema) SetBestKeys

func (ts *Schema) SetBestKeys(nold int)

SetBestKeys determines the BestKey for each index that requires the fewest additional columns. This should be done before IxSpecs. WARNING: this affects the stored index entries so it should only be used for empty indexes.

func (*Schema) SetLastMod

func (ts *Schema) SetLastMod(mod int)

func (*Schema) SetupIndexes

func (ts *Schema) SetupIndexes()

func (*Schema) SetupNewIndexes

func (ts *Schema) SetupNewIndexes(nold int) []schema.Index

SetupNewIndexes sets BestKey and creates Ixspecs.

func (*Schema) StorSize

func (ts *Schema) StorSize() int

func (*Schema) Write

func (ts *Schema) Write(w *stor.Writer)

type SchemaHamt

type SchemaHamt = hamt.Hamt[string, *Schema]

Directories

Path Synopsis
Package schema is a separate package so it can be used by query parsing.
Package schema is a separate package so it can be used by query parsing.

Jump to

Keyboard shortcuts

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