Sha256: 03ef64986073d5c8d2a2f7ba61ea37795951b947dca47cdcfd77af8867d6ae51

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

module Riak::TimeSeries

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

    # @!attribute [rw] query_text
    # @return [String] the SQL query to run
    attr_accessor :query_text

    # Values to be interpolated into the query, support planned in Riak TS
    # 1.2
    attr_accessor :interpolations

    # @!attribute [r] client
    # @return [Riak::Client] the Riak client to use for the TS query
    attr_reader :client

    # #!attribute [r] results
    # @return [Riak::Client::BeefcakeProtobuffsBackend::TsQueryResp]
    #   backend-dependent results object
    attr_reader :results

    # Initialize a query object
    #
    # @param [Riak::Client] client the client connected to the riak cluster
    # @param [String] query_text the SQL query to run
    # @param interpolations planned for Riak TS 1.1
    def initialize(client, query_text, interpolations = {})
      @client = client
      @query_text = query_text
      @interpolations = interpolations
    end

    # Run the query against Riak TS, and store the results in the `results`
    # attribute
    def issue!
      @results = client.backend do |be|
        be.time_series_query_operator.query(query_text, interpolations)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
riak-client-2.3.2 lib/riak/time_series/query.rb
riak-client-2.3.1 lib/riak/time_series/query.rb
riak-client-2.3.0 lib/riak/time_series/query.rb