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.
122 123 124 125 126 127 128 129 130 |
# File 'lib/sequel/extensions/pg_streaming.rb', line 122 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.
133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/sequel/extensions/pg_streaming.rb', line 133 def paged_each(opts=Sequel::OPTS, &block) unless block_given? return enum_for(:paged_each, opts) end if stream_results? each(&block) else super end end |
#stream ⇒ Object
Return a clone of the dataset that will use streaming to load rows.
147 148 149 |
# File 'lib/sequel/extensions/pg_streaming.rb', line 147 def stream clone(:stream=>true) end |