Class: TempoIQ::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/tempoiq/models/pipeline.rb

Overview

Used to transform a stream of devices using a list of function transformations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePipeline

Returns a new instance of Pipeline.



7
8
9
# File 'lib/tempoiq/models/pipeline.rb', line 7

def initialize
  @functions = []
end

Instance Attribute Details

#functionsObject (readonly)

Returns the value of attribute functions.



5
6
7
# File 'lib/tempoiq/models/pipeline.rb', line 5

def functions
  @functions
end

Instance Method Details

#aggregate(function) ⇒ Object

DataPoint aggregation

  • function [Symbol] - Function to aggregate by. One of:

    • count - The number of datapoints across sensors

    • sum - Summation of all datapoints across sensors

    • mult - Multiplication of all datapoints across sensors

    • min - The smallest datapoint value across sensors

    • max - The largest datapoint value across sensors

    • stddev - The standard deviation of the datapoint values across sensors

    • ss - Sum of squares of all datapoints across sensors

    • range - The maximum value less the minimum value of the datapoint values across sensors

    • percentile,N (where N is what percentile to calculate) - Percentile of datapoint values across sensors



23
24
25
26
27
28
# File 'lib/tempoiq/models/pipeline.rb', line 23

def aggregate(function)
  functions << {
    "name" => "aggregation",
    "arguments" => [function.to_s]
  }
end

#interpolate(period, interpolation_function, start, stop) ⇒ Object

Interpolate missing data within a sensor, based on

  • period [String] - The duration of each rollup. Specified by:

    • A number and unit of time: EG - ‘1min’ ‘10days’.

    • A valid ISO8601 duration

  • function [Symbol] - The type of interpolation to perform. One of:

    • linear - Perform linear interpolation

    • zoh - Zero order hold interpolation

  • start [Time] - The beginning of the interpolation range

  • stop [Time] - The end of the interpolation range



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/tempoiq/models/pipeline.rb', line 67

def interpolate(period, interpolation_function, start, stop)
  functions << {
    "name" => "interpolate",
    "arguments" => [
                    interpolation_function.to_s,
                    period,
                    start.iso8601(3),
                    stop.iso8601(3)
                   ]
  }
end

#rollup(period, function, start) ⇒ Object

Rollup a stream of DataPoints to a given period

  • period [String] - The duration of each rollup. Specified by:

    • A number and unit of time: EG - ‘1min’ ‘10days’.

    • A valid ISO8601 duration

  • function [Symbol] - Function to rollup by. One of:

    • count - The number of datapoints in the period

    • sum - Summation of all datapoint values in the period

    • mult - Multiplication of all datapoint values in the period

    • min - The smallest datapoint value in the period

    • max - The largest datapoint value in the period

    • stddev - The standard deviation of the datapoint values in the period

    • ss - Sum of squares of all datapoint values in the period

    • range - The maximum value less the minimum value of the datapoint values in the period

    • percentile,N (where N is what percentile to calculate) - Percentile of datapoint values in period

  • start [Time] - The beginning of the rollup interval



46
47
48
49
50
51
52
53
54
55
# File 'lib/tempoiq/models/pipeline.rb', line 46

def rollup(period, function, start)
  functions << {
    "name" => "rollup",
    "arguments" => [
                    function.to_s,
                    period,
                    start.iso8601(3)
                   ]
  }
end

#to_hashObject



79
80
81
82
83
# File 'lib/tempoiq/models/pipeline.rb', line 79

def to_hash
  {
    "functions" => functions
  }
end