testutil

package
v1.1.0-beta.0...-14a469a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenRandomChunks

func GenRandomChunks(schema []*types.FieldType, size int) *chunk.Chunk

GenRandomChunks generate random chunk data

Types

type AggTestCase

type AggTestCase struct {
	Ctx              sessionctx.Context
	ExecType         string
	AggFunc          string
	GroupByNDV       int
	Rows             int
	Concurrency      int
	DataSourceSorted bool
	HasDistinct      bool
}

AggTestCase has a fixed schema (aggCol Double, groupBy LongLong).

func DefaultAggTestCase

func DefaultAggTestCase(ctx sessionctx.Context, exec string) *AggTestCase

DefaultAggTestCase returns default agg test case

func (AggTestCase) Columns

func (AggTestCase) Columns() []*expression.Column

Columns creates columns

func (AggTestCase) String

func (a AggTestCase) String() string

String gets case content

type LimitCase

type LimitCase struct {
	Ctx                   sessionctx.Context
	ChildUsedSchema       []bool
	Rows                  int
	Offset                int
	Count                 int
	UsingInlineProjection bool
}

LimitCase is the limit case

func DefaultLimitTestCase

func DefaultLimitTestCase(ctx sessionctx.Context) *LimitCase

DefaultLimitTestCase returns default limit test case

func (LimitCase) Columns

func (LimitCase) Columns() []*expression.Column

Columns creates columns

func (LimitCase) String

func (tc LimitCase) String() string

String gets case content

type MockActionOnExceed

type MockActionOnExceed struct {
	memory.BaseOOMAction
	// contains filtered or unexported fields
}

MockActionOnExceed is for test.

func (*MockActionOnExceed) Action

func (m *MockActionOnExceed) Action(*memory.Tracker)

Action add the triggered number.

func (*MockActionOnExceed) GetPriority

func (*MockActionOnExceed) GetPriority() int64

GetPriority get the priority of the Action.

func (*MockActionOnExceed) GetTriggeredNum

func (m *MockActionOnExceed) GetTriggeredNum() int

GetTriggeredNum get the triggered number of the Action

type MockDataPhysicalPlan

type MockDataPhysicalPlan struct {
	MockPhysicalPlan
	DataSchema *expression.Schema
	Exec       exec.Executor
}

MockDataPhysicalPlan mocks physical plan

func BuildMockDataPhysicalPlan

func BuildMockDataPhysicalPlan(_ sessionctx.Context, srcExec exec.Executor) *MockDataPhysicalPlan

BuildMockDataPhysicalPlan builds MockDataPhysicalPlan

func (*MockDataPhysicalPlan) ExplainID

func (*MockDataPhysicalPlan) ExplainID() fmt.Stringer

ExplainID returns explain id

func (*MockDataPhysicalPlan) GetExecutor

func (mp *MockDataPhysicalPlan) GetExecutor() exec.Executor

GetExecutor gets executor

func (*MockDataPhysicalPlan) ID

func (*MockDataPhysicalPlan) ID() int

ID returns 0

func (*MockDataPhysicalPlan) MemoryUsage

func (*MockDataPhysicalPlan) MemoryUsage() (sum int64)

MemoryUsage of mockDataPhysicalPlan is only for testing

func (*MockDataPhysicalPlan) QueryBlockOffset

func (*MockDataPhysicalPlan) QueryBlockOffset() int

QueryBlockOffset returns 0

func (*MockDataPhysicalPlan) Schema

func (mp *MockDataPhysicalPlan) Schema() *expression.Schema

Schema returns schema

func (*MockDataPhysicalPlan) Stats

Stats returns nil

type MockDataSource

type MockDataSource struct {
	GenData []*chunk.Chunk
	Chunks  []*chunk.Chunk
	P       MockDataSourceParameters
	exec.BaseExecutor
	ChunkPtr int
}

MockDataSource mocks data source

func BuildMockDataSource

func BuildMockDataSource(opt MockDataSourceParameters) *MockDataSource

BuildMockDataSource builds MockDataSource

func BuildMockDataSourceWithIndex

func BuildMockDataSourceWithIndex(opt MockDataSourceParameters, index []int) *MockDataSource

BuildMockDataSourceWithIndex builds MockDataSourceWithIndex

func (*MockDataSource) GenColDatums

func (mds *MockDataSource) GenColDatums(col int) (results []any)

GenColDatums get column datums

func (*MockDataSource) Next

func (mds *MockDataSource) Next(_ context.Context, req *chunk.Chunk) error

Next get next chunk

func (*MockDataSource) PrepareChunks

func (mds *MockDataSource) PrepareChunks()

PrepareChunks prepares chunks

func (*MockDataSource) RandDatum

func (*MockDataSource) RandDatum(typ *types.FieldType) any

RandDatum rand datum

type MockDataSourceParameters

type MockDataSourceParameters struct {
	Ctx         sessionctx.Context
	DataSchema  *expression.Schema
	GenDataFunc func(row int, typ *types.FieldType) any
	Ndvs        []int
	Orders      []bool

	// Sometimes, user wants to manually provide test data
	// and he can save provided test data at here.
	Datums [][]any

	Nulls [][]bool

	Rows   int
	HasSel bool
}

MockDataSourceParameters mpcks data source parameters

type MockPhysicalPlan

type MockPhysicalPlan interface {
	plannercore.PhysicalPlan
	GetExecutor() exec.Executor
}

MockPhysicalPlan is used to return a specified executor in when build. It is mainly used for testing.

type SortCase

type SortCase struct {
	Ctx        sessionctx.Context
	OrderByIdx []int
	Ndvs       []int
	Rows       int
}

SortCase is the sort case

func DefaultSortTestCase

func DefaultSortTestCase(ctx sessionctx.Context) *SortCase

DefaultSortTestCase returns default sort test case

func SortTestCaseWithMemoryLimit

func SortTestCaseWithMemoryLimit(ctx sessionctx.Context, bytesLimit int64) *SortCase

SortTestCaseWithMemoryLimit returns sort test case

func (SortCase) Columns

func (SortCase) Columns() []*expression.Column

Columns creates column

func (SortCase) String

func (tc SortCase) String() string

String gets case content

type WindowTestCase

type WindowTestCase struct {
	Ctx              sessionctx.Context
	Frame            *logicalop.WindowFrame
	WindowFunc       string
	RawDataSmall     string
	Columns          []*expression.Column
	NumFunc          int
	Ndv              int
	Rows             int
	Concurrency      int
	Pipelined        int
	DataSourceSorted bool
}

WindowTestCase has a fixed schema (col Double, partitionBy LongLong, rawData VarString(16), col LongLong).

func DefaultWindowTestCase

func DefaultWindowTestCase(ctx sessionctx.Context) *WindowTestCase

DefaultWindowTestCase returns default window test case

func (WindowTestCase) String

func (a WindowTestCase) String() string

String gets case content

Jump to

Keyboard shortcuts

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