internal

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VoidValue = Value{
	// contains filtered or unexported fields
}

Functions

func BigEndianUint128

func BigEndianUint128(hi, lo uint64) (v [16]byte)

BigEndianUint128 builds a big-endian uint128 value.

func Compare

func Compare(l, r V) (int, error)

Compare compares its operands. It returns -1, 0, 1 if l < r, l == r, l > r. Returns error if types are not comparable. Comparable types are all integer types, UUID, DyNumber, Float, Double, String, UTF8, Date, Datetime, Timestamp, Tuples and Lists. Primitive arguments are comparable if their types are the same. Optional type is comparable to underlying type, e.g. Optional<Optional<Float>> is comparable to Float. Null value is comparable to non-null value of the same type and is considered less than any non-null value. Tuples and Lists are comparable if their elements are comparable. Tuples and Lists are compared lexicographically. If tuples (lists) have different length and elements of the shorter tuple (list) are all equal to corresponding elements of the other tuple (list), than the shorter tuple (list) is considered less than the longer one.

func MarshalDate

func MarshalDate(t time.Time) uint32

func MarshalDatetime

func MarshalDatetime(t time.Time) uint32

func MarshalInterval

func MarshalInterval(d time.Duration) int64

func MarshalTimestamp

func MarshalTimestamp(t time.Time) uint64

func MarshalTzDate

func MarshalTzDate(t time.Time) string

func MarshalTzDatetime

func MarshalTzDatetime(t time.Time) string

func MarshalTzTimestamp

func MarshalTzTimestamp(t time.Time) string

func PrimitiveFromYDB

func PrimitiveFromYDB(x *Ydb.Value) (v interface{})

PrimitiveFromYDB returns a primitive value stored in x. Currently it may return one of this types:

bool
int32
uint32
int64
uint64
float32
float64
[]byte
string
[16]byte

Or nil.

func TypeToYDB

func TypeToYDB(t T) *Ydb.Type

func TypesEqual

func TypesEqual(a, b T) bool

func UnmarshalDate

func UnmarshalDate(n uint32) time.Time

Up to 11761191-01-20 00:00:00 +0000 UTC.

func UnmarshalDatetime

func UnmarshalDatetime(n uint32) time.Time

Up to 2106-02-07 06:28:15 +0000 UTC.

func UnmarshalInterval

func UnmarshalInterval(n int64) time.Duration

Up to ±292 years.

func UnmarshalTimestamp

func UnmarshalTimestamp(n uint64) time.Time

Up to 586524-01-19 08:01:49.000551615 +0000 UTC.

func UnmarshalTzDate

func UnmarshalTzDate(s string) (time.Time, error)

func UnmarshalTzDatetime

func UnmarshalTzDatetime(s string) (time.Time, error)

func UnmarshalTzTimestamp

func UnmarshalTzTimestamp(s string) (time.Time, error)

func ValueToYDB

func ValueToYDB(v V) *Ydb.TypedValue

func WriteTypeStringTo

func WriteTypeStringTo(buf *bytes.Buffer, t T)

func WriteValueStringTo

func WriteValueStringTo(buf *bytes.Buffer, v V)

Types

type DecimalType

type DecimalType struct {
	Precision uint32
	Scale     uint32
}

func (DecimalType) String

func (d DecimalType) String() string

type DictType

type DictType struct {
	Key     T
	Payload T
}

func (DictType) String

func (d DictType) String() string

type FeatureFlag

type FeatureFlag int
const (
	FeatureUnknown FeatureFlag = iota
	FeatureEnabled
	FeatureDisabled
)

func FeatureFlagFromYDB

func FeatureFlagFromYDB(f Ydb.FeatureFlag_Status) FeatureFlag

func (FeatureFlag) ToYDB

type ListType

type ListType struct {
	T T
}

func (ListType) String

func (l ListType) String() string

type NoOpResponse

type NoOpResponse interface {
	proto.Message
	GetStatus() Ydb.StatusIds_StatusCode
	GetIssues() []*Ydb_Issue.IssueMessage
}

type OpResponse

type OpResponse interface {
	proto.Message
	GetOperation() *Ydb_Operations.Operation
}

type Operation

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

func Wrap

func Wrap(method string, req, res proto.Message) Operation

func WrapWithResponse

func WrapWithResponse(method string, req proto.Message, resp Response) Operation

type OptionalType

type OptionalType struct {
	T T
}

func (OptionalType) String

func (opt OptionalType) String() string

type PrimitiveType

type PrimitiveType int
const (
	TypeUnknown PrimitiveType = iota
	TypeBool
	TypeInt8
	TypeUint8
	TypeInt16
	TypeUint16
	TypeInt32
	TypeUint32
	TypeInt64
	TypeUint64
	TypeFloat
	TypeDouble
	TypeDate
	TypeDatetime
	TypeTimestamp
	TypeInterval
	TypeTzDate
	TypeTzDatetime
	TypeTzTimestamp
	TypeString
	TypeUTF8
	TypeYSON
	TypeJSON
	TypeUUID
	TypeJSONDocument
	TypeDyNumber
)

Primitive TypesFromYDB known by YDB.

func (PrimitiveType) String

func (t PrimitiveType) String() string

type Response

type Response interface {
	GetOpReady() bool
	GetOpID() string
	GetStatus() Ydb.StatusIds_StatusCode
	GetIssues() []*Ydb_Issue.IssueMessage
	GetResult() *any.Any
	GetResponseProto() proto.Message
}

func Unwrap

func Unwrap(op Operation) (method string, req, res proto.Message, resp Response)

func WrapNoOpResponse

func WrapNoOpResponse(resp NoOpResponse) Response

func WrapOpResponse

func WrapOpResponse(resp OpResponse) Response

type StreamOperation

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

func WrapStreamOperation

func WrapStreamOperation(
	method string, req proto.Message,
	resp StreamOperationResponse,
	p func(error),
) StreamOperation

type StreamOperationResponse

type StreamOperationResponse interface {
	GetStatus() Ydb.StatusIds_StatusCode
	GetIssues() []*Ydb_Issue.IssueMessage
}

StreamOperationResponse is an interface that provides access to the API-specific response fields.

NOTE: YDB API currently does not provide generic response wrapper as it does with RPC API. Thus wee need to generalize it by the hand using this interface.

This generalization is needed for checking status codes and issues in one place.

func UnwrapStreamOperation

func UnwrapStreamOperation(op StreamOperation) (
	method string, req proto.Message,
	resp StreamOperationResponse,
	processor func(error),
)

type StructField

type StructField struct {
	Name string
	Type T
}

func StructFields

func StructFields(ms []*Ydb.StructMember) []StructField

type StructType

type StructType struct {
	Fields []StructField
}

func (StructType) Empty

func (s StructType) Empty() bool

func (StructType) Members

func (s StructType) Members() []*Ydb.StructMember

func (StructType) String

func (s StructType) String() string

type StructValueProto

type StructValueProto struct {
	Fields []StructField
	Values []*Ydb.Value
}

func (*StructValueProto) Add

func (s *StructValueProto) Add(name string, value V)

type T

type T interface {
	// contains filtered or unexported methods
}

func Dict

func Dict(key, payload T) T

func TypeFromYDB

func TypeFromYDB(x *Ydb.Type) T

func TypesFromYDB

func TypesFromYDB(es []*Ydb.Type) []T

type TupleType

type TupleType struct {
	Elems []T
}

func (TupleType) Elements

func (t TupleType) Elements() []*Ydb.Type

func (TupleType) Empty

func (t TupleType) Empty() bool

func (TupleType) String

func (t TupleType) String() string

type V

type V interface {
	// contains filtered or unexported methods
}

func ValueFromYDB

func ValueFromYDB(t *Ydb.Type, v *Ydb.Value) V

type Value

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

func BoolValue

func BoolValue(v bool) Value

func DateValue

func DateValue(v uint32) Value

func DatetimeValue

func DatetimeValue(v uint32) Value

func DecimalValue

func DecimalValue(t T, v [16]byte) Value

func DictValue

func DictValue(n int, it func(int) V) Value

func DoubleValue

func DoubleValue(v float64) Value

func DyNumberValue

func DyNumberValue(v string) Value

func FloatValue

func FloatValue(v float32) Value

func Int16Value

func Int16Value(v int16) Value

func Int32Value

func Int32Value(v int32) Value

func Int64Value

func Int64Value(v int64) Value

func Int8Value

func Int8Value(v int8) Value

func IntervalValue

func IntervalValue(v int64) Value

func JSONDocumentValue

func JSONDocumentValue(v string) Value

func JSONValue

func JSONValue(v string) Value

func ListValue

func ListValue(n int, it func(int) V) Value

It panics if vs is empty or contains not equal types.

func NullValue

func NullValue(t T) Value

NullValue returns NULL value of given type T.

For example, if T is Int32Type, then NullValue(Int32Type) will return value of type Optional<Int32Type> with NULL value.

Nested optional types are handled also.

func OptionalValue

func OptionalValue(v V) Value

func StringValue

func StringValue(v []byte) Value

func StructValue

func StructValue(p *StructValueProto) Value

func TimestampValue

func TimestampValue(v uint64) Value

func TupleValue

func TupleValue(n int, it func(int) V) Value

func TzDateValue

func TzDateValue(v string) Value

func TzDatetimeValue

func TzDatetimeValue(v string) Value

func TzTimestampValue

func TzTimestampValue(v string) Value

func UTF8Value

func UTF8Value(v string) Value

func UUIDValue

func UUIDValue(v [16]byte) Value

func Uint16Value

func Uint16Value(v uint16) Value

func Uint32Value

func Uint32Value(v uint32) Value

func Uint64Value

func Uint64Value(v uint64) Value

func Uint8Value

func Uint8Value(v uint8) Value

func VariantValue

func VariantValue(x V, i uint32, t T) Value

func YSONValue

func YSONValue(v string) Value

func ZeroValue

func ZeroValue(t T) Value

func (Value) String

func (v Value) String() string

type VariantType

type VariantType struct {
	S StructType
	T TupleType
}

func (VariantType) String

func (v VariantType) String() string

type VoidType

type VoidType struct{}

func (VoidType) String

func (v VoidType) String() string

Directories

Path Synopsis
cache
lru
Package ydbtest provides tools for stubbing ydb server up.
Package ydbtest provides tools for stubbing ydb server up.
Package ydbtypes provides tools for integration ydb types with go/types package.
Package ydbtypes provides tools for integration ydb types with go/types package.

Jump to

Keyboard shortcuts

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