engine

package
v0.0.0-...-b91652b Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TruePredicate = Predicate{
	True: true,
}

TruePredicate is a predicate wich return always true

Functions

func TrueOperator

func TrueOperator(leftValue Value, rightValue Value) bool

TrueOperator always returns true

Types

type Attribute

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

Attribute is a named column of a relation AKA Field AKA Column

func NewAttribute

func NewAttribute(name string, typeName string, autoIncrement bool) Attribute

NewAttribute initialize a new Attribute struct

type Domain

type Domain struct {
}

Domain is the set of allowable values for an Attribute.

type Engine

type Engine struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Engine is the root struct of RamSQL server

func New

func New(endpoint protocol.EngineEndpoint) (e *Engine, err error)

New initialize a new RamSQL server

func (*Engine) Stop

func (e *Engine) Stop()

Stop shutdown the RamSQL server

type Operator

type Operator func(leftValue Value, rightValue Value) bool

Operator compares 2 values and return a boolean

func NewOperator

func NewOperator(token int, lexeme string) (Operator, error)

NewOperator initializes the operator matching the Token number

type Predicate

type Predicate struct {
	LeftValue  Value
	Operator   Operator
	RightValue Value
	True       bool
}

Predicate evaluate if a condition is valid with 2 values and an operator on this 2 values

func (*Predicate) Eval

func (p *Predicate) Eval(row virtualRow) (bool, error)

Eval fetches operand from virtual row and run operator

func (Predicate) String

func (p Predicate) String() string

type PredicateLinker

type PredicateLinker interface {
	Eval(v virtualRow) (bool, error)
}

PredicateLinker referes to AND and OR operators.

type Relation

type Relation struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Relation is a table with column and rows AKA File

func NewRelation

func NewRelation(t *Table) *Relation

NewRelation initializes a new Relation struct

func (*Relation) Insert

func (r *Relation) Insert(t *Tuple) error

Insert a tuple in relation

type Table

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

Table is defined by a name and attributes A table with data is called a Relation

func NewTable

func NewTable(name string) *Table

NewTable initializes a new Table

func (*Table) AddAttribute

func (t *Table) AddAttribute(attr Attribute) error

AddAttribute is used by CREATE TABLE and ALTER TABLE Want to check that name isn't already taken

func (Table) String

func (t Table) String() string

String returns a printable string with table name and attributes

type Tuple

type Tuple struct {
	Values []interface{}
}

Tuple is a row in a relation

func NewTuple

func NewTuple(values ...interface{}) *Tuple

NewTuple should check that value are for the right Attribute and match domain

func (*Tuple) Append

func (t *Tuple) Append(value interface{})

Append add a value to the tuple

type Value

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

Value is a value given to predicates

Directories

Path Synopsis
Package parser implements a parser for SQL statements Inspired by go/parser
Package parser implements a parser for SQL statements Inspired by go/parser

Jump to

Keyboard shortcuts

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