Documentation ¶
Index ¶
- Constants
- func CondenseUint64Even(value uint64) uint32
- func CondenseUint64Odd(value uint64) uint32
- func ConvertToStringKeys(value interface{}) interface{}
- func NewFactorNotFound(text string) error
- func ShiftTime(value time.Time) int64
- func TablePrefix(tableName string) ([]byte, error)
- func UnshiftTime(value int64) time.Time
- type Event
- func (e *Event) DecodeRaw(reader io.Reader) error
- func (e *Event) Dedupe(a *Event)
- func (e *Event) EncodeRaw(writer io.Writer) error
- func (e *Event) Equal(x *Event) bool
- func (e *Event) MarshalRaw() ([]byte, error)
- func (e *Event) Merge(a *Event)
- func (e *Event) MergePermanent(a *Event)
- func (e *Event) UnmarshalRaw(data []byte) error
- type EventList
- type ExecutionEngine
- func (e *ExecutionEngine) Aggregate() (interface{}, error)
- func (e *ExecutionEngine) Destroy()
- func (e *ExecutionEngine) FullAnnotatedSource() string
- func (e *ExecutionEngine) FullSource() string
- func (e *ExecutionEngine) Header() string
- func (e *ExecutionEngine) Merge(results interface{}, data interface{}) (interface{}, error)
- func (e *ExecutionEngine) SetIterator(iterator *levigo.Iterator) error
- func (e *ExecutionEngine) Source() string
- type FactorNotFound
- type Factors
- func (f *Factors) Close()
- func (f *Factors) Defactorize(namespace string, id string, value uint64) (string, error)
- func (f *Factors) Factorize(namespace string, id string, value string, createIfMissing bool) (uint64, error)
- func (f *Factors) IsOpen() bool
- func (f *Factors) Open() error
- func (f *Factors) Path() string
- type Property
- type PropertyFile
- func (p *PropertyFile) Close()
- func (p *PropertyFile) CreateProperty(name string, transient bool, dataType string) (*Property, error)
- func (p *PropertyFile) DbPath() string
- func (p *PropertyFile) Decode(reader io.Reader) error
- func (p *PropertyFile) DeleteProperty(property *Property)
- func (p *PropertyFile) DenormalizeMap(m map[int64]interface{}) (map[string]interface{}, error)
- func (p *PropertyFile) Encode(writer io.Writer) error
- func (p *PropertyFile) Factorize(property *Property, value interface{}) (interface{}, error)
- func (p *PropertyFile) GetAllProperties() []*Property
- func (p *PropertyFile) GetProperties() []*Property
- func (p *PropertyFile) GetProperty(id int64) *Property
- func (p *PropertyFile) GetPropertyByName(name string) *Property
- func (p *PropertyFile) IsOpen() bool
- func (p *PropertyFile) NextIdentifiers() (int64, int64)
- func (p *PropertyFile) NormalizeMap(m map[string]interface{}) (map[int64]interface{}, error)
- func (p *PropertyFile) Open() error
- func (p *PropertyFile) Path() string
- func (p *PropertyFile) Reset()
- func (p *PropertyFile) Save() error
- type PropertyList
- type Query
- func (q *Query) Codegen() (string, error)
- func (q *Query) CodegenAggregateFunction() string
- func (q *Query) CodegenMergeFunction() string
- func (q *Query) Decode(reader io.Reader) error
- func (q *Query) Defactorize(data interface{}) error
- func (q *Query) Deserialize(obj map[string]interface{}) error
- func (q *Query) Encode(writer io.Writer) error
- func (q *Query) Factors() *Factors
- func (q *Query) NextIdentifier() int
- func (q *Query) Serialize() map[string]interface{}
- func (q *Query) Table() *Table
- type QueryCondition
- func (c *QueryCondition) CodegenAggregateFunction() (string, error)
- func (c *QueryCondition) CodegenExpression() (string, error)
- func (c *QueryCondition) CodegenMergeFunction() (string, error)
- func (c *QueryCondition) Defactorize(data interface{}) error
- func (c *QueryCondition) Deserialize(obj map[string]interface{}) error
- func (c *QueryCondition) FunctionName() string
- func (c *QueryCondition) GetSteps() QueryStepList
- func (c *QueryCondition) MergeFunctionName() string
- func (c *QueryCondition) Query() *Query
- func (c *QueryCondition) Serialize() map[string]interface{}
- type QuerySelection
- func (s *QuerySelection) CodegenAggregateFunction() (string, error)
- func (s *QuerySelection) CodegenInnerMergeFunction(index int) (string, error)
- func (s *QuerySelection) CodegenMergeFunction() (string, error)
- func (s *QuerySelection) Defactorize(data interface{}) error
- func (s *QuerySelection) Deserialize(obj map[string]interface{}) error
- func (s *QuerySelection) FunctionName() string
- func (s *QuerySelection) GetSteps() QueryStepList
- func (s *QuerySelection) MergeFunctionName() string
- func (s *QuerySelection) Query() *Query
- func (s *QuerySelection) Serialize() map[string]interface{}
- type QuerySelectionField
- type QueryStep
- type QueryStepList
- type Server
- func (s *Server) ApiHandleFunc(route string, ...) *mux.Route
- func (s *Server) DataPath() string
- func (s *Server) DeleteTable(name string) error
- func (s *Server) FactorsPath() string
- func (s *Server) GetAllTables() ([]*Table, error)
- func (s *Server) GetObjectContext(tableName string, objectId string) (*Table, *Servlet, error)
- func (s *Server) GetObjectServletIndex(t *Table, objectId string) (uint32, error)
- func (s *Server) GetTable(name string) *Table
- func (s *Server) ListenAndServe(shutdownChannel chan bool) error
- func (s *Server) OpenTable(name string) (*Table, error)
- func (s *Server) Path() string
- func (s *Server) RunQuery(table *Table, query *Query) (interface{}, error)
- func (s *Server) Running() bool
- func (s *Server) Shutdown() error
- func (s *Server) Silence()
- func (s *Server) TablePath(name string) string
- func (s *Server) TablesPath() string
- type Servlet
- func (s *Servlet) Close()
- func (s *Servlet) DeleteEvent(table *Table, objectId string, timestamp time.Time) error
- func (s *Servlet) DeleteEvents(table *Table, objectId string) error
- func (s *Servlet) GetEvent(table *Table, objectId string, timestamp time.Time) (*Event, error)
- func (s *Servlet) GetEvents(table *Table, objectId string) ([]*Event, *Event, error)
- func (s *Servlet) GetState(table *Table, objectId string) (*Event, []byte, error)
- func (s *Servlet) Lock()
- func (s *Servlet) Open() error
- func (s *Servlet) PutEvent(table *Table, objectId string, event *Event, replace bool) error
- func (s *Servlet) SetEvents(table *Table, objectId string, events []*Event, state *Event) error
- func (s *Servlet) SetRawEvents(table *Table, objectId string, data []byte, state *Event) error
- func (s *Servlet) Unlock()
- type Table
- func (t *Table) Close()
- func (t *Table) Create() error
- func (t *Table) CreateProperty(name string, transient bool, dataType string) (*Property, error)
- func (t *Table) DefactorizeEvent(event *Event, factors *Factors) error
- func (t *Table) Delete() error
- func (t *Table) DeleteProperty(property *Property) error
- func (t *Table) DenormalizeMap(m map[int64]interface{}) (map[string]interface{}, error)
- func (t *Table) DeserializeEvent(m map[string]interface{}) (*Event, error)
- func (t *Table) EncodeObjectId(objectId string) ([]byte, error)
- func (t *Table) Exists() bool
- func (t *Table) FactorizeEvent(event *Event, factors *Factors, createIfMissing bool) error
- func (t *Table) GetProperties() ([]*Property, error)
- func (t *Table) GetProperty(id int64) (*Property, error)
- func (t *Table) GetPropertyByName(name string) (*Property, error)
- func (t *Table) IsOpen() bool
- func (t *Table) NormalizeMap(m map[string]interface{}) (map[int64]interface{}, error)
- func (t *Table) Open() error
- func (t *Table) Path() string
- func (t *Table) SavePropertyFile() error
- func (t *Table) SerializeEvent(event *Event) (map[string]interface{}, error)
- type TextPlainContentTypeError
Constants ¶
const ( FactorDataType = "factor" StringDataType = "string" IntegerDataType = "integer" FloatDataType = "float" BooleanDataType = "boolean" )
const ( QueryConditionUnitSteps = "steps" QueryConditionUnitSessions = "sessions" QueryConditionUnitSeconds = "seconds" )
const ( QueryStepTypeCondition = "condition" QueryStepTypeSelection = "selection" )
const LuaHeader = `` /* 3011-byte string literal not displayed */
const (
Version = "0.3.0"
)
Variables ¶
This section is empty.
Functions ¶
func CondenseUint64Even ¶
Condenses the even bits of a 64-bit integer into 32 bits.
func CondenseUint64Odd ¶
Condenses the odd bits of a 64-bit integer into 32 bits.
func ConvertToStringKeys ¶
func ConvertToStringKeys(value interface{}) interface{}
Converts untyped map to a map[string]interface{} if passed a map.
func NewFactorNotFound ¶
func TablePrefix ¶
Generates a prefix key used for iterating over the table's data.
func UnshiftTime ¶
Shifts a Sky timestamp format into a Go time.
Types ¶
type Event ¶
An Event is a state change that occurs at a particular point in time.
func (*Event) MarshalRaw ¶
Encodes an event to MsgPack format and returns the byte array.
func (*Event) MergePermanent ¶
Merges the persistent data of another event into this event.
func (*Event) UnmarshalRaw ¶
type EventList ¶
type EventList []*Event
type ExecutionEngine ¶
type ExecutionEngine struct {
// contains filtered or unexported fields
}
An ExecutionEngine is used to iterate over a series of objects.
func NewExecutionEngine ¶
func NewExecutionEngine(table *Table, source string) (*ExecutionEngine, error)
func (*ExecutionEngine) Aggregate ¶
func (e *ExecutionEngine) Aggregate() (interface{}, error)
Executes an aggregation over the iterator.
func (*ExecutionEngine) FullAnnotatedSource ¶
func (e *ExecutionEngine) FullAnnotatedSource() string
Retrieves the full annotated source with line numbers.
func (*ExecutionEngine) FullSource ¶
func (e *ExecutionEngine) FullSource() string
Retrieves the full source sent to the Lua compiler.
func (*ExecutionEngine) Header ¶
func (e *ExecutionEngine) Header() string
Retrieves the generated header for the engine.
func (*ExecutionEngine) Merge ¶
func (e *ExecutionEngine) Merge(results interface{}, data interface{}) (interface{}, error)
Executes an merge over the iterator.
func (*ExecutionEngine) SetIterator ¶
func (e *ExecutionEngine) SetIterator(iterator *levigo.Iterator) error
Sets the iterator to use.
func (*ExecutionEngine) Source ¶
func (e *ExecutionEngine) Source() string
Retrieves the source for the engine.
type FactorNotFound ¶
type FactorNotFound struct {
// contains filtered or unexported fields
}
func (*FactorNotFound) Error ¶
func (e *FactorNotFound) Error() string
type Factors ¶
type Factors struct {
// contains filtered or unexported fields
}
A Factors object manages the factorization and defactorization of values.
func (*Factors) Defactorize ¶
Converts the factorized value for a given id in a given namespace to its internal representation.
func (*Factors) Factorize ¶
func (f *Factors) Factorize(namespace string, id string, value string, createIfMissing bool) (uint64, error)
Converts the defactorized value for a given id in a given namespace to its internal representation.
type Property ¶
type Property struct { Id int64 `json:"id"` Name string `json:"name"` Transient bool `json:"transient"` DataType string `json:"dataType"` }
A Property is a loose schema column on a Table.
type PropertyFile ¶
type PropertyFile struct {
// contains filtered or unexported fields
}
A PropertyFile manages the serialization of Property objects for a table.
func NewPropertyFile ¶
func NewPropertyFile(path string) *PropertyFile
NewProperty returns a new PropertyFile.
func (*PropertyFile) CreateProperty ¶
func (p *PropertyFile) CreateProperty(name string, transient bool, dataType string) (*Property, error)
Adds a new property to the property file and generate an identifier for it.
func (*PropertyFile) DbPath ¶
func (p *PropertyFile) DbPath() string
The path to the factors database.
func (*PropertyFile) Decode ¶
func (p *PropertyFile) Decode(reader io.Reader) error
Decodes a property file.
func (*PropertyFile) DeleteProperty ¶
func (p *PropertyFile) DeleteProperty(property *Property)
Deletes a property.
func (*PropertyFile) DenormalizeMap ¶
func (p *PropertyFile) DenormalizeMap(m map[int64]interface{}) (map[string]interface{}, error)
Converts a map with property identifier keys to use string keys.
func (*PropertyFile) Encode ¶
func (p *PropertyFile) Encode(writer io.Writer) error
Encodes a property file.
func (*PropertyFile) Factorize ¶
func (p *PropertyFile) Factorize(property *Property, value interface{}) (interface{}, error)
Converts the value for a given property to its internal representation. This only changes the value for 'factor' data types.
func (*PropertyFile) GetAllProperties ¶
func (p *PropertyFile) GetAllProperties() []*Property
Retrieves a list of all properties sorted by id.
func (*PropertyFile) GetProperties ¶
func (p *PropertyFile) GetProperties() []*Property
Retrieves a list of undeleted properties sorted by id.
func (*PropertyFile) GetProperty ¶
func (p *PropertyFile) GetProperty(id int64) *Property
Retrieves a single property by id.
func (*PropertyFile) GetPropertyByName ¶
func (p *PropertyFile) GetPropertyByName(name string) *Property
Retrieves a single property by name.
func (*PropertyFile) IsOpen ¶
func (p *PropertyFile) IsOpen() bool
Returns whether the property file is currently open.
func (*PropertyFile) NextIdentifiers ¶
func (p *PropertyFile) NextIdentifiers() (int64, int64)
Finds the next available action and object property identifiers.
func (*PropertyFile) NormalizeMap ¶
func (p *PropertyFile) NormalizeMap(m map[string]interface{}) (map[int64]interface{}, error)
Converts a map with string keys to use property identifier keys.
func (*PropertyFile) Path ¶
func (p *PropertyFile) Path() string
The path to the property file on disk.
type PropertyList ¶
type PropertyList []*Property
A slice of Property objects.
func (PropertyList) Less ¶
func (s PropertyList) Less(i, j int) bool
Compares two properties in a list.
type Query ¶
type Query struct { Steps QueryStepList SessionIdleTime int // contains filtered or unexported fields }
A Query is a structured way of aggregating data in the database.
func (*Query) CodegenAggregateFunction ¶
Generates the 'aggregate()' function.
func (*Query) CodegenMergeFunction ¶
Generates the 'merge()' function.
func (*Query) Defactorize ¶
Converts factorized results from the aggregate function results to use the appropriate strings.
func (*Query) Deserialize ¶
Decodes a query from an untyped map.
func (*Query) NextIdentifier ¶
Returns an autoincrementing numeric identifier.
type QueryCondition ¶
type QueryCondition struct { Expression string WithinRangeStart int WithinRangeEnd int WithinUnits string Steps QueryStepList // contains filtered or unexported fields }
A condition step made within a query.
func NewQueryCondition ¶
func NewQueryCondition(query *Query) *QueryCondition
Creates a new condition.
func (*QueryCondition) CodegenAggregateFunction ¶
func (c *QueryCondition) CodegenAggregateFunction() (string, error)
Generates Lua code for the query.
func (*QueryCondition) CodegenExpression ¶
func (c *QueryCondition) CodegenExpression() (string, error)
Generates Lua code for the expression.
func (*QueryCondition) CodegenMergeFunction ¶
func (c *QueryCondition) CodegenMergeFunction() (string, error)
Generates Lua code for the query.
func (*QueryCondition) Defactorize ¶
func (c *QueryCondition) Defactorize(data interface{}) error
Converts factorized fields back to their original strings.
func (*QueryCondition) Deserialize ¶
func (c *QueryCondition) Deserialize(obj map[string]interface{}) error
Decodes a query condition from an untyped map.
func (*QueryCondition) FunctionName ¶
func (c *QueryCondition) FunctionName() string
Retrieves the function name used during codegen.
func (*QueryCondition) GetSteps ¶
func (c *QueryCondition) GetSteps() QueryStepList
Retrieves the child steps.
func (*QueryCondition) MergeFunctionName ¶
func (c *QueryCondition) MergeFunctionName() string
Retrieves the merge function name used during codegen.
func (*QueryCondition) Query ¶
func (c *QueryCondition) Query() *Query
Retrieves the query this condition is associated with.
func (*QueryCondition) Serialize ¶
func (c *QueryCondition) Serialize() map[string]interface{}
Encodes a query condition into an untyped map.
type QuerySelection ¶
type QuerySelection struct { Name string Dimensions []string Fields []*QuerySelectionField // contains filtered or unexported fields }
A selection step aggregates data in a query.
func NewQuerySelection ¶
func NewQuerySelection(query *Query) *QuerySelection
Creates a new selection.
func (*QuerySelection) CodegenAggregateFunction ¶
func (s *QuerySelection) CodegenAggregateFunction() (string, error)
Generates Lua code for the selection aggregation.
func (*QuerySelection) CodegenInnerMergeFunction ¶
func (s *QuerySelection) CodegenInnerMergeFunction(index int) (string, error)
Generates Lua code for the inner merge.
func (*QuerySelection) CodegenMergeFunction ¶
func (s *QuerySelection) CodegenMergeFunction() (string, error)
Generates Lua code for the selection merge.
func (*QuerySelection) Defactorize ¶
func (s *QuerySelection) Defactorize(data interface{}) error
Converts factorized fields back to their original strings.
func (*QuerySelection) Deserialize ¶
func (s *QuerySelection) Deserialize(obj map[string]interface{}) error
Decodes a query selection from an untyped map.
func (*QuerySelection) FunctionName ¶
func (s *QuerySelection) FunctionName() string
Retrieves the function name used during codegen.
func (*QuerySelection) GetSteps ¶
func (s *QuerySelection) GetSteps() QueryStepList
Retrieves the child steps.
func (*QuerySelection) MergeFunctionName ¶
func (s *QuerySelection) MergeFunctionName() string
Retrieves the merge function name used during codegen.
func (*QuerySelection) Query ¶
func (s *QuerySelection) Query() *Query
Retrieves the query this selection is associated with.
func (*QuerySelection) Serialize ¶
func (s *QuerySelection) Serialize() map[string]interface{}
Encodes a query selection into an untyped map.
type QuerySelectionField ¶
func NewQuerySelectionField ¶
func NewQuerySelectionField(name string, expression string) *QuerySelectionField
Creates a new selection field.
func (*QuerySelectionField) CodegenExpression ¶
func (f *QuerySelectionField) CodegenExpression() (string, error)
Generates Lua code for the expression.
func (*QuerySelectionField) CodegenMergeExpression ¶
func (f *QuerySelectionField) CodegenMergeExpression() (string, error)
Generates Lua code for the merge expression.
func (*QuerySelectionField) Deserialize ¶
func (f *QuerySelectionField) Deserialize(obj map[string]interface{}) error
Decodes a query selection from an untyped map.
func (*QuerySelectionField) Serialize ¶
func (f *QuerySelectionField) Serialize() map[string]interface{}
Encodes a query selection into an untyped map.
type QueryStepList ¶
type QueryStepList []QueryStep
func DeserializeQueryStepList ¶
func DeserializeQueryStepList(obj interface{}, q *Query) (QueryStepList, error)
Decodes a query step list from an untyped slice.
func (QueryStepList) CodegenAggregateFunctions ¶
func (l QueryStepList) CodegenAggregateFunctions() (string, error)
Generates aggregate code for all steps.
func (QueryStepList) CodegenMergeFunctions ¶
func (l QueryStepList) CodegenMergeFunctions() (string, error)
Generates merge code for all steps.
func (QueryStepList) CodegenMergeInvoke ¶
func (l QueryStepList) CodegenMergeInvoke() string
Generates merge invocations.
func (QueryStepList) Defactorize ¶
func (l QueryStepList) Defactorize(data interface{}) error
Defactorizes results generated from the aggregate function.
func (QueryStepList) Serialize ¶
func (l QueryStepList) Serialize() []interface{}
Encodes a query step list into an untyped object.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
A Server is the front end that controls access to tables.
func (*Server) ApiHandleFunc ¶
func (s *Server) ApiHandleFunc(route string, handlerFunction func(http.ResponseWriter, *http.Request, map[string]interface{}) (interface{}, error)) *mux.Route
Parses incoming JSON objects and converts outgoing responses to JSON.
func (*Server) FactorsPath ¶
The path to the factors database.
func (*Server) GetAllTables ¶
Retrieves a list of all tables in the database but does not open them. Do not use these table references for anything but informational purposes!
func (*Server) GetObjectContext ¶
Executes a function through a single-threaded servlet context.
func (*Server) GetObjectServletIndex ¶
Calculates a tablet index based on the object identifier even hash.
func (*Server) ListenAndServe ¶
Runs the server.
func (*Server) TablesPath ¶
The path to the table metadata directory.
type Servlet ¶
type Servlet struct {
// contains filtered or unexported fields
}
A Servlet is a small wrapper around a single shard of a LevelDB data file.
func NewServlet ¶
NewServlet returns a new Servlet with a data shard stored at a given path.
func (*Servlet) DeleteEvent ¶
Removes an event for a given object in a table to a servlet.
func (*Servlet) DeleteEvents ¶
Deletes all events for a given object in a table.
func (*Servlet) GetEvents ¶
Retrieves a list of events and the current state for a given object in a table.
func (*Servlet) GetState ¶
Retrieves the state and the remaining serialized event stream for an object.
func (*Servlet) SetRawEvents ¶
Writes a list of events for an object in table.
type Table ¶
type Table struct { Name string `json:"name"` // contains filtered or unexported fields }
A Table is a collection of objects.
func (*Table) CreateProperty ¶
Adds a property to the table.
func (*Table) DefactorizeEvent ¶
Defactorizes the values in an event.
func (*Table) DeleteProperty ¶
Deletes a single property on the table.
func (*Table) DenormalizeMap ¶
Converts a map with property identifier keys to use string keys.
func (*Table) DeserializeEvent ¶
Deserializes a map into a normalized event.
func (*Table) EncodeObjectId ¶
Encodes an object identifier for this table.
func (*Table) FactorizeEvent ¶
Factorizes the values in an event.
func (*Table) GetProperties ¶
Retrieves a list of all properties on the table.
func (*Table) GetProperty ¶
Retrieves a single property from the table by id.
func (*Table) GetPropertyByName ¶
Retrieves a single property from the table by name.
func (*Table) NormalizeMap ¶
Converts a map with string keys to use property identifier keys.
func (*Table) SavePropertyFile ¶
Saves the property file on the table.
type TextPlainContentTypeError ¶
type TextPlainContentTypeError struct { }
Hackish way to return plain text for query codegen. Might fix later but it's rarely used.
func (*TextPlainContentTypeError) Error ¶
func (e *TextPlainContentTypeError) Error() string
Source Files ¶
- bit.go
- cast.go
- data_type.go
- event.go
- event_list.go
- execution_engine.go
- execution_engine_callback.go
- factors.go
- lua_cmsgpack.go
- lua_header.go
- property.go
- property_file.go
- property_list.go
- query.go
- query_condition.go
- query_selection.go
- query_selection_field.go
- query_step.go
- server.go
- server_event_handlers.go
- server_handlers.go
- server_property_handlers.go
- server_query_handlers.go
- server_table_handlers.go
- servlet.go
- table.go
- test.go
- time.go
- util.go
- version.go