Documentation ¶
Index ¶
- Constants
- Variables
- func Exists(name string) (err error)
- func Fatal(err error, wrapper string)
- func GetFamilies() (families []string)
- func GetMD5Hash(text string) string
- type CalibrationModel
- type Database
- func (self *Database) AddCalibration(ProbabilityMeans []float64, ProbabilitiesOfBestGuess interface{}, ...) error
- func (self *Database) AddPrediction(timestamp int64, aidata []models.LocationPrediction) error
- func (self *Database) AddSensor(s models.SensorData) (err error)
- func (self *Database) Close() (err error)
- func (self *Database) Delete() (err error)
- func (self *Database) DeleteLocation(location_id string) error
- func (self *Database) Dump() (dumped string, err error)
- func (self *Database) Get(key string, v interface{}) error
- func (self *Database) GetAllForClassification(clbk func(s []models.SensorData, err error))
- func (self *Database) GetAllFromQuery(query string, args ...interface{}) ([]models.SensorData, error)
- func (self *Database) GetAllNotForClassification(clbk func(s []models.SensorData, err error))
- func (self *Database) GetCalibration() (CalibrationModel, error)
- func (self *Database) GetDeviceCounts() (map[string]int, error)
- func (self *Database) GetDeviceCountsFromDevices(devices []string) (map[string]int, error)
- func (self *Database) GetDeviceFirstTime() (map[string]time.Time, error)
- func (self *Database) GetDeviceFirstTimeFromDevices(devices []string) (map[string]time.Time, error)
- func (self *Database) GetDevices() ([]string, error)
- func (self *Database) GetLastSensorInsertTimeWithLocationId() (time.Time, error)
- func (self *Database) GetLastSensorTimestamp() (int64, error)
- func (self *Database) GetLatest(device_id string) (models.SensorData, error)
- func (self *Database) GetLocationCounts() (map[string]int, error)
- func (self *Database) GetLocations() ([]string, error)
- func (self *Database) GetPending() int
- func (self *Database) GetPrediction(timestamp int64) ([]models.LocationPrediction, error)
- func (self *Database) GetSensorFromGreaterTime(timeBlockInMilliseconds int64) ([]models.SensorData, error)
- func (self *Database) GetSensorFromTime(timestamp interface{}) (models.SensorData, error)
- func (self *Database) Insert(query string, executor func(*sql.Stmt) error) error
- func (self *Database) MakeTables() (err error)
- func (self *Database) NumDevices() (int, error)
- func (self *Database) NumDevicesWithLocation() (int, error)
- func (self *Database) PrepareQuery(query string) (*sql.Stmt, error)
- func (self *Database) Select(clbk func(string, *Database) error) error
- func (self *Database) Set(key string, value interface{}) error
- func (self *Database) SetBatch(key string, value interface{}) error
- func (self *Database) SetGPS(p models.SensorData) error
- func (self *Database) StartRequestQueue()
- func (self *Database) TotalLearnedCount() (int64, error)
Constants ¶
const DEFAULT_DATA_FOLDER = "."
Variables ¶
var CALIBRATION_SQL = `` /* 748-byte string literal not displayed */
CALIBRATION_SQL is the sql json template for calibration objects
var DataFolder = DEFAULT_DATA_FOLDER
DataFolder is set to where you want each Sqlite3 database to be stored
var LOCATION_PREDICTION_SQL = `` /* 218-byte string literal not displayed */
LOCATION_PREDICTION_SQL is the sql json template for a location_prediction object.
var SENSOR_SQL = `` /* 296-byte string literal not displayed */
SENSOR_SQL is the sql json template for a sensor object.
var TABLES_SQL = `` /* 2875-byte string literal not displayed */
TABLES_SQL defines the main database tables and trigger functions.
Functions ¶
Types ¶
type CalibrationModel ¶
type CalibrationModel struct { Id int `json:"id"` Probability_means []float64 `json:"probability_means"` ProbabilitiesOfBestGuess []float64 `json:"probabilities_of_best_guess"` PercentCorrect float64 `json:"percent_correct"` AccuracyBreakdown map[string]float64 `json:"accuracy_breakdown"` PredictionAnalysis map[string]map[string]map[string]int `json:"prediction_analysis"` AlgorithmEfficacy map[string]map[string]models.BinaryStats `json:"algorithm_efficacy"` CalibrationTime time.Time `json:"calibration_time"` CreateAt time.Time `json:"create_at"` UpdateAt time.Time `json:"update_at"` }
type Database ¶
Database is the main structure for holding the information pertaining to the name of the database.
func (*Database) AddCalibration ¶
func (self *Database) AddCalibration(ProbabilityMeans []float64, ProbabilitiesOfBestGuess interface{}, PercentCorrect float64, AccuracyBreakdown interface{}, PredictionAnalysis interface{}, AlgorithmEfficacy interface{}) error
AddCalibration inserts calibration data as single transaction in a single row TODO INSERT AND GET AS A SINGLE TRANSACTION
func (*Database) AddPrediction ¶
func (self *Database) AddPrediction(timestamp int64, aidata []models.LocationPrediction) error
AddPrediction will insert or update a prediction in the database
func (*Database) AddSensor ¶
func (self *Database) AddSensor(s models.SensorData) (err error)
AddSensor will insert a sensor data into the database TODO: AddSensor should be special case of AddSensors
func (*Database) DeleteLocation ¶
DeleteLocation deletes sensors that have a locationid
func (*Database) Get ¶
// Get will retrieve the value associated with a key. // channel event listener makes database call synchronous
func (*Database) GetAllForClassification ¶
func (self *Database) GetAllForClassification(clbk func(s []models.SensorData, err error))
GetAllForClassification will return a sensor data for classifying
func (*Database) GetAllFromQuery ¶
func (self *Database) GetAllFromQuery(query string, args ...interface{}) ([]models.SensorData, error)
GetAllFromQuery
func (*Database) GetAllNotForClassification ¶
func (self *Database) GetAllNotForClassification(clbk func(s []models.SensorData, err error))
GetAllForClassification will return a sensor data for classifying
func (*Database) GetCalibration ¶
func (self *Database) GetCalibration() (CalibrationModel, error)
GetCalibration
func (*Database) GetDeviceCounts ¶
GetDeviceCounts get counts for devices
func (*Database) GetDeviceCountsFromDevices ¶
GetDeviceCountsFromDevices same as GetDeviceCounts but filters based on supplied devices
func (*Database) GetDeviceFirstTime ¶
GetDeviceFirstTime returns map of timestamps for devices in the sensor table
func (*Database) GetDeviceFirstTimeFromDevices ¶
GetDeviceFirstTimeFromDevices same as GetDeviceFirstTime but only returns devices supplied in arguments.
func (*Database) GetDevices ¶
GetDevices returns list of deviceids
func (*Database) GetLastSensorInsertTimeWithLocationId ¶
GetLastSensorInsertTimeWithLocationId gets the last updated_at timestamp for a sensor with a location.
func (*Database) GetLastSensorTimestamp ¶
Get will retrieve the value associated with a key.
func (*Database) GetLatest ¶
func (self *Database) GetLatest(device_id string) (models.SensorData, error)
GetLatest will return a sensor data for classifying
func (*Database) GetLocationCounts ¶
GetLocationCounts returns counts for locations
func (*Database) GetLocations ¶
GetLocations return list of locationids
func (*Database) GetPending ¶
GetPending returns pending insert requests
func (*Database) GetPrediction ¶
func (self *Database) GetPrediction(timestamp int64) ([]models.LocationPrediction, error)
GetPrediction will retrieve models.LocationAnalysis associated with that timestamp
func (*Database) GetSensorFromGreaterTime ¶
func (self *Database) GetSensorFromGreaterTime(timeBlockInMilliseconds int64) ([]models.SensorData, error)
GetSensorFromGreaterTime will return a sensor data for a given timeframe
func (*Database) GetSensorFromTime ¶
func (self *Database) GetSensorFromTime(timestamp interface{}) (models.SensorData, error)
GetSensorFromTime will return a sensor data for a given timestamp
func (*Database) Insert ¶
Insert runs an insert query. Since there can only be one writer, only one of these can be run at a time. It is prefered to use one of the pre-cannded insert functions that use the insertAsync or insertSync methods.
func (*Database) MakeTables ¶
MakeTables creates database tables and triggers.
func (*Database) NumDevices ¶
NumDevices returns number of unique devices found in the sensor table
func (*Database) NumDevicesWithLocation ¶
NumDevices returns number of unique devices found in the sensor table that have locations
func (*Database) PrepareQuery ¶
PrepareQuery runs the database Prepare method on the supplied query.
func (*Database) Select ¶
Select runs a select query contained in a callback function. To have multiple readers a new database connection is opened and passed into the callback function. * TODO
- - Add database connection pool for reads
func (*Database) SetGPS ¶
func (self *Database) SetGPS(p models.SensorData) error
SetGPS will set a GPS value in the GPS database
func (*Database) StartRequestQueue ¶
func (self *Database) StartRequestQueue()
StartRequestQueue starts insert queue for callbacks
func (*Database) TotalLearnedCount ¶
Get will retrieve the value associated with a key.