Class: OfflineSort::Chunk::InputOutput::MessagePack

Inherits:
Base
  • Object
show all
Defined in:
lib/offline_sort/chunk/input_output/message_pack.rb

Constant Summary

Constants inherited from Base

Base::MethodNotImplementedError

Instance Attribute Summary collapse

Attributes inherited from Base

#io

Instance Method Summary collapse

Methods inherited from Base

#close, #each, #rewind, #write_entries

Constructor Details

#initialize(io) ⇒ MessagePack

Returns a new instance of MessagePack.



10
11
12
13
14
# File 'lib/offline_sort/chunk/input_output/message_pack.rb', line 10

def initialize(io)
  super
  @packer = ::MessagePack::Packer.new(io)
  @unpacker = ::MessagePack::Unpacker.new(io)
end

Instance Attribute Details

#packerObject (readonly)

Returns the value of attribute packer.



8
9
10
# File 'lib/offline_sort/chunk/input_output/message_pack.rb', line 8

def packer
  @packer
end

#unpackerObject (readonly)

Returns the value of attribute unpacker.



8
9
10
# File 'lib/offline_sort/chunk/input_output/message_pack.rb', line 8

def unpacker
  @unpacker
end

Instance Method Details

#flushObject



24
25
26
27
# File 'lib/offline_sort/chunk/input_output/message_pack.rb', line 24

def flush
  packer.flush
  super
end

#read_entryObject



16
17
18
# File 'lib/offline_sort/chunk/input_output/message_pack.rb', line 16

def read_entry
  unpacker.read
end

#write_entry(entry) ⇒ Object



20
21
22
# File 'lib/offline_sort/chunk/input_output/message_pack.rb', line 20

def write_entry(entry)
  packer.write(entry)
end