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 = 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.
96 97 98 99 100 101 102 103 104 |
# File 'lib/sequel/extensions/pg_streaming.rb', line 96 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 = OPTS, &block) ⇒ Object
Use streaming to implement paging.
107 108 109 |
# File 'lib/sequel/extensions/pg_streaming.rb', line 107 def paged_each(opts=OPTS, &block) stream.each(&block) end |
#stream ⇒ Object
Return a clone of the dataset that will use streaming to load rows.
113 114 115 |
# File 'lib/sequel/extensions/pg_streaming.rb', line 113 def stream clone(:stream=>true) end |