engine

package
v0.0.0-...-65fd79d Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package engine implement an engine that can execute a command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToNumericValue

func ToNumericValue(s string) (types.Value, bool)

ToNumericValue checks whether the given string is of this form https://www.sqlite.org/lang_expr.html#literal_values_constants_ . If it is, an appropriate value is returned (either types.IntegerValue or types.RealValue). If it is not, false will be returned. This will never return the NULL value, even if the given string is empty. In that case, nil and false is returned.

Types

type Engine

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

Engine is the component that is used to evaluate commands.

func New

func New(dbfs *dbfs.DBFS, opts ...Option) (Engine, error)

New creates a new engine object and applies the given options to it.

func (Engine) Close

func (e Engine) Close() error

Close closes the underlying database file.

func (Engine) Evaluate

func (e Engine) Evaluate(cmd command.Command) (table.Table, error)

Evaluate evaluates the given command. This implicitly creates a transaction and attempts to submit it after the evaluation. To pass in an explicit transaction, call EvaluateInTransaction.

func (Engine) EvaluateInTransaction

func (e Engine) EvaluateInTransaction(cmd command.Command, tx *transaction.TX) (table.Table, error)

EvaluateInTransaction will evaluate the given command within the given transaction. The caller is responsible for submitting the transaction.

func (Engine) LoadTable

func (e Engine) LoadTable(tx *transaction.TX, name string) (table.Table, error)

LoadTable loads a table with the given name from secondary storage. Only table meta information, such as column information are loaded into memory. No rows are read from disk by calling this method. To check whether a table with a given name exists in the currently loaded database, call HasTable.

type Error

type Error string

Error is a sentinel error.

const (
	// ErrUnsupported indicates that a requested feature is explicitely not
	// supported. This is different from ErrUnimplemented, since
	// ErrUnimplemented indicates, that the feature has not been implemented
	// yet, while ErrUnsupported indicates, that the feature is intentionally
	// unimplemented.
	ErrUnsupported Error = "unsupported"
	// ErrAlreadyExists indicates, that whatever was meant to be created, already
	// exists, and therefore, the new thing cannot be created.
	ErrAlreadyExists Error = "already exists"
)

func ErrNoSuchColumn

func ErrNoSuchColumn(name string) Error

ErrNoSuchColumn returns an error indicating that a requested column is not contained in the current result table.

func ErrNoSuchFunction

func ErrNoSuchFunction(name string) Error

ErrNoSuchFunction returns an error indicating that a function with the given name can not be found.

func ErrUncomparable

func ErrUncomparable(t types.Type) Error

ErrUncomparable returns an error indicating that the given type does not implement the types.Comparator interface, and thus, values of that type cannot be compared.

func ErrUnimplemented

func ErrUnimplemented(what interface{}) Error

ErrUnimplemented returns an error indicating a missing implementation for the requested feature. It may be implemented in the next version.

func (Error) Error

func (e Error) Error() string

type ExecutionContext

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

ExecutionContext is a context that is passed down throughout a complete evaluation. It may be populated further.

func (ExecutionContext) IntermediateRow

func (c ExecutionContext) IntermediateRow(row table.RowWithColInfo) ExecutionContext

IntermediateRow sets the current intermediate row that might be needed for evaluating expressions in the context, and returns the context.

func (ExecutionContext) String

func (c ExecutionContext) String() string

type Inserter

type Inserter interface {
	Insert(table.Row) error
}

Inserter describes a component in which a row can be inserted. Tables may implement this interface, if they allow insertion.

type Namer

type Namer interface {
	Name() string
}

Namer wraps the simple method Name, which returns the name of the implementing component. Tables may implement this interface, if they are named.

type Option

type Option func(*Engine)

Option is an option that can is applied to an Engine on creation.

func WithLogger

func WithLogger(log zerolog.Logger) Option

WithLogger specifies a logger for the Engine.

func WithProfiler

func WithProfiler(profiler *profile.Profiler) Option

WithProfiler passes a profiler into the engine. The default for the engine is not using a profiler at all.

func WithRandomProvider

func WithRandomProvider(rp randomProvider) Option

WithRandomProvider sets a random provider, which will be used by the engine to evaluate expressions, that require a random source, such as the function RANDOM().

func WithTimeProvider

func WithTimeProvider(tp timeProvider) Option

WithTimeProvider sets a time provider, which will be used by the engine to evaluate expressions, that require a timestamp, such as the function NOW().

func WithTransactionManager

func WithTransactionManager(txmgr transaction.Manager) Option

WithTransactionManager sets a transaction manager that will be used by the engine to start and submit transactions.

type Table

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

Table is a representation of an on-disk table used by the engine. It is an intermediate layer to access and manipulate data inside the table's pages.

func (*Table) Cols

func (t *Table) Cols() ([]table.Col, error)

Cols returns the column information of this table as a slice of projectedColumns.

func (*Table) Insert

func (t *Table) Insert(row table.Row) error

Insert inserts the given row into this table in secondary storage.

func (Table) Name

func (t Table) Name() string

Name returns the name of this table.

func (*Table) Rows

func (t *Table) Rows() (table.RowIterator, error)

Rows returns a row iterator that will iterate over all rows in this table. Data is read from the transaction that this table belongs to.

Directories

Path Synopsis
Package page describes generic pages.
Package page describes generic pages.
Package profile implements profiling with generic events.
Package profile implements profiling with generic events.
Package types provides a type system for the add engine.
Package types provides a type system for the add engine.

Jump to

Keyboard shortcuts

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