binary

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxFsp is the maximum digit of fractional seconds part.
	MaxFsp = 6
)

Variables

View Source
var (
	// WeekdayNames lists names of weekdays, which are used in builtin function `date_format`.
	WeekdayNames = []string{
		"Monday",
		"Tuesday",
		"Wednesday",
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday",
	}

	// MonthNames lists names of months, which are used in builtin function `date_format`.
	MonthNames = []string{
		"January",
		"February",
		"March",
		"April",
		"May",
		"June",
		"July",
		"August",
		"September",
		"October",
		"November",
		"December",
	}

	// AbbrevWeekdayName lists Abbreviation of week names, which are used int builtin function 'date_format'
	AbbrevWeekdayName = []string{
		"Sun",
		"Mon",
		"Tue",
		"Wed",
		"Thu",
		"Fri",
		"Sat",
	}
)
View Source
var (
	Int16ToInt8   = NumericToNumeric[int16, int8]
	Int32ToInt8   = NumericToNumeric[int32, int8]
	Int64ToInt8   = NumericToNumeric[int64, int8]
	Uint8ToInt8   = NumericToNumeric[uint8, int8]
	Uint16ToInt8  = NumericToNumeric[uint16, int8]
	Uint32ToInt8  = NumericToNumeric[uint32, int8]
	Uint64ToInt8  = NumericToNumeric[uint64, int8]
	Float32ToInt8 = FloatToIntWithoutError[float32, int8]
	Float64ToInt8 = FloatToIntWithoutError[float64, int8]

	Int8ToInt16    = NumericToNumeric[int8, int16]
	Int32ToInt16   = NumericToNumeric[int32, int16]
	Int64ToInt16   = NumericToNumeric[int64, int16]
	Uint8ToInt16   = NumericToNumeric[uint8, int16]
	Uint16ToInt16  = NumericToNumeric[uint16, int16]
	Uint32ToInt16  = NumericToNumeric[uint32, int16]
	Uint64ToInt16  = NumericToNumeric[uint64, int16]
	Float32ToInt16 = FloatToIntWithoutError[float32, int16]
	Float64ToInt16 = FloatToIntWithoutError[float64, int16]

	Int8ToInt32    = NumericToNumeric[int8, int32]
	Int16ToInt32   = NumericToNumeric[int16, int32]
	Int64ToInt32   = NumericToNumeric[int64, int32]
	Uint8ToInt32   = NumericToNumeric[uint8, int32]
	Uint16ToInt32  = NumericToNumeric[uint16, int32]
	Uint32ToInt32  = NumericToNumeric[uint32, int32]
	Uint64ToInt32  = NumericToNumeric[uint64, int32]
	Float32ToInt32 = NumericToNumeric[float32, int32]
	Float64ToInt32 = NumericToNumeric[float64, int32]

	Int8ToInt64    = NumericToNumeric[int8, int64]
	Int16ToInt64   = NumericToNumeric[int16, int64]
	Int32ToInt64   = NumericToNumeric[int32, int64]
	Uint8ToInt64   = NumericToNumeric[uint8, int64]
	Uint16ToInt64  = NumericToNumeric[uint16, int64]
	Uint32ToInt64  = NumericToNumeric[uint32, int64]
	Uint64ToInt64  = uint64ToInt64 // we handle overflow error in this function
	Float32ToInt64 = FloatToIntWithoutError[float32, int64]
	Float64ToInt64 = float64ToInt64

	Int8ToUint8    = NumericToNumeric[int8, uint8]
	Int16ToUint8   = NumericToNumeric[int16, uint8]
	Int32ToUint8   = NumericToNumeric[int32, uint8]
	Int64ToUint8   = NumericToNumeric[int64, uint8]
	Uint16ToUint8  = NumericToNumeric[uint16, uint8]
	Uint32ToUint8  = NumericToNumeric[uint32, uint8]
	Uint64ToUint8  = NumericToNumeric[uint64, uint8]
	Float32ToUint8 = FloatToIntWithoutError[float32, uint8]
	Float64ToUint8 = FloatToIntWithoutError[float64, uint8]

	Int8ToUint16    = NumericToNumeric[int8, uint16]
	Int16ToUint16   = NumericToNumeric[int16, uint16]
	Int32ToUint16   = NumericToNumeric[int32, uint16]
	Int64ToUint16   = NumericToNumeric[int64, uint16]
	Uint8ToUint16   = NumericToNumeric[uint8, uint16]
	Uint32ToUint16  = NumericToNumeric[uint32, uint16]
	Uint64ToUint16  = NumericToNumeric[uint64, uint16]
	Float32ToUint16 = NumericToNumeric[float32, uint16]
	Float64ToUint16 = NumericToNumeric[float64, uint16]

	Int8ToUint32    = NumericToNumeric[int8, uint32]
	Int16ToUint32   = NumericToNumeric[int16, uint32]
	Int32ToUint32   = NumericToNumeric[int32, uint32]
	Int64ToUint32   = NumericToNumeric[int64, uint32]
	Uint8ToUint32   = NumericToNumeric[uint8, uint32]
	Uint16ToUint32  = NumericToNumeric[uint16, uint32]
	Uint64ToUint32  = NumericToNumeric[uint64, uint32]
	Float32ToUint32 = FloatToIntWithoutError[float32, uint32]
	Float64ToUint32 = FloatToIntWithoutError[float64, uint32]

	Int8ToUint64    = NumericToNumeric[int8, uint64]
	Int16ToUint64   = NumericToNumeric[int16, uint64]
	Int32ToUint64   = NumericToNumeric[int32, uint64]
	Int64ToUint64   = int64ToUint64
	Uint8ToUint64   = NumericToNumeric[uint8, uint64]
	Uint16ToUint64  = NumericToNumeric[uint16, uint64]
	Uint32ToUint64  = NumericToNumeric[uint32, uint64]
	Float32ToUint64 = FloatToIntWithoutError[float32, uint64]
	Float64ToUint64 = FloatToIntWithoutError[float64, uint64]

	Int8ToFloat32    = NumericToNumeric[int8, float32]
	Int16ToFloat32   = NumericToNumeric[int16, float32]
	Int32ToFloat32   = NumericToNumeric[int32, float32]
	Int64ToFloat32   = NumericToNumeric[int64, float32]
	Uint8ToFloat32   = NumericToNumeric[uint8, float32]
	Uint16ToFloat32  = NumericToNumeric[uint16, float32]
	Uint32ToFloat32  = NumericToNumeric[uint32, float32]
	Uint64ToFloat32  = NumericToNumeric[uint64, float32]
	Float64ToFloat32 = NumericToNumeric[float64, float32]

	Int8ToFloat64    = NumericToNumeric[int8, float64]
	Int16ToFloat64   = NumericToNumeric[int16, float64]
	Int32ToFloat64   = NumericToNumeric[int32, float64]
	Int64ToFloat64   = NumericToNumeric[int64, float64]
	Uint8ToFloat64   = NumericToNumeric[uint8, float64]
	Uint16ToFloat64  = NumericToNumeric[uint16, float64]
	Uint32ToFloat64  = NumericToNumeric[uint32, float64]
	Uint64ToFloat64  = NumericToNumeric[uint64, float64]
	Float32ToFloat64 = NumericToNumeric[float32, float64]

	BytesToInt8    = BytesToInt[int8]
	Int8ToBytes    = IntToBytes[int8]
	BytesToInt16   = BytesToInt[int16]
	Int16ToBytes   = IntToBytes[int16]
	BytesToInt32   = BytesToInt[int32]
	Int32ToBytes   = IntToBytes[int32]
	BytesToInt64   = BytesToInt[int64]
	Int64ToBytes   = IntToBytes[int64]
	BytesToUint8   = BytesToUint[uint8]
	Uint8ToBytes   = UintToBytes[uint8]
	BytesToUint16  = BytesToUint[uint16]
	Uint16ToBytes  = UintToBytes[uint16]
	BytesToUint32  = BytesToUint[uint32]
	Uint32ToBytes  = UintToBytes[uint32]
	BytesToUint64  = BytesToUint[uint64]
	Uint64ToBytes  = UintToBytes[uint64]
	BytesToFloat32 = BytesToFloat[float32]
	Float32ToBytes = FloatToBytes[float32]
	BytesToFloat64 = BytesToFloat[float64]
	Float64ToBytes = FloatToBytes[float64]

	Decimal64ToDecimal128 = decimal64ToDecimal128Pure

	Int8ToDecimal128   = IntToDecimal128[int8]
	Int16ToDecimal128  = IntToDecimal128[int16]
	Int32ToDecimal128  = IntToDecimal128[int32]
	Int64ToDecimal128  = IntToDecimal128[int64]
	Uint8ToDecimal128  = UintToDecimal128[uint8]
	Uint16ToDecimal128 = UintToDecimal128[uint16]
	Uint32ToDecimal128 = UintToDecimal128[uint32]
	Uint64ToDecimal128 = UintToDecimal128[uint64]

	TimestampToDatetime = timestampToDatetime
	TimestampToVarchar  = timestampToVarchar
	BoolToBytes         = boolToBytes
	DateToBytes         = dateToBytes
	DateToDatetime      = dateToDateTime
	DateToTime          = dateToTime
	DatetimeToBytes     = datetimeToBytes
	DatetimeToTime      = datetimeToTime
	TimeToBytes         = timeToBytes
	TimeToDate          = timeToDate
	TimeToDatetime      = timeToDatetime
	DatetimeToDate      = datetimeToDate
	UuidToBytes         = uuidToBytes
)

Functions

func AbbrDayOfMonth added in v0.6.0

func AbbrDayOfMonth(day int) string

AbbrDayOfMonth: Get the abbreviation of month of day

func BinaryByteToDecimal128 added in v0.6.0

func BinaryByteToDecimal128(ctx context.Context, xs []string, rs []types.Decimal128) ([]types.Decimal128, error)

func BoolToNumeric added in v0.6.0

func BoolToNumeric[T constraints.Integer | constraints.Float](xs []bool, rs []T) ([]T, error)

func BytesToFloat

func BytesToFloat[T constraints.Float](ctx context.Context, xs []string, rs []T, isBin bool, isEmptyStringOrNull ...[]int) ([]T, error)

func BytesToInt

func BytesToInt[T constraints.Signed](ctx context.Context, xs []string, rs []T, isBin ...bool) ([]T, error)

func BytesToUint

func BytesToUint[T constraints.Unsigned](ctx context.Context, xs []string, rs []T, isBin ...bool) ([]T, error)

func CalcDateFromat added in v0.6.0

func CalcDateFromat(ctx context.Context, datetimes []types.Datetime, format string, ns *nulls.Nulls) ([]string, error)

CalcDateFromat: DateFromat is used to formating the datetime values according to the format string.

func CalcStrToDate added in v0.6.0

func CalcStrToDate(ctx context.Context, timestrs []string, format string, ns *nulls.Nulls, rNsp *nulls.Nulls) ([]types.Date, error)

func CalcStrToDatetime added in v0.6.0

func CalcStrToDatetime(ctx context.Context, timestrs []string, format string, ns *nulls.Nulls, rNsp *nulls.Nulls) ([]types.Datetime, error)

func CalcStrToTime added in v0.6.0

func CalcStrToTime(ctx context.Context, timestrs []string, format string, ns *nulls.Nulls, rNsp *nulls.Nulls) ([]types.Time, error)

func CoreStrToDate added in v0.6.0

func CoreStrToDate(cctx context.Context, t *GeneralTime, date string, format string) bool

func DateDiff added in v0.6.0

func DateDiff(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

func DateFSP added in v0.6.0

func DateFSP(date string) (fsp int)

DateFSP gets fsp from date string.

func DateFormat added in v0.6.0

func DateFormat(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

DateFromat: Formats the date value according to the format string. If either argument is NULL, the function returns NULL.

func Decimal128ToBytes

func Decimal128ToBytes(xs []types.Decimal128, rs []string, scale int32) ([]string, error)

func Decimal128ToDecimal128 added in v0.6.0

func Decimal128ToDecimal128(ctx context.Context, xs []types.Decimal128, width, scale int32, rs []types.Decimal128) ([]types.Decimal128, error)

func Decimal128ToDecimal64

func Decimal128ToDecimal64(ctx context.Context, xs []types.Decimal128, width, scale int32, rs []types.Decimal64) ([]types.Decimal64, error)

the scale of decimal128 is guaranteed to be less than 18 this cast function is too slow, and therefore only temporary, rewrite needed

func Decimal128ToFloat32

func Decimal128ToFloat32(ctx context.Context, xs []types.Decimal128, scale int32, rs []float32) ([]float32, error)

func Decimal128ToFloat64

func Decimal128ToFloat64(ctx context.Context, xs []types.Decimal128, scale int32, rs []float64) ([]float64, error)

func Decimal128ToInt32 added in v0.6.0

func Decimal128ToInt32(ctx context.Context, xs []types.Decimal128, scale int32, rs []int32) ([]int32, error)

func Decimal128ToInt64

func Decimal128ToInt64(ctx context.Context, xs []types.Decimal128, scale int32, rs []int64) ([]int64, error)

func Decimal128ToTime added in v0.6.0

func Decimal128ToTime(ctx context.Context, xs []types.Decimal128, rs []types.Time, precision int32) ([]types.Time, error)

func Decimal128ToTimestamp

func Decimal128ToTimestamp(xs []types.Decimal128, precision int32, scale int32, rs []types.Timestamp) ([]types.Timestamp, error)

func Decimal128ToUint64

func Decimal128ToUint64(ctx context.Context, xs []types.Decimal128, scale int32, rs []uint64) ([]uint64, error)

func Decimal64ToBytes

func Decimal64ToBytes(xs []types.Decimal64, rs []string, scale int32) ([]string, error)

func Decimal64ToFloat32

func Decimal64ToFloat32(ctx context.Context, xs []types.Decimal64, scale int32, rs []float32) ([]float32, error)

func Decimal64ToFloat64

func Decimal64ToFloat64(ctx context.Context, xs []types.Decimal64, scale int32, rs []float64) ([]float64, error)

func Decimal64ToInt64

func Decimal64ToInt64(ctx context.Context, xs []types.Decimal64, scale int32, rs []int64) ([]int64, error)

func Decimal64ToTime added in v0.6.0

func Decimal64ToTime(ctx context.Context, xs []types.Decimal64, rs []types.Time, precision int32) ([]types.Time, error)

func Decimal64ToTimestamp

func Decimal64ToTimestamp(xs []types.Decimal64, precision int32, scale int32, rs []types.Timestamp) ([]types.Timestamp, error)

func Decimal64ToUint64

func Decimal64ToUint64(ctx context.Context, xs []types.Decimal64, scale int32, rs []uint64) ([]uint64, error)

func Endswith

func Endswith(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

func ExtractFromDate

func ExtractFromDate(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

func ExtractFromDatetime

func ExtractFromDatetime(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

func FindInSet

func FindInSet(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

func FloatToBytes

func FloatToBytes[T constraints.Float](xs []T, rs []string) ([]string, error)

func FloatToIntWithoutError

func FloatToIntWithoutError[T1 constraints.Float, T2 constraints.Integer](ctx context.Context, xs []T1, rs []T2) ([]T2, error)

func FormatIntByWidth added in v0.6.0

func FormatIntByWidth(num, n int) string

FormatIntByWidth: Formatintwidthn is used to format ints with width parameter n. Insufficient numbers are filled with 0.

func GetTimeFormatType added in v0.6.0

func GetTimeFormatType(format string) (isTime, isDate bool)

GetTimeFormatType checks the type(Time, Date or Datetime) of a format string.

func Instr added in v0.7.0

func Instr(vecs []*vector.Vector, proc *process.Process) (ret *vector.Vector, err error)

func IntToBytes

func IntToBytes[T constraints.Integer](xs []T, rs []string, ZeroAndBin ...int64) ([]string, error)

XXX Potentially we can do much better with types.Varlena

func IntToDecimal128

func IntToDecimal128[T constraints.Integer](ctx context.Context, xs []T, rs []types.Decimal128, width, scale int32) ([]types.Decimal128, error)

func IntToDecimal64

func IntToDecimal64[T constraints.Integer](ctx context.Context, xs []T, rs []types.Decimal64, width, scale int32) ([]types.Decimal64, error)

func JudgmentToDateReturnType added in v0.6.0

func JudgmentToDateReturnType(format string) (tp types.T, fsp int)

Judge the return value type of the str_to_date function according to the value of the fromat parameter

func Left added in v0.6.0

func Left(vs []*vector.Vector, proc *process.Process) (*vector.Vector, error)

func NumericToBool

func NumericToBool[T constraints.Integer | constraints.Float](xs []T, rs []bool) ([]bool, error)

func NumericToNumeric

func NumericToNumeric[T1, T2 constraints.Integer | constraints.Float](ctx context.Context, xs []T1, rs []T2) ([]T2, error)

func NumericToNumericOverflow added in v0.6.0

func NumericToNumericOverflow[T1, T2 constraints.Integer | constraints.Float](ctx context.Context, xs []T1, rs []T2) error

func NumericToTime added in v0.6.0

func NumericToTime[T constraints.Integer](ctx context.Context, xs []T, rs []types.Time, precision int32) ([]types.Time, error)

func NumericToTimestamp

func NumericToTimestamp[T constraints.Integer](xs []T, rs []types.Timestamp) ([]types.Timestamp, error)

func Power

func Power(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

func ShowVisibleBin added in v0.6.0

func ShowVisibleBin(vec []*vector.Vector, proc *process.Process) (*vector.Vector, error)

func Startswith

func Startswith(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

func StrToDate added in v0.6.0

func StrToDate(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

Convert the string to date type value according to the format string

func StrToDateTime added in v0.6.0

func StrToDateTime(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

Convert the string to datetime type value according to the format string

func StrToTime added in v0.6.0

func StrToTime(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

// Convert the string to time type value according to the format string,such as '09:30:17'

func TimeDiff added in v0.6.0

func TimeDiff[T timediff.DiffT](vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

func TimeToDecimal128 added in v0.6.0

func TimeToDecimal128(ctx context.Context, xs []types.Time, rs []types.Decimal128, width, precision int32) ([]types.Decimal128, error)

func TimeToDecimal64 added in v0.6.0

func TimeToDecimal64(ctx context.Context, xs []types.Time, rs []types.Decimal64, width, precision int32) ([]types.Decimal64, error)

func TimeToNumeric added in v0.6.0

func TimeToNumeric[T constraints.Integer](ctx context.Context, xs []types.Time, rs []T) ([]T, error)

func ToDate

func ToDate(vectors []*vector.Vector, proc *process.Process) (*vector.Vector, error)

func ToDateInputBytes

func ToDateInputBytes(ctx context.Context, inputs []string, format string, inputNsp *nulls.Nulls, result []string) ([]string, *nulls.Nulls, error)

func UintToBytes added in v0.6.0

func UintToBytes[T constraints.Integer](xs []T, rs []string) ([]string, error)

XXX Potentially we can do much better with types.Varlena

func UintToDecimal128

func UintToDecimal128[T constraints.Integer](ctx context.Context, xs []T, rs []types.Decimal128, width, scale int32) ([]types.Decimal128, error)

Types

type GeneralTime added in v0.6.0

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

GeneralTime is the internal struct type for Time.

func FromDate added in v0.6.0

func FromDate(year int, month int, day int, hour int, minute int, second int, microsecond int) GeneralTime

func NewGeneralTime added in v0.6.0

func NewGeneralTime() *GeneralTime

func (GeneralTime) Minute added in v0.6.0

func (t GeneralTime) Minute() int

Minute returns the minute value.

func (GeneralTime) ResetTime added in v0.6.0

func (t GeneralTime) ResetTime()

Reset GeneralTime to initialization state

func (GeneralTime) String added in v0.6.0

func (t GeneralTime) String() string

String implements fmt.Stringer.

type Month added in v0.6.0

type Month int

The month represents one month of the year (January=1,...).

const (
	January Month = 1 + iota
	February
	March
	April
	May
	June
	July
	August
	September
	October
	November
	December
)

Jump to

Keyboard shortcuts

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