coerce

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IncompatibleTypes = errors.New("incompatible types")
View Source
var Overflow = errors.New("integer overflow: uint64 value too large for int64")

Functions

func ToBool

func ToBool(zv *zed.Value) (bool, bool)

func ToDuration

func ToDuration(in *zed.Value) (nano.Duration, bool)

ToDuration attempts to convert a value to a duration. Int and Double are converted as seconds. The resulting coerced value is written to out, and true is returned. If the value cannot be coerced, then false is returned.

func ToFloat

func ToFloat(zv *zed.Value) (float64, bool)

func ToInt

func ToInt(zv *zed.Value) (int64, bool)

func ToTime

func ToTime(zv *zed.Value) (nano.Ts, bool)

func ToUint

func ToUint(zv *zed.Value) (uint64, bool)

Types

type Pair

type Pair struct {
	// a and b point to inputs that can't change
	A zcode.Bytes
	B zcode.Bytes
	// Buffer is a scratch buffer that stays around between calls and is the
	// landing place for either the a or b value if one of them needs to
	// be coerced (you never need to coerce both).  Then we point a or b
	// at buf and let go of the other input pointer.
	result.Buffer
	// contains filtered or unexported fields
}

Pair provides a buffer to decode values into while doing comparisons so the same buffers can be reused on each call without zcode.Bytes buffers escaping to GC. This method uses the zed.AppendInt(), zed.AppendUint(), etc to encode zcode.Bytes as an in-place slice instead of allocating new slice buffers for every value created.

func (*Pair) Coerce

func (c *Pair) Coerce(a, b *zed.Value) (int, error)

func (*Pair) Equal

func (c *Pair) Equal() bool

Jump to

Keyboard shortcuts

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