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.



502
503
504
# File 'lib/avro/ipc.rb', line 502

def initialize(reader)
  @reader = reader
end

Instance Attribute Details

#readerObject (readonly)

Returns the value of attribute reader.



500
501
502
# File 'lib/avro/ipc.rb', line 500

def reader
  @reader
end

Instance Method Details

#read_framed_messageObject



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# File 'lib/avro/ipc.rb', line 506

def read_framed_message
  message = []
  loop do
    buffer = ''.force_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