Documentation ¶
Index ¶
- Constants
- Variables
- func AlignDecimal128UsingScaleDiffBatch(src, dst []Decimal128, scaleDiff int32)
- func AppendBoolToByteArray(b bool, arr []byte) []byte
- func CompareDecimal128Decimal128(a, b Decimal128, aScale, bScale int32) (result int64)
- func CompareDecimal128Decimal128Aligned(a, b Decimal128) (result int64)
- func CompareDecimal64Decimal64(a, b Decimal64, aScale, bScale int32) (result int64)
- func CompareDecimal64Decimal64Aligned(a, b Decimal64) (result int64)
- func Decimal128IsNegative(a Decimal128) (result bool)
- func Decimal128IsNotZero(a Decimal128) (result bool)
- func Decimal128IsPositive(a Decimal128) (result bool)
- func Decimal128IsZero(a Decimal128) (result bool)
- func JudgeIntervalNumOverflow(num int64, it IntervalType) error
- func LastDay(year uint16, month uint8) int
- func ModDecimal128By10Abs(a Decimal128) (result int64)
- func ParseBool(s string) (bool, error)
- func ParseValueToBool(num *tree.NumVal) (bool, error)
- func TypeSize(oid T) int
- func UnitIsDayOrLarger(it IntervalType) bool
- func ValidTimestamp(timestamp Timestamp) bool
- type Bytes
- type Date
- func (d Date) Calendar(full bool) (year int32, month, day uint8, yday uint16)
- func (d Date) Day() uint8
- func (d Date) DayOfWeek() Weekday
- func (d Date) DayOfYear() uint16
- func (d Date) Month() uint8
- func (d Date) Quarter() uint32
- func (d Date) String() string
- func (d Date) ToTime() Datetime
- func (d Date) ToTimeUTC() Timestamp
- func (d Date) WeekOfYear() (year int32, week uint8)
- func (d Date) WeekOfYear2() uint8
- func (d Date) Year() uint16
- func (d Date) YearMonth() uint32
- func (d Date) YearMonthStr() string
- type Datetime
- func (dt Datetime) AddDateTime(date gotime.Time, ...) (Datetime, bool)
- func (dt Datetime) AddInterval(nums int64, its IntervalType, timeType TimeType) (Datetime, bool)
- func (dt Datetime) Clock() (hour, min, sec int8)
- func (dt Datetime) ConvertToGoTime() gotime.Time
- func (dt Datetime) Day() uint8
- func (dt Datetime) DayHourStr() string
- func (dt Datetime) DayMicrosecondStr() string
- func (dt Datetime) DayMinuteStr() string
- func (dt Datetime) DaySecondStr() string
- func (dt Datetime) Hour() int8
- func (dt Datetime) HourMicrosecondStr() string
- func (dt Datetime) HourMinuteStr() string
- func (dt Datetime) HourSecondStr() string
- func (dt Datetime) MicroSec() int64
- func (dt Datetime) Minute() int8
- func (dt Datetime) MinuteMicrosecondStr() string
- func (dt Datetime) MinuteSecondStr() string
- func (dt Datetime) Month() uint8
- func (dt Datetime) Sec() int8
- func (dt Datetime) SecondMicrosecondStr() string
- func (dt Datetime) String() string
- func (dt Datetime) String2(precision int32) string
- func (dt Datetime) ToDate() Date
- func (dt Datetime) ToInt64() int64
- func (dt Datetime) UTC() Datetime
- func (dt Datetime) UnixTimestamp() int64
- func (dt Datetime) WeekOfYear() (int32, uint8)
- func (dt Datetime) Year() uint16
- func (dt Datetime) YearMonthStr() string
- type Decimal
- type Decimal128
- func AddDecimal128ByInt64(a Decimal128, value int64) (result Decimal128)
- func Decimal128Add(a, b Decimal128, aScale, bScale int32) (result Decimal128)
- func Decimal128AddAligned(a, b Decimal128) (result Decimal128)
- func Decimal128Decimal128Div(a, b Decimal128, aScale, bScale int32) (result Decimal128)
- func Decimal128Decimal128DivAligned(a, b Decimal128) (result Decimal128)
- func Decimal128Decimal128Mul(a Decimal128, b Decimal128) (result Decimal128)
- func Decimal128Int64Div(a Decimal128, b int64) (result Decimal128)
- func Decimal128Int64Mul(a Decimal128, b int64) (result Decimal128)
- func Decimal128Sub(a, b Decimal128, aScale, bScale int32) (result Decimal128)
- func Decimal128SubAligned(a, b Decimal128) (result Decimal128)
- func Decimal64Decimal64Div(a, b Decimal64, aScale, bScale int32) (result Decimal128)
- func Decimal64Decimal64Mul(a Decimal64, b Decimal64) (result Decimal128)
- func Decimal64ToDecimal128(a Decimal64) (result Decimal128)
- func DivideDecimal128By10(a Decimal128) (result Decimal128)
- func InitDecimal128(value int64) (result Decimal128)
- func InitDecimal128UsingUint(value uint64) (result Decimal128)
- func NegDecimal128(a Decimal128) (result Decimal128)
- func ParseStringToDecimal128(s string, precision, scale int32) (result Decimal128, err error)
- func ParseStringToDecimal128WithoutTable(s string) (result Decimal128, scale int32, err error)
- func ScaleDecimal128By10(a Decimal128) (result Decimal128)
- type Decimal64
- func AlignDecimal64UsingScaleDiffBatch(src, dst []Decimal64, scaleDiff int32) []Decimal64
- func Decimal64Add(a, b Decimal64, aScale, bScale int32) (result Decimal64)
- func Decimal64AddAligned(a, b Decimal64) (result Decimal64)
- func Decimal64Int64Mul(a Decimal64, b int64) (result Decimal64)
- func Decimal64Sub(a, b Decimal64, aScale, bScale int32) (result Decimal64)
- func Decimal64SubAligned(a, b Decimal64) (result Decimal64)
- func InitDecimal64(value int64, scale int64) (result Decimal64)
- func ParseStringToDecimal64(s string, precision, scale int32) (result Decimal64, err error)
- func ScaleDecimal64(a Decimal64, b int64) (result Decimal64)
- func ScaleDecimal64By10(a Decimal64) (result Decimal64)
- type Floats
- type Generic
- type IntervalType
- type Ints
- type Number
- type String
- type T
- type TimeType
- type Timestamp
- func DateToTimestamp(xs []Date, rs []Timestamp) ([]Timestamp, error)
- func DatetimeToTimestamp(xs []Datetime, rs []Timestamp) ([]Timestamp, error)
- func FromClockUTC(year int32, month, day, hour, min, sec uint8, msec uint32) Timestamp
- func NowUTC() Timestamp
- func ParseTimestamp(s string, precision int32) (Timestamp, error)
- func UnixToTimestamp(time int64) Timestamp
- type Type
- type UInts
- type Weekday
Constants ¶
const ( MaxDateYear = 9999 MinDateYear = 1 MaxMonthInYear = 12 MinMonthInYear = 1 )
const ( DateType = 0 DateTimeType = 1 TimeStampType = 2 )
const ( //secsPerWeek = 7 * secsPerDay //microSecondBitMask = 0xfffff MaxDatetimeYear = 9999 MinDatetimeYear = 1 )
const IntervalInt64MAX = int64(^uint64(0) >> 1)
const IntervalNumMAX = int32(^uint32(0) >> 1)
Variables ¶
var ( ErrIncorrectDateValue = errors.New(errno.DataException, "Incorrect date format") //regDate = regexp.MustCompile(`^(?P<year>[0-9]+)[-](?P<month>[0-9]+)[-](?P<day>[0-9]+)$`) ErrInvalidDateAddInterval = errors.New(errno.DataException, "Beyond the range of date") )
var ( ErrIncorrectDatetimeValue = errors.New(errno.DataException, "Incorrect datetime format") ErrInvalidDatetimeAddInterval = errors.New(errno.DataException, "Beyond the range of datetime") )
var Decimal128Max = Decimal128{}
var Decimal128Min = Decimal128{}
var (
ErrIntervalNumOverflow = errors.New(errno.DataException, "Interval num overflow")
)
var (
ErrInvalidTimestampAddInterval = errors.New(errno.DataException, "Beyond the range of timestamp")
)
var OneSecInMicroSeconds = uint32(1000000)
var Types map[string]T = map[string]T{ "bool": T_bool, "tinyint": T_int8, "smallint": T_int16, "int": T_int32, "integer": T_int32, "bigint": T_int64, "tinyint unsigned": T_uint8, "smallint unsigned": T_uint16, "int unsigned": T_uint32, "integer unsigned": T_uint32, "bigint unsigned": T_uint64, "decimal64": T_decimal64, "decimal128": T_decimal128, "float": T_float32, "double": T_float64, "date": T_date, "datetime": T_datetime, "timestamp": T_timestamp, "interval": T_interval, "char": T_char, "varchar": T_varchar, "json": T_json, }
Functions ¶
func AlignDecimal128UsingScaleDiffBatch ¶ added in v0.5.0
func AlignDecimal128UsingScaleDiffBatch(src, dst []Decimal128, scaleDiff int32)
void align_int128_using_scale_diff(void* src, void* dst, void* length, void* scale_diff) {
func AppendBoolToByteArray ¶ added in v0.5.0
func CompareDecimal128Decimal128 ¶
func CompareDecimal128Decimal128(a, b Decimal128, aScale, bScale int32) (result int64)
func CompareDecimal128Decimal128Aligned ¶
func CompareDecimal128Decimal128Aligned(a, b Decimal128) (result int64)
func CompareDecimal64Decimal64 ¶
CompareDecimal64Decimal64 returns -1 if a < b, returns 1 if a > b, returns 0 if a == b
func Decimal128IsNegative ¶
func Decimal128IsNegative(a Decimal128) (result bool)
func Decimal128IsNotZero ¶
func Decimal128IsNotZero(a Decimal128) (result bool)
func Decimal128IsPositive ¶ added in v0.5.0
func Decimal128IsPositive(a Decimal128) (result bool)
func Decimal128IsZero ¶
func Decimal128IsZero(a Decimal128) (result bool)
func JudgeIntervalNumOverflow ¶ added in v0.5.0
func JudgeIntervalNumOverflow(num int64, it IntervalType) error
func ModDecimal128By10Abs ¶
func ModDecimal128By10Abs(a Decimal128) (result int64)
func UnitIsDayOrLarger ¶ added in v0.5.0
func UnitIsDayOrLarger(it IntervalType) bool
if interval type unit is day or larger, we return true else return false use to judge a string whether need to become date/datetime type when we use date_add/sub(str string, interval type)
func ValidTimestamp ¶ added in v0.5.0
Types ¶
type Bytes ¶
func (*Bytes) AppendOnce ¶ added in v0.5.0
type Date ¶
type Date int32
func FromCalendar ¶
func ParseDate ¶
ParseDate will parse a string to be a Date Support Format: `yyyy-mm-dd` `yyyy-mm-d` `yyyy-m-dd` `yyyy-m-d` `yyyymmdd`
func ParseDateCast ¶ added in v0.5.0
ParseDate will parse a string to be a Date (this is used for cast string to date,it's different from above) Support Format: we exchange '.' with '-' anyway. `yyyy-mm-dd` `yyyymmdd` `yyyy-mm.dd` `yyyy-mm.dd hh` `yyyy-mm.dd hh:mm:ss` `yyyy-mm.dd hh:mm:ss.(msc)`
func (Date) WeekOfYear ¶
func (Date) WeekOfYear2 ¶ added in v0.5.0
func (Date) YearMonthStr ¶ added in v0.5.0
type Datetime ¶
type Datetime int64
func ParseDatetime ¶
ParseDatetime will parse a string to be a Datetime Support Format: 1. all the Date value 2. yyyy-mm-dd hh:mm:ss(.msec) now support mm/dd/hh/mm/ss can be single number 3. yyyymmddhhmmss(.msec) during parsing, the Datetime value will be rounded(away from zero) to the predefined precision, for example: Datetime(3) input string parsing result
"1999-09-09 11:11:11.1234" "1999-09-09 11:11:11.123" "1999-09-09 11:11:11.1235" "1999-09-09 11:11:11.124" "1999-09-09 11:11:11.9994" "1999-09-09 11:11:11.999" "1999-09-09 11:11:11.9995" "1999-09-09 11:11:12.000"
func TimestampToDatetime ¶ added in v0.5.0
func (Datetime) AddDateTime ¶ added in v0.5.0
func (Datetime) AddInterval ¶ added in v0.5.0
AddInterval now date or datetime use the function to add/sub date, we need a bool arg to tell isDate/isDatetime date/datetime have different regions, so we don't use same valid function return type bool means the if the date/datetime is valid
func (Datetime) ConvertToGoTime ¶ added in v0.5.0
func (Datetime) DayHourStr ¶ added in v0.5.0
func (Datetime) DayMicrosecondStr ¶ added in v0.5.0
func (Datetime) DayMinuteStr ¶ added in v0.5.0
func (Datetime) DaySecondStr ¶ added in v0.5.0
func (Datetime) HourMicrosecondStr ¶ added in v0.5.0
func (Datetime) HourMinuteStr ¶ added in v0.5.0
func (Datetime) HourSecondStr ¶ added in v0.5.0
func (Datetime) MinuteMicrosecondStr ¶ added in v0.5.0
func (Datetime) MinuteSecondStr ¶ added in v0.5.0
func (Datetime) SecondMicrosecondStr ¶ added in v0.5.0
func (Datetime) UnixTimestamp ¶ added in v0.5.0
func (Datetime) WeekOfYear ¶ added in v0.5.0
func (Datetime) YearMonthStr ¶ added in v0.5.0
type Decimal ¶ added in v0.5.0
type Decimal interface { Decimal64 | Decimal128 }
type Decimal128 ¶
func AddDecimal128ByInt64 ¶
func AddDecimal128ByInt64(a Decimal128, value int64) (result Decimal128)
func Decimal128Add ¶
func Decimal128Add(a, b Decimal128, aScale, bScale int32) (result Decimal128)
func Decimal128AddAligned ¶
func Decimal128AddAligned(a, b Decimal128) (result Decimal128)
func Decimal128Decimal128Div ¶
func Decimal128Decimal128Div(a, b Decimal128, aScale, bScale int32) (result Decimal128)
func Decimal128Decimal128DivAligned ¶ added in v0.5.0
func Decimal128Decimal128DivAligned(a, b Decimal128) (result Decimal128)
func Decimal128Decimal128Mul ¶
func Decimal128Decimal128Mul(a Decimal128, b Decimal128) (result Decimal128)
func Decimal128Int64Div ¶ added in v0.5.0
func Decimal128Int64Div(a Decimal128, b int64) (result Decimal128)
func Decimal128Int64Mul ¶ added in v0.5.0
func Decimal128Int64Mul(a Decimal128, b int64) (result Decimal128)
func Decimal128Sub ¶
func Decimal128Sub(a, b Decimal128, aScale, bScale int32) (result Decimal128)
func Decimal128SubAligned ¶
func Decimal128SubAligned(a, b Decimal128) (result Decimal128)
func Decimal64Decimal64Div ¶
func Decimal64Decimal64Div(a, b Decimal64, aScale, bScale int32) (result Decimal128)
func Decimal64Decimal64Mul ¶
func Decimal64Decimal64Mul(a Decimal64, b Decimal64) (result Decimal128)
func Decimal64ToDecimal128 ¶
func Decimal64ToDecimal128(a Decimal64) (result Decimal128)
func DivideDecimal128By10 ¶
func DivideDecimal128By10(a Decimal128) (result Decimal128)
func InitDecimal128 ¶
func InitDecimal128(value int64) (result Decimal128)
func InitDecimal128UsingUint ¶ added in v0.5.0
func InitDecimal128UsingUint(value uint64) (result Decimal128)
func NegDecimal128 ¶
func NegDecimal128(a Decimal128) (result Decimal128)
func ParseStringToDecimal128 ¶
func ParseStringToDecimal128(s string, precision, scale int32) (result Decimal128, err error)
func ParseStringToDecimal128WithoutTable ¶
func ParseStringToDecimal128WithoutTable(s string) (result Decimal128, scale int32, err error)
func ScaleDecimal128By10 ¶
func ScaleDecimal128By10(a Decimal128) (result Decimal128)
func (Decimal128) Decimal128ToString ¶
func (a Decimal128) Decimal128ToString(scale int32) []byte
type Decimal64 ¶
type Decimal64 int64
func AlignDecimal64UsingScaleDiffBatch ¶ added in v0.5.0
func Decimal64Add ¶
func Decimal64AddAligned ¶
func Decimal64Int64Mul ¶ added in v0.5.0
func Decimal64Sub ¶
func Decimal64SubAligned ¶
func InitDecimal64 ¶ added in v0.5.0
func ParseStringToDecimal64 ¶
todo: use strconv to simplify this code
func ScaleDecimal64 ¶
func ScaleDecimal64By10 ¶
func (Decimal64) Decimal64ToString ¶
type IntervalType ¶ added in v0.5.0
type IntervalType int8
const ( IntervalTypeInvalid IntervalType = iota MicroSecond Second Minute Hour Day Week Month Quarter Year Second_MicroSecond Minute_MicroSecond Minute_Second Hour_MicroSecond Hour_Second Hour_Minute Day_MicroSecond Day_Second Day_Minute Day_Hour Year_Month IntervalTypeMax )
func IntervalTypeOf ¶ added in v0.5.0
func IntervalTypeOf(s string) (IntervalType, error)
func NormalizeInterval ¶ added in v0.5.0
func NormalizeInterval(s string, it IntervalType) (ret int64, rettype IntervalType, err error)
func (IntervalType) String ¶ added in v0.5.0
func (it IntervalType) String() string
type T ¶
type T uint8
const ( // any family T_any T = T(plan.Type_ANY) // bool family T_bool T = T(plan.Type_BOOL) // numeric/integer family T_int8 T = T(plan.Type_INT8) T_int16 T = T(plan.Type_INT16) T_int32 T = T(plan.Type_INT32) T_int64 T = T(plan.Type_INT64) T_uint8 T = T(plan.Type_UINT8) T_uint16 T = T(plan.Type_UINT16) T_uint32 T = T(plan.Type_UINT32) T_uint64 T = T(plan.Type_UINT64) // numeric/float family - unsigned attribute is deprecated T_float32 T = T(plan.Type_FLOAT32) T_float64 T = T(plan.Type_FLOAT64) // date family T_date T = T(plan.Type_DATE) T_datetime T = T(plan.Type_DATETIME) T_timestamp T = T(plan.Type_TIMESTAMP) T_interval T = T(plan.Type_INTERVAL) T_time T = T(plan.Type_TIME) // string family T_char T = T(plan.Type_CHAR) T_varchar T = T(plan.Type_VARCHAR) // json family T_json T = T(plan.Type_JSON) // numeric/decimal family - unsigned attribute is deprecated T_decimal64 = T(plan.Type_DECIMAL64) T_decimal128 = T(plan.Type_DECIMAL128) // system family T_sel T = T(plan.Type_SEL) //selection T_tuple T = T(plan.Type_TUPLE) // immutable, size = 24 )
func (T) FixedLength ¶
dangerous code, use TypeLen() if you don't want -8, -16, -24
type Timestamp ¶ added in v0.5.0
type Timestamp int64
var TimestampMaxValue Timestamp
var TimestampMinValue Timestamp
func DateToTimestamp ¶ added in v0.5.0
func DatetimeToTimestamp ¶ added in v0.5.0
func FromClockUTC ¶ added in v0.5.0
FromClockUTC gets the utc time value in Timestamp
func ParseTimestamp ¶ added in v0.5.0
ParseTimestamp will parse a string to be a Timestamp Support Format: 1. all the Date value 2. yyyy-mm-dd hh:mm:ss(.msec) 3. yyyymmddhhmmss(.msec)
func UnixToTimestamp ¶ added in v0.5.0
type Type ¶
type Type struct { Oid T `json:"oid,string"` Size int32 `json:"size,string"` // e.g. int8.Size = 1, int16.Size = 2, char.Size = 24(SliceHeader size) // Width means max Display width for float and double, char and varchar // todo: need to add new attribute DisplayWidth ? Width int32 `json:"width,string"` Scale int32 `json:"Scale,string"` Precision int32 `json:"Precision,string"` }