Class: Riak::SecondaryIndex
- Includes:
- Client::FeatureDetection, Util::Translation
- Defined in:
- lib/riak/secondary_index.rb
Overview
SecondaryIndex provides an object-oriented interface to secondary index (“2i”) functionality in Riak, available on the ‘memory` and `leveldb` backends.
Constant Summary
Constants included from Client::FeatureDetection
Client::FeatureDetection::VERSION
Instance Method Summary collapse
- #get_server_version ⇒ Object
-
#has_next_page? ⇒ Boolean
Determine whether a SecondaryIndex fetch has a next page available.
-
#initialize(bucket, index, query, options = {}) ⇒ SecondaryIndex
constructor
Create a Riak Secondary Index operation.
-
#keys(&block) ⇒ Object
Get the array of matched keys.
-
#next_page ⇒ Object
Get a new SecondaryIndex fetch for the next page.
-
#values ⇒ Object
Get the array of values.
Methods included from Client::FeatureDetection
#http_props_clearable?, #index_pagination?, #index_return_terms?, #index_streaming?, #key_object_bucket_timeouts?, #mapred_phaseless?, #pb_conditionals?, #pb_head?, #pb_indexes?, #pb_search?, #quorum_controls?, #server_version, #tombstone_vclocks?
Methods included from Util::Translation
Constructor Details
#initialize(bucket, index, query, options = {}) ⇒ SecondaryIndex
Create a Riak Secondary Index operation
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/riak/secondary_index.rb', line 17 def initialize(bucket, index, query, = {}) @bucket = bucket @client = @bucket.client @index = index @query = query @options = if @bucket.is_a? Riak::BucketTyped::Bucket @options = { type: @bucket.type.name }.merge @options end end |
Instance Method Details
#get_server_version ⇒ Object
31 32 33 |
# File 'lib/riak/secondary_index.rb', line 31 def get_server_version @client.backend { |b| b.send :get_server_version } end |
#has_next_page? ⇒ Boolean
Determine whether a SecondaryIndex fetch has a next page available
59 60 61 |
# File 'lib/riak/secondary_index.rb', line 59 def has_next_page? !!keys.continuation end |
#keys(&block) ⇒ Object
Get the array of matched keys
36 37 38 39 40 41 |
# File 'lib/riak/secondary_index.rb', line 36 def keys(&block) @collection ||= @client.backend do |b| b.get_index @bucket, @index, @query, @options, &block end end |
#next_page ⇒ Object
Get a new SecondaryIndex fetch for the next page
49 50 51 52 53 54 55 56 |
# File 'lib/riak/secondary_index.rb', line 49 def next_page fail t('index.no_next_page') unless keys.continuation self.class.new(@bucket, @index, @query, @options.merge(continuation: keys.continuation)) end |
#values ⇒ Object
Get the array of values
44 45 46 |
# File 'lib/riak/secondary_index.rb', line 44 def values @values ||= @bucket.get_many(keys).values end |