Class: ActiveRecord::ConnectionAdapters::ClickHouse::HTTPConnection::ChunkedBody
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::ClickHouse::HTTPConnection::ChunkedBody
- Defined in:
- lib/active_record/connection_adapters/clickhouse/http_connection.rb
Overview
Adapts an enumerator of encoded lines to the partial-read IO contract Net::HTTP uses for chunked transfer encoding, so a streamed INSERT never holds more than one chunk of the body in memory.
Constant Summary collapse
- CHUNK_BYTES =
64 * 1024
Instance Method Summary collapse
-
#initialize(lines) ⇒ ChunkedBody
constructor
A new instance of ChunkedBody.
- #read(length = CHUNK_BYTES, out = +"")) ⇒ Object
Constructor Details
#initialize(lines) ⇒ ChunkedBody
Returns a new instance of ChunkedBody.
119 120 121 122 |
# File 'lib/active_record/connection_adapters/clickhouse/http_connection.rb', line 119 def initialize(lines) @lines = lines @buffer = +"" end |
Instance Method Details
#read(length = CHUNK_BYTES, out = +"")) ⇒ Object
124 125 126 127 128 129 |
# File 'lib/active_record/connection_adapters/clickhouse/http_connection.rb', line 124 def read(length = CHUNK_BYTES, out = +"") buffer_lines(length) return nil if @buffer.empty? out.replace(@buffer.slice!(0, length)) end |