executors

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DistSerial int32 = 0
View Source
const DistUniform int32 = 1
View Source
const TEST1_SIZE uint32 = 1000
View Source
const TEST2_SIZE uint32 = 100
View Source
const TEST_VARLEN_SIZE uint32 = 10

Variables

This section is empty.

Functions

func ExecuteDeleteTestCase

func ExecuteDeleteTestCase(t *testing.T, testCase DeleteTestCase)

func ExecuteIndexPointScanTestCase added in v0.0.2

func ExecuteIndexPointScanTestCase(t *testing.T, testCase IndexPointScanTestCase, indexType index_constants.IndexKind)

func ExecuteIndexRangeScanTestCase added in v0.0.2

func ExecuteIndexRangeScanTestCase(t *testing.T, testCase IndexRangeScanTestCase, indexType index_constants.IndexKind)

func ExecuteSeqScanTestCase

func ExecuteSeqScanTestCase(t *testing.T, testCase SeqScanTestCase)

func FillTable

func FillTable(info *catalog.TableMetadata, table_meta *TableInsertMeta, txn *access.Transaction)

func GenNumericValues

func GenNumericValues(col_meta *ColumnInsertMeta, count uint32) []types.Value

func GenNumericValuesFloat

func GenNumericValuesFloat(col_meta *ColumnInsertMeta, count uint32) []types.Value

func GetValue

func GetValue(data interface{}) (value types.Value)

func GetValueType

func GetValueType(data interface{}) (value types.TypeID)

func HashValuesOnAggregateKey

func HashValuesOnAggregateKey(key *plans.AggregateKey) uint32

geneate a hash value from types.Value objs plans.AggregateKey has

func MakeAggregateValueExpression

func MakeAggregateValueExpression(is_group_by_term bool, col_index uint32) expression.Expression

func MakeColumnValueExpression

func MakeColumnValueExpression(schema_ *schema.Schema, tuple_idx_on_join uint32,
	col_name string) expression.Expression

func MakeConstantValueExpression

func MakeConstantValueExpression(val *types.Value) expression.Expression

func MakeOutputSchema

func MakeOutputSchema(exprs []MakeSchemaMeta) *schema.Schema

func MakeOutputSchemaAgg

func MakeOutputSchemaAgg(exprs []MakeSchemaMetaAgg) *schema.Schema

func MakeValues

func MakeValues(col_meta *ColumnInsertMeta, count uint32) []types.Value

Types

type AggregateHTIterator

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

*

  • An iterator through the simplified aggregation hash table.

func NewAggregateHTIteratorIterator

func NewAggregateHTIteratorIterator(keys []*plans.AggregateKey, values []*plans.AggregateValue) *AggregateHTIterator

* Creates an iterator for the aggregate map.

func (*AggregateHTIterator) IsEnd

func (it *AggregateHTIterator) IsEnd() bool

func (*AggregateHTIterator) IsNextEnd

func (it *AggregateHTIterator) IsNextEnd() bool

return whether iterator is End state if Next method is called

func (*AggregateHTIterator) Key

func (*AggregateHTIterator) Next

func (it *AggregateHTIterator) Next() bool

func (*AggregateHTIterator) Val

type AggregationExecutor

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

* * AggregationExecutor executes an aggregation operation (e.g. COUNT, SUM, MIN, MAX) on the tuples of a child executor.

func NewAggregationExecutor

func NewAggregationExecutor(exec_ctx *ExecutorContext, plan *plans.AggregationPlanNode,
	child Executor) *AggregationExecutor

*

  • Creates a new aggregation executor.
  • @param exec_ctx the context that the aggregation should be performed in
  • @param plan the aggregation plan node
  • @param child the child executor

func (*AggregationExecutor) GetOutputSchema

func (e *AggregationExecutor) GetOutputSchema() *schema.Schema

func (*AggregationExecutor) GetTableMetaData added in v0.0.2

func (e *AggregationExecutor) GetTableMetaData() *catalog.TableMetadata

func (*AggregationExecutor) Init

func (e *AggregationExecutor) Init()

func (*AggregationExecutor) MakeKey

func (e *AggregationExecutor) MakeKey(tuple_ *tuple.Tuple) *plans.AggregateKey

* @return the tuple as an AggregateKey

func (*AggregationExecutor) MakeVal

func (e *AggregationExecutor) MakeVal(tuple_ *tuple.Tuple) *plans.AggregateValue

* @return the tuple as an AggregateValue

func (*AggregationExecutor) Next

func (e *AggregationExecutor) Next() (*tuple.Tuple, Done, error)

type Assertion

type Assertion struct {
	Column string
	Exp    interface{}
}

type Column

type Column struct {
	Name string
	Kind types.TypeID
}

type ColumnIdx

type ColumnIdx struct {
	Name     string
	Kind     types.TypeID
	HasIndex bool
}

type ColumnInsertMeta

type ColumnInsertMeta struct {
	/**
	 * Name of the column
	 */
	Name_ string
	/**
	 * Type of the column
	 */
	Type_ types.TypeID
	/**
	 * Whether the column is nullable
	 */
	Nullable_ bool
	/**
	 * Distribution of values
	 */
	Dist_ int32
	/**
	 * Min value of the column
	 */
	Min_ int32
	/**
	 * Max value of the column
	 */
	Max_ int32
	/**
	 * Counter to generate serial data
	 */
	Serial_counter_ int32
}

type DeleteExecutor

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

*

  • DeleteExecutor executes a sequential scan over a table and delete tuples according to predicate.

func (*DeleteExecutor) GetOutputSchema

func (e *DeleteExecutor) GetOutputSchema() *schema.Schema

func (*DeleteExecutor) GetTableMetaData added in v0.0.2

func (e *DeleteExecutor) GetTableMetaData() *catalog.TableMetadata

func (*DeleteExecutor) Init

func (e *DeleteExecutor) Init()

func (*DeleteExecutor) Next

func (e *DeleteExecutor) Next() (*tuple.Tuple, Done, error)

Next implements the next method for the sequential scan operator It uses the table heap iterator to iterate through the table heap tyring to find a tuple to be deleted. It performs selection on-the-fly if find tuple to be delete, mark it to be deleted at commit and return value

type DeleteTestCase

type DeleteTestCase struct {
	Description        string
	TransactionManager *access.TransactionManager
	ExecutionEngine    *ExecutionEngine
	ExecutorContext    *ExecutorContext
	TableMetadata      *catalog.TableMetadata
	Columns            []Column
	Predicate          Predicate
	Asserts            []Assertion
	TotalHits          uint32
}

type Done

type Done bool

type ExecutionEngine

type ExecutionEngine struct {
}

ExecutionEngine is the query execution engine.

It is an implementation of the GetRangeScanIterator Model (also called Pipeline model or Volcano) It receives a Plan, create a Executor for that plan and execute it All executors follow the same pattern implementing the Executor interface Executors are the operators in relation algebra

func (*ExecutionEngine) CreateExecutor

func (e *ExecutionEngine) CreateExecutor(plan plans.Plan, context *ExecutorContext) Executor

func (*ExecutionEngine) Execute

func (e *ExecutionEngine) Execute(plan plans.Plan, context *ExecutorContext) []*tuple.Tuple

type Executor

type Executor interface {
	Init()
	Next() (*tuple.Tuple, Done, error)
	GetOutputSchema() *schema.Schema
	GetTableMetaData() *catalog.TableMetadata
}

Executor represents a relational algebra operator in the ite

Init initializes this executor. This function must be called before Next() is called!

Next produces the next tuple

func NewDeleteExecutor

func NewDeleteExecutor(context *ExecutorContext, plan *plans.DeletePlanNode, child Executor) Executor

func NewFilterExecutor

func NewFilterExecutor(context *ExecutorContext, plan *plans.FilterPlanNode, child Executor) Executor

func NewInsertExecutor

func NewInsertExecutor(context *ExecutorContext, plan *plans.InsertPlanNode) Executor

func NewLimitExecutor

func NewLimitExecutor(context *ExecutorContext, plan *plans.LimitPlanNode, child Executor) Executor

func NewPointScanWithIndexExecutor added in v0.0.2

func NewPointScanWithIndexExecutor(context *ExecutorContext, plan *plans.PointScanWithIndexPlanNode) Executor

func NewRangeScanWithIndexExecutor added in v0.0.2

func NewRangeScanWithIndexExecutor(context *ExecutorContext, plan *plans.RangeScanWithIndexPlanNode) Executor

func NewSeqScanExecutor

func NewSeqScanExecutor(context *ExecutorContext, plan *plans.SeqScanPlanNode) Executor

NewSeqScanExecutor creates a new sequential executor

func NewUpdateExecutor

func NewUpdateExecutor(context *ExecutorContext, plan *plans.UpdatePlanNode, child Executor) Executor

type ExecutorContext

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

*

  • ExecutorContext stores all the context necessary to run an executor.

func NewExecutorContext

func NewExecutorContext(catalog *catalog.Catalog, bpm *buffer.BufferPoolManager, txn *access.Transaction) *ExecutorContext

func (*ExecutorContext) GetBufferPoolManager

func (e *ExecutorContext) GetBufferPoolManager() *buffer.BufferPoolManager

func (*ExecutorContext) GetCatalog

func (e *ExecutorContext) GetCatalog() *catalog.Catalog

func (*ExecutorContext) GetTransaction

func (e *ExecutorContext) GetTransaction() *access.Transaction

func (*ExecutorContext) SetTransaction

func (e *ExecutorContext) SetTransaction(txn *access.Transaction)

type FilterExecutor

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

func (*FilterExecutor) GetOutputSchema

func (e *FilterExecutor) GetOutputSchema() *schema.Schema

func (*FilterExecutor) GetTableMetaData added in v0.0.2

func (e *FilterExecutor) GetTableMetaData() *catalog.TableMetadata

func (*FilterExecutor) Init

func (e *FilterExecutor) Init()

func (*FilterExecutor) Next

func (e *FilterExecutor) Next() (*tuple.Tuple, Done, error)

type HashJoinExecutor

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

* * HashJoinExecutor executes hash join operations (inner join).

func NewHashJoinExecutor

func NewHashJoinExecutor(exec_ctx *ExecutorContext, plan *plans.HashJoinPlanNode, left Executor,
	right Executor) *HashJoinExecutor

* * Creates a new hash join executor. * @param exec_ctx the context that the hash join should be performed in * @param plan the hash join plan node * @param left the left child, used by convention to build the hash table * @param right the right child, used by convention to probe the hash table

func (*HashJoinExecutor) FetchTupleFromTmpTuplePage

func (e *HashJoinExecutor) FetchTupleFromTmpTuplePage(tuple_ *tuple.Tuple, tmp_tuple *hash.TmpTuple)

func (*HashJoinExecutor) GetJHT

* @return the JHT in use. Do not modify this function, otherwise you will get a zero.

func (*HashJoinExecutor) GetOutputSchema

func (e *HashJoinExecutor) GetOutputSchema() *schema.Schema

func (*HashJoinExecutor) GetTableMetaData added in v0.0.2

func (e *HashJoinExecutor) GetTableMetaData() *catalog.TableMetadata

can not be used

func (*HashJoinExecutor) Init

func (e *HashJoinExecutor) Init()

func (*HashJoinExecutor) IsValidCombination

func (e *HashJoinExecutor) IsValidCombination(left_tuple *tuple.Tuple, right_tuple *tuple.Tuple) bool

func (*HashJoinExecutor) MakeOutputTuple

func (e *HashJoinExecutor) MakeOutputTuple(left_tuple *tuple.Tuple, right_tuple *tuple.Tuple) *tuple.Tuple

func (*HashJoinExecutor) Next

func (e *HashJoinExecutor) Next() (*tuple.Tuple, Done, error)

TODO: (SDB) need to refactor HashJoinExecutor::Next method to use GetExpr method of Column class

current impl is avoiding the method because it does not exist when this code was wrote

type IndexPointScanTestCase added in v0.0.2

type IndexPointScanTestCase struct {
	Description     string
	ExecutionEngine *ExecutionEngine
	ExecutorContext *ExecutorContext
	TableMetadata   *catalog.TableMetadata
	Columns         []Column
	Predicate       Predicate
	Asserts         []Assertion
	TotalHits       uint32
}

type IndexRangeScanTestCase added in v0.0.2

type IndexRangeScanTestCase struct {
	Description     string
	ExecutionEngine *ExecutionEngine
	ExecutorContext *ExecutorContext
	TableMetadata   *catalog.TableMetadata
	Columns         []Column
	Predicate       Predicate
	ColIdx          int32 // column idx of column which has index to be used on scan
	ScanRange       []*types.Value
	TotalHits       uint32
}

type InsertExecutor

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

*

  • InsertExecutor executes an insert into a table.
  • Inserted values can either be embedded in the plan itself ("raw insert") or come from a child executor.

func (*InsertExecutor) GetOutputSchema

func (e *InsertExecutor) GetOutputSchema() *schema.Schema

func (*InsertExecutor) GetTableMetaData added in v0.0.2

func (e *InsertExecutor) GetTableMetaData() *catalog.TableMetadata

func (*InsertExecutor) Init

func (e *InsertExecutor) Init()

func (*InsertExecutor) Next

func (e *InsertExecutor) Next() (*tuple.Tuple, Done, error)

Next inserts the tuples into the tables Note that Insert does not return any tuple We return an error if the insert failed for any reason, and return nil if all inserts succeeded.

type LimitExecutor

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

LimitExecutor implements the limit/offset operation

func (*LimitExecutor) GetOutputSchema

func (e *LimitExecutor) GetOutputSchema() *schema.Schema

func (*LimitExecutor) GetTableMetaData added in v0.0.2

func (e *LimitExecutor) GetTableMetaData() *catalog.TableMetadata

func (*LimitExecutor) Init

func (e *LimitExecutor) Init()

func (*LimitExecutor) Next

func (e *LimitExecutor) Next() (*tuple.Tuple, Done, error)

type MakeSchemaMeta

type MakeSchemaMeta struct {
	Col_name_ string
	Expr_     expression.ColumnValue
}

type MakeSchemaMetaAgg

type MakeSchemaMetaAgg struct {
	Col_name_ string
	Expr_     expression.AggregateValueExpression
}

type OrderbyExecutor

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

* * OrderbyExecutor executes an aggregation operation (e.g. COUNT, SUM, MIN, MAX) on the tuples of a child executor.

func NewOrderbyExecutor

func NewOrderbyExecutor(exec_ctx *ExecutorContext, plan *plans.OrderbyPlanNode,
	child Executor) *OrderbyExecutor

*

  • Creates a new aggregation executor.
  • @param exec_ctx the context that the aggregation should be performed in
  • @param plan the aggregation plan node
  • @param child the child executor

func (*OrderbyExecutor) GetChildOutputSchema

func (e *OrderbyExecutor) GetChildOutputSchema() *schema.Schema

func (*OrderbyExecutor) GetOutputSchema

func (e *OrderbyExecutor) GetOutputSchema() *schema.Schema

func (*OrderbyExecutor) GetTableMetaData added in v0.0.2

func (e *OrderbyExecutor) GetTableMetaData() *catalog.TableMetadata

func (*OrderbyExecutor) Init

func (e *OrderbyExecutor) Init()

func (*OrderbyExecutor) Next

func (e *OrderbyExecutor) Next() (*tuple.Tuple, Done, error)

type PointScanWithIndexExecutor added in v0.0.2

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

*

  • PointScanWithIndexExecutor executes scan with hash index to filter rows matches predicate.

func (*PointScanWithIndexExecutor) GetOutputSchema added in v0.0.2

func (e *PointScanWithIndexExecutor) GetOutputSchema() *schema.Schema

func (*PointScanWithIndexExecutor) GetTableMetaData added in v0.0.2

func (e *PointScanWithIndexExecutor) GetTableMetaData() *catalog.TableMetadata

func (*PointScanWithIndexExecutor) Init added in v0.0.2

func (e *PointScanWithIndexExecutor) Init()

func (*PointScanWithIndexExecutor) Next added in v0.0.2

type Predicate

type Predicate struct {
	LeftColumn  string
	Operator    expression.ComparisonType
	RightColumn interface{}
}

type RangeScanWithIndexExecutor added in v0.0.2

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

*

  • RangeScanWithIndexExecutor executes scan with hash index to filter rows matches predicate.

func (*RangeScanWithIndexExecutor) GetOutputSchema added in v0.0.2

func (e *RangeScanWithIndexExecutor) GetOutputSchema() *schema.Schema

func (*RangeScanWithIndexExecutor) GetTableMetaData added in v0.0.2

func (e *RangeScanWithIndexExecutor) GetTableMetaData() *catalog.TableMetadata

func (*RangeScanWithIndexExecutor) Init added in v0.0.2

func (e *RangeScanWithIndexExecutor) Init()

func (*RangeScanWithIndexExecutor) Next added in v0.0.2

Next implements the next method for the sequential scan operator It uses the table heap iterator to iterate through the table heap tyring to find a tuple. It performs selection and projection on-the-fly

type SeqScanExecutor

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

*

  • SeqScanExecutor executes a sequential scan over a table.

func (*SeqScanExecutor) GetOutputSchema

func (e *SeqScanExecutor) GetOutputSchema() *schema.Schema

func (*SeqScanExecutor) GetTableMetaData added in v0.0.2

func (e *SeqScanExecutor) GetTableMetaData() *catalog.TableMetadata

func (*SeqScanExecutor) Init

func (e *SeqScanExecutor) Init()

func (*SeqScanExecutor) Next

func (e *SeqScanExecutor) Next() (*tuple.Tuple, Done, error)

Next implements the next method for the sequential scan operator It uses the table heap iterator to iterate through the table heap tyring to find a tuple. It performs selection and projection on-the-fly

type SeqScanTestCase

type SeqScanTestCase struct {
	Description     string
	ExecutionEngine *ExecutionEngine
	ExecutorContext *ExecutorContext
	TableMetadata   *catalog.TableMetadata
	Columns         []Column
	Predicate       Predicate
	Asserts         []Assertion
	TotalHits       uint32
}

type SimpleAggregationHashTable

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

*

  • A simplified hash table that has all the necessary functionality for aggregations.

func NewSimpleAggregationHashTable

func NewSimpleAggregationHashTable(agg_exprs []expression.Expression, agg_types []plans.AggregationType) *SimpleAggregationHashTable

*

  • Create a new simplified aggregation hash table.
  • @param agg_exprs the aggregation expressions
  • @param agg_types the types of aggregations

func (*SimpleAggregationHashTable) Begin

* @return iterator to the start of the hash table

func (*SimpleAggregationHashTable) CombineAggregateValues

func (aht *SimpleAggregationHashTable) CombineAggregateValues(result *plans.AggregateValue, input *plans.AggregateValue)

* Combines the input into the aggregation result.

func (*SimpleAggregationHashTable) GenerateInitialAggregateValue

func (ht *SimpleAggregationHashTable) GenerateInitialAggregateValue() *plans.AggregateValue

* @return the initial aggregrate value for this aggregation executor

func (*SimpleAggregationHashTable) InsertCombine

func (aht *SimpleAggregationHashTable) InsertCombine(agg_key *plans.AggregateKey, agg_val *plans.AggregateValue)

*

  • Inserts a value into the hash table and then combines it with the current aggregation.
  • @param agg_key the key to be inserted
  • @param agg_val the value to be inserted

type SimpleHashJoinHashTable

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

func NewSimpleHashJoinHashTable

func NewSimpleHashJoinHashTable() *SimpleHashJoinHashTable

func (*SimpleHashJoinHashTable) GetValue

func (jht *SimpleHashJoinHashTable) GetValue(h uint32) []hash.TmpTuple

*

  • Gets the values in the hash table that match the given hash key.
  • @param txn the transaction that we execute in
  • @param h the hash key
  • @param[out] t the list of tuples that matched the key

func (*SimpleHashJoinHashTable) Insert

func (jht *SimpleHashJoinHashTable) Insert(h uint32, t *hash.TmpTuple) bool

*

  • Inserts a (hash key, tuple) pair into the hash table.
  • @param txn the transaction that we execute in
  • @param h the hash key
  • @param t the tuple to associate with the key
  • @return true if the insert succeeded

type TableInsertMeta

type TableInsertMeta struct {
	/**
	 * Name of the table
	 */
	Name_ string
	/**
	 * Number of rows
	 */
	Num_rows_ uint32
	/**
	 * Columns
	 */
	Col_meta_ []*ColumnInsertMeta
}

type UpdateExecutor

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

*

  • UpdateExecutor executes a sequential scan over a table and update tuples according to predicate.

func (*UpdateExecutor) GetOutputSchema

func (e *UpdateExecutor) GetOutputSchema() *schema.Schema

func (*UpdateExecutor) GetTableMetaData added in v0.0.2

func (e *UpdateExecutor) GetTableMetaData() *catalog.TableMetadata

func (*UpdateExecutor) Init

func (e *UpdateExecutor) Init()

func (*UpdateExecutor) Next

func (e *UpdateExecutor) Next() (*tuple.Tuple, Done, error)

Next implements the next method for the sequential scan operator It uses the table heap iterator to iterate through the table heap tyring to find a tuple to be updated. It performs selection on-the-fly

Jump to

Keyboard shortcuts

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