Class: SpannerLib::Rows
- Inherits:
-
Object
- Object
- SpannerLib::Rows
- Includes:
- Enumerable
- Defined in:
- lib/spannerlib/rows.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #close ⇒ Object
- #each ⇒ Object
-
#initialize(connection, rows_id) ⇒ Rows
constructor
A new instance of Rows.
- #metadata ⇒ Object
- #next ⇒ Object
- #result_set_stats ⇒ Object
Constructor Details
#initialize(connection, rows_id) ⇒ Rows
Returns a new instance of Rows.
23 24 25 26 27 |
# File 'lib/spannerlib/rows.rb', line 23 def initialize(connection, rows_id) @connection = connection @id = rows_id @closed = false end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
21 22 23 |
# File 'lib/spannerlib/rows.rb', line 21 def connection @connection end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/spannerlib/rows.rb', line 21 def id @id end |
Instance Method Details
#close ⇒ Object
60 61 62 63 64 65 |
# File 'lib/spannerlib/rows.rb', line 60 def close return if @closed SpannerLib.close_rows(connection.pool_id, connection.conn_id, id) @closed = true end |
#each ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/spannerlib/rows.rb', line 29 def each return enum_for(:each) unless block_given? while (row = self.next) yield row end ensure close end |
#metadata ⇒ Object
52 53 54 |
# File 'lib/spannerlib/rows.rb', line 52 def SpannerLib.(connection.pool_id, connection.conn_id, id) end |
#next ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/spannerlib/rows.rb', line 39 def next return nil if @closed row_data = SpannerLib.next(connection.pool_id, connection.conn_id, id, 1, 0) if row_data.nil? || row_data.empty? || (row_data.respond_to?(:values) && row_data.values.empty?) close return nil end row_data end |
#result_set_stats ⇒ Object
56 57 58 |
# File 'lib/spannerlib/rows.rb', line 56 def result_set_stats SpannerLib.result_set_stats(connection.pool_id, connection.conn_id, id) end |