internal

package
v0.0.0-...-f437096 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COL_UNIQUE = iota + 1
	COL_NOTNULL
	COL_NOTNULLUNIQUE
	COL_PRIMARY
	COL_ROWID
)
View Source
const (
	COL_I_PRIMARYNULL insertType = iota
	COL_I_PRIMARYVALUED
	COL_I_VALUED
	COL_I_NULL
)
View Source
const (
	PAGESIZE    = 4096
	MAXPOOLSIZE = 10
)
View Source
const (
	INT = iota + 1
	FLOAT
	BOOL
	CHAR
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

func CreateNewDatabase

func CreateNewDatabase(dir string) *Backend

func OpenExistingDatabase

func OpenExistingDatabase(dir string) (*Backend, error)

func (*Backend) CreateTable

func (b *Backend) CreateTable(q Query) error

func (*Backend) GetTableParams

func (b *Backend) GetTableParams(table Table) (uint64, int64, error)

func (*Backend) Insert

func (b *Backend) Insert(q Query) error

func (*Backend) Select

func (b *Backend) Select(q Query) (driver.Rows, error)

type BitSet

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

https://stackoverflow.com/questions/23192262/how-would-you-set-and-clear-a-single-bit-in-go TODO: Allocate one more bit for specifying row exists

func InitializeBitSet

func InitializeBitSet(n uint64) BitSet

func (*BitSet) Size

func (b *BitSet) Size() uint64

func (*BitSet) ToString

func (b *BitSet) ToString() string

type BufferPoolManager

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

func NewBufferPool

func NewBufferPool(dir string) *BufferPoolManager

func (*BufferPoolManager) InsertData

func (bm *BufferPoolManager) InsertData(tablename string, pageid PageID, data [][]byte) (PageID, error)

return last page modified

func (*BufferPoolManager) NewPool

func (bm *BufferPoolManager) NewPool(tablename string, dir string)

func (*BufferPoolManager) SelectDataRange

func (bm *BufferPoolManager) SelectDataRange(tablename string, start, end PageID) []*InternalPage

func (*BufferPoolManager) UnpinPage

func (bm *BufferPoolManager) UnpinPage(tablename string, frameid int)

type Cell

type Cell []byte

Contain functions to convert byte slice to appropriate datatype as supported by database

func (*Cell) AsBool

func (c *Cell) AsBool() bool

func (*Cell) AsFloat

func (c *Cell) AsFloat() float64

func (*Cell) AsInt

func (c *Cell) AsInt() int64

func (*Cell) AsString

func (c *Cell) AsString() string

type Column

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

ColumnType values are define in parser.go

type Condition

type Condition struct {
	// Operand1 is the left hand side operand
	Operand1 string
	// Operand1IsField determines if Operand1 is a literal or a field name
	Operand1IsField bool
	// Operator is e.g. "=", ">"
	Operator Operator
	// Operand1 is the right hand side operand
	Operand2 string
	// Operand2IsField determines if Operand2 is a literal or a field name
	Operand2IsField bool
}

Condition is a single boolean condition in a WHERE clause

type InsertColumn

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

type InternalPage

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

type Operator

type Operator int

Operator is between operands in a condition

const (
	// UnknownOperator is the zero value for an Operator
	UnknownOperator Operator = iota
	// Eq -> "="
	Eq
	// Ne -> "!="
	Ne
	// Gt -> ">"
	Gt
	// Lt -> "<"
	Lt
	// Gte -> ">="
	Gte
	// Lte -> "<="
	Lte
)

type PageID

type PageID uint64

type Query

type Query struct {
	Type              Type
	TableName         string
	Conditions        []Condition
	Updates           map[string]string
	Inserts           [][]string
	Fields            []string // Used for SELECT (i.e. SELECTed field names) and INSERT (INSERTEDed field names)
	Aliases           map[string]string
	TableConstruction [][]string //Used for CREATE
}

Query represents a parsed query

func Parse

func Parse(sqls string) (Query, error)

Parse takes a string representing SQl query and parses it into a query.Query struct. May fail.

func ParseMany

func ParseMany(sqls []string) ([]Query, error)

ParseMany takes a string slice representing many SQL queries and parses them into a query.Query struct slice. It may f ail. If it fails, it will stop at the first failure.

type ResultColumn

type ResultColumn struct {
	Name       string
	ColumnType uint8
}

type Rows

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

Result from sql select statement in driver query Must use pointer for interface to be properly implements and allow pointer to struct Implements driver.Rows

func (*Rows) Close

func (r *Rows) Close() error

func (*Rows) Columns

func (r *Rows) Columns() []string

func (*Rows) Next

func (r *Rows) Next(dest []driver.Value) error

type Table

type Table struct {
	Columns []Column
	Name    string
	// contains filtered or unexported fields
}

TableName must be checked to be within 2 bytes range ColumnNames must have length within 1 byte range Columns slice must preserve order

func (*Table) GenerateFields

func (t *Table) GenerateFields()

func (*Table) GenerateRowBytes

func (t *Table) GenerateRowBytes() uint64

func (*Table) ToString

func (t *Table) ToString() string

type Type

type Type int

Type is the type of SQL query, e.g. SELECT/UPDATE

const (
	// UnknownType is the zero value for a Type
	UnknownType Type = iota
	// Select represents a SELECT query
	Select
	// Update represents an UPDATE query
	Update
	// Insert represents an INSERT query
	Insert
	// Delete represents a DELETE query
	Delete
	// Create represents a CREATE query
	Create
	//Drop represents a DROP query
	Drop
)

Jump to

Keyboard shortcuts

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