Class: Avro::IPC::FramedReader

Inherits:
Object
  • Object
show all
Defined in:
lib/avro/ipc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reader) ⇒ FramedReader

Returns a new instance of FramedReader.



506
507
508
# File 'lib/avro/ipc.rb', line 506

def initialize(reader)
  @reader = reader
end

Instance Attribute Details

#readerObject (readonly)

Returns the value of attribute reader.



504
505
506
# File 'lib/avro/ipc.rb', line 504

def reader
  @reader
end

Instance Method Details

#read_framed_messageObject



510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'lib/avro/ipc.rb', line 510

def read_framed_message
  message = []
  loop do
    buffer = String.new('', encoding: 'BINARY')
    buffer_size = read_buffer_size

    return message.join if buffer_size == 0

    while buffer.bytesize < buffer_size
      chunk = reader.read(buffer_size - buffer.bytesize)
      chunk_error?(chunk)
      buffer << chunk
    end
    message << buffer
  end
end