query

package
v0.0.0-...-451def6 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 45 Imported by: 0

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

View Source
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
)
View Source
const (
	ReqNone   Use = 0
	ReqGroup      = UsePrefix | UseSet   // used with Select
	ReqUnique     = UseFull | UseSet     // used with Lookup
	ReqOrder      = UsePrefix | UseOrder // used to Get in a particular order
	ReqAny        = 0xff                 // used with Table SetIndex
)

Variables

View Source
var HistoryFields = [][]string{{"asof"}}
View Source
var MakeSuTran func(qt QueryTran) *SuTran

MakeSuTran is injected by dbms to avoid import cycle

View Source
var Two = IntVal(2)

Functions

func CalcSelf

func CalcSelf(q0 Query)

func DoAction

func DoAction(th *Thread, ut *db19.UpdateTran, action string) int

func DoAdmin

func DoAdmin(db *db19.Database, cmd string, sv *Sviews, perms *Perms)

func DoAdminTest

func DoAdminTest(db *db19.Database, cmd string)

func Format

func Format(t QueryTran, query string) string

func GetSort

func GetSort(query string) string

GetSort returns the sort (if present) or else ""

func IdxUse

func IdxUse(table string, idx []string)

func JustTable

func JustTable(query string) string

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 NewQueryParser(src string, t QueryTran, sv *Sviews) *queryParser

func NewSuQueryNode

func NewSuQueryNode(q Query) Value

func PullIdxUse

func PullIdxUse() map[string]int

PullIdxUse returns the current index usage and resets it

func Setup

func Setup(q Query, mode Mode, t QueryTran) (Query, Cost, Cost)

Setup prepares a parsed query for execution. It calls Transform, Optimize, and SetApproach. The resulting Query is ready for execution.

func Setup1

func Setup1(q Query, mode Mode, t QueryTran) (Query, Cost, Cost)

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 SetupReq

func SetupReq(q Query, mode Mode, t QueryTran, req Require) (Query, Cost, Cost)

func Strategy

func Strategy(q Query) string

func Strategy2

func Strategy2(q Query) string

Strategy2 is like Strategy but without the cost/size estimates so it is more stable for tests

func String

func String(q Query) string

String prints the full query, including child sources whereas query.String only shows that operation

func StripSort

func StripSort(query string) string

StripSort returns the query without a sort (if present). The result is undefined if the query is not valid.

func Warnings

func Warnings(query string, q Query)

Types

type Action

type Action interface {
	String() string
	// contains filtered or unexported methods
}

func ParseAction

func ParseAction(src string, t QueryTran, sv *Sviews) Action

ParseAction parses insert, update, and delete actions

type Admin

type Admin interface {
	String() string
	// contains filtered or unexported methods
}

func ParseAdmin

func ParseAdmin(src string) Admin

type Columns

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

func (*Columns) Clone

func (*Columns) Clone() *Table

func (*Columns) Columns

func (cs *Columns) Columns() []string

func (*Columns) Fixed

func (*Columns) Fixed() Fixed

func (*Columns) Get

func (cs *Columns) Get(_ *Thread, dir Dir) Row

func (*Columns) Header

func (*Columns) Header() *Header

func (*Columns) Indexes

func (*Columns) Indexes() [][]string

func (*Columns) Init

func (*Columns) Init()

func (*Columns) Keys

func (*Columns) Keys() [][]string

func (*Columns) Lookup

func (cs *Columns) Lookup(th *Thread, sels Sels) Row

func (*Columns) Metrics

func (st *Columns) Metrics() *metrics

func (*Columns) Name

func (*Columns) Name() string

func (*Columns) Nrows

func (cs *Columns) Nrows() (int, int)

func (*Columns) Order

func (*Columns) Order() []string

func (*Columns) Output

func (*Columns) Output(th *Thread, _ Record)

func (*Columns) Rewind

func (cs *Columns) Rewind()

func (*Columns) Select

func (*Columns) Select(Sels)

func (*Columns) SetIndex

func (*Columns) SetIndex(index []string, mode Mode)

func (*Columns) SetTran

func (cs *Columns) SetTran(tran QueryTran)

func (*Columns) Simple

func (*Columns) Simple(*Thread) []Row

func (*Columns) SingleTable

func (*Columns) SingleTable() bool

func (*Columns) String

func (*Columns) String() string

func (*Columns) Transform

func (cs *Columns) Transform() Query

func (*Columns) UniqueIndexes

func (*Columns) UniqueIndexes() [][]string

func (*Columns) Updateable

func (*Columns) Updateable() string

func (*Columns) ValueGet

func (cs *Columns) ValueGet(key Value) Value

type Compatible

type Compatible struct {
	Query2
	// contains filtered or unexported fields
}

Compatible is shared by Intersect, Minus, and Union

func (*Compatible) Columns

func (q *Compatible) Columns() []string

func (*Compatible) Fixed

func (q *Compatible) Fixed() Fixed

func (*Compatible) Header

func (q *Compatible) Header() *Header

func (*Compatible) Indexes

func (q *Compatible) Indexes() [][]string

func (*Compatible) Keys

func (q *Compatible) Keys() [][]string

func (*Compatible) Metrics

func (q *Compatible) Metrics() *metrics

func (*Compatible) Nrows

func (q *Compatible) Nrows() (int, int)

func (*Compatible) Order

func (*Compatible) Order() []string

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) Columns

func (q *Compatible1) Columns() []string

func (*Compatible1) Fixed

func (q *Compatible1) Fixed() Fixed

func (*Compatible1) Header

func (q *Compatible1) Header() *Header

func (*Compatible1) Indexes

func (q *Compatible1) Indexes() [][]string

func (*Compatible1) Keys

func (q *Compatible1) Keys() [][]string

func (*Compatible1) Metrics

func (q *Compatible1) Metrics() *metrics

func (*Compatible1) Nrows

func (q *Compatible1) Nrows() (int, int)

func (*Compatible1) Order

func (*Compatible1) Order() []string

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 Cost

type Cost = int

func Optimize

func Optimize(q Query, mode Mode, req Require) (fixcost, varcost Cost)

func WhereCost

func WhereCost(cost, inFrac, irFrac, ifFrac float64, df bool) Cost

type Extend

type Extend struct {
	Query1
	// contains filtered or unexported fields
}

func NewExtend

func NewExtend(src Query, cols []string, exprs []ast.Expr) *Extend

func (*Extend) Columns

func (q *Extend) Columns() []string

func (*Extend) Fixed

func (e *Extend) Fixed() Fixed

func (*Extend) Get

func (e *Extend) Get(th *Thread, dir Dir) Row

func (*Extend) Header

func (q *Extend) Header() *Header

func (*Extend) Indexes

func (q *Extend) Indexes() [][]string

func (*Extend) Keys

func (q *Extend) Keys() [][]string

func (*Extend) Lookup

func (e *Extend) Lookup(th *Thread, sels Sels) Row

func (*Extend) Metrics

func (q *Extend) Metrics() *metrics

func (*Extend) Nrows

func (q *Extend) Nrows() (int, int)

func (*Extend) Order

func (*Extend) Order() []string

func (*Extend) Select

func (e *Extend) Select(sels Sels)

func (*Extend) SetTran

func (e *Extend) SetTran(t QueryTran)

func (*Extend) Simple

func (e *Extend) Simple(th *Thread) []Row

func (*Extend) SingleTable

func (q *Extend) SingleTable() bool

func (*Extend) String

func (e *Extend) String() string

func (*Extend) Transform

func (e *Extend) Transform() Query

func (*Extend) ValueGet

func (e *Extend) ValueGet(key Value) Value

type Fix

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

func NewFix

func NewFix(col string, val Value) Fix

NewFix returns a new Fix with the given value (packed)

func (Fix) Single

func (f Fix) Single() bool

Single returns true if there is a single value

func (Fix) String

func (f Fix) String() string

func (Fix) With

func (f Fix) With(val string) Fix

With returns a new Fix with the given value appended

type Fixed

type Fixed []Fix

func (Fixed) All

func (fixed Fixed) All(cols []string) bool

All returns true if all cols are single fixed

func (Fixed) Combine

func (fixed Fixed) Combine(fixed2 Fixed) (result Fixed, none bool)

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) Conflicts

func (fixed Fixed) Conflicts(sels Sels) bool

Conflicts returns true if sels conflict with fixed

func (Fixed) Equal

func (fixed Fixed) Equal(fixed2 Fixed) bool

Equal returns true if fixed and fixed2 are equal

func (Fixed) Get

func (fixed Fixed) Get(col string) []string

Get returns the values for a column, or nil if not found

func (Fixed) Has

func (fixed Fixed) Has(col string) bool

Has returns true if col is fixed, possibly with multiple values

func (Fixed) Match

func (fixed Fixed) Match(sels Sels) (satisfied, conflict bool)

Match returns satisfied=true if sels are satisfied by fixed and conflict=true if sels conflict with fixed

func (Fixed) RemoveFrom

func (fixed Fixed) RemoveFrom(cols []string) []string

RemoveFrom returns cols without the single fixed columns

func (Fixed) RemoveFromAll

func (fixed Fixed) RemoveFromAll(cols [][]string) [][]string

RemoveFromAll returns cols without the single fixed columns

func (Fixed) Single

func (fixed Fixed) Single(col string) bool

Single returns true if col is fixed with a single value

func (Fixed) String

func (fixed Fixed) String() string

type History

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

func (*History) Clone

func (*History) Clone() *Table

func (*History) Columns

func (*History) Columns() []string

func (*History) Fixed

func (*History) Fixed() Fixed

func (*History) Get

func (his *History) Get(_ *Thread, dir Dir) Row

func (*History) Header

func (*History) Header() *Header

func (*History) Indexes

func (*History) Indexes() [][]string

func (*History) Init

func (*History) Init()

func (*History) Keys

func (*History) Keys() [][]string

func (*History) Lookup

func (his *History) Lookup(th *Thread, sels Sels) Row

func (*History) Metrics

func (st *History) Metrics() *metrics

func (*History) Nrows

func (his *History) Nrows() (int, int)

func (*History) Order

func (*History) Order() []string

func (*History) Output

func (*History) Output(th *Thread, _ Record)

func (*History) Rewind

func (his *History) Rewind()

func (*History) Select

func (*History) Select(Sels)

func (*History) SetIndex

func (*History) SetIndex(index []string, mode Mode)

func (*History) SetTran

func (his *History) SetTran(tran QueryTran)

func (*History) Simple

func (*History) Simple(*Thread) []Row

func (*History) SingleTable

func (*History) SingleTable() bool

func (*History) String

func (*History) String() string

func (*History) Transform

func (his *History) Transform() Query

func (*History) UniqueIndexes

func (*History) UniqueIndexes() [][]string

func (*History) Updateable

func (*History) Updateable() string

func (*History) ValueGet

func (his *History) ValueGet(key Value) Value

type Index

type Index = schema.Index

type Indexes

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

func (*Indexes) Clone

func (*Indexes) Clone() *Table

func (*Indexes) Columns

func (*Indexes) Columns() []string

func (*Indexes) Fixed

func (*Indexes) Fixed() Fixed

func (*Indexes) Get

func (is *Indexes) Get(_ *Thread, dir Dir) Row

func (*Indexes) Header

func (*Indexes) Header() *Header

func (*Indexes) Indexes

func (*Indexes) Indexes() [][]string

func (*Indexes) Init

func (*Indexes) Init()

func (*Indexes) Keys

func (*Indexes) Keys() [][]string

func (*Indexes) Lookup

func (is *Indexes) Lookup(th *Thread, sels Sels) Row

func (*Indexes) Metrics

func (st *Indexes) Metrics() *metrics

func (*Indexes) Name

func (*Indexes) Name() string

func (*Indexes) Nrows

func (is *Indexes) Nrows() (int, int)

func (*Indexes) Order

func (*Indexes) Order() []string

func (*Indexes) Output

func (*Indexes) Output(th *Thread, _ Record)

func (*Indexes) Rewind

func (is *Indexes) Rewind()

func (*Indexes) Select

func (*Indexes) Select(Sels)

func (*Indexes) SetIndex

func (*Indexes) SetIndex(index []string, mode Mode)

func (*Indexes) SetTran

func (is *Indexes) SetTran(tran QueryTran)

func (*Indexes) Simple

func (*Indexes) Simple(*Thread) []Row

func (*Indexes) SingleTable

func (*Indexes) SingleTable() bool

func (*Indexes) String

func (*Indexes) String() string

func (*Indexes) Transform

func (is *Indexes) Transform() Query

func (*Indexes) UniqueIndexes

func (*Indexes) UniqueIndexes() [][]string

func (*Indexes) Updateable

func (*Indexes) Updateable() string

func (*Indexes) ValueGet

func (is *Indexes) ValueGet(key Value) Value

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 NewIntersect(src1, src2 Query, t QueryTran) *Intersect

func (*Intersect) Columns

func (q *Intersect) Columns() []string

func (*Intersect) Fixed

func (q *Intersect) Fixed() Fixed

func (*Intersect) Get

func (it *Intersect) Get(th *Thread, dir Dir) Row

func (*Intersect) Header

func (q *Intersect) Header() *Header

func (*Intersect) Indexes

func (q *Intersect) Indexes() [][]string

func (*Intersect) Keys

func (q *Intersect) Keys() [][]string

func (*Intersect) Lookup

func (it *Intersect) Lookup(th *Thread, sels Sels) Row

func (*Intersect) Metrics

func (q *Intersect) Metrics() *metrics

func (*Intersect) Nrows

func (q *Intersect) Nrows() (int, int)

func (*Intersect) Order

func (*Intersect) Order() []string

func (*Intersect) Simple

func (it *Intersect) Simple(th *Thread) []Row

func (*Intersect) String

func (it *Intersect) String() string

func (*Intersect) Transform

func (it *Intersect) Transform() Query

func (*Intersect) Updateable

func (*Intersect) Updateable() string

Updateable is overridden by Query1

func (*Intersect) ValueGet

func (it *Intersect) ValueGet(key Value) Value

type Join

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

func (*Join) Get

func (jn *Join) Get(th *Thread, dir Dir) Row

func (*Join) Lookup

func (jn *Join) Lookup(th *Thread, sels Sels) Row

func (*Join) Rewind

func (jb *Join) Rewind()

func (*Join) Select

func (jn *Join) Select(sels Sels)

func (*Join) SetTran

func (jb *Join) SetTran(qt QueryTran)

func (*Join) Simple

func (jn *Join) Simple(th *Thread) []Row

func (*Join) String

func (jn *Join) String() string

func (*Join) Transform

func (jn *Join) Transform() Query

func (*Join) ValueGet

func (jn *Join) ValueGet(key Value) Value

func (*Join) With

func (jn *Join) With(src1, src2 Query) *Join

type LeftJoin

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

func NewLeftJoin

func NewLeftJoin(src1, src2 Query, by []string, t QueryTran) *LeftJoin

func (*LeftJoin) Get

func (lj *LeftJoin) Get(th *Thread, dir Dir) (r Row)

func (*LeftJoin) Lookup

func (lj *LeftJoin) Lookup(th *Thread, sels Sels) Row

func (*LeftJoin) Rewind

func (jb *LeftJoin) Rewind()

func (*LeftJoin) Select

func (lj *LeftJoin) Select(sels Sels)

func (*LeftJoin) SetTran

func (jb *LeftJoin) SetTran(qt QueryTran)

func (*LeftJoin) Simple

func (lj *LeftJoin) Simple(th *Thread) []Row

func (*LeftJoin) String

func (lj *LeftJoin) String() string

func (*LeftJoin) Transform

func (lj *LeftJoin) Transform() Query

func (*LeftJoin) ValueGet

func (lj *LeftJoin) ValueGet(key Value) Value

func (*LeftJoin) With

func (lj *LeftJoin) With(src1, src2 Query) *LeftJoin

type Minus

type Minus struct {
	Compatible1
	// contains filtered or unexported fields
}

func NewMinus

func NewMinus(src1, src2 Query, t QueryTran) *Minus

func (*Minus) Columns

func (q *Minus) Columns() []string

func (*Minus) Fixed

func (q *Minus) Fixed() Fixed

func (*Minus) Get

func (m *Minus) Get(th *Thread, dir Dir) Row

func (*Minus) Header

func (q *Minus) Header() *Header

func (*Minus) Indexes

func (q *Minus) Indexes() [][]string

func (*Minus) Keys

func (q *Minus) Keys() [][]string

func (*Minus) Lookup

func (m *Minus) Lookup(th *Thread, sels Sels) Row

func (*Minus) Metrics

func (q *Minus) Metrics() *metrics

func (*Minus) Nrows

func (q *Minus) Nrows() (int, int)

func (*Minus) Order

func (*Minus) Order() []string

func (*Minus) Simple

func (m *Minus) Simple(th *Thread) []Row

func (*Minus) String

func (m *Minus) String() string

func (*Minus) Transform

func (m *Minus) Transform() Query

func (*Minus) Updateable

func (*Minus) Updateable() string

Updateable is overridden by Query1

func (*Minus) ValueGet

func (m *Minus) ValueGet(key Value) Value

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.

const (
	// CursorMode is used for cursor queries that span multiple transactions
	CursorMode Mode = iota + 1
	// ReadMode is used for read-only queries within a single transaction
	ReadMode
	// UpdateMode is used for updates within a single transaction
	UpdateMode
)

func (Mode) String

func (mode Mode) String() string

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 NewNothing(q Query) *Nothing

func (*Nothing) Columns

func (q *Nothing) Columns() []string

func (*Nothing) Fixed

func (q *Nothing) Fixed() Fixed

func (*Nothing) Get

func (*Nothing) Get(*Thread, Dir) Row

func (*Nothing) Header

func (q *Nothing) Header() *Header

func (*Nothing) Indexes

func (*Nothing) Indexes() [][]string

func (*Nothing) Keys

func (*Nothing) Keys() [][]string

func (*Nothing) Lookup

func (*Nothing) Lookup(*Thread, Sels) Row

func (*Nothing) Metrics

func (q *Nothing) Metrics() *metrics

func (*Nothing) Nrows

func (*Nothing) Nrows() (int, int)

func (*Nothing) Order

func (*Nothing) Order() []string

func (*Nothing) Output

func (no *Nothing) Output(th *Thread, rec Record)

func (*Nothing) Rewind

func (*Nothing) Rewind()

func (*Nothing) Select

func (*Nothing) Select(Sels)

func (*Nothing) SetTran

func (no *Nothing) SetTran(tran QueryTran)

func (*Nothing) Simple

func (*Nothing) Simple(*Thread) []Row

func (*Nothing) SingleTable

func (*Nothing) SingleTable() bool

func (*Nothing) String

func (no *Nothing) String() string

func (*Nothing) Transform

func (no *Nothing) Transform() Query

func (*Nothing) Updateable

func (no *Nothing) Updateable() string

func (*Nothing) ValueGet

func (no *Nothing) ValueGet(key Value) Value

type Project

type Project struct {
	Query1
	// contains filtered or unexported fields
}

func NewProject

func NewProject(src Query, cols []string) *Project

func NewRemove

func NewRemove(src Query, cols []string) *Project

func (*Project) Columns

func (q *Project) Columns() []string

func (*Project) Fixed

func (p *Project) Fixed() Fixed

func (*Project) Get

func (p *Project) Get(th *Thread, dir Dir) Row

func (*Project) Header

func (q *Project) Header() *Header

func (*Project) Indexes

func (q *Project) Indexes() [][]string

func (*Project) Keys

func (q *Project) Keys() [][]string

func (*Project) Lookup

func (p *Project) Lookup(th *Thread, sels Sels) Row

func (*Project) Metrics

func (q *Project) Metrics() *metrics

func (*Project) Nrows

func (q *Project) Nrows() (int, int)

func (*Project) Order

func (*Project) Order() []string

func (*Project) Output

func (p *Project) Output(th *Thread, rec Record)

func (*Project) Rewind

func (p *Project) Rewind()

func (*Project) Select

func (p *Project) Select(sels Sels)

func (*Project) SetTran

func (p *Project) SetTran(t QueryTran)

func (*Project) Simple

func (p *Project) Simple(th *Thread) []Row

func (*Project) SingleTable

func (q *Project) SingleTable() bool

func (*Project) String

func (p *Project) String() string

func (*Project) Transform

func (p *Project) Transform() Query

func (*Project) Updateable

func (p *Project) Updateable() string

func (*Project) ValueGet

func (p *Project) ValueGet(key Value) Value

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 JustParse

func JustParse(t QueryTran, query string) Query

func NewJoin

func NewJoin(src1, src2 Query, by []string, t QueryTran) Query

func NewTable

func NewTable(t QueryTran, name string) Query

func ParseQuery

func ParseQuery(src string, t QueryTran, sv *Sviews) Query

func SetApproach

func SetApproach(q Query, req Require, tran QueryTran) Query

SetApproach finalizes the chosen approach. It also adds temp indexes where required.

func SetupKey

func SetupKey(q Query, mode Mode, t QueryTran) Query

SetupKey is like Setup but it ensures a key index It is used by updateAction (action.go)

type Query1

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

func (*Query1) Columns

func (q *Query1) Columns() []string

func (*Query1) Fixed

func (q *Query1) Fixed() Fixed

func (*Query1) Header

func (q *Query1) Header() *Header

func (*Query1) Indexes

func (q *Query1) Indexes() [][]string

func (*Query1) Keys

func (q *Query1) Keys() [][]string

func (*Query1) Metrics

func (q *Query1) Metrics() *metrics

func (*Query1) Nrows

func (q *Query1) Nrows() (int, int)

func (*Query1) Order

func (*Query1) Order() []string

func (*Query1) Output

func (q1 *Query1) Output(th *Thread, rec Record)

func (*Query1) Rewind

func (q1 *Query1) Rewind()

func (*Query1) SetTran

func (q1 *Query1) SetTran(t QueryTran)

func (*Query1) SingleTable

func (q *Query1) SingleTable() bool

func (*Query1) Source

func (q1 *Query1) Source() Query

func (*Query1) Updateable

func (q1 *Query1) Updateable() string

type Query2

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

func (*Query2) Columns

func (q *Query2) Columns() []string

func (*Query2) Fixed

func (q *Query2) Fixed() Fixed

func (*Query2) Header

func (q *Query2) Header() *Header

func (*Query2) Indexes

func (q *Query2) Indexes() [][]string

func (*Query2) Keys

func (q *Query2) Keys() [][]string

func (*Query2) Metrics

func (q *Query2) Metrics() *metrics

func (*Query2) Nrows

func (q *Query2) Nrows() (int, int)

func (*Query2) Order

func (*Query2) Order() []string

func (*Query2) Output

func (*Query2) Output(*Thread, Record)

func (*Query2) SetTran

func (q2 *Query2) SetTran(t QueryTran)

func (*Query2) SingleTable

func (q2 *Query2) SingleTable() bool

func (*Query2) Source

func (q2 *Query2) Source() Query

func (*Query2) Source2

func (q2 *Query2) Source2() Query

func (*Query2) Updateable

func (*Query2) Updateable() string

Updateable is overridden by Query1

type QueryHash

type QueryHash struct {
	Hdr    *Header
	Fields []string
	// contains filtered or unexported fields
}

func NewQueryHasher

func NewQueryHasher(hdr *Header) *QueryHash

func (*QueryHash) CheckDups

func (qh *QueryHash) CheckDups() *QueryHash

func (*QueryHash) Result

func (qh *QueryHash) Result(details bool) Value

func (*QueryHash) Row

func (qh *QueryHash) Row(row Row) uint64

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 NewRename

func NewRename(src Query, from, to []string) *Rename

func (*Rename) Columns

func (q *Rename) Columns() []string

func (*Rename) Fixed

func (r *Rename) Fixed() Fixed

func (*Rename) Get

func (r *Rename) Get(th *Thread, dir Dir) Row

func (*Rename) Header

func (q *Rename) Header() *Header

func (*Rename) Indexes

func (q *Rename) Indexes() [][]string

func (*Rename) Keys

func (q *Rename) Keys() [][]string

func (*Rename) Lookup

func (r *Rename) Lookup(th *Thread, sels Sels) Row

func (*Rename) Metrics

func (q *Rename) Metrics() *metrics

func (*Rename) Nrows

func (q *Rename) Nrows() (int, int)

func (*Rename) Order

func (*Rename) Order() []string

func (*Rename) Select

func (r *Rename) Select(sels Sels)

func (*Rename) Simple

func (r *Rename) Simple(th *Thread) []Row

func (*Rename) SingleTable

func (q *Rename) SingleTable() bool

func (*Rename) String

func (r *Rename) String() string

func (*Rename) Transform

func (r *Rename) Transform() Query

func (*Rename) ValueGet

func (r *Rename) ValueGet(key Value) Value

type Renames

type Renames struct {
	From []string
	To   []string
}

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 GroupReq

func GroupReq(cols []string, frac float32, nseeks int32) Require

GroupReq will return NoneReq if cols is empty

func NoneReq

func NoneReq(frac float32) Require

func OrderReq

func OrderReq(cols []string, frac float32) Require

OrderReq will return NoneReq if cols is empty

func UniqueReq

func UniqueReq(cols []string, nseeks int32) Require

UniqueReq will return NoneReq if cols is empty

func (Require) SatisfiedBy

func (r Require) SatisfiedBy(index []string) bool

SatisfiedBy does not check that ReqUnique cols include a key

func (Require) SatisfiedByWithFixed

func (r Require) SatisfiedByWithFixed(index []string, fixed Fixed) bool

SatisfiedByWithFixed does not check that ReqUnique cols include a key

func (Require) SeekCount

func (r Require) SeekCount(nrows1 int) int32

func (Require) SelectFrac

func (r Require) SelectFrac(nrows int) float32

SelectFrac returns the fraction of rows/groups the parent will access, for scaling a downstream source's iteration varcost or its own child frac.

func (Require) String

func (r Require) String() string

type Schema

type Schema = schema.Schema

type Sel

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

func NewSel

func NewSel(col, val string) Sel

type Sels

type Sels []Sel

func Split

func Split(cloned bool, sels Sels, cols []string) (isels, osels Sels)

Split partitions sels relative to cols, returning sub-slices. It clones sels only if modifications are needed.

func (Sels) All

func (sels Sels) All() iter.Seq2[string, string]

func (Sels) ColsAre

func (sels Sels) ColsAre(cols []string) bool

ColsAre returns true if the columns are the same set (ignoring order). Does NOT handle duplicates.

func (Sels) FindCol

func (sels Sels) FindCol(col string) int

func (Sels) Get

func (sels Sels) Get(col string) (string, bool)

func (Sels) HasCol

func (sels Sels) HasCol(col string) bool

func (Sels) MustGet

func (sels Sels) MustGet(col string) string

func (Sels) String

func (sels Sels) String() string

type SemiJoin

type SemiJoin struct {
	Query2
	// contains filtered or unexported fields
}

func NewSemiJoin

func NewSemiJoin(src1, src2 Query, by []string, t QueryTran) *SemiJoin

func (*SemiJoin) Columns

func (q *SemiJoin) Columns() []string

func (*SemiJoin) Fixed

func (q *SemiJoin) Fixed() Fixed

func (*SemiJoin) Get

func (sj *SemiJoin) Get(th *Thread, dir Dir) Row

func (*SemiJoin) Header

func (q *SemiJoin) Header() *Header

func (*SemiJoin) Indexes

func (q *SemiJoin) Indexes() [][]string

func (*SemiJoin) Keys

func (q *SemiJoin) Keys() [][]string

func (*SemiJoin) Lookup

func (sj *SemiJoin) Lookup(th *Thread, sels Sels) Row

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) Metrics

func (q *SemiJoin) Metrics() *metrics

func (*SemiJoin) Nrows

func (q *SemiJoin) Nrows() (int, int)

func (*SemiJoin) Order

func (*SemiJoin) Order() []string

func (*SemiJoin) Rewind

func (sj *SemiJoin) Rewind()

func (*SemiJoin) Select

func (sj *SemiJoin) Select(sels Sels)

func (*SemiJoin) SetTran

func (sj *SemiJoin) SetTran(t QueryTran)

func (*SemiJoin) Simple

func (sj *SemiJoin) Simple(th *Thread) []Row

func (*SemiJoin) String

func (sj *SemiJoin) String() string

func (*SemiJoin) Transform

func (sj *SemiJoin) Transform() Query

func (*SemiJoin) Updateable

func (*SemiJoin) Updateable() string

Updateable is overridden by Query1

func (*SemiJoin) ValueGet

func (sj *SemiJoin) ValueGet(key Value) Value

func (*SemiJoin) With

func (sj *SemiJoin) With(src1, src2 Query) *SemiJoin

type Sort

type Sort struct {
	Query1
	// contains filtered or unexported fields
}

func NewSort

func NewSort(src Query, reverse bool, order []string) *Sort

func (*Sort) Columns

func (q *Sort) Columns() []string

func (*Sort) Fixed

func (q *Sort) Fixed() Fixed

func (*Sort) Get

func (sort *Sort) Get(th *Thread, dir Dir) Row

func (*Sort) Header

func (q *Sort) Header() *Header

func (*Sort) Indexes

func (*Sort) Indexes() [][]string

func (*Sort) Keys

func (q *Sort) Keys() [][]string

func (*Sort) Lookup

func (*Sort) Lookup(*Thread, Sels) Row

func (*Sort) Metrics

func (q *Sort) Metrics() *metrics

func (*Sort) Nrows

func (q *Sort) Nrows() (int, int)

func (*Sort) Order

func (sort *Sort) Order() []string

func (*Sort) Select

func (sort *Sort) Select(sels Sels)

func (*Sort) Simple

func (sort *Sort) Simple(th *Thread) []Row

func (*Sort) SingleTable

func (q *Sort) SingleTable() bool

func (*Sort) String

func (sort *Sort) String() string

func (*Sort) Transform

func (sort *Sort) Transform() Query

func (*Sort) ValueGet

func (sort *Sort) ValueGet(key Value) Value

type StatsTable

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

func (*StatsTable) Clone

func (*StatsTable) Clone() *Table

func (*StatsTable) Columns

func (*StatsTable) Columns() []string

func (*StatsTable) Fixed

func (*StatsTable) Fixed() Fixed

func (*StatsTable) Get

func (st *StatsTable) Get(_ *Thread, dir Dir) Row

func (*StatsTable) Header

func (*StatsTable) Header() *Header

func (*StatsTable) Indexes

func (*StatsTable) Indexes() [][]string

func (*StatsTable) Init

func (*StatsTable) Init()

func (*StatsTable) Keys

func (*StatsTable) Keys() [][]string

func (*StatsTable) Lookup

func (st *StatsTable) Lookup(th *Thread, sels Sels) Row

func (*StatsTable) Metrics

func (st *StatsTable) Metrics() *metrics

func (*StatsTable) Name

func (*StatsTable) Name() string

func (*StatsTable) Nrows

func (st *StatsTable) Nrows() (int, int)

func (*StatsTable) Order

func (*StatsTable) Order() []string

func (*StatsTable) Output

func (*StatsTable) Output(th *Thread, _ Record)

func (*StatsTable) Rewind

func (st *StatsTable) Rewind()

func (*StatsTable) Select

func (*StatsTable) Select(Sels)

func (*StatsTable) SetIndex

func (*StatsTable) SetIndex(index []string, mode Mode)

func (*StatsTable) SetTran

func (st *StatsTable) SetTran(tran QueryTran)

func (*StatsTable) Simple

func (*StatsTable) Simple(*Thread) []Row

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 NewSummarize(src Query, hint sumHint, by, cols, ops, ons []string) *Summarize

func (*Summarize) Columns

func (q *Summarize) Columns() []string

func (*Summarize) Fixed

func (q *Summarize) Fixed() Fixed

func (*Summarize) Get

func (su *Summarize) Get(th *Thread, dir Dir) Row

func (*Summarize) Header

func (q *Summarize) Header() *Header

func (*Summarize) Indexes

func (q *Summarize) Indexes() [][]string

func (*Summarize) Keys

func (q *Summarize) Keys() [][]string

func (*Summarize) Len

func (su *Summarize) Len() int

Len / Less / Swap implement sort.Interface

func (*Summarize) Less

func (su *Summarize) Less(i, j int) bool

func (*Summarize) Lookup

func (su *Summarize) Lookup(th *Thread, sels Sels) Row

func (*Summarize) Metrics

func (q *Summarize) Metrics() *metrics

func (*Summarize) Nrows

func (q *Summarize) Nrows() (int, int)

func (*Summarize) Order

func (*Summarize) Order() []string

func (*Summarize) Output

func (*Summarize) Output(*Thread, Record)

func (*Summarize) Rewind

func (su *Summarize) Rewind()

func (*Summarize) Select

func (su *Summarize) Select(sels Sels)

func (*Summarize) SetTran

func (su *Summarize) SetTran(t QueryTran)

func (*Summarize) Simple

func (su *Summarize) Simple(th *Thread) []Row

func (*Summarize) SingleTable

func (su *Summarize) SingleTable() bool

func (*Summarize) String

func (su *Summarize) String() string

func (*Summarize) Swap

func (su *Summarize) Swap(i, j int)

func (*Summarize) Transform

func (su *Summarize) Transform() Query

func (*Summarize) Updateable

func (su *Summarize) Updateable() string

func (*Summarize) ValueGet

func (su *Summarize) ValueGet(key Value) Value

type Table

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

func (*Table) Clone

func (tbl *Table) Clone() *Table

func (*Table) Columns

func (q *Table) Columns() []string

func (*Table) Fixed

func (tbl *Table) Fixed() Fixed

func (*Table) Get

func (tbl *Table) Get(_ *Thread, dir Dir) Row

func (*Table) GetFilter

func (tbl *Table) GetFilter(dir Dir, filter func(key string) bool) Row

func (*Table) Header

func (q *Table) Header() *Header

func (*Table) IndexEncodes

func (tbl *Table) IndexEncodes(index []string) bool

IndexEncodes returns whether the index key is encoded (multi-field or non-key, i.e. has BestKey appended or Fields2)

func (*Table) Indexes

func (q *Table) Indexes() [][]string

func (*Table) Keys

func (q *Table) Keys() [][]string

func (*Table) Lookup

func (tbl *Table) Lookup(_ *Thread, sels Sels) Row

func (*Table) LookupRaw

func (tbl *Table) LookupRaw(key string) Row

func (*Table) Metrics

func (q *Table) Metrics() *metrics

func (*Table) Name

func (tbl *Table) Name() string

func (*Table) Nrows

func (tbl *Table) Nrows() (int, int)

func (*Table) Order

func (*Table) Order() []string

func (*Table) Output

func (tbl *Table) Output(th *Thread, rec Record)

func (*Table) RangeFrac

func (tbl *Table) RangeFrac(index []string, sels Sels) float64

func (*Table) Rewind

func (tbl *Table) Rewind()

func (*Table) Select

func (tbl *Table) Select(sels Sels)

func (*Table) SelectRaw

func (tbl *Table) SelectRaw(org, end string)

func (*Table) SelectSkipScan

func (tbl *Table) SelectSkipScan(prefixRng, suffixRng iface.Range, skipStart int)

func (*Table) SetIndex

func (tbl *Table) SetIndex(index []string, mode Mode)

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) SetTran

func (tbl *Table) SetTran(t QueryTran)

func (*Table) Simple

func (tbl *Table) Simple(*Thread) []Row

func (*Table) SingleTable

func (tbl *Table) SingleTable() bool

func (*Table) String

func (tbl *Table) String() string

func (*Table) Transform

func (tbl *Table) Transform() Query

func (*Table) UniqueIndexes

func (tbl *Table) UniqueIndexes() [][]string

UniqueIndexes returns the columns of the unique ('u') indexes

func (*Table) Updateable

func (tbl *Table) Updateable() string

func (*Table) ValueGet

func (tbl *Table) ValueGet(key Value) Value

type Tables

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

func (*Tables) Clone

func (*Tables) Clone() *Table

func (*Tables) Columns

func (*Tables) Columns() []string

func (*Tables) Fixed

func (*Tables) Fixed() Fixed

func (*Tables) Get

func (ts *Tables) Get(_ *Thread, dir Dir) Row

func (*Tables) Header

func (*Tables) Header() *Header

func (*Tables) Indexes

func (*Tables) Indexes() [][]string

func (*Tables) Init

func (*Tables) Init()

func (*Tables) Keys

func (*Tables) Keys() [][]string

func (*Tables) Lookup

func (ts *Tables) Lookup(th *Thread, sels Sels) Row

func (*Tables) Metrics

func (st *Tables) Metrics() *metrics

func (*Tables) Name

func (*Tables) Name() string

func (*Tables) Nrows

func (ts *Tables) Nrows() (int, int)

func (*Tables) Order

func (*Tables) Order() []string

func (*Tables) Output

func (*Tables) Output(th *Thread, _ Record)

func (*Tables) Rewind

func (ts *Tables) Rewind()

func (*Tables) Select

func (*Tables) Select(Sels)

func (*Tables) SetIndex

func (*Tables) SetIndex(index []string, mode Mode)

func (*Tables) SetTran

func (ts *Tables) SetTran(tran QueryTran)

func (*Tables) Simple

func (*Tables) Simple(*Thread) []Row

func (*Tables) SingleTable

func (*Tables) SingleTable() bool

func (*Tables) String

func (*Tables) String() string

func (*Tables) Transform

func (ts *Tables) Transform() Query

func (*Tables) UniqueIndexes

func (*Tables) UniqueIndexes() [][]string

func (*Tables) Updateable

func (*Tables) Updateable() string

func (*Tables) ValueGet

func (ts *Tables) ValueGet(key Value) Value

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 NewTempIndex

func NewTempIndex(src Query, order []string, tran QueryTran) *TempIndex

func (*TempIndex) Columns

func (q *TempIndex) Columns() []string

func (*TempIndex) Fixed

func (q *TempIndex) Fixed() Fixed

func (*TempIndex) Get

func (ti *TempIndex) Get(th *Thread, dir Dir) Row

func (*TempIndex) Header

func (q *TempIndex) Header() *Header

func (*TempIndex) Indexes

func (q *TempIndex) Indexes() [][]string

func (*TempIndex) Keys

func (q *TempIndex) Keys() [][]string

func (*TempIndex) Lookup

func (ti *TempIndex) Lookup(th *Thread, sels Sels) Row

func (*TempIndex) Metrics

func (q *TempIndex) Metrics() *metrics

func (*TempIndex) Nrows

func (q *TempIndex) Nrows() (int, int)

func (*TempIndex) Order

func (*TempIndex) Order() []string

func (*TempIndex) Rewind

func (ti *TempIndex) Rewind()

func (*TempIndex) Select

func (ti *TempIndex) Select(sels Sels)

func (*TempIndex) SetTran

func (ti *TempIndex) SetTran(tran QueryTran)

func (*TempIndex) Simple

func (ti *TempIndex) Simple(th *Thread) []Row

func (*TempIndex) SingleTable

func (q *TempIndex) SingleTable() bool

func (*TempIndex) String

func (ti *TempIndex) String() string

func (*TempIndex) Transform

func (ti *TempIndex) Transform() Query

func (*TempIndex) ValueGet

func (ti *TempIndex) ValueGet(key Value) Value

type Times

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

func NewTimes

func NewTimes(src1, src2 Query) *Times

func (*Times) Get

func (t *Times) Get(th *Thread, dir Dir) Row

func (*Times) Lookup

func (t *Times) Lookup(th *Thread, sels Sels) Row

func (*Times) Rewind

func (t *Times) Rewind()

func (*Times) Select

func (t *Times) Select(sels Sels)

func (*Times) Simple

func (t *Times) Simple(th *Thread) []Row

func (*Times) String

func (t *Times) String() string

func (*Times) Transform

func (t *Times) Transform() Query

func (*Times) ValueGet

func (t *Times) ValueGet(key Value) Value

type Union

type Union struct {
	Compatible
	// contains filtered or unexported fields
}

func NewUnion

func NewUnion(src1, src2 Query) *Union

func (*Union) Columns

func (q *Union) Columns() []string

func (*Union) Fixed

func (u *Union) Fixed() Fixed

func (*Union) Get

func (u *Union) Get(th *Thread, dir Dir) Row

func (*Union) Header

func (q *Union) Header() *Header

func (*Union) Indexes

func (q *Union) Indexes() [][]string

func (*Union) Keys

func (u *Union) Keys() [][]string

func (*Union) Lookup

func (u *Union) Lookup(th *Thread, sels Sels) Row

func (*Union) Metrics

func (q *Union) Metrics() *metrics

func (*Union) Nrows

func (q *Union) Nrows() (int, int)

func (*Union) Order

func (*Union) Order() []string

func (*Union) Rewind

func (u *Union) Rewind()

func (*Union) Select

func (u *Union) Select(sels Sels)

func (*Union) Simple

func (u *Union) Simple(th *Thread) []Row

func (*Union) String

func (u *Union) String() string

func (*Union) Transform

func (u *Union) Transform() Query

func (*Union) Updateable

func (*Union) Updateable() string

Updateable is overridden by Query1

func (*Union) ValueGet

func (u *Union) ValueGet(key Value) Value

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.

func (Use) String

func (use Use) String() string

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 NewView

func NewView(name string, src Query) *View

func (*View) Columns

func (q *View) Columns() []string

func (*View) Fixed

func (q *View) Fixed() Fixed

func (*View) Get

func (v *View) Get(th *Thread, dir Dir) Row

func (*View) Header

func (q *View) Header() *Header

func (*View) Indexes

func (q *View) Indexes() [][]string

func (*View) Keys

func (q *View) Keys() [][]string

func (*View) Lookup

func (v *View) Lookup(*Thread, Sels) Row

func (*View) Metrics

func (q *View) Metrics() *metrics

func (*View) Nrows

func (q *View) Nrows() (int, int)

func (*View) Order

func (*View) Order() []string

func (*View) Select

func (v *View) Select(Sels)

func (*View) Simple

func (*View) Simple(*Thread) []Row

func (*View) SingleTable

func (q *View) SingleTable() bool

func (*View) String

func (v *View) String() string

func (*View) Transform

func (v *View) Transform() Query

func (*View) ValueGet

func (v *View) ValueGet(key Value) Value

type Views

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

func (*Views) Clone

func (*Views) Clone() *Table

func (*Views) Columns

func (*Views) Columns() []string

func (*Views) Fixed

func (*Views) Fixed() Fixed

func (*Views) Get

func (vs *Views) Get(_ *Thread, dir Dir) Row

func (*Views) Header

func (*Views) Header() *Header

func (*Views) Indexes

func (*Views) Indexes() [][]string

func (*Views) Init

func (*Views) Init()

func (*Views) Keys

func (*Views) Keys() [][]string

func (*Views) Len

func (vs *Views) Len() int

func (*Views) Less

func (vs *Views) Less(i, j int) bool

func (*Views) Lookup

func (vs *Views) Lookup(th *Thread, sels Sels) Row

func (*Views) Metrics

func (st *Views) Metrics() *metrics

func (*Views) Name

func (*Views) Name() string

func (*Views) Nrows

func (vs *Views) Nrows() (int, int)

func (*Views) Order

func (*Views) Order() []string

func (*Views) Output

func (*Views) Output(th *Thread, _ Record)

func (*Views) Rewind

func (vs *Views) Rewind()

func (*Views) Select

func (*Views) Select(Sels)

func (*Views) SetIndex

func (*Views) SetIndex(index []string, mode Mode)

func (*Views) SetTran

func (vs *Views) SetTran(tran QueryTran)

func (*Views) Simple

func (*Views) Simple(*Thread) []Row

func (*Views) SingleTable

func (*Views) SingleTable() bool

func (*Views) String

func (*Views) String() string

func (*Views) Swap

func (vs *Views) Swap(i, j int)

func (*Views) Transform

func (vs *Views) Transform() Query

func (*Views) UniqueIndexes

func (*Views) UniqueIndexes() [][]string

func (*Views) Updateable

func (*Views) Updateable() string

func (*Views) ValueGet

func (vs *Views) ValueGet(key Value) Value

type Where

type Where struct {
	Query1
	// contains filtered or unexported fields
}

func NewWhere

func NewWhere(src Query, expr ast.Expr, t QueryTran) *Where

func (*Where) Columns

func (q *Where) Columns() []string

func (*Where) Fixed

func (q *Where) Fixed() Fixed

func (*Where) Get

func (w *Where) Get(th *Thread, dir Dir) Row

func (*Where) Header

func (q *Where) Header() *Header

func (*Where) InCount

func (w *Where) InCount() int

func (*Where) Indexes

func (w *Where) Indexes() [][]string

func (*Where) Keys

func (w *Where) Keys() [][]string

func (*Where) Lookup

func (w *Where) Lookup(th *Thread, sels Sels) Row

func (*Where) Metrics

func (q *Where) Metrics() *metrics

func (*Where) Nrows

func (w *Where) Nrows() (int, int)

func (*Where) Order

func (*Where) Order() []string

func (*Where) Rewind

func (w *Where) Rewind()

func (*Where) Select

func (w *Where) Select(sels Sels)

func (*Where) SetTran

func (w *Where) SetTran(t QueryTran)

func (*Where) Simple

func (w *Where) Simple(th *Thread) []Row

func (*Where) SingleTable

func (q *Where) SingleTable() bool

func (*Where) String

func (w *Where) String() string

func (*Where) Transform

func (w *Where) Transform() Query

func (*Where) ValueGet

func (w *Where) ValueGet(key Value) Value

Jump to

Keyboard shortcuts

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