class Riak::Client::BeefcakeProtobuffsBackend::TimeSeriesListOperator

Public Class Methods

new(backend, convert_timestamp) click to toggle source
# File lib/riak/client/beefcake/time_series_list_operator.rb, line 10
def initialize(backend, convert_timestamp)
  super(backend)
  @convert_timestamp = convert_timestamp
end

Public Instance Methods

list(table_name, block, options = { }) click to toggle source
# File lib/riak/client/beefcake/time_series_list_operator.rb, line 15
def list(table_name, block, options = {  })
  request = TsListKeysReq.new options.merge(table: table_name)

  return streaming_list_keys(request, &block) unless block.nil?

  Riak::TimeSeries::Collection.new.tap do |key_buffer|
    streaming_list_keys(request) do |key_row|
      key_buffer << key_row
    end
  end
end

Private Instance Methods

streaming_list_keys(request) { |key_fields| ... } click to toggle source
# File lib/riak/client/beefcake/time_series_list_operator.rb, line 29
def streaming_list_keys(request)
  backend.protocol do |p|
    p.write :TsListKeysReq, request

    codec = TsCellCodec.new(@convert_timestamp)

    while resp = p.expect(:TsListKeysResp, TsListKeysResp)
      break if resp.done
      resp.keys.each do |row|
        key_fields = codec.scalars_for row.cells
        yield key_fields
      end
    end
  end

  true
end