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



10
11
12
# File 'lib/riak/index_collection.rb', line 10

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:



15
16
17
# File 'lib/riak/index_collection.rb', line 15

def with_terms
  @with_terms
end

Class Method Details

.new_from_json(json) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/riak/index_collection.rb', line 17

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



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

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