Method: Aerospike::MultiCommand#read_bytes

Defined in:
lib/aerospike/command/multi_command.rb

#read_bytes(length) ⇒ Object

[View source]

205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/aerospike/command/multi_command.rb', line 205

def read_bytes(length)
  if length > @data_buffer.length
    # Corrupted data streams can result in a huge length.
    # Do a sanity check here.
    if length > Aerospike::Buffer::MAX_BUFFER_SIZE
      raise Aerospike::Exceptions::Parse.new("Invalid read_bytes length: #{length}", [@node])
    end
    @data_buffer = Buffer.new(length)
  end

  if compressed?
    @data_buffer.write_binary(@compressed_data_buffer.buf[@compressed_data_offset...@compressed_data_offset+length], 0)
    @compressed_data_offset += length
  else
    @conn.read(@data_buffer, length)
  end

  @data_offset += length
end