exp

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheFilename

func CacheFilename(ent *CacheEntry) string

CacheFilename computes the filename from a cache entry.

func CacheFilenameWithName

func CacheFilenameWithName(ent *CacheEntry, name, ext string) string

CacheFilenameWithNodeName computes the filename from a cache entry with a custom node name.

func SaveCacheToFile

func SaveCacheToFile(cache *Cache, filename string) error

SaveCacheToFile saves Cache to a file.

func SetUp

func SetUp() cli.Command

SetUp sets up SensorBee's experimenting command.

func StateCacheFilename

func StateCacheFilename(ent *CacheEntry, stateName string) string

Types

type Cache

type Cache struct {
	Seed     string        `json:"seed"`
	Applied  []*CacheEntry `json:"applied"`
	Outdated []*CacheEntry `json:"outdated"`
	// contains filtered or unexported fields
}

Cache has information of cached results generated from each BQL statement.

func LoadCache

func LoadCache(body []byte) (*Cache, error)

LoadCache loads a cache from in-memory data.

func LoadCacheFromFile

func LoadCacheFromFile(filename string) (*Cache, error)

LoadCacheFromFile loads Cache from a file.

func (*Cache) Add

func (c *Cache) Add(e *CacheEntry)

Add adds a CacheEntry.

func (*Cache) Get

func (c *Cache) Get(i int) *CacheEntry

Get returns i-th CacheEntry in the cache. It returns nil if the index is out of bounds.

func (*Cache) Node

func (c *Cache) Node(name string) *CacheEntry

Node returns a CacheEntry of a data source node (a source or a stream) having the name.

func (*Cache) Save

func (c *Cache) Save(w io.Writer) error

Save saves the Cache.

func (*Cache) TruncateAfter

func (c *Cache) TruncateAfter(i int)

TruncateAfter removes all cache information after i-th position. For example, if the cache has three entries [a, b, c], TruncateAfter(0) removes b and c, and only a remains.

type CacheEntry

type CacheEntry struct {
	NodeName  string    `json:"node_name,omitempty"`
	Hash      string    `json:"hash"`
	Stmt      string    `json:"stmt"`
	States    []string  `json:"states"`
	Timestamp time.Time `json:"timestamp"`
}

CacheEntry has an cache information of a specific BQL statement.

type Statement

type Statement struct {
	Stmt interface{}
}

Statement is a wrapper of BQL statement structs.

func NewStatement

func NewStatement(s interface{}) (*Statement, error)

NewStatement creates a Statement from a BQL statement. Currently, following statements are not supported:

  • SELECT (CREATE STREAM is supported)
  • UPDATE SOURCE/SINK/STATE
  • DROP SOURCE/STREAM/SINK/STATE
  • SAVE/LOAD STATE (they are automatically saved)

func (*Statement) Input

func (s *Statement) Input() ([]string, error)

Input returns input node names of SELECT statements. It doesn't support Sinks.

func (*Statement) IsCreateStateStatement

func (s *Statement) IsCreateStateStatement() bool

IsCreateStateStatement returns true when the statement is CREATE STATE. Because LOAD STATE isn't supported by the command, it only check if the statement is CREATE STATE.

func (*Statement) IsDataSourceNodeQuery

func (s *Statement) IsDataSourceNodeQuery() bool

IsDataSourceNodeQuery returns true if the statement creates or manipulate a data source node, which is a source or a stream.

func (*Statement) IsInsertStatement

func (s *Statement) IsInsertStatement() bool

IsInsertStatement returns true when the statement is INSERT INTO.

func (*Statement) IsStream

func (s *Statement) IsStream() bool

IsStream returns true if the statement is a stream.

func (*Statement) NodeName

func (s *Statement) NodeName() string

NodeName returns the name of node that the statement creates or manipulates. If the statement doesn't create a node or the statement creates a sink, it returns an empty string. Instead, INSERT INTO statements returns a name of a sink.

func (*Statement) String

func (s *Statement) String() string

String returns a string representation of the statement.

type Statements

type Statements struct {
	Stmts []*Statement
}

Statements is a collection of Statement.

func Parse

func Parse(bql string) (*Statements, error)

Parse parses BQL statements and create Statements.

Jump to

Keyboard shortcuts

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