Class: Spark::Serializer::Pair

Inherits:
Base
  • Object
show all
Defined in:
lib/spark/serializer/pair.rb

Constant Summary

Constants included from Constant

Constant::ACCUMULATOR_ACK, Constant::CREATE_WORKER, Constant::DATA_EOF, Constant::KILL_WORKER, Constant::KILL_WORKER_AND_WAIT, Constant::SUCCESSFULLY_KILLED, Constant::UNSUCCESSFUL_KILLING, Constant::WORKER_DONE, Constant::WORKER_ERROR

Constants included from Helper::Serialize

Helper::Serialize::DIRECTIVE_CHARS, Helper::Serialize::DIRECTIVE_DOUBLES_BIG_ENDIAN, Helper::Serialize::DIRECTIVE_DOUBLE_BIG_ENDIAN, Helper::Serialize::DIRECTIVE_INTEGERS_BIG_ENDIAN, Helper::Serialize::DIRECTIVE_INTEGER_BIG_ENDIAN, Helper::Serialize::DIRECTIVE_LONGS_BIG_ENDIAN, Helper::Serialize::DIRECTIVE_LONG_BIG_ENDIAN, Helper::Serialize::DIRECTIVE_UNSIGNED_CHARS

Instance Attribute Summary collapse

Attributes inherited from Base

#batch_size

Instance Method Summary collapse

Methods inherited from Base

#==, #dump, #dump_to_java, #initialize, #load, #load_from_io, #load_from_iterator, #read_int, #try, #unbatch!

Methods included from Helper::Serialize

#pack_double, #pack_doubles, #pack_int, #pack_ints, #pack_long, #pack_longs, #pack_unsigned_chars, #unpack_chars, #unpack_int, #unpack_long

Constructor Details

This class inherits a constructor from Spark::Serializer::Base

Instance Attribute Details

#firstObject (readonly)

Returns the value of attribute first.



5
6
7
# File 'lib/spark/serializer/pair.rb', line 5

def first
  @first
end

#secondObject (readonly)

Returns the value of attribute second.



5
6
7
# File 'lib/spark/serializer/pair.rb', line 5

def second
  @second
end

Instance Method Details

#batched?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/spark/serializer/pair.rb', line 14

def batched?
  false
end

#load_next_from_io(io, lenght) ⇒ Object



18
19
20
21
22
23
# File 'lib/spark/serializer/pair.rb', line 18

def load_next_from_io(io, lenght)
  key_value = []
  key_value << @first.load_next_from_io(io, lenght)
  key_value << @second.load_next_from_io(io, read_int(io))
  key_value
end

#set(first, second) ⇒ Object



7
8
9
10
11
12
# File 'lib/spark/serializer/pair.rb', line 7

def set(first, second)
  unbatch!
  @first  = first
  @second = second
  self
end