Documentation ¶
Index ¶
- Constants
- Variables
- func AppendBool(zb zcode.Bytes, b bool) zcode.Bytes
- func AppendDuration(bytes zcode.Bytes, d nano.Duration) zcode.Bytes
- func AppendFloat32(zb zcode.Bytes, f float32) zcode.Bytes
- func AppendFloat64(zb zcode.Bytes, d float64) zcode.Bytes
- func AppendIP(zb zcode.Bytes, a net.IP) zcode.Bytes
- func AppendInt(bytes zcode.Bytes, i int64) zcode.Bytes
- func AppendNet(zb zcode.Bytes, subnet *net.IPNet) zcode.Bytes
- func AppendTime(bytes zcode.Bytes, t nano.Ts) zcode.Bytes
- func AppendUint(bytes zcode.Bytes, i uint64) zcode.Bytes
- func ContainedType(typ Type) (Type, []Column)
- func DecodeBool(zv zcode.Bytes) (bool, error)
- func DecodeBytes(zv zcode.Bytes) ([]byte, error)
- func DecodeDuration(zv zcode.Bytes) (nano.Duration, error)
- func DecodeError(zv zcode.Bytes) (error, error)
- func DecodeFloat(zb zcode.Bytes) (float64, error)
- func DecodeFloat32(zb zcode.Bytes) (float32, error)
- func DecodeFloat64(zv zcode.Bytes) (float64, error)
- func DecodeIP(zv zcode.Bytes) (net.IP, error)
- func DecodeInt(zv zcode.Bytes) (int64, error)
- func DecodeNet(zv zcode.Bytes) (*net.IPNet, error)
- func DecodeString(zv zcode.Bytes) (string, error)
- func DecodeTime(zv zcode.Bytes) (nano.Ts, error)
- func DecodeUint(zv zcode.Bytes) (uint64, error)
- func EncodeBool(b bool) zcode.Bytes
- func EncodeBytes(b []byte) zcode.Bytes
- func EncodeDuration(d nano.Duration) zcode.Bytes
- func EncodeError(err error) zcode.Bytes
- func EncodeFloat32(d float32) zcode.Bytes
- func EncodeFloat64(d float64) zcode.Bytes
- func EncodeIP(a net.IP) zcode.Bytes
- func EncodeInt(i int64) zcode.Bytes
- func EncodeNet(subnet *net.IPNet) zcode.Bytes
- func EncodeString(s string) zcode.Bytes
- func EncodeTime(t nano.Ts) zcode.Bytes
- func EncodeTypeValue(t Type) zcode.Bytes
- func EncodeUint(i uint64) zcode.Bytes
- func IDChar(c rune) bool
- func IsContainerType(typ Type) bool
- func IsIdentifier(s string) bool
- func IsPrimitiveType(typ Type) bool
- func IsRecordType(typ Type) bool
- func IsTrue(zv zcode.Bytes) bool
- func IsTypeName(s string) bool
- func IsUnionType(typ Type) bool
- func TypeChar(c rune) bool
- func TypeID(typ Type) int
- type Allocator
- type Column
- type CompressionFormat
- type Context
- func (c *Context) Lookup(id int) *TypeRecord
- func (c *Context) LookupByValue(tv zcode.Bytes) (Type, error)
- func (c *Context) LookupType(id int) (Type, error)
- func (c *Context) LookupTypeArray(inner Type) *TypeArray
- func (c *Context) LookupTypeDef(name string) *TypeNamed
- func (c *Context) LookupTypeEnum(symbols []string) *TypeEnum
- func (c *Context) LookupTypeMap(keyType, valType Type) *TypeMap
- func (c *Context) LookupTypeNamed(name string, target Type) (*TypeNamed, error)
- func (c *Context) LookupTypeRecord(columns []Column) (*TypeRecord, error)
- func (c *Context) LookupTypeSet(inner Type) *TypeSet
- func (c *Context) LookupTypeUnion(types []Type) *TypeUnion
- func (c *Context) LookupTypeValue(typ Type) *Value
- func (c *Context) MustLookupTypeRecord(columns []Column) *TypeRecord
- func (c *Context) Reset()
- func (c *Context) TranslateType(ext Type) (Type, error)
- func (t *Context) TranslateTypeRecord(ext *TypeRecord) (*TypeRecord, error)
- type Type
- type TypeArray
- type TypeEnum
- type TypeMap
- type TypeNamed
- type TypeOfBool
- type TypeOfBstring
- type TypeOfBytes
- type TypeOfDuration
- type TypeOfError
- type TypeOfFloat32
- type TypeOfFloat64
- type TypeOfIP
- type TypeOfInt16
- type TypeOfInt32
- type TypeOfInt64
- type TypeOfInt8
- type TypeOfNet
- type TypeOfNull
- type TypeOfString
- type TypeOfTime
- type TypeOfType
- type TypeOfUint16
- type TypeOfUint32
- type TypeOfUint64
- type TypeOfUint8
- type TypeRecord
- type TypeSet
- type TypeUnion
- type Value
- func NewBool(b bool) *Value
- func NewBstring(s string) *Value
- func NewBytes(b []byte) *Value
- func NewDuration(d nano.Duration) *Value
- func NewError(err error) *Value
- func NewErrorf(format string, args ...interface{}) *Value
- func NewFloat32(f float32) *Value
- func NewFloat64(f float64) *Value
- func NewIP(a net.IP) *Value
- func NewNet(s *net.IPNet) *Value
- func NewString(s string) *Value
- func NewTime(ts nano.Ts) *Value
- func NewTypeValue(t Type) *Value
- func NewUint64(v uint64) *Value
- func NewValue(zt Type, zb zcode.Bytes) *Value
- func Not(zb zcode.Bytes) *Value
Constants ¶
const ( MaxColumns = 100_000 MaxEnumSymbols = 100_000 MaxUnionTypes = 100_000 )
const ( IDUint8 = 0 IDUint16 = 1 IDUint32 = 2 IDUint64 = 3 IDInt8 = 4 IDInt16 = 5 IDInt32 = 6 IDInt64 = 7 IDDuration = 8 IDTime = 9 IDFloat16 = 10 IDFloat32 = 11 IDFloat64 = 12 IDDecimal = 13 IDBool = 14 IDBytes = 15 IDString = 16 IDBstring = 17 IDIP = 18 IDNet = 19 IDType = 20 IDError = 21 IDNull = 22 IDTypeDef = 23 // 0x17 IDTypeName = 24 // 0x18 IDTypeRecord = 25 // 0x19 IDTypeArray = 26 // 0x20 IDTypeSet = 27 // 0x21 IDTypeUnion = 28 // 0x22 IDTypeEnum = 29 // 0x23 IDTypeMap = 30 // 0x24 )
const ( CtrlValueEscape = 0xf5 TypeDefRecord = 0xf6 TypeDefArray = 0xf7 TypeDefSet = 0xf8 TypeDefUnion = 0xf9 TypeDefEnum = 0xfa TypeDefMap = 0xfb TypeDefNamed = 0xfc CtrlCompressed = 0xfd CtrlAppMessage = 0xfe CtrlEOS = 0xff AppEncodingZNG = 0 AppEncodingJSON = 1 AppEncodingZSON = 2 AppEncodingString = 3 AppEncodingBinary = 4 )
Variables ¶
var ( ErrNotArray = errors.New("cannot index a non-array") ErrIndex = errors.New("array index out of bounds") ErrUnionSelector = errors.New("union selector out of bounds") ErrEnumIndex = errors.New("enum index out of bounds") )
var ( TypeUint8 = &TypeOfUint8{} TypeUint16 = &TypeOfUint16{} TypeUint32 = &TypeOfUint32{} TypeUint64 = &TypeOfUint64{} TypeInt8 = &TypeOfInt8{} TypeInt16 = &TypeOfInt16{} TypeInt32 = &TypeOfInt32{} TypeInt64 = &TypeOfInt64{} TypeDuration = &TypeOfDuration{} TypeTime = &TypeOfTime{} // XXX add TypeFloat16 TypeFloat32 = &TypeOfFloat32{} TypeFloat64 = &TypeOfFloat64{} // XXX add TypeDecimal TypeBool = &TypeOfBool{} TypeBytes = &TypeOfBytes{} TypeString = &TypeOfString{} TypeBstring = &TypeOfBstring{} TypeIP = &TypeOfIP{} TypeNet = &TypeOfNet{} TypeType = &TypeOfType{} TypeError = &TypeOfError{} TypeNull = &TypeOfNull{} )
var ( NullUint8 = &Value{Type: TypeUint8} NullUint16 = &Value{Type: TypeUint16} NullUint32 = &Value{Type: TypeUint32} NullUint64 = &Value{Type: TypeUint64} NullInt8 = &Value{Type: TypeInt8} NullInt16 = &Value{Type: TypeInt16} NullInt32 = &Value{Type: TypeInt32} NullInt64 = &Value{Type: TypeInt64} NullDuration = &Value{Type: TypeDuration} NullTime = &Value{Type: TypeTime} NullFloat32 = &Value{Type: TypeFloat32} NullFloat64 = &Value{Type: TypeFloat64} NullBool = &Value{Type: TypeBool} NullBytes = &Value{Type: TypeBytes} NullString = &Value{Type: TypeString} NullIP = &Value{Type: TypeIP} NullNet = &Value{Type: TypeNet} NullType = &Value{Type: TypeType} Null = &Value{Type: TypeNull} )
var ErrMissing = errors.New("missing")
ErrMissing is a Go error that implies a missing value in the runtime logic whereas Missing is a Zed error value that represents a missing value embedded in the dataflow computation.
var ErrTypeSyntax = errors.New("syntax error parsing type string")
var False = &Value{TypeBool, []byte{0}}
var Missing = &Value{TypeError, zcode.Bytes("missing")}
Missing is value that represents an error condition arising from a referenced entity not present, e.g., a reference to a non-existent record field, a map lookup for a key not present, an array index that is out of range, etc. The Missing error can be propagated through functions and expressions and each operator has clearly defined semantics with respect to the Missing value. For example, "true AND MISSING" is MISSING.
var Quiet = &Value{TypeError, zcode.Bytes("quiet")}
var True = &Value{TypeBool, []byte{1}}
Functions ¶
func ContainedType ¶
ContainedType returns the inner type for set and array types in the first return value and the columns of its of type for record types in the second return value. ContainedType returns nil for both return values if the type is not a set, array, or record.
func EncodeBool ¶
func EncodeBytes ¶
func EncodeError ¶
func EncodeFloat32 ¶
func EncodeFloat64 ¶
func EncodeString ¶
func EncodeTypeValue ¶
func EncodeUint ¶
func IsContainerType ¶
func IsIdentifier ¶
func IsPrimitiveType ¶
func IsRecordType ¶
func IsTypeName ¶
IsTypeName returns true iff s is a valid zson typedef name (exclusive of integer names for locally-scoped typedefs).
func IsUnionType ¶
Types ¶
type CompressionFormat ¶
type CompressionFormat int
const CompressionFormatLZ4 CompressionFormat = 0x00
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
A Context implements the "type context" in the Zed model. For a given set of related Values, each Value has a type from a shared Context. The Context manages the transitive closure of Types so that each unique type corresponds to exactly one Type pointer allowing type equivlance to be determined by pointer comparison. (Type pointers from distinct Contexts obviously do not have this property.) A Context also provides an efficient means to translate type values (represented as serialized ZNG) to Types. This provides an efficient means to translate Type pointers from one context to another.
func NewContext ¶
func NewContext() *Context
func (*Context) Lookup ¶
func (c *Context) Lookup(id int) *TypeRecord
func (*Context) LookupByValue ¶
LookupByValue returns the Type indicated by a binary-serialized type value. This provides a means to translate a type-context-independent serialized encoding for an arbitrary type into the reciever Context.
func (*Context) LookupTypeArray ¶
func (*Context) LookupTypeDef ¶
func (*Context) LookupTypeEnum ¶
func (*Context) LookupTypeMap ¶
func (*Context) LookupTypeNamed ¶
func (*Context) LookupTypeRecord ¶
func (c *Context) LookupTypeRecord(columns []Column) (*TypeRecord, error)
LookupTypeRecord returns a TypeRecord within this context that binds with the indicated columns. Subsequent calls with the same columns will return the same record pointer. If the type doesn't exist, it's created, stored, and returned. The closure of types within the columns must all be from this type context. If you want to use columns from a different type context, use TranslateTypeRecord.
func (*Context) LookupTypeSet ¶
func (*Context) LookupTypeUnion ¶
func (*Context) LookupTypeValue ¶
func (*Context) MustLookupTypeRecord ¶
func (c *Context) MustLookupTypeRecord(columns []Column) *TypeRecord
func (*Context) TranslateType ¶
TranslateType takes a type from another context and creates and returns that type in this context.
func (*Context) TranslateTypeRecord ¶
func (t *Context) TranslateTypeRecord(ext *TypeRecord) (*TypeRecord, error)
type Type ¶
type Type interface { // ID returns a unique (per Context) identifier that // represents this type. For a named type, this identifier // represents the underlying type and not the named type itself. // Callers that care about the underlying type of a Value for // example should prefer to use this instead of using the go // .(type) operator on a Type instance. ID() int }
A Type is an interface presented by a zeek type. Types can be used to infer type compatibility and create new values of the underlying type.
func InnerType ¶
InnerType returns the element type for the underlying set or array type or nil if the underlying type is not a set or array.
func LookupPrimitive ¶
func LookupPrimitiveByID ¶
type TypeArray ¶
type TypeArray struct { Type Type // contains filtered or unexported fields }
func NewTypeArray ¶
type TypeEnum ¶
type TypeEnum struct { Symbols []string // contains filtered or unexported fields }
func NewTypeEnum ¶
type TypeMap ¶
func NewTypeMap ¶
type TypeOfBool ¶
type TypeOfBool struct{}
func (*TypeOfBool) ID ¶
func (t *TypeOfBool) ID() int
func (*TypeOfBool) String ¶
func (t *TypeOfBool) String() string
type TypeOfBstring ¶
type TypeOfBstring struct{}
func (*TypeOfBstring) ID ¶
func (t *TypeOfBstring) ID() int
type TypeOfBytes ¶
type TypeOfBytes struct{}
func (*TypeOfBytes) ID ¶
func (t *TypeOfBytes) ID() int
func (*TypeOfBytes) String ¶
func (t *TypeOfBytes) String() string
type TypeOfDuration ¶
type TypeOfDuration struct{}
func (*TypeOfDuration) ID ¶
func (t *TypeOfDuration) ID() int
func (*TypeOfDuration) Marshal ¶
func (t *TypeOfDuration) Marshal(zv zcode.Bytes) (interface{}, error)
func (*TypeOfDuration) String ¶
func (t *TypeOfDuration) String() string
type TypeOfError ¶
type TypeOfError struct{}
func (*TypeOfError) ID ¶
func (t *TypeOfError) ID() int
type TypeOfFloat32 ¶
type TypeOfFloat32 struct{}
func (*TypeOfFloat32) ID ¶
func (t *TypeOfFloat32) ID() int
func (*TypeOfFloat32) Marshal ¶
func (t *TypeOfFloat32) Marshal(zb zcode.Bytes) (interface{}, error)
func (*TypeOfFloat32) String ¶
func (t *TypeOfFloat32) String() string
type TypeOfFloat64 ¶
type TypeOfFloat64 struct{}
func (*TypeOfFloat64) ID ¶
func (t *TypeOfFloat64) ID() int
func (*TypeOfFloat64) Marshal ¶
func (t *TypeOfFloat64) Marshal(zv zcode.Bytes) (interface{}, error)
func (*TypeOfFloat64) String ¶
func (t *TypeOfFloat64) String() string
type TypeOfInt16 ¶
type TypeOfInt16 struct{}
func (*TypeOfInt16) ID ¶
func (t *TypeOfInt16) ID() int
func (*TypeOfInt16) String ¶
func (t *TypeOfInt16) String() string
type TypeOfInt32 ¶
type TypeOfInt32 struct{}
func (*TypeOfInt32) ID ¶
func (t *TypeOfInt32) ID() int
func (*TypeOfInt32) String ¶
func (t *TypeOfInt32) String() string
type TypeOfInt64 ¶
type TypeOfInt64 struct{}
func (*TypeOfInt64) ID ¶
func (t *TypeOfInt64) ID() int
func (*TypeOfInt64) String ¶
func (t *TypeOfInt64) String() string
type TypeOfInt8 ¶
type TypeOfInt8 struct{}
func (*TypeOfInt8) ID ¶
func (t *TypeOfInt8) ID() int
func (*TypeOfInt8) String ¶
func (t *TypeOfInt8) String() string
type TypeOfNull ¶
type TypeOfNull struct{}
func (*TypeOfNull) ID ¶
func (t *TypeOfNull) ID() int
func (*TypeOfNull) String ¶
func (t *TypeOfNull) String() string
type TypeOfString ¶
type TypeOfString struct{}
func (*TypeOfString) ID ¶
func (t *TypeOfString) ID() int
type TypeOfTime ¶
type TypeOfTime struct{}
func (*TypeOfTime) ID ¶
func (t *TypeOfTime) ID() int
func (*TypeOfTime) String ¶
func (t *TypeOfTime) String() string
type TypeOfUint16 ¶
type TypeOfUint16 struct{}
func (*TypeOfUint16) ID ¶
func (t *TypeOfUint16) ID() int
func (*TypeOfUint16) String ¶
func (t *TypeOfUint16) String() string
type TypeOfUint32 ¶
type TypeOfUint32 struct{}
func (*TypeOfUint32) ID ¶
func (t *TypeOfUint32) ID() int
func (*TypeOfUint32) String ¶
func (t *TypeOfUint32) String() string
type TypeOfUint64 ¶
type TypeOfUint64 struct{}
func (*TypeOfUint64) ID ¶
func (t *TypeOfUint64) ID() int
func (*TypeOfUint64) String ¶
func (t *TypeOfUint64) String() string
type TypeOfUint8 ¶
type TypeOfUint8 struct{}
func (*TypeOfUint8) ID ¶
func (t *TypeOfUint8) ID() int
func (*TypeOfUint8) String ¶
func (t *TypeOfUint8) String() string
type TypeRecord ¶
type TypeRecord struct { Columns []Column LUT map[string]int // contains filtered or unexported fields }
func NewTypeRecord ¶
func NewTypeRecord(id int, columns []Column) *TypeRecord
func TypeRecordOf ¶
func TypeRecordOf(typ Type) *TypeRecord
func (*TypeRecord) ID ¶
func (t *TypeRecord) ID() int
type TypeSet ¶
type TypeSet struct { Type Type // contains filtered or unexported fields }
func NewTypeSet ¶
type TypeUnion ¶
type TypeUnion struct { Types []Type // contains filtered or unexported fields }
func NewTypeUnion ¶
type Value ¶
func NewBstring ¶
func NewDuration ¶
func NewFloat32 ¶
func NewFloat64 ¶
func NewTypeValue ¶
func (*Value) Copy ¶
Copy returns a copy of v that does not share v.Bytes. The copy's Bytes field is nil if and only if v.Bytes is nil.
func (*Value) CopyFrom ¶
CopyFrom copies from into v, reusing v.Bytes if possible and setting v.Bytes to nil if and only if from.Bytes is nil.