Module: Sequel::Postgres::Streaming::DatasetMethods
- Defined in:
- lib/sequel/extensions/pg_streaming.rb
Overview
Dataset methods used to implement streaming.
Instance Method Summary collapse
-
#fetch_rows(sql) ⇒ Object
If streaming has been requested and the current dataset can be streamed, request the database use streaming when executing this query, and use yield_each_row to process the separate PGresult for each row in the connection.
-
#paged_each(opts = Sequel::OPTS, &block) ⇒ Object
Use streaming to implement paging.
-
#stream ⇒ Object
Return a clone of the dataset that will use streaming to load rows.
Instance Method Details
#fetch_rows(sql) ⇒ Object
If streaming has been requested and the current dataset can be streamed, request the database use streaming when executing this query, and use yield_each_row to process the separate PGresult for each row in the connection.
110 111 112 113 114 115 116 117 118 |
# File 'lib/sequel/extensions/pg_streaming.rb', line 110 def fetch_rows(sql) if stream_results? execute(sql, :stream=>true) do |conn| yield_each_row(conn){|h| yield h} end else super end end |
#paged_each(opts = Sequel::OPTS, &block) ⇒ Object
Use streaming to implement paging.
121 122 123 |
# File 'lib/sequel/extensions/pg_streaming.rb', line 121 def paged_each(opts=Sequel::OPTS, &block) stream.each(&block) end |
#stream ⇒ Object
Return a clone of the dataset that will use streaming to load rows.
127 128 129 |
# File 'lib/sequel/extensions/pg_streaming.rb', line 127 def stream clone(:stream=>true) end |