Class: Impala::Cursor
- Inherits:
-
Object
- Object
- Impala::Cursor
- Includes:
- Enumerable
- Defined in:
- lib/impala/cursor.rb
Instance Method Summary collapse
- #close ⇒ Object
- #each ⇒ Object
- #fetch_all ⇒ Object
- #fetch_row ⇒ Object
-
#initialize(handle, service, buffer_length = 1024) ⇒ Cursor
constructor
A new instance of Cursor.
Constructor Details
#initialize(handle, service, buffer_length = 1024) ⇒ Cursor
Returns a new instance of Cursor.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/impala/cursor.rb', line 5 def initialize(handle, service, buffer_length=1024) @handle = handle @service = service @metadata = @service.(@handle) @buffer_length = buffer_length @row_buffer = [] @done = false @closed = false end |
Instance Method Details
#close ⇒ Object
41 42 43 44 |
# File 'lib/impala/cursor.rb', line 41 def close @closed = true @service.close(@handle) end |
#each ⇒ Object
17 18 19 20 21 |
# File 'lib/impala/cursor.rb', line 17 def each while row = fetch_row yield row end end |
#fetch_all ⇒ Object
37 38 39 |
# File 'lib/impala/cursor.rb', line 37 def fetch_all self.to_a end |
#fetch_row ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/impala/cursor.rb', line 23 def fetch_row raise CursorError.new("Cursor has expired or been closed") if @closed if @row_buffer.empty? if @done return nil else fetch_more end end @row_buffer.shift end |