Class: Riak::IndexCollection

Inherits:
Array show all
Defined in:
lib/riak/index_collection.rb

Overview

IndexCollection provides extra tools for managing index matches returned by a Secondary Index query. In Riak 1.4, these queries can be paginaged, and match keys up with the index values they matched against.

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Array

#extract_options!, #to_param, #to_query

Instance Attribute Details

#continuationString

paginated query.

Returns:

  • (String)

    The continuation used to retrieve the next page of a



24
25
26
# File 'lib/riak/index_collection.rb', line 24

def continuation
  @continuation
end

#with_termsHash<Integer/String, String>

Integer, depending on whether the query was a binary or integer) to arrays of keys.

Returns:



29
30
31
# File 'lib/riak/index_collection.rb', line 29

def with_terms
  @with_terms
end

Class Method Details

.new_from_json(json) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/riak/index_collection.rb', line 31

def self.new_from_json(json)
  parsed = JSON.parse json
  fresh = nil
  if parsed['keys']
    fresh = new parsed['keys']
  elsif parsed['results']
    fresh_terms = load_json_terms(parsed)
    fresh = new fresh_terms.values.flatten
    fresh.with_terms = fresh_terms
  else
    fresh = new []
  end
  fresh.continuation = parsed['continuation']

  fresh
end

.new_from_protobuf(message) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/riak/index_collection.rb', line 48

def self.new_from_protobuf(message)
  fresh = nil
  if message.keys
    fresh = new message.keys
  elsif message.results
    fresh_terms = load_pb_terms(message)
    fresh = new fresh_terms.values.flatten
    fresh.with_terms = fresh_terms
  else
    fresh = new
  end
  fresh.continuation = message.continuation

  fresh
end