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.



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

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.



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

def packer
  @packer
end

#unpackerObject (readonly)

Returns the value of attribute unpacker.



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

def unpacker
  @unpacker
end

Instance Method Details

#flushObject



26
27
28
29
# File 'lib/offline_sort/chunk/input_output/message_pack.rb', line 26

def flush
  packer.flush
  super
end

#read_entryObject



18
19
20
# File 'lib/offline_sort/chunk/input_output/message_pack.rb', line 18

def read_entry
  unpacker.read
end

#write_entry(entry) ⇒ Object



22
23
24
# File 'lib/offline_sort/chunk/input_output/message_pack.rb', line 22

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