value

package
v1.0.0-preview-2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package value holds Kusto data value representations. All types provide a Kusto that stores the native value and Valid which indicates if the value was set or was null.

Kusto Value

A value.Kusto can hold types that represent Kusto Scalar types that define column data. We represent that with an interface:

type Kusto interface

This interface can hold the following values:

value.Bool
value.Int
value.Long
value.Real
value.Decimal
value.String
value.Dynamic
value.DateTime
value.Timespan

Each type defined above has at minimum two fields:

.Value - The type specific value
.Valid - True if the value was non-null in the Kusto table

Each provides at minimum the following two methods:

.String() - Returns the string representation of the value.
.Unmarshal() - Unmarshals the value into a standard Go type.

The Unmarshal() is for internal use, it should not be needed by an end user. Use .Value or table.Row.ToStruct() instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert[T any](holder interface{}, p *pointerValue[T], v reflect.Value) error

func TimespanString

func TimespanString(d time.Duration) string

func TryConvert

func TryConvert[T any](holder interface{}, p *pointerValue[T], v reflect.Value) bool

Types

type Bool

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

Bool represents a Kusto boolean type. Bool implements Kusto.

func NewBool

func NewBool(v bool) *Bool

func NewNullBool

func NewNullBool() *Bool

func (*Bool) Convert

func (bo *Bool) Convert(v reflect.Value) error

Convert Bool into reflect value.

func (*Bool) GetType

func (bo *Bool) GetType() types.Column

GetType returns the type of the value.

func (*Bool) GetValue

func (p *Bool) GetValue() interface{}

func (*Bool) Ptr

func (p *Bool) Ptr() *T

func (*Bool) String

func (p *Bool) String() string

func (*Bool) Unmarshal

func (p *Bool) Unmarshal(i interface{}) error

type DateTime

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

DateTime represents a Kusto datetime type. DateTime implements Kusto.

func NewDateTime

func NewDateTime(v time.Time) *DateTime

NewDateTime creates a new DateTime.

func NewNullDateTime

func NewNullDateTime() *DateTime

NewNullDateTime creates a new null DateTime.

func (*DateTime) Convert

func (d *DateTime) Convert(v reflect.Value) error

Convert DateTime into reflect value.

func (*DateTime) GetType

func (d *DateTime) GetType() types.Column

GetType returns the type of the value.

func (*DateTime) GetValue

func (p *DateTime) GetValue() interface{}

func (*DateTime) Marshal

func (d *DateTime) Marshal() string

Marshal marshals the DateTime into a Kusto compatible string.

func (*DateTime) Ptr

func (p *DateTime) Ptr() *T

func (*DateTime) String

func (d *DateTime) String() string

String implements fmt.Stringer.

func (*DateTime) Unmarshal

func (d *DateTime) Unmarshal(i interface{}) error

Unmarshal unmarshals i into DateTime. i must be a string representing RFC3339Nano or nil.

type Decimal

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

Decimal represents a Kusto decimal type. Decimal implements Kusto.

func DecimalFromFloat

func DecimalFromFloat(f float64) *Decimal

func DecimalFromString

func DecimalFromString(s string) *Decimal

func NewDecimal

func NewDecimal(v decimal.Decimal) *Decimal

func NewNullDecimal

func NewNullDecimal() *Decimal

func (*Decimal) Convert

func (d *Decimal) Convert(v reflect.Value) error

Convert Decimal into reflect value.

func (*Decimal) GetType

func (d *Decimal) GetType() types.Column

GetType returns the type of the value.

func (*Decimal) GetValue

func (p *Decimal) GetValue() interface{}

func (*Decimal) ParseFloat

func (d *Decimal) ParseFloat(base int, prec uint, mode big.RoundingMode) (f *big.Float, b int, err error)

ParseFloat provides builtin support for Go's *big.Float conversion where that type meets your needs.

func (*Decimal) Ptr

func (p *Decimal) Ptr() *T

func (*Decimal) String

func (p *Decimal) String() string

func (*Decimal) Unmarshal

func (d *Decimal) Unmarshal(i interface{}) error

Unmarshal unmarshals i into Decimal. i must be a string representing a decimal type or nil.

type Dynamic

type Dynamic struct {
	Value []byte
}

Dynamic represents a Kusto dynamic type. Dynamic implements Kusto.

func DynamicFromInterface

func DynamicFromInterface(v interface{}) *Dynamic

func NewDynamic

func NewDynamic(v []byte) *Dynamic

NewDynamic creates a new Dynamic.

func NewNullDynamic

func NewNullDynamic() *Dynamic

NewNullDynamic creates a new null Dynamic.

func (*Dynamic) Convert

func (d *Dynamic) Convert(v reflect.Value) error

Convert Dynamic into reflect value.

func (*Dynamic) GetType

func (d *Dynamic) GetType() types.Column

GetType returns the type of the value.

func (*Dynamic) GetValue

func (d *Dynamic) GetValue() interface{}

func (*Dynamic) String

func (d *Dynamic) String() string

func (*Dynamic) Unmarshal

func (d *Dynamic) Unmarshal(i interface{}) error

Unmarshal unmarshal's i into Dynamic. i must be a string, []byte, map[string]interface{}, []interface{}, other JSON serializable value or nil. If []byte or string, must be a JSON representation of a value.

type GUID

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

GUID represents a Kusto GUID type. GUID implements Kusto.

func NewGUID

func NewGUID(v uuid.UUID) *GUID

NewGUID creates a new GUID.

func NewNullGUID

func NewNullGUID() *GUID

NewNullGUID creates a new null GUID.

func (*GUID) Convert

func (g *GUID) Convert(v reflect.Value) error

Convert GUID into reflect value.

func (*GUID) GetType

func (g *GUID) GetType() types.Column

GetType returns the type of the value.

func (*GUID) GetValue

func (p *GUID) GetValue() interface{}

func (*GUID) Ptr

func (p *GUID) Ptr() *T

func (*GUID) String

func (p *GUID) String() string

func (*GUID) Unmarshal

func (g *GUID) Unmarshal(i interface{}) error

Unmarshal unmarshals i into GUID. i must be a string representing a GUID or nil.

type Int

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

Int represents a Kusto boolean type. Bool implements Kusto.

func NewInt

func NewInt(v int32) *Int

func NewNullInt

func NewNullInt() *Int

func (*Int) Convert

func (in *Int) Convert(v reflect.Value) error

Convert Int into reflect value.

func (*Int) GetType

func (in *Int) GetType() types.Column

GetType returns the type of the value.

func (*Int) GetValue

func (p *Int) GetValue() interface{}

func (*Int) Ptr

func (p *Int) Ptr() *T

func (*Int) String

func (p *Int) String() string

func (*Int) Unmarshal

func (in *Int) Unmarshal(i interface{}) error

type Kusto

type Kusto interface {
	fmt.Stringer
	Convert(v reflect.Value) error
	GetValue() interface{}
	GetType() types.Column
	Unmarshal(interface{}) error
}

Kusto represents a Kusto value.

func Default

func Default(t types.Column) Kusto

type Long

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

Long represents a Kusto long type, which is an int64. Long implements Kusto.

func NewLong

func NewLong(i int64) *Long

func NewNullLong

func NewNullLong() *Long

func (*Long) Convert

func (l *Long) Convert(v reflect.Value) error

Convert Long into reflect value.

func (*Long) GetType

func (l *Long) GetType() types.Column

GetType returns the type of the value.

func (*Long) GetValue

func (p *Long) GetValue() interface{}

func (*Long) Ptr

func (p *Long) Ptr() *T

func (*Long) String

func (p *Long) String() string

func (*Long) Unmarshal

func (l *Long) Unmarshal(i interface{}) error

Unmarshal unmarshals i into Long. i must be an int64 or nil.

type Real

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

Real represents a Kusto real type. Real implements Kusto.

func NewNullReal

func NewNullReal() *Real

func NewReal

func NewReal(i float64) *Real

func (*Real) Convert

func (r *Real) Convert(v reflect.Value) error

Convert Real into reflect value.

func (*Real) GetType

func (r *Real) GetType() types.Column

GetType returns the type of the value.

func (*Real) GetValue

func (p *Real) GetValue() interface{}

func (*Real) Ptr

func (p *Real) Ptr() *T

func (*Real) String

func (p *Real) String() string

func (*Real) Unmarshal

func (r *Real) Unmarshal(i interface{}) error

Unmarshal unmarshals i into Real. i must be a json.Number(that is a float64), float64 or nil.

type String

type String struct {
	// Value holds the value of the type.
	Value string
}

String represents a Kusto string type. String implements Kusto.

func NewString

func NewString(v string) *String

func (*String) Convert

func (s *String) Convert(v reflect.Value) error

Convert String into reflect value.

func (*String) GetType

func (s *String) GetType() types.Column

GetType returns the type of the value.

func (*String) GetValue

func (s *String) GetValue() interface{}

GetValue returns the value of the type.

func (*String) String

func (s *String) String() string

String implements fmt.Stringer.

func (*String) Unmarshal

func (s *String) Unmarshal(i interface{}) error

Unmarshal unmarshals i into String. i must be a string or nil.

type Timespan

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

Timespan represents a Kusto timespan type. Timespan implements Kusto.

func NewNullTimespan

func NewNullTimespan() *Timespan

func NewTimespan

func NewTimespan(v time.Duration) *Timespan

func TimespanFromString

func TimespanFromString(s string) (*Timespan, error)

func (*Timespan) Convert

func (t *Timespan) Convert(v reflect.Value) error

Convert Timespan into reflect value.

func (*Timespan) GetType

func (t *Timespan) GetType() types.Column

GetType returns the type of the value.

func (*Timespan) GetValue

func (p *Timespan) GetValue() interface{}

func (*Timespan) Marshal

func (t *Timespan) Marshal() string

Marshal marshals the Timespan into a Kusto compatible string. The string is the contant invariant(c) format. See https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings .

func (*Timespan) Ptr

func (p *Timespan) Ptr() *T

func (*Timespan) String

func (p *Timespan) String() string

func (*Timespan) Unmarshal

func (t *Timespan) Unmarshal(i interface{}) error

Unmarshal unmarshals i into Timespan. i must be a string representing a Values timespan or nil.

type Values

type Values []Kusto

Values is a list of Kusto values, usually an ordered row.

Jump to

Keyboard shortcuts

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