Sha256: e1655b5ab8941d402a407c789b8ab76b33c78beaef22d0d594df1c9899057539

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

require_relative './ts_cell_codec'
require_relative './operator'

class Riak::Client::BeefcakeProtobuffsBackend
  def time_series_get_operator(convert_timestamp)
    TimeSeriesGetOperator.new(self, convert_timestamp)
  end

  class TimeSeriesGetOperator < Operator
    def initialize(backend, convert_timestamp)
      super(backend)
      @convert_timestamp = convert_timestamp
    end

    def get(table_name, key_components, options = {})
      codec = TsCellCodec.new(@convert_timestamp)

      request_options = options.merge(table: table_name,
                                      key: codec.cells_for(key_components))

      request = TsGetReq.new request_options

      result = begin
        backend.protocol do |p|
          p.write :TsGetReq, request
          result = p.expect :TsGetResp, TsGetResp, empty_body_acceptable: true
        end
      rescue Riak::ProtobuffsErrorResponse => e
        raise unless e.code == 10
        return nil
      end

      return nil if result == :empty

      Riak::TimeSeries::Collection.new(result.rows.map do |row|
        Riak::TimeSeries::Row.new codec.scalars_for row.cells
      end.to_a)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
riak-client-2.6.0 lib/riak/client/beefcake/time_series_get_operator.rb
riak-client-2.5.0 lib/riak/client/beefcake/time_series_get_operator.rb
riak-client-2.4.1 lib/riak/client/beefcake/time_series_get_operator.rb
riak-client-2.4.0 lib/riak/client/beefcake/time_series_get_operator.rb
riak-client-2.4.0.pre1 lib/riak/client/beefcake/time_series_get_operator.rb