types

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MaxDateYear    = 9999
	MinDateYear    = 0
	MaxMonthInYear = 12
	MinMonthInYear = 1
)

Variables

View Source
var Types map[string]T = map[string]T{
	"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,

	"char":    T_char,
	"varchar": T_varchar,

	"json": T_json,
}

Functions

func CompareDecimal128Decimal128

func CompareDecimal128Decimal128(a, b Decimal128, aScale, bScale int32) (result int64)

func CompareDecimal128Decimal128Aligned

func CompareDecimal128Decimal128Aligned(a, b Decimal128) (result int64)

func CompareDecimal64Decimal64

func CompareDecimal64Decimal64(a, b Decimal64, aScale, bScale int32) (result int64)

func CompareDecimal64Decimal64Aligned

func CompareDecimal64Decimal64Aligned(a, b Decimal64) (result int64)

func Decimal128IsNegative

func Decimal128IsNegative(a Decimal128) (result bool)

func Decimal128IsNotZero

func Decimal128IsNotZero(a Decimal128) (result bool)

func Decimal128IsZero

func Decimal128IsZero(a Decimal128) (result bool)

func ModDecimal128By10Abs

func ModDecimal128By10Abs(a Decimal128) (result int64)

Types

type Bytes

type Bytes struct {
	Data    []byte
	Offsets []uint32
	Lengths []uint32
}

func (*Bytes) Append

func (a *Bytes) Append(vs [][]byte) error

func (*Bytes) Get

func (a *Bytes) Get(n int64) []byte

func (*Bytes) Reset

func (a *Bytes) Reset()

func (*Bytes) String

func (a *Bytes) String() string

func (*Bytes) Swap

func (a *Bytes) Swap(i, j int64)

func (*Bytes) Window

func (a *Bytes) Window(start, end int) *Bytes

type Date

type Date int32

func FromCalendar

func FromCalendar(year int32, month, day uint8) Date

func ParseDate

func ParseDate(s string) (Date, error)

ParseDate will parse a string to be a Date Support Format: `yyyy-mm-dd` `yyyymmdd`

func Today

func Today() Date

Holds number of days since January 1, year 1 in Gregorian calendar

func (Date) Calendar

func (d Date) Calendar(full bool) (year int32, month, day uint8, yday uint16)

func (Date) DayOfWeek

func (d Date) DayOfWeek() Weekday

func (Date) DayOfYear

func (d Date) DayOfYear() uint16

func (Date) Month

func (d Date) Month() uint8

func (Date) String

func (d Date) String() string

func (Date) ToTime

func (d Date) ToTime() Datetime

func (Date) WeekOfYear

func (d Date) WeekOfYear() (year int32, week uint8)

func (Date) Year

func (d Date) Year() uint16

Year takes a date and returns an uint16 number as the year of this date

type Datetime

type Datetime int64

func FromClock

func FromClock(year int32, month, day, hour, min, sec uint8, msec uint32) Datetime

func Now

func Now() Datetime

func ParseDatetime

func ParseDatetime(s string) (Datetime, error)

ParseDatetime will parse a string to be a Datetime Support Format: 1. all the Date value 2. yyyy-mm-dd hh:mm:ss(.msec) 3. yyyymmddhhmmss(.msec)

func (Datetime) Clock

func (dt Datetime) Clock() (hour, min, sec int8)

func (Datetime) Month

func (dt Datetime) Month() uint8

func (Datetime) String

func (dt Datetime) String() string

func (Datetime) ToDate

func (dt Datetime) ToDate() Date

func (Datetime) UTC

func (dt Datetime) UTC() Datetime

UTC turn local datetime to utc datetime

func (Datetime) Year

func (dt Datetime) Year() uint16

type Decimal128

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

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 Decimal128Decimal128Mul

func Decimal128Decimal128Mul(a Decimal128, b Decimal128) (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 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 Decimal64Add

func Decimal64Add(a, b Decimal64, aScale, bScale int32) (result Decimal64)

func Decimal64AddAligned

func Decimal64AddAligned(a, b Decimal64) (result Decimal64)

func Decimal64Sub

func Decimal64Sub(a, b Decimal64, aScale, bScale int32) (result Decimal64)

func Decimal64SubAligned

func Decimal64SubAligned(a, b Decimal64) (result Decimal64)

func ParseStringToDecimal64

func ParseStringToDecimal64(s string, precision, scale int32) (result Decimal64, err error)

todo: use strconv to simplify this code

func ScaleDecimal64

func ScaleDecimal64(a Decimal64, b int64) (result Decimal64)

func ScaleDecimal64By10

func ScaleDecimal64By10(a Decimal64) (result Decimal64)

func (Decimal64) Decimal64ToString

func (a Decimal64) Decimal64ToString(scale int32) []byte

type T

type T uint8
const (
	// any family
	T_any T = T(plan.Type_ANY)

	// 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)

	// 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

func (t T) FixedLength() int

func (T) GoGoType

func (t T) GoGoType() string

GoGoType returns special go type string for T

func (T) GoType

func (t T) GoType() string

GoType returns go type string for T

func (T) OidString

func (t T) OidString() string

OidString returns T string

func (T) String

func (t T) String() string

func (T) ToType

func (t T) ToType() Type

func (T) TypeLen

func (t T) TypeLen() int

TypeLen returns type's length whose type oid is T

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"`
}

func (Type) Eq

func (a Type) Eq(b Type) bool

func (Type) String

func (t Type) String() string

type Weekday

type Weekday uint8
const (
	Sunday Weekday = iota
	Monday
	Tuesday
	Wednesday
	Thursday
	Friday
	Saturday
)

Jump to

Keyboard shortcuts

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