Class: Riak::TimeSeries::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/riak/time_series/query.rb

Overview

A query for Riak Time Series. Supports SQL for querying (data manipulation language, or DML).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, query_text, interpolations = {}) ⇒ Query

Initialize a query object

Parameters:

  • client (Riak::Client)

    the client connected to the riak cluster

  • query_text (String)

    the SQL query to run

  • interpolations (defaults to: {})

    planned for Riak TS 1.1



29
30
31
32
33
# File 'lib/riak/time_series/query.rb', line 29

def initialize(client, query_text, interpolations = {})
  @client = client
  @query_text = query_text
  @interpolations = interpolations
end

Instance Attribute Details

#clientRiak::Client (readonly)

Returns the Riak client to use for the TS query.

Returns:

  • (Riak::Client)

    the Riak client to use for the TS query



17
18
19
# File 'lib/riak/time_series/query.rb', line 17

def client
  @client
end

#interpolationsObject

Values to be interpolated into the query, support planned in Riak TS 1.2



13
14
15
# File 'lib/riak/time_series/query.rb', line 13

def interpolations
  @interpolations
end

#query_textString

Returns the SQL query to run.

Returns:

  • (String)

    the SQL query to run



9
10
11
# File 'lib/riak/time_series/query.rb', line 9

def query_text
  @query_text
end

#resultsRiak::Client::BeefcakeProtobuffsBackend::TsQueryResp (readonly)

#!attribute [r] results

Returns:



22
23
24
# File 'lib/riak/time_series/query.rb', line 22

def results
  @results
end

Instance Method Details

#issue!Object

Run the query against Riak TS, and store the results in the ‘results` attribute



37
38
39
40
41
42
# File 'lib/riak/time_series/query.rb', line 37

def issue!
  @results = client.backend do |be|
    op = be.time_series_query_operator(client.convert_timestamp)
    op.query(query_text, interpolations)
  end
end