Class: Avro::IPC::FramedWriter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(writer) ⇒ FramedWriter

Returns a new instance of FramedWriter.



470
471
472
# File 'lib/avro/ipc.rb', line 470

def initialize(writer)
  @writer = writer
end

Instance Attribute Details

#writerObject (readonly)

Returns the value of attribute writer.



469
470
471
# File 'lib/avro/ipc.rb', line 469

def writer
  @writer
end

Instance Method Details

#to_sObject



489
# File 'lib/avro/ipc.rb', line 489

def to_s; writer.string; end

#write_framed_message(message) ⇒ Object



474
475
476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/avro/ipc.rb', line 474

def write_framed_message(message)
  message_size = message.bytesize
  total_bytes_sent = 0
  while message_size - total_bytes_sent > 0
    if message_size - total_bytes_sent > BUFFER_SIZE
      buffer_size = BUFFER_SIZE
    else
      buffer_size = message_size - total_bytes_sent
    end
    write_buffer(message[total_bytes_sent, buffer_size])
    total_bytes_sent += buffer_size
  end
  write_buffer_size(0)
end