value

package
v1.0.0-beta.122 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INDEX_MAX_STRING_LEN = 64
)
View Source
const (
	// SmallestNonZeroNormalFloat32 is the smallest positive non-zero floating number. The go package version
	// has the denormalized form which is higher than this.
	SmallestNonZeroNormalFloat32 = 0x1p-126
)

Variables

View Source
var EmptyCollation = NewCollation()

Functions

func AnyCompare

func AnyCompare(element any, v Value) int

func SecondaryMaxOrder

func SecondaryMaxOrder() int

func SecondaryMinOrder

func SecondaryMinOrder() int

func SecondaryNullOrder

func SecondaryNullOrder() int

func ToSecondaryOrder

func ToSecondaryOrder(dataType schema.FieldType, val Value) int

Types

type ArrayValue

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

func NewArrayValue

func NewArrayValue(v []byte, decoded []any) *ArrayValue

func (*ArrayValue) AsInterface

func (a *ArrayValue) AsInterface() any

func (*ArrayValue) CompareTo

func (a *ArrayValue) CompareTo(v Value) (int, error)

func (*ArrayValue) DataType

func (*ArrayValue) DataType() schema.FieldType

func (*ArrayValue) String

func (a *ArrayValue) String() string

type BoolValue

type BoolValue bool

func NewBoolValue

func NewBoolValue(v bool) *BoolValue

func (*BoolValue) AsInterface

func (b *BoolValue) AsInterface() any

func (*BoolValue) CompareTo

func (b *BoolValue) CompareTo(v Value) (int, error)

func (*BoolValue) DataType

func (*BoolValue) DataType() schema.FieldType

func (*BoolValue) String

func (b *BoolValue) String() string

type BytesValue

type BytesValue []byte

func NewBytesValue

func NewBytesValue(v []byte) *BytesValue

func (*BytesValue) AsInterface

func (b *BytesValue) AsInterface() any

func (*BytesValue) CompareTo

func (b *BytesValue) CompareTo(v Value) (int, error)

func (*BytesValue) DataType

func (*BytesValue) DataType() schema.FieldType

func (*BytesValue) String

func (b *BytesValue) String() string

type Collation

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

func NewCollation

func NewCollation() *Collation

func NewCollationFrom

func NewCollationFrom(apiCollation *api.Collation) *Collation

func NewSortKeyCollation

func NewSortKeyCollation() *Collation

NewSortKeyCollation is used for with the secondary index. We generate a sort key when storing a string in the index and also use it when comparing strings when filtering.

func (*Collation) CompareString

func (x *Collation) CompareString(a string, b string) int

CompareString returns an integer comparing the two strings. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.

func (*Collation) GenerateSortKey

func (x *Collation) GenerateSortKey(input string) []byte

func (*Collation) IsCaseInsensitive

func (x *Collation) IsCaseInsensitive() bool

func (*Collation) IsCaseSensitive

func (x *Collation) IsCaseSensitive() bool

func (*Collation) IsCollationSortKey

func (x *Collation) IsCollationSortKey() bool

func (*Collation) IsValid

func (x *Collation) IsValid() error

type Comparable

type Comparable interface {
	// CompareTo returns a value indicating the relationship between the receiver and the parameter.
	//
	// Returns a negative integer, zero, or a positive integer as the receiver is less than, equal
	// to, or greater than the parameter i.e. v1.CompareTo(v2) returns -1 if v1 < v2
	CompareTo(v Value) (int, error)
}

type DateTimeValue

type DateTimeValue struct {
	Value string
}

func NewDateTimeValue

func NewDateTimeValue(v string) *DateTimeValue

func (*DateTimeValue) AsInterface

func (d *DateTimeValue) AsInterface() any

func (*DateTimeValue) CompareTo

func (d *DateTimeValue) CompareTo(v Value) (int, error)

func (*DateTimeValue) DataType

func (*DateTimeValue) DataType() schema.FieldType

func (*DateTimeValue) String

func (d *DateTimeValue) String() string

type DoubleValue

type DoubleValue struct {
	Double float64

	Float *big.Float
	// contains filtered or unexported fields
}

func NewDoubleUsingFloat

func NewDoubleUsingFloat(v float64) *DoubleValue

func NewDoubleValue

func NewDoubleValue(raw string) (*DoubleValue, error)

func (*DoubleValue) AsInterface

func (d *DoubleValue) AsInterface() any

func (*DoubleValue) CompareTo

func (d *DoubleValue) CompareTo(v Value) (int, error)

func (*DoubleValue) DataType

func (*DoubleValue) DataType() schema.FieldType

func (*DoubleValue) String

func (d *DoubleValue) String() string

type IntValue

type IntValue int64

func NewIntValue

func NewIntValue(v int64) *IntValue

func (*IntValue) AsInterface

func (i *IntValue) AsInterface() any

func (*IntValue) CompareTo

func (i *IntValue) CompareTo(v Value) (int, error)

func (*IntValue) DataType

func (*IntValue) DataType() schema.FieldType

func (*IntValue) String

func (i *IntValue) String() string

type MaxValue

type MaxValue struct{}

func NewMaxValue

func NewMaxValue() *MaxValue

func (*MaxValue) AsInterface

func (*MaxValue) AsInterface() any

func (*MaxValue) CompareTo

func (*MaxValue) CompareTo(v Value) (int, error)

func (*MaxValue) DataType

func (*MaxValue) DataType() schema.FieldType

func (*MaxValue) String

func (*MaxValue) String() string

type NullValue

type NullValue struct{}

func NewNullValue

func NewNullValue() *NullValue

func (*NullValue) AsInterface

func (*NullValue) AsInterface() any

func (*NullValue) CompareTo

func (*NullValue) CompareTo(v Value) (int, error)

func (*NullValue) DataType

func (*NullValue) DataType() schema.FieldType

func (*NullValue) String

func (*NullValue) String() string

type StringValue

type StringValue struct {
	Value     string
	Collation *Collation
}

func NewStringValue

func NewStringValue(v string, collation *Collation) *StringValue

func (*StringValue) AsInterface

func (s *StringValue) AsInterface() any

func (*StringValue) CompareTo

func (s *StringValue) CompareTo(v Value) (int, error)

func (*StringValue) DataType

func (*StringValue) DataType() schema.FieldType

func (*StringValue) String

func (s *StringValue) String() string

type Value

type Value interface {
	fmt.Stringer
	Comparable

	// AsInterface to return the value as interface
	AsInterface() any
	DataType() schema.FieldType
}

Value is our value object that implements comparable so that two values can be compared. This is used to build the keys(primary key or any other index key), or to build the selector filter. Note: if the field data type is byte/binary then the value object returned is base64 decoded. The reason is that JSON has encoded the byte array to base64 so to make sure we are using the user provided value in building the key and the filter we must first decode this field. This allows us later to perform prefix scans.

func MaxOrderValue

func MaxOrderValue() Value

func MinOrderValue

func MinOrderValue() Value

func NewValue

func NewValue(fieldType schema.FieldType, value []byte) (Value, error)

NewValue returns the value of the field from the raw json value. It uses schema to get the type of the field.

func NewValueUsingCollation

func NewValueUsingCollation(fieldType schema.FieldType, value []byte, collation *Collation) (Value, error)

Jump to

Keyboard shortcuts

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