Sha256: bbec7de7b9597e4670010806d7ee246173424bde6c113f7044752ee836fb8d0c

Contents?: true

Size: 1015 Bytes

Versions: 3

Compression:

Stored size: 1015 Bytes

Contents

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

class Riak::Client::BeefcakeProtobuffsBackend
  def time_series_list_operator
    TimeSeriesListOperator.new(self)
  end

  class TimeSeriesListOperator < Operator
    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

    def streaming_list_keys(request)
      backend.protocol do |p|
        p.write :TsListKeysReq, request

        codec = TsCellCodec.new

        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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
riak-client-2.3.2 lib/riak/client/beefcake/time_series_list_operator.rb
riak-client-2.3.1 lib/riak/client/beefcake/time_series_list_operator.rb
riak-client-2.3.0 lib/riak/client/beefcake/time_series_list_operator.rb