voodoo

package module
v0.0.0-...-b6322a5 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2017 License: MIT Imports: 9 Imported by: 0

README

Voodoo Build Status

! WIP !

A NewSQLy Database of sorts.

Declarative DDL - the entire database structure is kept in a single file, any changes are "applied".

Datatypes

Voodoo has a relatively restricted set of primitive datatypes.

  • TIMESTAMP
  • TIMEZONE
  • DATE
  • INT64
  • FLOAT64
  • TEXT
  • BOOL

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateNames = errors.New("voodoo/dataspace: conflicting names within dataspace")
)

Errors returned during dataspace parsing/validation

View Source
var (
	ErrNoKeyExists = errors.New("voodoo/keyvalue: no key exists")
)

Functions

func TestKeyValue

func TestKeyValue(t *testing.T, kv func() (KeyValue, error))

Types

type Column

type Column struct {
	Name       string     `json:"name"`
	Type       ColumnType `json:"type"`
	PrimaryKey bool       `json:"primary_key,omitempty"`
}

A Column is a column of a table

type ColumnType

type ColumnType string

A ColumnType is the datatype of a column

var (
	Float64   ColumnType = "float64"
	Int64     ColumnType = "int64"
	Timezone  ColumnType = "timezone"
	Timestamp ColumnType = "timestamp"
	Date      ColumnType = "date"
	Text      ColumnType = "text"
	Bool      ColumnType = "bool"
)

type Dataspace

type Dataspace struct {
	Name    string  `json:"name"`
	Tables  []Table `json:"tables"`
	Indexes []Index `json:"indexes"`
}

Dataspace is the overall db metadata

func LoadDataspace

func LoadDataspace(r io.Reader) (*Dataspace, error)

LoadDataspace parses and validates a given dataspace from a json file

type Index

type Index struct {
	Name string
}

An Index is a non-primary-key index used in Query Planning and evaluation.

type Iterator

type Iterator interface {
	// get the value at the iterator location
	Val() []byte
	// get the current key
	Key() []byte
	// move to the first key
	First() bool
	// move to the last key
	Last() bool
	// move to the next key
	Next() bool
	// move to the previous key
	Prev() bool
}

An Iterator is used to traverse the keyspace

type KeyValue

type KeyValue interface {
	Get(key []byte) ([]byte, error)
	Set(key []byte, val []byte) error

	// Walk is used to traverse parts of the keyspace
	Walk(prefix []byte) (Iterator, error)
}

KeyValue is the primitive interface on top of which SQL is mapped.

/columnspace/pkey = row

type ResultSet

type ResultSet struct {
	// types of each column, in order
	ColumnTypes []ColumnType
	// names of each column in the resultset
	ColumnNames []string
	// all rows returned
	Rows []Row
	// an error, if any
	Err error
}

A ResultSet is returned from a query

type Row

type Row []interface{}

func (*Row) MarshalBinary

func (r *Row) MarshalBinary() ([]byte, error)

MarshalBinary encodes the row

func (*Row) UnmarshalBinary

func (r *Row) UnmarshalBinary(buf []byte) error

UnmarshalBinary decodes the given row from a byte array

func (*Row) Validate

func (r *Row) Validate() bool

type Table

type Table struct {
	Name    string   `json:"name"`
	Columns []Column `json:"columns"`
}

A Table is a table in the dataspace

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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