Documentation
¶
Overview ¶
Package query implements query parsing, optimization, and execution.
Query Table Nothing ProjectNone schemaTable Tables TablesLookup Columns Indexes History Query1 Extend Project / Remove Rename Sort Summarize TempIndex Where View Query2 Compatible Union Compatible1 Intersect Minus joinLike Times joinBase Join LeftJoin SemiJoin
Index ¶
- Constants
- Variables
- func CalcSelf(q0 Query)
- func DoAction(th *Thread, ut *db19.UpdateTran, action string) int
- func DoAdmin(db *db19.Database, cmd string, sv *Sviews, perms *Perms)
- func DoAdminTest(db *db19.Database, cmd string)
- func Format(t QueryTran, query string) string
- func GetSort(query string) string
- func IdxUse(table string, idx []string)
- func JustTable(query string) string
- func NewAdminParser(src string) *adminParser
- func NewQueryParser(src string, t QueryTran, sv *Sviews) *queryParser
- func NewSuQueryNode(q Query) Value
- func PullIdxUse() map[string]int
- func Setup(q Query, mode Mode, t QueryTran) (Query, Cost, Cost)
- func Setup1(q Query, mode Mode, t QueryTran) (Query, Cost, Cost)
- func SetupReq(q Query, mode Mode, t QueryTran, req Require) (Query, Cost, Cost)
- func Strategy(q Query) string
- func Strategy2(q Query) string
- func String(q Query) string
- func StripSort(query string) string
- func Warnings(query string, q Query)
- type Action
- type Admin
- type Columns
- func (*Columns) Clone() *Table
- func (cs *Columns) Columns() []string
- func (*Columns) Fixed() Fixed
- func (cs *Columns) Get(_ *Thread, dir Dir) Row
- func (*Columns) Header() *Header
- func (*Columns) Indexes() [][]string
- func (*Columns) Init()
- func (*Columns) Keys() [][]string
- func (cs *Columns) Lookup(th *Thread, sels Sels) Row
- func (st *Columns) Metrics() *metrics
- func (*Columns) Name() string
- func (cs *Columns) Nrows() (int, int)
- func (*Columns) Order() []string
- func (*Columns) Output(th *Thread, _ Record)
- func (cs *Columns) Rewind()
- func (*Columns) Select(Sels)
- func (*Columns) SetIndex(index []string, mode Mode)
- func (cs *Columns) SetTran(tran QueryTran)
- func (*Columns) Simple(*Thread) []Row
- func (*Columns) SingleTable() bool
- func (*Columns) String() string
- func (cs *Columns) Transform() Query
- func (*Columns) UniqueIndexes() [][]string
- func (*Columns) Updateable() string
- func (cs *Columns) ValueGet(key Value) Value
- type Compatible
- func (q *Compatible) Columns() []string
- func (q *Compatible) Fixed() Fixed
- func (q *Compatible) Header() *Header
- func (q *Compatible) Indexes() [][]string
- func (q *Compatible) Keys() [][]string
- func (q *Compatible) Metrics() *metrics
- func (q *Compatible) Nrows() (int, int)
- func (*Compatible) Order() []string
- func (c *Compatible) SetTran(t QueryTran)
- func (*Compatible) Updateable() string
- type Compatible1
- func (q *Compatible1) Columns() []string
- func (q *Compatible1) Fixed() Fixed
- func (q *Compatible1) Header() *Header
- func (q *Compatible1) Indexes() [][]string
- func (q *Compatible1) Keys() [][]string
- func (q *Compatible1) Metrics() *metrics
- func (q *Compatible1) Nrows() (int, int)
- func (*Compatible1) Order() []string
- func (c1 *Compatible1) Rewind()
- func (c1 *Compatible1) Select(sels Sels)
- func (*Compatible1) Updateable() string
- type Cost
- type Extend
- func (q *Extend) Columns() []string
- func (e *Extend) Fixed() Fixed
- func (e *Extend) Get(th *Thread, dir Dir) Row
- func (q *Extend) Header() *Header
- func (q *Extend) Indexes() [][]string
- func (q *Extend) Keys() [][]string
- func (e *Extend) Lookup(th *Thread, sels Sels) Row
- func (q *Extend) Metrics() *metrics
- func (q *Extend) Nrows() (int, int)
- func (*Extend) Order() []string
- func (e *Extend) Select(sels Sels)
- func (e *Extend) SetTran(t QueryTran)
- func (e *Extend) Simple(th *Thread) []Row
- func (q *Extend) SingleTable() bool
- func (e *Extend) String() string
- func (e *Extend) Transform() Query
- func (e *Extend) ValueGet(key Value) Value
- type Fix
- type Fixed
- func (fixed Fixed) All(cols []string) bool
- func (fixed Fixed) Combine(fixed2 Fixed) (result Fixed, none bool)
- func (fixed Fixed) Conflicts(sels Sels) bool
- func (fixed Fixed) Equal(fixed2 Fixed) bool
- func (fixed Fixed) Get(col string) []string
- func (fixed Fixed) Has(col string) bool
- func (fixed Fixed) Match(sels Sels) (satisfied, conflict bool)
- func (fixed Fixed) RemoveFrom(cols []string) []string
- func (fixed Fixed) RemoveFromAll(cols [][]string) [][]string
- func (fixed Fixed) Single(col string) bool
- func (fixed Fixed) String() string
- type History
- func (*History) Clone() *Table
- func (*History) Columns() []string
- func (*History) Fixed() Fixed
- func (his *History) Get(_ *Thread, dir Dir) Row
- func (*History) Header() *Header
- func (*History) Indexes() [][]string
- func (*History) Init()
- func (*History) Keys() [][]string
- func (his *History) Lookup(th *Thread, sels Sels) Row
- func (st *History) Metrics() *metrics
- func (his *History) Nrows() (int, int)
- func (*History) Order() []string
- func (*History) Output(th *Thread, _ Record)
- func (his *History) Rewind()
- func (*History) Select(Sels)
- func (*History) SetIndex(index []string, mode Mode)
- func (his *History) SetTran(tran QueryTran)
- func (*History) Simple(*Thread) []Row
- func (*History) SingleTable() bool
- func (*History) String() string
- func (his *History) Transform() Query
- func (*History) UniqueIndexes() [][]string
- func (*History) Updateable() string
- func (his *History) ValueGet(key Value) Value
- type Index
- type Indexes
- func (*Indexes) Clone() *Table
- func (*Indexes) Columns() []string
- func (*Indexes) Fixed() Fixed
- func (is *Indexes) Get(_ *Thread, dir Dir) Row
- func (*Indexes) Header() *Header
- func (*Indexes) Indexes() [][]string
- func (*Indexes) Init()
- func (*Indexes) Keys() [][]string
- func (is *Indexes) Lookup(th *Thread, sels Sels) Row
- func (st *Indexes) Metrics() *metrics
- func (*Indexes) Name() string
- func (is *Indexes) Nrows() (int, int)
- func (*Indexes) Order() []string
- func (*Indexes) Output(th *Thread, _ Record)
- func (is *Indexes) Rewind()
- func (*Indexes) Select(Sels)
- func (*Indexes) SetIndex(index []string, mode Mode)
- func (is *Indexes) SetTran(tran QueryTran)
- func (*Indexes) Simple(*Thread) []Row
- func (*Indexes) SingleTable() bool
- func (*Indexes) String() string
- func (is *Indexes) Transform() Query
- func (*Indexes) UniqueIndexes() [][]string
- func (*Indexes) Updateable() string
- func (is *Indexes) ValueGet(key Value) Value
- type Intersect
- func (q *Intersect) Columns() []string
- func (q *Intersect) Fixed() Fixed
- func (it *Intersect) Get(th *Thread, dir Dir) Row
- func (q *Intersect) Header() *Header
- func (q *Intersect) Indexes() [][]string
- func (q *Intersect) Keys() [][]string
- func (it *Intersect) Lookup(th *Thread, sels Sels) Row
- func (q *Intersect) Metrics() *metrics
- func (q *Intersect) Nrows() (int, int)
- func (*Intersect) Order() []string
- func (it *Intersect) Simple(th *Thread) []Row
- func (it *Intersect) String() string
- func (it *Intersect) Transform() Query
- func (*Intersect) Updateable() string
- func (it *Intersect) ValueGet(key Value) Value
- type Join
- func (jn *Join) Get(th *Thread, dir Dir) Row
- func (jn *Join) Lookup(th *Thread, sels Sels) Row
- func (jb *Join) Rewind()
- func (jn *Join) Select(sels Sels)
- func (jb *Join) SetTran(qt QueryTran)
- func (jn *Join) Simple(th *Thread) []Row
- func (jn *Join) String() string
- func (jn *Join) Transform() Query
- func (jn *Join) ValueGet(key Value) Value
- func (jn *Join) With(src1, src2 Query) *Join
- type LeftJoin
- func (lj *LeftJoin) Get(th *Thread, dir Dir) (r Row)
- func (lj *LeftJoin) Lookup(th *Thread, sels Sels) Row
- func (jb *LeftJoin) Rewind()
- func (lj *LeftJoin) Select(sels Sels)
- func (jb *LeftJoin) SetTran(qt QueryTran)
- func (lj *LeftJoin) Simple(th *Thread) []Row
- func (lj *LeftJoin) String() string
- func (lj *LeftJoin) Transform() Query
- func (lj *LeftJoin) ValueGet(key Value) Value
- func (lj *LeftJoin) With(src1, src2 Query) *LeftJoin
- type Minus
- func (q *Minus) Columns() []string
- func (q *Minus) Fixed() Fixed
- func (m *Minus) Get(th *Thread, dir Dir) Row
- func (q *Minus) Header() *Header
- func (q *Minus) Indexes() [][]string
- func (q *Minus) Keys() [][]string
- func (m *Minus) Lookup(th *Thread, sels Sels) Row
- func (q *Minus) Metrics() *metrics
- func (q *Minus) Nrows() (int, int)
- func (*Minus) Order() []string
- func (m *Minus) Simple(th *Thread) []Row
- func (m *Minus) String() string
- func (m *Minus) Transform() Query
- func (*Minus) Updateable() string
- func (m *Minus) ValueGet(key Value) Value
- type Mode
- type Nothing
- func (q *Nothing) Columns() []string
- func (q *Nothing) Fixed() Fixed
- func (*Nothing) Get(*Thread, Dir) Row
- func (q *Nothing) Header() *Header
- func (*Nothing) Indexes() [][]string
- func (*Nothing) Keys() [][]string
- func (*Nothing) Lookup(*Thread, Sels) Row
- func (q *Nothing) Metrics() *metrics
- func (*Nothing) Nrows() (int, int)
- func (*Nothing) Order() []string
- func (no *Nothing) Output(th *Thread, rec Record)
- func (*Nothing) Rewind()
- func (*Nothing) Select(Sels)
- func (no *Nothing) SetTran(tran QueryTran)
- func (*Nothing) Simple(*Thread) []Row
- func (*Nothing) SingleTable() bool
- func (no *Nothing) String() string
- func (no *Nothing) Transform() Query
- func (no *Nothing) Updateable() string
- func (no *Nothing) ValueGet(key Value) Value
- type Project
- func (q *Project) Columns() []string
- func (p *Project) Fixed() Fixed
- func (p *Project) Get(th *Thread, dir Dir) Row
- func (q *Project) Header() *Header
- func (q *Project) Indexes() [][]string
- func (q *Project) Keys() [][]string
- func (p *Project) Lookup(th *Thread, sels Sels) Row
- func (q *Project) Metrics() *metrics
- func (q *Project) Nrows() (int, int)
- func (*Project) Order() []string
- func (p *Project) Output(th *Thread, rec Record)
- func (p *Project) Rewind()
- func (p *Project) Select(sels Sels)
- func (p *Project) SetTran(t QueryTran)
- func (p *Project) Simple(th *Thread) []Row
- func (q *Project) SingleTable() bool
- func (p *Project) String() string
- func (p *Project) Transform() Query
- func (p *Project) Updateable() string
- func (p *Project) ValueGet(key Value) Value
- type ProjectNone
- func (*ProjectNone) Columns() []string
- func (*ProjectNone) Fixed() Fixed
- func (pn *ProjectNone) Get(_ *Thread, _ Dir) Row
- func (*ProjectNone) Header() *Header
- func (*ProjectNone) Indexes() [][]string
- func (*ProjectNone) Keys() [][]string
- func (pn *ProjectNone) Lookup(_ *Thread, sels Sels) Row
- func (*ProjectNone) Metrics() *metrics
- func (pn *ProjectNone) Nrows() (int, int)
- func (*ProjectNone) Order() []string
- func (*ProjectNone) Output(*Thread, Record)
- func (pn *ProjectNone) Rewind()
- func (pn *ProjectNone) Select(sels Sels)
- func (pn *ProjectNone) SetTran(t QueryTran)
- func (pn *ProjectNone) Simple(th *Thread) []Row
- func (*ProjectNone) SingleTable() bool
- func (*ProjectNone) String() string
- func (pn *ProjectNone) Transform() Query
- func (*ProjectNone) Updateable() string
- func (pn *ProjectNone) ValueGet(key Value) Value
- type Query
- func JustParse(t QueryTran, query string) Query
- func NewJoin(src1, src2 Query, by []string, t QueryTran) Query
- func NewTable(t QueryTran, name string) Query
- func ParseQuery(src string, t QueryTran, sv *Sviews) Query
- func SetApproach(q Query, req Require, tran QueryTran) Query
- func SetupKey(q Query, mode Mode, t QueryTran) Query
- type Query1
- func (q *Query1) Columns() []string
- func (q *Query1) Fixed() Fixed
- func (q *Query1) Header() *Header
- func (q *Query1) Indexes() [][]string
- func (q *Query1) Keys() [][]string
- func (q *Query1) Metrics() *metrics
- func (q *Query1) Nrows() (int, int)
- func (*Query1) Order() []string
- func (q1 *Query1) Output(th *Thread, rec Record)
- func (q1 *Query1) Rewind()
- func (q1 *Query1) SetTran(t QueryTran)
- func (q *Query1) SingleTable() bool
- func (q1 *Query1) Source() Query
- func (q1 *Query1) Updateable() string
- type Query2
- func (q *Query2) Columns() []string
- func (q *Query2) Fixed() Fixed
- func (q *Query2) Header() *Header
- func (q *Query2) Indexes() [][]string
- func (q *Query2) Keys() [][]string
- func (q *Query2) Metrics() *metrics
- func (q *Query2) Nrows() (int, int)
- func (*Query2) Order() []string
- func (*Query2) Output(*Thread, Record)
- func (q2 *Query2) SetTran(t QueryTran)
- func (q2 *Query2) SingleTable() bool
- func (q2 *Query2) Source() Query
- func (q2 *Query2) Source2() Query
- func (*Query2) Updateable() string
- type QueryHash
- type QueryTran
- type Rename
- func (q *Rename) Columns() []string
- func (r *Rename) Fixed() Fixed
- func (r *Rename) Get(th *Thread, dir Dir) Row
- func (q *Rename) Header() *Header
- func (q *Rename) Indexes() [][]string
- func (q *Rename) Keys() [][]string
- func (r *Rename) Lookup(th *Thread, sels Sels) Row
- func (q *Rename) Metrics() *metrics
- func (q *Rename) Nrows() (int, int)
- func (*Rename) Order() []string
- func (r *Rename) Select(sels Sels)
- func (r *Rename) Simple(th *Thread) []Row
- func (q *Rename) SingleTable() bool
- func (r *Rename) String() string
- func (r *Rename) Transform() Query
- func (r *Rename) ValueGet(key Value) Value
- type Renames
- type Require
- type Schema
- type Sel
- type Sels
- func (sels Sels) All() iter.Seq2[string, string]
- func (sels Sels) ColsAre(cols []string) bool
- func (sels Sels) FindCol(col string) int
- func (sels Sels) Get(col string) (string, bool)
- func (sels Sels) HasCol(col string) bool
- func (sels Sels) MustGet(col string) string
- func (sels Sels) String() string
- type SemiJoin
- func (q *SemiJoin) Columns() []string
- func (q *SemiJoin) Fixed() Fixed
- func (sj *SemiJoin) Get(th *Thread, dir Dir) Row
- func (q *SemiJoin) Header() *Header
- func (q *SemiJoin) Indexes() [][]string
- func (q *SemiJoin) Keys() [][]string
- func (sj *SemiJoin) Lookup(th *Thread, sels Sels) Row
- func (q *SemiJoin) Metrics() *metrics
- func (q *SemiJoin) Nrows() (int, int)
- func (*SemiJoin) Order() []string
- func (sj *SemiJoin) Rewind()
- func (sj *SemiJoin) Select(sels Sels)
- func (sj *SemiJoin) SetTran(t QueryTran)
- func (sj *SemiJoin) Simple(th *Thread) []Row
- func (sj *SemiJoin) String() string
- func (sj *SemiJoin) Transform() Query
- func (*SemiJoin) Updateable() string
- func (sj *SemiJoin) ValueGet(key Value) Value
- func (sj *SemiJoin) With(src1, src2 Query) *SemiJoin
- type Sort
- func (q *Sort) Columns() []string
- func (q *Sort) Fixed() Fixed
- func (sort *Sort) Get(th *Thread, dir Dir) Row
- func (q *Sort) Header() *Header
- func (*Sort) Indexes() [][]string
- func (q *Sort) Keys() [][]string
- func (*Sort) Lookup(*Thread, Sels) Row
- func (q *Sort) Metrics() *metrics
- func (q *Sort) Nrows() (int, int)
- func (sort *Sort) Order() []string
- func (sort *Sort) Select(sels Sels)
- func (sort *Sort) Simple(th *Thread) []Row
- func (q *Sort) SingleTable() bool
- func (sort *Sort) String() string
- func (sort *Sort) Transform() Query
- func (sort *Sort) ValueGet(key Value) Value
- type StatsTable
- func (*StatsTable) Clone() *Table
- func (*StatsTable) Columns() []string
- func (*StatsTable) Fixed() Fixed
- func (st *StatsTable) Get(_ *Thread, dir Dir) Row
- func (*StatsTable) Header() *Header
- func (*StatsTable) Indexes() [][]string
- func (*StatsTable) Init()
- func (*StatsTable) Keys() [][]string
- func (st *StatsTable) Lookup(th *Thread, sels Sels) Row
- func (st *StatsTable) Metrics() *metrics
- func (*StatsTable) Name() string
- func (st *StatsTable) Nrows() (int, int)
- func (*StatsTable) Order() []string
- func (*StatsTable) Output(th *Thread, _ Record)
- func (st *StatsTable) Rewind()
- func (*StatsTable) Select(Sels)
- func (*StatsTable) SetIndex(index []string, mode Mode)
- func (st *StatsTable) SetTran(tran QueryTran)
- func (*StatsTable) Simple(*Thread) []Row
- func (*StatsTable) SingleTable() bool
- func (*StatsTable) String() string
- func (st *StatsTable) Transform() Query
- func (*StatsTable) UniqueIndexes() [][]string
- func (*StatsTable) Updateable() string
- func (st *StatsTable) ValueGet(key Value) Value
- type SuQueryNode
- type Summarize
- func (q *Summarize) Columns() []string
- func (q *Summarize) Fixed() Fixed
- func (su *Summarize) Get(th *Thread, dir Dir) Row
- func (q *Summarize) Header() *Header
- func (q *Summarize) Indexes() [][]string
- func (q *Summarize) Keys() [][]string
- func (su *Summarize) Len() int
- func (su *Summarize) Less(i, j int) bool
- func (su *Summarize) Lookup(th *Thread, sels Sels) Row
- func (q *Summarize) Metrics() *metrics
- func (q *Summarize) Nrows() (int, int)
- func (*Summarize) Order() []string
- func (*Summarize) Output(*Thread, Record)
- func (su *Summarize) Rewind()
- func (su *Summarize) Select(sels Sels)
- func (su *Summarize) SetTran(t QueryTran)
- func (su *Summarize) Simple(th *Thread) []Row
- func (su *Summarize) SingleTable() bool
- func (su *Summarize) String() string
- func (su *Summarize) Swap(i, j int)
- func (su *Summarize) Transform() Query
- func (su *Summarize) Updateable() string
- func (su *Summarize) ValueGet(key Value) Value
- type Table
- func (tbl *Table) Clone() *Table
- func (q *Table) Columns() []string
- func (tbl *Table) Fixed() Fixed
- func (tbl *Table) Get(_ *Thread, dir Dir) Row
- func (tbl *Table) GetFilter(dir Dir, filter func(key string) bool) Row
- func (q *Table) Header() *Header
- func (tbl *Table) IndexEncodes(index []string) bool
- func (q *Table) Indexes() [][]string
- func (q *Table) Keys() [][]string
- func (tbl *Table) Lookup(_ *Thread, sels Sels) Row
- func (tbl *Table) LookupRaw(key string) Row
- func (q *Table) Metrics() *metrics
- func (tbl *Table) Name() string
- func (tbl *Table) Nrows() (int, int)
- func (*Table) Order() []string
- func (tbl *Table) Output(th *Thread, rec Record)
- func (tbl *Table) RangeFrac(index []string, sels Sels) float64
- func (tbl *Table) Rewind()
- func (tbl *Table) Select(sels Sels)
- func (tbl *Table) SelectRaw(org, end string)
- func (tbl *Table) SelectSkipScan(prefixRng, suffixRng iface.Range, skipStart int)
- func (tbl *Table) SetIndex(index []string, mode Mode)
- func (tbl *Table) SetTran(t QueryTran)
- func (tbl *Table) Simple(*Thread) []Row
- func (tbl *Table) SingleTable() bool
- func (tbl *Table) String() string
- func (tbl *Table) Transform() Query
- func (tbl *Table) UniqueIndexes() [][]string
- func (tbl *Table) Updateable() string
- func (tbl *Table) ValueGet(key Value) Value
- type Tables
- func (*Tables) Clone() *Table
- func (*Tables) Columns() []string
- func (*Tables) Fixed() Fixed
- func (ts *Tables) Get(_ *Thread, dir Dir) Row
- func (*Tables) Header() *Header
- func (*Tables) Indexes() [][]string
- func (*Tables) Init()
- func (*Tables) Keys() [][]string
- func (ts *Tables) Lookup(th *Thread, sels Sels) Row
- func (st *Tables) Metrics() *metrics
- func (*Tables) Name() string
- func (ts *Tables) Nrows() (int, int)
- func (*Tables) Order() []string
- func (*Tables) Output(th *Thread, _ Record)
- func (ts *Tables) Rewind()
- func (*Tables) Select(Sels)
- func (*Tables) SetIndex(index []string, mode Mode)
- func (ts *Tables) SetTran(tran QueryTran)
- func (*Tables) Simple(*Thread) []Row
- func (*Tables) SingleTable() bool
- func (*Tables) String() string
- func (ts *Tables) Transform() Query
- func (*Tables) UniqueIndexes() [][]string
- func (*Tables) Updateable() string
- func (ts *Tables) ValueGet(key Value) Value
- type TempIndex
- func (q *TempIndex) Columns() []string
- func (q *TempIndex) Fixed() Fixed
- func (ti *TempIndex) Get(th *Thread, dir Dir) Row
- func (q *TempIndex) Header() *Header
- func (q *TempIndex) Indexes() [][]string
- func (q *TempIndex) Keys() [][]string
- func (ti *TempIndex) Lookup(th *Thread, sels Sels) Row
- func (q *TempIndex) Metrics() *metrics
- func (q *TempIndex) Nrows() (int, int)
- func (*TempIndex) Order() []string
- func (ti *TempIndex) Rewind()
- func (ti *TempIndex) Select(sels Sels)
- func (ti *TempIndex) SetTran(tran QueryTran)
- func (ti *TempIndex) Simple(th *Thread) []Row
- func (q *TempIndex) SingleTable() bool
- func (ti *TempIndex) String() string
- func (ti *TempIndex) Transform() Query
- func (ti *TempIndex) ValueGet(key Value) Value
- type Times
- func (t *Times) Get(th *Thread, dir Dir) Row
- func (t *Times) Lookup(th *Thread, sels Sels) Row
- func (t *Times) Rewind()
- func (t *Times) Select(sels Sels)
- func (t *Times) Simple(th *Thread) []Row
- func (t *Times) String() string
- func (t *Times) Transform() Query
- func (t *Times) ValueGet(key Value) Value
- type Union
- func (q *Union) Columns() []string
- func (u *Union) Fixed() Fixed
- func (u *Union) Get(th *Thread, dir Dir) Row
- func (q *Union) Header() *Header
- func (q *Union) Indexes() [][]string
- func (u *Union) Keys() [][]string
- func (u *Union) Lookup(th *Thread, sels Sels) Row
- func (q *Union) Metrics() *metrics
- func (q *Union) Nrows() (int, int)
- func (*Union) Order() []string
- func (u *Union) Rewind()
- func (u *Union) Select(sels Sels)
- func (u *Union) Simple(th *Thread) []Row
- func (u *Union) String() string
- func (u *Union) Transform() Query
- func (*Union) Updateable() string
- func (u *Union) ValueGet(key Value) Value
- type Use
- type View
- func (q *View) Columns() []string
- func (q *View) Fixed() Fixed
- func (v *View) Get(th *Thread, dir Dir) Row
- func (q *View) Header() *Header
- func (q *View) Indexes() [][]string
- func (q *View) Keys() [][]string
- func (v *View) Lookup(*Thread, Sels) Row
- func (q *View) Metrics() *metrics
- func (q *View) Nrows() (int, int)
- func (*View) Order() []string
- func (v *View) Select(Sels)
- func (*View) Simple(*Thread) []Row
- func (q *View) SingleTable() bool
- func (v *View) String() string
- func (v *View) Transform() Query
- func (v *View) ValueGet(key Value) Value
- type Views
- func (*Views) Clone() *Table
- func (*Views) Columns() []string
- func (*Views) Fixed() Fixed
- func (vs *Views) Get(_ *Thread, dir Dir) Row
- func (*Views) Header() *Header
- func (*Views) Indexes() [][]string
- func (*Views) Init()
- func (*Views) Keys() [][]string
- func (vs *Views) Len() int
- func (vs *Views) Less(i, j int) bool
- func (vs *Views) Lookup(th *Thread, sels Sels) Row
- func (st *Views) Metrics() *metrics
- func (*Views) Name() string
- func (vs *Views) Nrows() (int, int)
- func (*Views) Order() []string
- func (*Views) Output(th *Thread, _ Record)
- func (vs *Views) Rewind()
- func (*Views) Select(Sels)
- func (*Views) SetIndex(index []string, mode Mode)
- func (vs *Views) SetTran(tran QueryTran)
- func (*Views) Simple(*Thread) []Row
- func (*Views) SingleTable() bool
- func (*Views) String() string
- func (vs *Views) Swap(i, j int)
- func (vs *Views) Transform() Query
- func (*Views) UniqueIndexes() [][]string
- func (*Views) Updateable() string
- func (vs *Views) ValueGet(key Value) Value
- type Where
- func (q *Where) Columns() []string
- func (q *Where) Fixed() Fixed
- func (w *Where) Get(th *Thread, dir Dir) Row
- func (q *Where) Header() *Header
- func (w *Where) InCount() int
- func (w *Where) Indexes() [][]string
- func (w *Where) Keys() [][]string
- func (w *Where) Lookup(th *Thread, sels Sels) Row
- func (q *Where) Metrics() *metrics
- func (w *Where) Nrows() (int, int)
- func (*Where) Order() []string
- func (w *Where) Rewind()
- func (w *Where) Select(sels Sels)
- func (w *Where) SetTran(t QueryTran)
- func (w *Where) Simple(th *Thread) []Row
- func (q *Where) SingleTable() bool
- func (w *Where) String() string
- func (w *Where) Transform() Query
- func (w *Where) ValueGet(key Value) Value
Constants ¶
const ( UsePrefix = 0b100 // cols can be a prefix of index UseFull = 0b101 // cols must be the entire index UseSet = 0b100 // cols are a set (order is not significant) UseOrder = 0b110 // cols are ordered )
Variables ¶
var HistoryFields = [][]string{{"asof"}}
var MakeSuTran func(qt QueryTran) *SuTran
MakeSuTran is injected by dbms to avoid import cycle
var Two = IntVal(2)
Functions ¶
func DoAdminTest ¶
func JustTable ¶
JustTable returns the table name if the query is just a table name, ignoring whitespace and comments. Returns an empty string if the query contains anything other than a single table name.
func NewAdminParser ¶
func NewAdminParser(src string) *adminParser
func NewQueryParser ¶
func NewSuQueryNode ¶
func NewSuQueryNode(q Query) Value
func PullIdxUse ¶
PullIdxUse returns the current index usage and resets it
func Setup ¶
Setup prepares a parsed query for execution. It calls Transform, Optimize, and SetApproach. The resulting Query is ready for execution.
func Setup1 ¶
Setup1 is the same as Setup except it passes a frac of 1/nrows which will minimize fixed cost e.g. by avoiding temp indexes. It is used by DbmsLocal for Query1, QueryFirst, QueryLast
func Strategy2 ¶
Strategy2 is like Strategy but without the cost/size estimates so it is more stable for tests
func String ¶
String prints the full query, including child sources whereas query.String only shows that operation
Types ¶
type Action ¶
type Action interface {
String() string
// contains filtered or unexported methods
}
func ParseAction ¶
ParseAction parses insert, update, and delete actions
type Admin ¶
type Admin interface {
String() string
// contains filtered or unexported methods
}
func ParseAdmin ¶
type Columns ¶
type Columns struct {
// contains filtered or unexported fields
}
func (*Columns) SingleTable ¶
func (*Columns) SingleTable() bool
func (*Columns) UniqueIndexes ¶
func (*Columns) UniqueIndexes() [][]string
func (*Columns) Updateable ¶
func (*Columns) Updateable() string
type Compatible ¶
type Compatible struct {
Query2
// contains filtered or unexported fields
}
Compatible is shared by Intersect, Minus, and Union
func (*Compatible) SetTran ¶
func (c *Compatible) SetTran(t QueryTran)
func (*Compatible) Updateable ¶
func (*Compatible) Updateable() string
Updateable is overridden by Query1
type Compatible1 ¶
type Compatible1 struct {
Compatible
}
Compatible1 is embedded by Intersect and Minus (that return a subset of source1 records)
func (*Compatible1) Rewind ¶
func (c1 *Compatible1) Rewind()
func (*Compatible1) Select ¶
func (c1 *Compatible1) Select(sels Sels)
func (*Compatible1) Updateable ¶
func (*Compatible1) Updateable() string
Updateable is overridden by Query1
type Extend ¶
type Extend struct {
Query1
// contains filtered or unexported fields
}
func (*Extend) SingleTable ¶
func (q *Extend) SingleTable() bool
type Fix ¶
type Fix struct {
// contains filtered or unexported fields
}
type Fixed ¶
type Fixed []Fix
func (Fixed) Combine ¶
Combine is used by Where, Join, and Intersect. The result is all the ones from fixed1 that are not in fixed2, plus the ones from fixed2 that are not in fixed1, plus the intersection of values of ones that are in both. If an intersection is empty, that is a conflict (none). e.g. a: 1, b: 2|3 COMBINE b: 3|4, c: 5 => a: 1, b: 3, c: 5
func (Fixed) Match ¶
Match returns satisfied=true if sels are satisfied by fixed and conflict=true if sels conflict with fixed
func (Fixed) RemoveFrom ¶
RemoveFrom returns cols without the single fixed columns
func (Fixed) RemoveFromAll ¶
RemoveFromAll returns cols without the single fixed columns
type History ¶
type History struct {
// contains filtered or unexported fields
}
func (*History) SingleTable ¶
func (*History) SingleTable() bool
func (*History) UniqueIndexes ¶
func (*History) UniqueIndexes() [][]string
func (*History) Updateable ¶
func (*History) Updateable() string
type Indexes ¶
type Indexes struct {
// contains filtered or unexported fields
}
func (*Indexes) SingleTable ¶
func (*Indexes) SingleTable() bool
func (*Indexes) UniqueIndexes ¶
func (*Indexes) UniqueIndexes() [][]string
func (*Indexes) Updateable ¶
func (*Indexes) Updateable() string
type Intersect ¶
type Intersect struct {
Compatible1
// contains filtered or unexported fields
}
Intersect is a Query that intersects two sources. It allows the sources to have different columns. The result columns are the intersection of the source columns (i.e. the common columns). All columns are compared when matching rows; so columns unique to either source must be "". (Rules could complicate this.) This means we don't need an extra deduplication step like we would if we only compared common columns. To get that behavior, use project on the sources before intersect.
func NewIntersect ¶
func (*Intersect) Updateable ¶
func (*Intersect) Updateable() string
Updateable is overridden by Query1
type Minus ¶
type Minus struct {
Compatible1
// contains filtered or unexported fields
}
type Mode ¶
type Mode int
Mode is the query execution context. It affects the use of temporary indexes — they are only valid within a single transaction, so they are disabled for CursorMode.
type Nothing ¶
type Nothing struct {
// contains filtered or unexported fields
}
Nothing is a null query that produces no output. It results from a Join, Where, or Intersect with a Fixed conflict. It is not generated by the query parser.
func NewNothing ¶
func (*Nothing) SingleTable ¶
func (*Nothing) Updateable ¶
type Project ¶
type Project struct {
Query1
// contains filtered or unexported fields
}
func NewProject ¶
func (*Project) SingleTable ¶
func (q *Project) SingleTable() bool
func (*Project) Updateable ¶
type ProjectNone ¶
type ProjectNone struct {
// contains filtered or unexported fields
}
ProjectNone produces a single empty row with no columns. It results from a Project with no columns. It is not generated by the query parser. It returns 0 rows when the source is empty, otherwise 1 row.
func (*ProjectNone) Columns ¶
func (*ProjectNone) Columns() []string
func (*ProjectNone) Fixed ¶
func (*ProjectNone) Fixed() Fixed
func (*ProjectNone) Get ¶
func (pn *ProjectNone) Get(_ *Thread, _ Dir) Row
func (*ProjectNone) Header ¶
func (*ProjectNone) Header() *Header
func (*ProjectNone) Indexes ¶
func (*ProjectNone) Indexes() [][]string
func (*ProjectNone) Keys ¶
func (*ProjectNone) Keys() [][]string
func (*ProjectNone) Lookup ¶
func (pn *ProjectNone) Lookup(_ *Thread, sels Sels) Row
func (*ProjectNone) Metrics ¶
func (*ProjectNone) Metrics() *metrics
func (*ProjectNone) Nrows ¶
func (pn *ProjectNone) Nrows() (int, int)
func (*ProjectNone) Order ¶
func (*ProjectNone) Order() []string
func (*ProjectNone) Output ¶
func (*ProjectNone) Output(*Thread, Record)
func (*ProjectNone) Rewind ¶
func (pn *ProjectNone) Rewind()
func (*ProjectNone) Select ¶
func (pn *ProjectNone) Select(sels Sels)
func (*ProjectNone) SetTran ¶
func (pn *ProjectNone) SetTran(t QueryTran)
func (*ProjectNone) Simple ¶
func (pn *ProjectNone) Simple(th *Thread) []Row
func (*ProjectNone) SingleTable ¶
func (*ProjectNone) SingleTable() bool
func (*ProjectNone) String ¶
func (*ProjectNone) String() string
func (*ProjectNone) Transform ¶
func (pn *ProjectNone) Transform() Query
func (*ProjectNone) Updateable ¶
func (*ProjectNone) Updateable() string
func (*ProjectNone) ValueGet ¶
func (pn *ProjectNone) ValueGet(key Value) Value
type Query ¶
type Query interface {
// Columns is all the available columns, including derived
Columns() []string
// Transform refactors the query for more efficient execution.
// This stage is not cost based, transforms are applied when possible.
//
// Transform methods MUST ensure they call Transform on their children.
// Transform is (mostly) bottom up, partly for path copying.
// Which means Transform methods should start by calling Transform
// on their children.
//
// Any changes should build new nodes, NOT modify nodes.
// This is partly to ensure that constructor validation is done.
Transform() Query
// SetTran is used for cursors
SetTran(tran QueryTran)
// Order is nil for everything except Sort
Order() []string
// Fixed returns the field values that are constant from Extend or Where
Fixed() Fixed
// Updateable returns the table name if the rows from the query can be updated
// else ""
Updateable() string
// SingleTable is used by TempIndex.
// It is true if the query Get returns a single record stored in the database
SingleTable() bool
// Indexes returns all the indexes.
// Unlike Keys, Indexes are physical access paths.
Indexes() [][]string
// Keys returns sets of fields that are unique primary keys.
// On a table this will be the key indexes, but on other operations
// this is logical, there may not be a physical index.
Keys() [][]string
// Nrows returns n the number of expected result rows from the query,
// and p the "population" it was drawn from.
// For example, a Where on a key selects a single row (n = 1),
// from the entire table with p rows.
//
// Nrows should be the same regardless of the strategy.
// For symmetrical/reversible operations e.g. join or union
// it should give the same result both ways.
//
// Nrows does *not* incorporate frac
Nrows() (n, p int)
// Rewind resets the query so Get Next gets first, or Prev gets last
// It does *not* clear any Select.
Rewind()
// Get returns the next or previous row, or nil if at end.
// It sticks at eof until Rewind.
// Rewind then Get Next returns the first row,
// Rewind then Get Prev returns the last row.
Get(th *Thread, dir Dir) Row
// Lookup returns the row matching the given key value, or nil if not found.
// It is valid (although not necessarily the most efficient)
// to implement Lookup with Select and Get (eg. [lookupViaSelectGet])
// in which case it should leave the select cleared.
// Lookup should rewind.
// Incoming Lookup should be consistent with the incoming Require.
// Outgoing Lookup should be consistent with the outgoing Require.
// It is valid for Require cols to specify a superset of key columns.
// It is ok for sels to contain extra columns,
// BUT they will be ignored, not applied.
// The originator of the sels is responsible for comparing extra columns.
// Lookup generally corresponds to [UniqueReq]
Lookup(th *Thread, sels Sels) Row
// Select restricts the query to records matching the given packed values.
// Ultimately, a Select specifies a prefix of an index.
// To clear the select, use Select(nil)
// Select should rewind.
// Incoming Select should be consistent with the incoming Require.
// Outgoing Select should be consistent with the outgoing Require.
// It is ok for sels to contain extra columns,
// BUT they will be ignored, not applied.
// Select generally corresponds to [GroupReq]
Select(sels Sels)
Header() *Header
Output(th *Thread, rec Record)
String() string
// Simple is simple, alternate execution method for testing.
// It should normally be used after just parsing,
// without transform or optimize.
// The result may be modified - do not return internal data.
// Simple should work correctly regardless of query operation state,
// including after an aborted execution.
Simple(th *Thread) []Row
// ValueGet is for Suneido.ParseQuery and queryvalue.go
// It would be Get, but that is already used in Query.
ValueGet(key Value) Value
Metrics() *metrics
// contains filtered or unexported methods
}
Query is the interface for nodes in a query tree. The interface covers both optimization and execution.
Query types form a hierarchy where nodes compose other Query nodes: single-source operations (Query1) have one source, and two-source operations (Query2) have two sources. Leaf nodes like Table access the database directly.
Optimization phase:
- Transform() refactors the query for efficiency (bottom-up).
- optimize()/caching selects the best execution strategy based on costs.
- setApproach() locks in the chosen strategy and sets up for execution.
- Requires/Nrows/Keys/Indexes provide metadata for cost estimation.
Execution phase:
- Get(Next/Prev) returns rows one at a time, sticking at EOF until Rewind.
- Lookup(sels) returns a single matching row (optimized path).
- Select(sels) restricts results to a key range (used by joins/filters).
- Rewind() resets the position for re-iteration.
Terminology:
- "incoming" means calls *to* a query operation
- "outgoing" means calls *from" a query operation
The "incoming" Require is the one passed to a node's own optimize/setApproach (called by its parent). The "outgoing" Require is the one this node passes to its children's optimize/setApproach via the package-level Optimize/SetApproach.
func ParseQuery ¶
func SetApproach ¶
SetApproach finalizes the chosen approach. It also adds temp indexes where required.
type Query1 ¶
type Query1 struct {
// contains filtered or unexported fields
}
func (*Query1) SingleTable ¶
func (q *Query1) SingleTable() bool
func (*Query1) Updateable ¶
type Query2 ¶
type Query2 struct {
// contains filtered or unexported fields
}
func (*Query2) SingleTable ¶
type QueryHash ¶
type QueryHash struct {
Hdr *Header
Fields []string
// contains filtered or unexported fields
}
func NewQueryHasher ¶
func NewQueryHasher(hdr *Header) *QueryHash
type QueryTran ¶
type QueryTran interface {
GetSchema(table string) *schema.Schema
HasTable(table string) bool
CheckPerm(table string, action TablePerm)
GetInfo(table string) *meta.Info
GetAllInfo() []*meta.Info
GetAllSchema() []*meta.Schema
GetAllViews() []string
GetView(string) string
GetStore() *stor.Stor
RangeFrac(table string, iIndex int, org, end string) float64
Lookup(table string, iIndex int, key string) *DbRec
Output(th *Thread, table string, rec Record)
GetIndexI(table string, iIndex int) *index.Overlay
GetRecord(off uint64) Record
MakeLess(is *ixkey.Spec) func(x, y uint64) bool
Read(string, int, string, string)
IndexIter(table string, iIndex int) index.IndexIter
Num() int
BusyAdd(col string, weight int)
Stats() stats.Stats
}
type Rename ¶
type Rename struct {
Query1
// contains filtered or unexported fields
}
func (*Rename) SingleTable ¶
func (q *Rename) SingleTable() bool
type Require ¶
type Require struct {
// contains filtered or unexported fields
}
Require specifies what a query node needs from its children during optimization. It bottoms out at Table.optimize which picks the lowest-cost index satisfying the Require.
func (Require) SatisfiedBy ¶
SatisfiedBy does not check that ReqUnique cols include a key
func (Require) SatisfiedByWithFixed ¶
SatisfiedByWithFixed does not check that ReqUnique cols include a key
func (Require) SelectFrac ¶
SelectFrac returns the fraction of rows/groups the parent will access, for scaling a downstream source's iteration varcost or its own child frac.
type Sels ¶
type Sels []Sel
func Split ¶
Split partitions sels relative to cols, returning sub-slices. It clones sels only if modifications are needed.
type SemiJoin ¶
type SemiJoin struct {
Query2
// contains filtered or unexported fields
}
func (*SemiJoin) Lookup ¶
Lookup uses source1.Lookup directly (source1 is always optimized with the same req as the semijoin itself, see optForward, so it supports Lookup whenever the semijoin does), then checks source2Has to confirm the join condition. This works for all join types and, importantly, never needs Select on source1, which would not be supported if source1 was set up for ReqUnique.
This is always the forward approach, regardless of sj.reverse: reverse only chooses a cheaper iteration order for Get, it's never chosen for ReqUnique (see optReverse), so Lookup is never called while reverse.
func (*SemiJoin) Updateable ¶
func (*SemiJoin) Updateable() string
Updateable is overridden by Query1
type Sort ¶
type Sort struct {
Query1
// contains filtered or unexported fields
}
func (*Sort) SingleTable ¶
func (q *Sort) SingleTable() bool
type StatsTable ¶
type StatsTable struct {
// contains filtered or unexported fields
}
func (*StatsTable) Columns ¶
func (*StatsTable) Columns() []string
func (*StatsTable) Get ¶
func (st *StatsTable) Get(_ *Thread, dir Dir) Row
func (*StatsTable) Header ¶
func (*StatsTable) Header() *Header
func (*StatsTable) Keys ¶
func (*StatsTable) Keys() [][]string
func (*StatsTable) Lookup ¶
func (st *StatsTable) Lookup(th *Thread, sels Sels) Row
func (*StatsTable) Name ¶
func (*StatsTable) Name() string
func (*StatsTable) Nrows ¶
func (st *StatsTable) Nrows() (int, int)
func (*StatsTable) Rewind ¶
func (st *StatsTable) Rewind()
func (*StatsTable) SetTran ¶
func (st *StatsTable) SetTran(tran QueryTran)
func (*StatsTable) SingleTable ¶
func (*StatsTable) SingleTable() bool
func (*StatsTable) String ¶
func (*StatsTable) String() string
func (*StatsTable) Transform ¶
func (st *StatsTable) Transform() Query
func (*StatsTable) UniqueIndexes ¶
func (*StatsTable) UniqueIndexes() [][]string
func (*StatsTable) Updateable ¶
func (*StatsTable) Updateable() string
func (*StatsTable) ValueGet ¶
func (st *StatsTable) ValueGet(key Value) Value
type SuQueryNode ¶
type SuQueryNode struct {
ValueBase[SuQueryNode]
// contains filtered or unexported fields
}
func (SuQueryNode) Equal ¶
func (SuQueryNode) Equal(any) bool
func (SuQueryNode) Get ¶
func (n SuQueryNode) Get(_ *Thread, key Value) Value
func (SuQueryNode) SetConcurrent ¶
func (SuQueryNode) SetConcurrent()
func (SuQueryNode) Type ¶
func (SuQueryNode) Type() types.Type
type Summarize ¶
type Summarize struct {
Query1
// contains filtered or unexported fields
}
func NewSummarize ¶
func (*Summarize) SingleTable ¶
func (*Summarize) Updateable ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) IndexEncodes ¶
IndexEncodes returns whether the index key is encoded (multi-field or non-key, i.e. has BestKey appended or Fields2)
func (*Table) SelectSkipScan ¶
func (*Table) SetIndex ¶
SetIndex sets the index used to access the table. It also sets req to ReqAny so that Select and Lookup can be used.
func (*Table) SingleTable ¶
func (*Table) UniqueIndexes ¶
UniqueIndexes returns the columns of the unique ('u') indexes
func (*Table) Updateable ¶
type Tables ¶
type Tables struct {
// contains filtered or unexported fields
}
func (*Tables) SingleTable ¶
func (*Tables) SingleTable() bool
func (*Tables) UniqueIndexes ¶
func (*Tables) UniqueIndexes() [][]string
func (*Tables) Updateable ¶
func (*Tables) Updateable() string
type TempIndex ¶
type TempIndex struct {
Query1
// contains filtered or unexported fields
}
TempIndex is inserted by SetApproach as required. It builds a sortlist of either DbRec or Row. Keys are not constructed for the index or Lookup/Select so there are no size limits.
func (*TempIndex) SingleTable ¶
func (q *TempIndex) SingleTable() bool
type Union ¶
type Union struct {
Compatible
// contains filtered or unexported fields
}
type Use ¶
type Use byte
Use specifies the type of requirement placed on index selection. There is an implicit contract between the Use type and the operations that can be performed:
- ReqNone: unordered Get, no Lookup, no Select
- ReqOrder: ordered Get, Select, no Lookup
- ReqGroup: grouped Get, Select, no Lookup
- ReqUnique: Lookup (cols must have an index as a subset), no Select
ReqOrder and ReqGroup do not support Lookup because they allow a longer index to be chosen which will not work with Lookup.
type View ¶
type View struct {
Query1
// contains filtered or unexported fields
}
View is a pass-through wrapper around a Query it is optionally added by parsequery so that format doesn't expand views. It should not be used when doing Transform and Optimize because it blocks identification of child queries.
func (*View) SingleTable ¶
func (q *View) SingleTable() bool
type Views ¶
type Views struct {
// contains filtered or unexported fields
}
func (*Views) SingleTable ¶
func (*Views) SingleTable() bool
func (*Views) UniqueIndexes ¶
func (*Views) UniqueIndexes() [][]string
func (*Views) Updateable ¶
func (*Views) Updateable() string
Source Files
¶
- action.go
- admin.go
- best.go
- cache.go
- compatible.go
- expr.go
- extend.go
- fixed.go
- format.go
- helpers.go
- idxsel.go
- idxuse.go
- intersect.go
- join.go
- lookup_cache.go
- metrics.go
- minus.go
- nothing.go
- parseaction.go
- parseadmin.go
- parsequery.go
- project.go
- projectnone.go
- query.go
- queryhash.go
- queryvalue.go
- rename.go
- require.go
- schema.go
- sels.go
- semijoin.go
- sort.go
- summarize.go
- table.go
- tempindex.go
- testdb.go
- testtran.go
- times.go
- union.go
- view.go
- warnings.go
- where.go
- where2.go
- where3.go