Documentation
¶
Index ¶
- type Grid
- func (g *Grid) AddColumn(name, dis string)
- func (g *Grid) AddRow(row []*TypedValue) error
- func (g *Grid) CloneStruct() *Grid
- func (g *Grid) GetCol(col string) ([]*TypedValue, bool)
- func (g *Grid) GetRowsMatching(match map[string]*TypedValue) ([][]*TypedValue, error)
- func (g *Grid) GobDecode(b []byte) error
- func (g *Grid) GobEncode() ([]byte, error)
- func (g *Grid) MarshalJSON() ([]byte, error)
- func (g *Grid) NewRow() int
- func (g *Grid) Set(row int, col string, value *TypedValue) error
- func (g *Grid) UnmarshalJSON(b []byte) error
- type HaystackType
- type RowIterator
- type TypedValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Grid ¶
type Grid struct { Meta map[string]string Cols map[int]string // this is a reverse index string is the col name, and int its index // contains filtered or unexported fields }
Grid is a simple database structure, column based
func (*Grid) AddColumn ¶
AddColumn with name and description. This column does not extend the existing rows and therefore is not safe for use after AddRow has been called. Column is added at the end of the stack, order of call to this function matters.
func (*Grid) AddRow ¶
func (g *Grid) AddRow(row []*TypedValue) error
AddRow to the grid at the end of the existing row stack
func (*Grid) GetCol ¶
func (g *Grid) GetCol(col string) ([]*TypedValue, bool)
GetCol returns the column value and a boolean to false if the column does not exists
func (*Grid) GetRowsMatching ¶
func (g *Grid) GetRowsMatching(match map[string]*TypedValue) ([][]*TypedValue, error)
GetRowsMatching returns rows matching the match hashmap. The key of match is the column name and *TypedValue a non nil value to be matched. The return value is a list of rows (the row is of length len(g.Cols)) This function returns an error if the key of match does not exist in the grid and if any of the pointer to TypedValue is nil in the request.
func (*Grid) MarshalJSON ¶
MarshalJSON encode the grid in a haystack compatible format
func (*Grid) Set ¶
func (g *Grid) Set(row int, col string, value *TypedValue) error
Set the value in the grid; silently override any existing value. returns an error if col or row is out of range.
func (*Grid) UnmarshalJSON ¶
UnmarshalJSON implemented the json.Unmarshaler. Reads a haystack json payload and creates a grid.
type HaystackType ¶
type HaystackType int
HaystackType represents a type handled by haystack
const ( // HaystackTypeUndefined ... HaystackTypeUndefined HaystackType = iota // HaystackTypeGrid is a Grid object HaystackTypeGrid // HaystackTypeList Array HaystackTypeList // HaystackTypeDict Object HaystackTypeDict // HaystackTypenull null HaystackTypenull // HaystackTypeBool Boolean HaystackTypeBool // HaystackTypeMarker "m:" HaystackTypeMarker // HaystackTypeRemove "-:" HaystackTypeRemove // HaystackTypeNA "z:" HaystackTypeNA // HaystackTypeNumber "n:<float> [unit]" "n:45.5" "n:73.2 °F" "n:-INF" HaystackTypeNumber // HaystackTypeRef "r:<id> [dis]" "r:abc-123" "r:abc-123 RTU #3" HaystackTypeRef // HaystackTypeStr "hello" "s:hello" HaystackTypeStr // HaystackTypeDate "d:2014-01-03" HaystackTypeDate // HaystackTypeTime "h:23:59" HaystackTypeTime // HaystackTypeDateTime "t:2015-06-08T15:47:41-04:00 New_York" HaystackTypeDateTime // HaystackTypeURI "u:http://project-haystack.org/" HaystackTypeURI // HaystackTypeCoord "c:<lat>,<lng>" "c:37.545,-77.449" HaystackTypeCoord //HaystackTypeXStr "x:Type:value" HaystackTypeXStr // HaystackLastType ... HaystackLastType )
type RowIterator ¶
type RowIterator struct {
// contains filtered or unexported fields
}
RowIterator is a top level structure to get the row of a db
func (*RowIterator) Len ¶
func (r *RowIterator) Len() int
Len returns the remaining number of rows to be iterated over.
func (*RowIterator) Next ¶
func (r *RowIterator) Next() bool
Next returns whether the next call of Row will return a valid row.
func (*RowIterator) Row ¶
func (r *RowIterator) Row() []*TypedValue
Row returns the current row of the iterator. Next must have been called prior to a call to Row.
type TypedValue ¶
type TypedValue struct { Type HaystackType Value interface{} }
TypedValue is any value that can be associated with a HaystackType
func NewTypedValue ¶
func NewTypedValue(typ HaystackType, value interface{}) *TypedValue
NewTypedValue holding the haystack type (not tag). There is not check done to see if the interface{} underlying type is compatible with the haystack type.
func (*TypedValue) Equal ¶
func (tv *TypedValue) Equal(tv2 *TypedValue) bool
Equal returns true if type and value are equal