mqldb

package
v0.0.0-...-6751b53 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProcessFieldType          = 1
	SampleFieldType           = 2
	ProcessAttributeFieldType = 3
	SampleAttributeFieldType  = 4
	ProcessFuncType           = 5
	SampleFuncType            = 6
)

Variables

This section is empty.

Functions

func EvalStatement

func EvalStatement(db *DB, selection Selection, statement Statement) ([]mcmodel.Activity, []mcmodel.Entity)

EvalStatement runs a query and returns the results. At the moment selection is a simple boolean flag on whether to return samples and/or processes from the matches.

func LoadProject

func LoadProject(projectID int)

Types

type Activity2Entity

type Activity2Entity struct {
	ID         int
	ActivityID int
	EntityID   int
}

Activity2Entity represents the join table for mapping the relationships between processes and samples.

func (Activity2Entity) TableName

func (Activity2Entity) TableName() string

type AndStatement

type AndStatement struct {
	// Ignored field that is here to distinguish json from "OrStatement"
	And   int       `json:"and"`
	Left  Statement `json:"left"`
	Right Statement `json:"right"`
}

type DB

type DB struct {
	ProjectID int

	// Process and process data lookups
	Processes                    []mcmodel.Activity
	AllProcessAttributes         []*mcmodel.Attribute
	ProcessAttributesByProcessID map[int]map[string]*mcmodel.Attribute
	ProcessSamples               map[int][]*mcmodel.Entity

	// Sample and sample data lookups
	Samples             []mcmodel.Entity
	SampleProcesses     map[int][]*mcmodel.Activity
	AllSampleAttributes []*mcmodel.Attribute

	SampleAttributesBySampleIDAndStates map[int]map[int]map[string]*mcmodel.Attribute
	// contains filtered or unexported fields
}

func NewDB

func NewDB(projectID int, db *gorm.DB) *DB

NewDB creates a new in memory instance of the samples, processes, attributes and their relationships DB that is used by the evaluator for query processing.

func (*DB) Load

func (db *DB) Load() error

Load loads the samples, processes and attributes for the given project into memory.

type MatchStatement

type MatchStatement struct {
	FieldType int         `json:"field_type"`
	FieldName string      `json:"field_name"`
	Operation string      `json:"operation"`
	Value     interface{} `json:"value"`
}

type OrStatement

type OrStatement struct {
	// Ignored field that is here to distinguish json from "AndStatement"
	Or    int       `json:"or"`
	Left  Statement `json:"left"`
	Right Statement `json:"right"`
}

type ProcessSelection

type ProcessSelection struct {
	All        bool
	Name       bool
	ID         bool
	Attributes []string
}

type SampleSelection

type SampleSelection struct {
	All        bool
	Name       bool
	ID         bool
	Attributes []string
}

type SampleState

type SampleState struct {
	EntityStateID int
	// contains filtered or unexported fields
}

SampleState is the state associated with a sample. The IDs contained in the structures are used to look up items in the hash tables in the DB.

type Selection

type Selection struct {
	ProcessSelection ProcessSelection
	SampleSelection  SampleSelection
}

type Statement

type Statement interface {
	// contains filtered or unexported methods
}

func MapToStatement

func MapToStatement(m map[string]interface{}) Statement

MapToStatement takes a map, which represents the converted JSON payload for a statement and converts it to statement. It recursively calls itself to build out the full statement.

Jump to

Keyboard shortcuts

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