Class: Pyper::Pipes::Cassandra::AllItemsReader
- Inherits:
-
Struct
- Object
- Struct
- Pyper::Pipes::Cassandra::AllItemsReader
- Defined in:
- lib/pyper/pipes/cassandra/all_items_reader.rb
Overview
A pipe for reading all items from a single row in cassandra
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(table, client, page_size = 1000) ⇒ AllItemsReader
constructor
A new instance of AllItemsReader.
-
#pipe(arguments, status = {}) ⇒ Enumerator::Lazy<Hash>
Enumerator of items.
Constructor Details
#initialize(table, client, page_size = 1000) ⇒ AllItemsReader
Returns a new instance of AllItemsReader.
12 13 14 15 16 |
# File 'lib/pyper/pipes/cassandra/all_items_reader.rb', line 12 def initialize(table, client, page_size = 1000) @table = table @client = client @page_size = page_size end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client
5 6 7 |
# File 'lib/pyper/pipes/cassandra/all_items_reader.rb', line 5 def client @client end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
6 7 8 |
# File 'lib/pyper/pipes/cassandra/all_items_reader.rb', line 6 def page_size @page_size end |
#table ⇒ Object
Returns the value of attribute table
5 6 7 |
# File 'lib/pyper/pipes/cassandra/all_items_reader.rb', line 5 def table @table end |
Instance Method Details
#pipe(arguments, status = {}) ⇒ Enumerator::Lazy<Hash>
Returns enumerator of items.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pyper/pipes/cassandra/all_items_reader.rb', line 23 def pipe(arguments, status = {}) columns = arguments.delete(:columns) enum = Enumerator.new do |yielder| = { :page_size => page_size } paging_state = nil loop do [:paging_state] = paging_state if paging_state.present? result = @client.select(@table, columns).where(arguments).execute() result.each { |item| yielder << item } break if result.last_page? paging_state = result.paging_state end end enum.lazy end |