Class: Riak::TimeSeries::List

Inherits:
Object
  • Object
show all
Includes:
Util::Translation
Defined in:
lib/riak/time_series/list.rb

Overview

A request to list keys in a Riak Time Series collection. Very expensive, not recommended for use in production.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::Translation

#i18n_scope, #t

Constructor Details

#initialize(client, table_name) ⇒ List

Initializes but does not issue the list keys operation

Parameters:

  • client (Riak::Client)

    the Riak Client to list keys with

  • table_name (String)

    the table name to list keys in



45
46
47
48
49
# File 'lib/riak/time_series/list.rb', line 45

def initialize(client, table_name)
  @client = client
  @table_name = table_name
  @timeout = nil
end

Instance Attribute Details

#clientRiak::Client (readonly)

Returns the Riak client to use for the list keys operation.

Returns:

  • (Riak::Client)

    the Riak client to use for the list keys operation



30
31
32
# File 'lib/riak/time_series/list.rb', line 30

def client
  @client
end

#resultsRiak::TimeSeries::Collection<Riak::TimeSeries::Row> (readonly)

Returns each key as a row in a collection; nil if keys were streamed to a block.

Returns:



39
40
41
# File 'lib/riak/time_series/list.rb', line 39

def results
  @results
end

#table_nameString (readonly)

Returns the table name to list keys in.

Returns:

  • (String)

    the table name to list keys in



26
27
28
# File 'lib/riak/time_series/list.rb', line 26

def table_name
  @table_name
end

#timeoutInteger

Returns how many milliseconds Riak should wait for listing.

Returns:

  • (Integer)

    how many milliseconds Riak should wait for listing



34
35
36
# File 'lib/riak/time_series/list.rb', line 34

def timeout
  @timeout
end

Instance Method Details

#issue! {|key| ... } ⇒ Object

Issue the list keys request. Takes a block for streaming results, or sets the #results read-only attribute iff no block is given.

Yield Parameters:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/riak/time_series/list.rb', line 55

def issue!(&block)
  unless Riak.disable_list_exceptions
    msg = t('time_series.list_keys', :backtrace => caller.join("\n    "))
    raise Riak::ListError.new(msg)
  end

  options = { timeout: self.timeout }

  potential_results = nil

  client.backend do |be|
    op = be.time_series_list_operator(client.convert_timestamp)
    potential_results = op.list(table_name, block, options)
  end

  return @results = potential_results unless block_given?

  true
end