types

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateIndex

func DateIndex(attr string, val *Date) ([]string, error)

DateIndex indexs time type.

func DefaultIndexKeys

func DefaultIndexKeys(attr string, val *String) []string

DefaultIndexKeys tokenizes data as a string and return keys for indexing.

func FloatIndex

func FloatIndex(attr string, val *Float) ([]string, error)

FloatIndex indexs float type.

func IntIndex

func IntIndex(attr string, val *Int32) ([]string, error)

IntIndex indexs int type.

func TimeIndex

func TimeIndex(attr string, val *Time) ([]string, error)

TimeIndex indexs time type.

Types

type Bool

type Bool bool

Bool is the scalar type for bool

func (Bool) MarshalBinary

func (v Bool) MarshalBinary() ([]byte, error)

MarshalBinary marshals to binary

func (Bool) MarshalJSON

func (v Bool) MarshalJSON() ([]byte, error)

MarshalJSON marshals to json

func (Bool) MarshalText

func (v Bool) MarshalText() ([]byte, error)

MarshalText marshals to text

func (Bool) String

func (v Bool) String() string

func (Bool) Type

func (v Bool) Type() Scalar

Type returns the type of this value

func (*Bool) UnmarshalBinary

func (v *Bool) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals the data from a binary format.

func (*Bool) UnmarshalText

func (v *Bool) UnmarshalText(text []byte) error

UnmarshalText unmarshals the data from a text format.

type Bytes

type Bytes []byte

Bytes is the scalar type for []byte

func (Bytes) MarshalBinary

func (v Bytes) MarshalBinary() ([]byte, error)

MarshalBinary marshals to binary

func (Bytes) MarshalJSON

func (v Bytes) MarshalJSON() ([]byte, error)

MarshalJSON marshals to json

func (Bytes) MarshalText

func (v Bytes) MarshalText() ([]byte, error)

MarshalText marshals to text

func (Bytes) String

func (v Bytes) String() string

func (Bytes) Type

func (v Bytes) Type() Scalar

Type returns the type of this value

func (*Bytes) UnmarshalBinary

func (v *Bytes) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals the data from a binary format.

func (*Bytes) UnmarshalText

func (v *Bytes) UnmarshalText(text []byte) error

UnmarshalText unmarshals the data from a text format.

type Date

type Date struct {
	time.Time
}

Date represents a date (YYYY-MM-DD). There is no timezone information attached.

func (Date) MarshalBinary

func (v Date) MarshalBinary() ([]byte, error)

MarshalBinary marshals to binary

func (Date) MarshalJSON

func (v Date) MarshalJSON() ([]byte, error)

MarshalJSON marshals to json

func (Date) MarshalText

func (v Date) MarshalText() ([]byte, error)

MarshalText marshals to text

func (Date) String

func (v Date) String() string

func (Date) Type

func (v Date) Type() Scalar

Type returns the type of this value

func (*Date) UnmarshalBinary

func (v *Date) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals the data from a binary format.

func (*Date) UnmarshalText

func (v *Date) UnmarshalText(text []byte) error

UnmarshalText unmarshals the data from a text format.

type Float

type Float float64

Float is the scalar type for float64

func (Float) MarshalBinary

func (v Float) MarshalBinary() ([]byte, error)

MarshalBinary marshals to binary

func (Float) MarshalJSON

func (v Float) MarshalJSON() ([]byte, error)

MarshalJSON marshals to json

func (Float) MarshalText

func (v Float) MarshalText() ([]byte, error)

MarshalText marshals to text

func (Float) String

func (v Float) String() string

func (Float) Type

func (v Float) Type() Scalar

Type returns the type of this value

func (*Float) UnmarshalBinary

func (v *Float) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals the data from a binary format.

func (*Float) UnmarshalText

func (v *Float) UnmarshalText(text []byte) error

UnmarshalText unmarshals the data from a text format.

type Geo

type Geo struct {
	geom.T
}

Geo represents geo-spatial data.

func (Geo) MarshalBinary

func (v Geo) MarshalBinary() ([]byte, error)

MarshalBinary marshals to binary

func (Geo) MarshalJSON

func (v Geo) MarshalJSON() ([]byte, error)

MarshalJSON marshals to json

func (Geo) MarshalText

func (v Geo) MarshalText() ([]byte, error)

MarshalText marshals to text

func (Geo) String

func (v Geo) String() string

func (Geo) Type

func (v Geo) Type() Scalar

Type returns the type of this value

func (*Geo) UnmarshalBinary

func (v *Geo) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals the data from WKB

func (*Geo) UnmarshalText

func (v *Geo) UnmarshalText(text []byte) error

UnmarshalText parses the data from a Geojson

type Int32

type Int32 int32

Int32 is the scalar type for int32

func (Int32) MarshalBinary

func (v Int32) MarshalBinary() ([]byte, error)

MarshalBinary marshals to binary

func (Int32) MarshalJSON

func (v Int32) MarshalJSON() ([]byte, error)

MarshalJSON marshals to json

func (Int32) MarshalText

func (v Int32) MarshalText() ([]byte, error)

MarshalText marshals to text

func (Int32) String

func (v Int32) String() string

func (Int32) Type

func (v Int32) Type() Scalar

Type returns the type of this value

func (*Int32) UnmarshalBinary

func (v *Int32) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals the data from a binary format.

func (*Int32) UnmarshalText

func (v *Int32) UnmarshalText(text []byte) error

UnmarshalText unmarshals the data from a text format.

type Object

type Object struct {
	Name   string
	Fields map[string]string //field to type relationship
}

Object represents all object types in the schema definition.

func (Object) IsScalar

func (o Object) IsScalar() bool

IsScalar returns true if the object is of scalar type.

type Scalar

type Scalar struct {
	Name string // name of scalar type
	// contains filtered or unexported fields
}

Scalar type defines concrete structure for scalar types to use. Almost all scalar types can also act as input types. Scalars (along with Enums) form leaf nodes of request or input values to arguements.

func (Scalar) Convert

func (to Scalar) Convert(value Value) (Value, error)

Convert converts the value to given scalar type.

func (Scalar) ID

func (s Scalar) ID() TypeID

ID function returns the storage identifier of this type

func (Scalar) IsScalar

func (s Scalar) IsScalar() bool

IsScalar returns true if the object is of scalar type.

func (Scalar) Sort

func (s Scalar) Sort(v []Value, ul *task.List) error

Sort sorts the given array in-place.

func (Scalar) String

func (s Scalar) String() string

String function to implement string interface

type String

type String string

String is the scalar type for string

func (String) MarshalBinary

func (v String) MarshalBinary() ([]byte, error)

MarshalBinary marshals to binary

func (String) MarshalJSON

func (v String) MarshalJSON() ([]byte, error)

MarshalJSON marshals to json

func (String) MarshalText

func (v String) MarshalText() ([]byte, error)

MarshalText marshals to text

func (String) String

func (v String) String() string

func (String) Type

func (v String) Type() Scalar

Type returns the type of this value

func (*String) UnmarshalBinary

func (v *String) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshals the data from a binary format.

func (*String) UnmarshalText

func (v *String) UnmarshalText(text []byte) error

UnmarshalText unmarshals the data from a text format.

type Time

type Time struct {
	time.Time
}

Time wraps time.Time to add the Value interface

func (Time) Type

func (v Time) Type() Scalar

Type returns the type of this value

func (*Time) UnmarshalText

func (v *Time) UnmarshalText(text []byte) error

UnmarshalText unmarshals the data from a text format.

type Type

type Type interface {
	IsScalar() bool
}

Type interface is the wrapper interface for all types

func TypeForName

func TypeForName(name string) (Type, bool)

TypeForName returns the type corresponding to the given name. If name is not recognized, it returns nil.

type TypeID

type TypeID byte

TypeID is the id used to identify a type.

const (
	BytesID    TypeID = 0
	Int32ID    TypeID = 1
	FloatID    TypeID = 2
	BoolID     TypeID = 3
	DateTimeID TypeID = 4
	StringID   TypeID = 5
	DateID     TypeID = 6
	GeoID      TypeID = 7
)

Note: These ids are stored in the posting lists to indicate the type of the data. The order *cannot* be changed without breaking existing data. When adding a new type *always* add to the end of this list. Never delete anything from this list even if it becomes unused.

type Value

type Value interface {
	encoding.TextMarshaler
	encoding.TextUnmarshaler
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
	json.Marshaler
	// Type returns the type of this value
	Type() Scalar
	fmt.Stringer
}

Value is the interface that all scalar values need to implement.

func ValueForType

func ValueForType(id TypeID) Value

ValueForType returns the zero value for a type id

Jump to

Keyboard shortcuts

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