testutil

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestUtilMp = mpool.MustNewZero()

	MakeBoolVector = func(values []bool) *vector.Vector {
		return makeVector(values, nil, boolType)
	}

	MakeBooleanlVector = func(values []bool, nsp []uint64) *vector.Vector {
		return makeVector(values, nsp, boolType)
	}

	MakeInt64Vector = func(values []int64, nsp []uint64) *vector.Vector {
		return makeVector(values, nsp, int64Type)
	}

	MakeInt32Vector = func(values []int32, nsp []uint64) *vector.Vector {
		return makeVector(values, nsp, int32Type)
	}

	MakeInt16Vector = func(values []int16, nsp []uint64) *vector.Vector {
		return makeVector(values, nsp, int16Type)
	}

	MakeInt8Vector = func(values []int8, nsp []uint64) *vector.Vector {
		return makeVector(values, nsp, int8Type)
	}

	MakeUint64Vector = func(values []uint64, nsp []uint64) *vector.Vector {
		return makeVector(values, nsp, uint64Type)
	}

	MakeUint32Vector = func(values []uint32, nsp []uint64) *vector.Vector {
		return makeVector(values, nsp, uint32Type)
	}

	MakeUint16Vector = func(values []uint16, nsp []uint64) *vector.Vector {
		return makeVector(values, nsp, uint16Type)
	}

	MakeUint8Vector = func(values []uint8, nsp []uint64) *vector.Vector {
		return makeVector(values, nsp, uint8Type)
	}

	MakeFloat32Vector = func(values []float32, nsp []uint64) *vector.Vector {
		return makeVector(values, nsp, float32Type)
	}

	MakeFloat64Vector = func(values []float64, nsp []uint64) *vector.Vector {
		return makeVector(values, nsp, float64Type)
	}

	MakeCharVector = func(values []string, nsp []uint64) *vector.Vector {
		return makeStringVector(values, nsp, charType)
	}

	MakeVarcharVector = func(values []string, nsp []uint64) *vector.Vector {
		return makeStringVector(values, nsp, varcharType)
	}

	MakeBlobVector = func(values []string, nsp []uint64) *vector.Vector {
		return makeStringVector(values, nsp, blobType)
	}
	MakeTextVector = func(values []string, nsp []uint64) *vector.Vector {
		return makeStringVector(values, nsp, textType)
	}
	MakeDecimal64Vector = func(values []int64, nsp []uint64, _ types.Type) *vector.Vector {
		cols := make([]types.Decimal64, len(values))
		for i, v := range values {
			d, _ := types.InitDecimal64(v, 64, 0)
			cols[i] = d
		}
		return makeVector(cols, nsp, decimal64Type)
	}

	MakeDecimal128Vector = func(values []int64, nsp []uint64, _ types.Type) *vector.Vector {
		cols := make([]types.Decimal128, len(values))
		for i, v := range values {
			d, _ := types.InitDecimal128(v, 64, 0)
			cols[i] = d
		}
		return makeVector(cols, nsp, decimal128Type)
	}

	MakeDateVector = func(values []string, nsp []uint64) *vector.Vector {
		ds := make([]types.Date, len(values))
		ns := nulls.Build(len(values), nsp...)
		for i, s := range values {
			if nulls.Contains(ns, uint64(i)) {
				continue
			}
			d, err := types.ParseDate(s)
			if err != nil {
				panic(err)
			}
			ds[i] = d
		}
		return vector.NewWithFixed(types.T_date.ToType(), ds, ns, TestUtilMp)
	}

	MakeTimeVector = func(values []string, nsp []uint64) *vector.Vector {
		ds := make([]types.Time, len(values))
		ns := nulls.Build(len(values), nsp...)
		for i, s := range values {
			if nulls.Contains(ns, uint64(i)) {
				continue
			}
			d, err := types.ParseTime(s, 6)
			if err != nil {
				panic(err)
			}
			ds[i] = d
		}
		return vector.NewWithFixed(types.T_time.ToType(), ds, ns, TestUtilMp)
	}

	MakeDateTimeVector = func(values []string, nsp []uint64) *vector.Vector {
		ds := make([]types.Datetime, len(values))
		ns := nulls.Build(len(values), nsp...)
		for i, s := range values {
			if nulls.Contains(ns, uint64(i)) {
				continue
			}
			d, err := types.ParseDatetime(s, 6)
			if err != nil {
				panic(err)
			}
			ds[i] = d
		}
		return vector.NewWithFixed(types.T_datetime.ToType(), ds, ns, TestUtilMp)
	}

	MakeTimeStampVector = func(values []string, nsp []uint64) *vector.Vector {
		ds := make([]types.Timestamp, len(values))
		ns := nulls.Build(len(values), nsp...)
		for i, s := range values {
			if nulls.Contains(ns, uint64(i)) {
				continue
			}
			d, err := types.ParseTimestamp(time.Local, s, 6)
			if err != nil {
				panic(err)
			}
			ds[i] = d
		}
		return vector.NewWithFixed(types.T_timestamp.ToType(), ds, ns, TestUtilMp)
	}

	MakeUuidVector = func(values []types.Uuid, nsp []uint64) *vector.Vector {
		ns := nulls.Build(len(values), nsp...)
		return vector.NewWithFixed(uuidType, values, ns, TestUtilMp)
	}

	MakeUuidVectorByString = func(values []string, nsp []uint64) *vector.Vector {
		ds := make([]types.Uuid, len(values))
		ns := nulls.Build(len(values), nsp...)
		for i, s := range values {
			if nulls.Contains(ns, uint64(i)) {
				continue
			}
			d, err := types.ParseUuid(s)
			if err != nil {
				panic(err)
			}
			ds[i] = d
		}
		return vector.NewWithFixed(types.T_uuid.ToType(), ds, ns, TestUtilMp)
	}
)

All vectors generated by the Make Function, their memory is not allocated through the memory pool if you want to generate a vector in memory pool, use NewFunction to instead of MakeFunction.

View Source
var (
	MakeScalarNull = func(typ types.T, length int) *vector.Vector {
		vec := NewProc().AllocConstNullVector(typ.ToType(), length)
		return vec
	}

	MakeScalarBool = func(v bool, length int) *vector.Vector {
		return makeScalar(v, length, boolType)
	}

	MakeScalarInt64 = func(v int64, length int) *vector.Vector {
		return makeScalar(v, length, int64Type)
	}

	MakeScalarInt32 = func(v int32, length int) *vector.Vector {
		return makeScalar(v, length, int32Type)
	}

	MakeScalarInt16 = func(v int16, length int) *vector.Vector {
		return makeScalar(v, length, int16Type)
	}

	MakeScalarInt8 = func(v int8, length int) *vector.Vector {
		return makeScalar(v, length, int8Type)
	}

	MakeScalarUint64 = func(v uint64, length int) *vector.Vector {
		return makeScalar(v, length, uint64Type)
	}

	MakeScalarUint3 = func(v uint32, length int) *vector.Vector {
		return makeScalar(v, length, uint32Type)
	}

	MakeScalarUint16 = func(v uint16, length int) *vector.Vector {
		return makeScalar(v, length, uint16Type)
	}

	MakeScalarUint8 = func(v uint8, length int) *vector.Vector {
		return makeScalar(v, length, uint8Type)
	}

	MakeScalarFloat32 = func(v float32, length int) *vector.Vector {
		return makeScalar(v, length, float32Type)
	}

	MakeScalarFloat64 = func(v float64, length int) *vector.Vector {
		return makeScalar(v, length, float64Type)
	}

	MakeScalarChar = func(value string, length int) *vector.Vector {
		return makeScalarString(value, length, charType)
	}

	MakeScalarVarchar = func(value string, length int) *vector.Vector {
		return makeScalarString(value, length, varcharType)
	}

	MakeTextVarchar = func(value string, length int) *vector.Vector {
		return makeScalarString(value, length, textType)
	}

	MakeScalarDate = func(value string, length int) *vector.Vector {
		d, err := types.ParseDate(value)
		if err != nil {
			panic(err)
		}
		return vector.NewConstFixed(dateType, length, d, TestUtilMp)
	}

	MakeScalarTime = func(value string, length int) *vector.Vector {
		d, err := types.ParseTime(value, 6)
		if err != nil {
			panic(err)
		}
		return vector.NewConstFixed(timeType, length, d, TestUtilMp)
	}

	MakeScalarDateTime = func(value string, length int) *vector.Vector {
		d, err := types.ParseDatetime(value, 6)
		if err != nil {
			panic(err)
		}
		return vector.NewConstFixed(datetimeType, length, d, TestUtilMp)
	}

	MakeScalarTimeStamp = func(value string, length int) *vector.Vector {
		d, err := types.ParseTimestamp(time.Local, value, 6)
		if err != nil {
			panic(err)
		}
		return vector.NewConstFixed(timestampType, length, d, TestUtilMp)
	}

	MakeScalarDecimal64 = func(v int64, length int, _ types.Type) *vector.Vector {
		d, _ := types.InitDecimal64(v, 64, 0)
		return vector.NewConstFixed(decimal64Type, length, d, TestUtilMp)
	}

	MakeScalarDecimal128 = func(v uint64, length int, _ types.Type) *vector.Vector {
		d, _ := types.InitDecimal128UsingUint(v, 64, 0)
		return vector.NewConstFixed(decimal64Type, length, d, TestUtilMp)
	}

	MakeScalarDecimal128ByFloat64 = func(v float64, length int, _ types.Type) *vector.Vector {
		val := fmt.Sprintf("%f", v)
		_, scale, err := types.ParseStringToDecimal128WithoutTable(val)
		if err != nil {
			panic(err)
		}
		dec128Val, err := types.ParseStringToDecimal128(val, 34, scale, false)
		if err != nil {
			panic(err)
		}
		return vector.NewConstFixed(decimal128Type, length, dec128Val, TestUtilMp)
	}
)

functions to make a scalar vector for test.

View Source
var NewProc = NewProcess

Functions

func CompareVectors added in v0.6.0

func CompareVectors(expected *vector.Vector, got *vector.Vector) bool

func MakeBatchZs added in v0.6.0

func MakeBatchZs(n int, random bool) []int64

func MakeDecimal64ArrByFloat64Arr added in v0.6.0

func MakeDecimal64ArrByFloat64Arr(input []float64) []types.Decimal64

func MakeDecimal64ArrByInt64Arr added in v0.6.0

func MakeDecimal64ArrByInt64Arr(input []int64) []types.Decimal64

func MakeDecimal64Type added in v0.6.0

func MakeDecimal64Type(precision, scalar int32) types.Type

func MakeDecimal128ArrByFloat64Arr added in v0.6.0

func MakeDecimal128ArrByFloat64Arr(input []float64) []types.Decimal128

func MakeDecimal128ArrByInt64Arr added in v0.6.0

func MakeDecimal128ArrByInt64Arr(input []int64) []types.Decimal128

func MakeDecimal128Type added in v0.6.0

func MakeDecimal128Type(precision, scalar int32) types.Type

func MakeRandomStrings added in v0.6.0

func MakeRandomStrings(cardinality, targetRows int) []string

func NewBatch

func NewBatch(ts []types.Type, random bool, n int, m *mpool.MPool) *batch.Batch

func NewBatchWithNulls added in v0.6.0

func NewBatchWithNulls(ts []types.Type, random bool, n int, m *mpool.MPool) *batch.Batch

func NewBatchWithVectors added in v0.6.0

func NewBatchWithVectors(vs []*vector.Vector, zs []int64) *batch.Batch

func NewBoolVector

func NewBoolVector(n int, typ types.Type, m *mpool.MPool, _ bool, vs []bool) *vector.Vector

func NewDateVector

func NewDateVector(n int, typ types.Type, m *mpool.MPool, random bool, vs []string) *vector.Vector

func NewDatetimeVector

func NewDatetimeVector(n int, typ types.Type, m *mpool.MPool, random bool, vs []string) *vector.Vector

func NewDecimal64Vector

func NewDecimal64Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []types.Decimal64) *vector.Vector

func NewDecimal128Vector

func NewDecimal128Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []types.Decimal128) *vector.Vector

func NewFS added in v0.6.0

func NewFS() *fileservice.FileServices

func NewFloat32Vector

func NewFloat32Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []float32) *vector.Vector

func NewFloat64Vector

func NewFloat64Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []float64) *vector.Vector

func NewInt8Vector

func NewInt8Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []int8) *vector.Vector

func NewInt16Vector

func NewInt16Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []int16) *vector.Vector

func NewInt32Vector

func NewInt32Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []int32) *vector.Vector

func NewInt64Vector

func NewInt64Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []int64) *vector.Vector

func NewJsonVector added in v0.6.0

func NewJsonVector(n int, typ types.Type, m *mpool.MPool, _ bool, vs []string) *vector.Vector

func NewProcess added in v0.6.0

func NewProcess() *process.Process

func NewProcessWithMPool added in v0.6.0

func NewProcessWithMPool(mp *mpool.MPool) *process.Process

func NewStringVector

func NewStringVector(n int, typ types.Type, m *mpool.MPool, random bool, vs []string) *vector.Vector

func NewTimeVector added in v0.6.0

func NewTimeVector(n int, typ types.Type, m *mpool.MPool, random bool, vs []string) *vector.Vector

func NewTimestampVector

func NewTimestampVector(n int, typ types.Type, m *mpool.MPool, random bool, vs []string) *vector.Vector

func NewUInt8Vector

func NewUInt8Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []uint8) *vector.Vector

func NewUInt16Vector

func NewUInt16Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []uint16) *vector.Vector

func NewUInt32Vector

func NewUInt32Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []uint32) *vector.Vector

func NewUInt64Vector

func NewUInt64Vector(n int, typ types.Type, m *mpool.MPool, random bool, vs []uint64) *vector.Vector

func NewVector

func NewVector(n int, typ types.Type, m *mpool.MPool, random bool, Values interface{}) *vector.Vector

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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