query

package
v0.0.0-...-2047864 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 33 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

Index

Constants

This section is empty.

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)

func Format

func Format(t QueryTran, query string) string

func LookupCost

func LookupCost(q Query, mode Mode, index []string, nrows int) (
	Cost, Cost)

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 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 Strategy

func Strategy(q Query) string

func String

func String(q Query) string

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) 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 (*Columns) Lookup(*Thread, []string, []string) Row

func (*Columns) Metrics

func (st *Columns) Metrics() *metrics

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([]string, []string)

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

func (*Columns) Updateable() string

func (*Columns) ValueGet

func (q *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) String

func (c *Compatible) String(s string) string

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(cols, vals []string)

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, index []string, frac float64) (
	fixcost, varcost Cost)

Optimize determines the best (lowest estimated cost) query execution approach

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, cols, vals []string) 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(cols, vals []string)

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 (q *Extend) ValueGet(key Value) Value

type Fixed

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

func NewFixed

func NewFixed(col string, val Value) Fixed

func (*Fixed) String

func (f *Fixed) String() string

type History

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

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 (*History) Lookup(*Thread, []string, []string) 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([]string, []string)

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

func (*History) Updateable() string

func (*History) ValueGet

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

type Index

type Index = schema.Index

type Indexes

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

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 (*Indexes) Lookup(*Thread, []string, []string) Row

func (*Indexes) Metrics

func (st *Indexes) Metrics() *metrics

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([]string, []string)

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

func (*Indexes) Updateable() string

func (*Indexes) ValueGet

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

type Intersect

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

func NewIntersect

func NewIntersect(src1, src2 Query) *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, cols, vals []string) 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 (q *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, cols, vals []string) Row

func (*Join) Rewind

func (jb *Join) Rewind()

func (*Join) Select

func (jn *Join) Select(cols, vals []string)

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 (q *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, cols, vals []string) Row

func (*LeftJoin) Rewind

func (jb *LeftJoin) Rewind()

func (*LeftJoin) Select

func (lj *LeftJoin) Select(cols, vals []string)

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 (q *LeftJoin) ValueGet(key Value) Value

func (*LeftJoin) With

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

type Minus

type Minus struct {
	Compatible1
}

func NewMinus

func NewMinus(src1, src2 Query) *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, cols, vals []string) 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 (q *Minus) ValueGet(key Value) Value

type Mode

type Mode int

Mode is the transaction context - cursor, read, or update. It affects the use of temporary indexes.

const (
	CursorMode Mode = iota
	ReadMode
	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, []string, []string) 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([]string, []string)

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 (q *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, cols, vals []string) 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(cols, vals []string)

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 (q *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.

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 (*ProjectNone) Lookup(*Thread, []string, []string) Row

func (*ProjectNone) Metrics

func (*ProjectNone) Metrics() *metrics

func (*ProjectNone) Nrows

func (*ProjectNone) Nrows() (int, int)

func (*ProjectNone) Order

func (*ProjectNone) Order() []string

func (*ProjectNone) Output

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

func (*ProjectNone) Rewind

func (*ProjectNone) Rewind()

func (*ProjectNone) Select

func (*ProjectNone) Select([]string, []string)

func (*ProjectNone) SetTran

func (*ProjectNone) SetTran(QueryTran)

func (*ProjectNone) Simple

func (*ProjectNone) Simple(*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 (q *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 i.e. fast access paths.
	// Where returns []string{} not nil for singleton. (slc.Empty)
	Indexes() [][]string

	// Keys returns sets of fields that are unique keys.
	// On a table this will be the key indexes, but on other operations
	// this is logical, there may not necessarily be an 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(th *Thread, dir Dir) Row

	// Lookup returns the row matching the given key value, or nil if not found.
	// It is used by Where and Compatible (Intersect, Minus, Union)
	// It is valid (although not necessarily the most efficient)
	// to implement Lookup with Select and Get
	// in which case it should leave the select cleared.
	// Lookup should rewind.
	Lookup(th *Thread, cols, vals []string) Row

	// Select restricts the query to records matching the given packed values.
	// It is used by Where, Join, and LeftJoin.
	// To clear the select, use Select(nil, nil)
	// Select should rewind.
	Select(cols, vals []string)

	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.
	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
}

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, index []string, frac float64, 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

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

func (*Query1) Lookup(*Thread, []string, []string) Row

Lookup default applies to Summarize and Sort

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 QueryTran

type QueryTran interface {
	GetSchema(table string) *schema.Schema
	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)
}

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, cols, vals []string) 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(cols, vals []string)

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 (q *Rename) ValueGet(key Value) Value

type Renames

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

type Schema

type Schema = schema.Schema

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) 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(cols, vals []string)

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 (q *Sort) 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, cols, vals []string) 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(cols, vals []string)

func (*Summarize) SetTran

func (su *Summarize) SetTran(t QueryTran)

func (*Summarize) Simple

func (*Summarize) Simple(*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 (q *Summarize) ValueGet(key Value) Value

type Table

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

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

func (q *Table) Header() *Header

func (*Table) Indexes

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

func (*Table) Keys

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

func (*Table) Lookup

func (tbl *Table) Lookup(_ *Thread, cols, vals []string) Row

func (*Table) Metrics

func (q *Table) Metrics() *metrics

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

func (tbl *Table) Rewind()

func (*Table) Select

func (tbl *Table) Select(cols, vals []string)

func (*Table) SelectRaw

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

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

func (tbl *Table) Updateable() string

func (*Table) ValueGet

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

type Tables

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

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 (*Tables) Lookup(*Thread, []string, []string) Row

func (*Tables) Metrics

func (st *Tables) Metrics() *metrics

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([]string, []string)

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

func (*Tables) Updateable() string

func (*Tables) ValueGet

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

type TablesLookup

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

TablesLookup is used to optimize lookups on tables. It is inserted by Where Transform.

func NewTablesLookup

func NewTablesLookup(tran QueryTran, table string) *TablesLookup

func (*TablesLookup) Fixed

func (*TablesLookup) Fixed() []Fixed

func (*TablesLookup) Get

func (tl *TablesLookup) Get(*Thread, Dir) Row

func (*TablesLookup) Indexes

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

func (*TablesLookup) Init

func (*TablesLookup) Init()

func (*TablesLookup) Lookup

func (*TablesLookup) Lookup(*Thread, []string, []string) Row

func (*TablesLookup) Metrics

func (st *TablesLookup) Metrics() *metrics

func (*TablesLookup) Nrows

func (*TablesLookup) Nrows() (int, int)

func (*TablesLookup) Order

func (*TablesLookup) Order() []string

func (*TablesLookup) Output

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

func (*TablesLookup) Select

func (*TablesLookup) Select([]string, []string)

func (*TablesLookup) Simple

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

func (*TablesLookup) SingleTable

func (*TablesLookup) SingleTable() bool

func (*TablesLookup) String

func (tl *TablesLookup) String() string

func (*TablesLookup) Transform

func (tl *TablesLookup) Transform() Query

func (*TablesLookup) Updateable

func (*TablesLookup) Updateable() string

func (*TablesLookup) ValueGet

func (q *TablesLookup) 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 (*TempIndex) Indexes() [][]string

func (*TempIndex) Keys

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

func (*TempIndex) Lookup

func (ti *TempIndex) Lookup(th *Thread, cols, vals []string) 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(cols, vals []string)

func (*TempIndex) Simple

func (*TempIndex) Simple(*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 (q *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, cols, vals []string) Row

func (*Times) Rewind

func (t *Times) Rewind()

func (*Times) Select

func (t *Times) Select(cols, vals []string)

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 (q *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, cols, vals []string) 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(cols, vals []string)

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 (q *Union) ValueGet(key Value) Value

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(th *Thread, cols []string, vals []string) 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(cols []string, vals []string)

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 (q *View) ValueGet(key Value) Value

type Views

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

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 (*Views) Lookup(*Thread, []string, []string) Row

func (*Views) Metrics

func (st *Views) Metrics() *metrics

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([]string, []string)

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

func (*Views) Updateable() string

func (*Views) ValueGet

func (q *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) Indexes

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

func (*Where) Keys

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

func (*Where) Lookup

func (w *Where) Lookup(th *Thread, cols, vals []string) 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(cols, vals []string)

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 (q *Where) ValueGet(key Value) Value

Jump to

Keyboard shortcuts

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