csr

package
v0.0.0-...-91c5940 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2017 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cursor_natural_order

func Cursor_natural_order(curs_from *Cursor_from) []rsql.IDataslot

Cursor_natural_order returns the natural order dataslots of the leftmost table if the FROM clause.

Only the leftmost table is significant, because other joined table are most often accessed by index, and cannot be taken into account for natural order.

func Grouptable_lookup_equality_or_insert

func Grouptable_lookup_equality_or_insert(wcache *cache.Wcache, gtabledef *rsql.GTabledef, base_insertion_row rsql.Row, base_row rsql.Row, selpad *btree.Selpad, inspad *btree.Inspad) (page_no cache.Page_no_t, tuple_index int, rsql_err *rsql.Error)

Grouptable_lookup_equality_or_insert looks up the row which native key is same as base_insertion_row native key. If not found, base_insertion_row is inserted. Tuple is loaded into base_row.

func Set_row_to_NULL

func Set_row_to_NULL(row []rsql.IDataslot)

Set_row_to_NULL is used by Reset(), to NULLify the record dataslots.

func Upsert_grouptable

func Upsert_grouptable(context *rsql.Context, table_qname rsql.Object_qname_t, gtabledef *rsql.GTabledef, feeding_cursor *Cursor_from, nk_basicblock *rsql.Basicblock, injection_basicblock *rsql.Basicblock, insertion_row rsql.Row, upsert_row rsql.Row, explicit_GROUP_BY_exists bool) *rsql.Error

Types

type Cond

type Cond struct {
	Cond_seqno int

	Cond_dataslot *data.BOOLEAN
}

type Cursor

type Cursor interface {
	Reset()
	Next(*rsql.Context) (State_t, *rsql.Error)
	State() State_t
}

type Cursor_from

type Cursor_from struct {
	Root_curs        Cursor
	Where_basicblock *rsql.Basicblock
	Where_result     *data.BOOLEAN
	// contains filtered or unexported fields
}

func New_cursor_from

func New_cursor_from(root_curs Cursor) *Cursor_from

func (*Cursor_from) Next

func (cursfrom *Cursor_from) Next(context *rsql.Context) (State_t, *rsql.Error)

func (*Cursor_from) Reset

func (cursfrom *Cursor_from) Reset()

func (*Cursor_from) State

func (cursfrom *Cursor_from) State() State_t

type Cursor_join

type Cursor_join struct {
	Jtype Join_type_t

	Left  Cursor
	Right Cursor

	On_basicblock *rsql.Basicblock
	On_result     *data.BOOLEAN
	// contains filtered or unexported fields
}

func New_cursor_join

func New_cursor_join(join_type Join_type_t, curs_left Cursor, curs_right Cursor) *Cursor_join

func (*Cursor_join) Next

func (cursjoin *Cursor_join) Next(context *rsql.Context) (State_t, *rsql.Error)

func (*Cursor_join) Reset

func (cursjoin *Cursor_join) Reset()

func (*Cursor_join) State

func (cursjoin *Cursor_join) State() State_t

type Cursor_select

type Cursor_select struct {
	Cols_facade []rsql.IDataslot // for external use. Exact copies of Cols_dataslots, but with type KIND_COL_LEAF. Each iteration just copy values from Cols_dataslots into Cols_facade.

	Cols_dataslots  []rsql.IDataslot // all SELECT columns. Dataslots can be KIND_RO_LEAF, KIND_VAR_LEAF, KIND_COL_LEAF or KIND_TMP. They are copied to Cols_facade.
	Cols_basicblock *rsql.Basicblock

	From *Cursor_from

	Grouping_flag                   bool             // true if grouping SELECT
	Grouping_explicit_GROUP_BY      bool             // SELECT has an explicit GROUP BY clause
	Grouptable_gtabledef            *rsql.GTabledef  // GTabledef of grouptable
	Grouptable_feeding_cursor       *Cursor_from     // Cursor_from from the original SELECT, which feeds grouptable
	Grouptable_nk_basicblock        *rsql.Basicblock // computes the nk fields (fields of the GROUP BY clause) of Grouptable_insertion_row
	Grouptable_insertion_row        rsql.Row         // row to insert in grouptable if not exists. Used for row lookup.
	Grouptable_upsert_row           rsql.Row         // upsert row
	Grouptable_injection_basicblock *rsql.Basicblock // injects values into aggregate fields of Grouptable_upsert_row
	Grouptable_is_created           bool             // during execution, if false, grouptable has not been created
	// contains filtered or unexported fields
}

Cursor for SELECT

Cols_facade contains all the columns as KIND_COL_LEAF, and are copies of Cols_dataslots. When Cursor_select is Reset(), these copies can be safely set to NULL, without fear of overwriting a @variable or constant (KIND_VAR_LEAF or KIND_RO_LEAF).

func New_cursor_select

func New_cursor_select(curs_from *Cursor_from, dataslot_list []rsql.IDataslot) *Cursor_select

func (*Cursor_select) Next

func (cursselect *Cursor_select) Next(context *rsql.Context) (State_t, *rsql.Error)

func (*Cursor_select) Reset

func (cursselect *Cursor_select) Reset()

func (*Cursor_select) State

func (cursselect *Cursor_select) State() State_t

type Cursor_single

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

func New_cursor_single

func New_cursor_single() *Cursor_single

func (*Cursor_single) Next

func (curssingle *Cursor_single) Next(context *rsql.Context) (State_t, *rsql.Error)

func (*Cursor_single) Reset

func (curssingle *Cursor_single) Reset()

func (*Cursor_single) State

func (curssingle *Cursor_single) State() State_t

type Cursor_table

type Cursor_table struct {
	Base_fields   []rsql.IDataslot // all fields of the table. Unused fields are nil.
	Gtabledef     *rsql.GTabledef
	Base_tabledef *rsql.Tabledef

	Lookup_type Sc_lookup_type_t

	Index_to_use                 *rsql.Tabledef     // the index to use to access the table
	Index_leaf_record            []rsql.IDataslot   // the leaf record of Index_to_use
	Index_is_covering            bool               // if false, the index must also access the base table to get missing column values
	Index_lookup                 []rsql.IDataslot   // same structure as Index_to_use leaf record, but only nk fields are filled with Sargs dataslots. The first Next call must walk the index btree native key to this position.
	Index_nk_sargs_expression_bb *rsql.Basicblock   // the first Next call must evaluate all computed expressions (right side of sarg: nk field <op> expression) for the Sargs in native key. May be nil, if expressions are all constants, variables, or columns; that is, if there is no operator nor function.
	Index_nk_sargs_expressions   []rsql.IDataslot   // Index_nk_sargs_expression_bb will put the computed expressions results in these dataslots
	Index_nk_sargs_bb            []*rsql.Basicblock // only bb for leading nk fields with Sargs. At each Next call, evaluate the comparison for each nk columns
	Index_nk_sargs_result        []*data.BOOLEAN    // result for above evaluation are stored here for each nk column

	Index_nk_fully_sarged bool // only for SC_LOOKUP_EQUALITY. Sargs are specified for all index nk fields. It means that at most one record can be returned.

	Index_nk_high_limit_bb           *rsql.Basicblock // only for SC_LOOKUP_RANGE.
	Index_nk_high_limit_col_dataslot rsql.IDataslot   // only for SC_LOOKUP_RANGE. This value is used only to check if it contains NULL.
	Index_nk_high_limit_result       *data.BOOLEAN    // only for SC_LOOKUP_RANGE. This value is checked only if Index_nk_high_limit_col_dataslot is not NULL.

	Index_other_conditions_bb     []*rsql.Basicblock // also used for SC_LOOKUP_BASE_TABLE_SCAN
	Index_other_conditions_result []*data.BOOLEAN    // also used for SC_LOOKUP_BASE_TABLE_SCAN

	Index_selpad      *btree.Selpad
	Base_table_selpad *btree.Selpad
	// contains filtered or unexported fields
}

func New_cursor_table

func New_cursor_table(gtabledef *rsql.GTabledef) *Cursor_table

func New_cursor_table_with_row

func New_cursor_table_with_row(gtabledef *rsql.GTabledef, table_row rsql.Row) *Cursor_table

New_cursor_table_with_row is used to create cursor for flah tables (grouptables and sorttables).

func (*Cursor_table) Next

func (curstable *Cursor_table) Next(context *rsql.Context) (State_t, *rsql.Error)

func (*Cursor_table) Next_for_base_table_scan

func (curstable *Cursor_table) Next_for_base_table_scan(context *rsql.Context) (State_t, *rsql.Error)

func (*Cursor_table) Next_for_lookup_equality

func (curstable *Cursor_table) Next_for_lookup_equality(context *rsql.Context) (State_t, *rsql.Error)

func (*Cursor_table) Next_for_lookup_range

func (curstable *Cursor_table) Next_for_lookup_range(context *rsql.Context) (State_t, *rsql.Error)

func (*Cursor_table) Reset

func (curstable *Cursor_table) Reset()

func (*Cursor_table) State

func (curstable *Cursor_table) State() State_t

type Cursor_union

type Cursor_union struct {
	Equalized_dataslots  []rsql.IDataslot   // equalized row for each cursor. Always KIND_COL_LEAF. Columns of SELECT or UNION members are copied here at each Next() iteration.
	Equalize_basicblocks []*rsql.Basicblock // CAST or copy instructions

	List_cursors   []Cursor // SELECT and UNION cursors
	Current_member int
	// contains filtered or unexported fields
}

func New_cursor_union

func New_cursor_union(curs_list []Cursor, equalized_dataslot_list []rsql.IDataslot) *Cursor_union

func (*Cursor_union) Next

func (cursunion *Cursor_union) Next(context *rsql.Context) (State_t, *rsql.Error)

func (*Cursor_union) Reset

func (cursunion *Cursor_union) Reset()

func (*Cursor_union) State

func (cursunion *Cursor_union) State() State_t

type Join_type_t

type Join_type_t uint8
const (
	JT_INNER_JOIN Join_type_t = iota + 1
	JT_LEFT_JOIN
)

func (Join_type_t) String

func (jtype Join_type_t) String() string

type Natural_order

type Natural_order []rsql.IDataslot // for the leftmost table, list of natural order dataslots

type Sarg

type Sarg struct {
	Table_qname        rsql.Object_qname_t
	Table_cursor       *Cursor_table
	Col_no             uint16
	Comp               Sarg_comp_t
	Comp_args_reversed bool // if true, column is on the right side of the comparison operator
	Comp_dataslot      *data.BOOLEAN
}

func (*Sarg) String

func (s *Sarg) String() string

type Sarg_comp_t

type Sarg_comp_t uint8
const (
	SARG_GREATER Sarg_comp_t = iota + 1
	SARG_GREATER_EQUAL
	SARG_EQUAL
	SARG_LESS_EQUAL
	SARG_LESS
)

func (Sarg_comp_t) String

func (s Sarg_comp_t) String() string

type Sc_lookup_type_t

type Sc_lookup_type_t uint8
const (
	SC_LOOKUP_EQUALITY        Sc_lookup_type_t = iota + 1 // score can be used for index lookup
	SC_LOOKUP_RANGE                                       // score can be used for index lookup
	SC_LOOKUP_BASE_TABLE_SCAN                             // score CANNOT BE USED for index lookup, but these Condinfos can be checked during base table scan
)

the value of these constants are used for sort purpose. Don't change their order !

func (Sc_lookup_type_t) String

func (st Sc_lookup_type_t) String() string

type State_t

type State_t uint8
const (
	CURS_RECORD_RESET State_t = iota + 1
	CURS_RECORD_AVAILABLE
)

func (State_t) String

func (state State_t) String() string

Jump to

Keyboard shortcuts

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