Module: Spark::Helper::Serialize

Included in:
Command::PartitionBy::Base, CommandBuilder, Worker::Base
Defined in:
lib/spark/helper/serialize.rb

Constant Summary collapse

DIRECTIVE_INTEGER_BIG_ENDIAN =
'l>'
DIRECTIVE_INTEGERS_BIG_ENDIAN =
'l>*'
DIRECTIVE_LONG_BIG_ENDIAN =
'q>'
DIRECTIVE_LONGS_BIG_ENDIAN =
'q>*'
DIRECTIVE_DOUBLE_BIG_ENDIAN =
'G'
DIRECTIVE_DOUBLES_BIG_ENDIAN =
'G*'
DIRECTIVE_UNSIGNED_CHARS =
'C*'
DIRECTIVE_CHARS =
'c*'

Instance Method Summary collapse

Instance Method Details

#pack_double(data) ⇒ Object



24
25
26
# File 'lib/spark/helper/serialize.rb', line 24

def pack_double(data)
  [data].pack(DIRECTIVE_DOUBLE_BIG_ENDIAN)
end

#pack_doubles(data) ⇒ Object



42
43
44
45
# File 'lib/spark/helper/serialize.rb', line 42

def pack_doubles(data)
  __check_array(data)
  data.pack(DIRECTIVE_DOUBLES_BIG_ENDIAN)
end

#pack_int(data) ⇒ Object

Packing



16
17
18
# File 'lib/spark/helper/serialize.rb', line 16

def pack_int(data)
  [data].pack(DIRECTIVE_INTEGER_BIG_ENDIAN)
end

#pack_ints(data) ⇒ Object



32
33
34
35
# File 'lib/spark/helper/serialize.rb', line 32

def pack_ints(data)
  __check_array(data)
  data.pack(DIRECTIVE_INTEGERS_BIG_ENDIAN)
end

#pack_long(data) ⇒ Object



20
21
22
# File 'lib/spark/helper/serialize.rb', line 20

def pack_long(data)
  [data].pack(DIRECTIVE_LONG_BIG_ENDIAN)
end

#pack_longs(data) ⇒ Object



37
38
39
40
# File 'lib/spark/helper/serialize.rb', line 37

def pack_longs(data)
  __check_array(data)
  data.pack(DIRECTIVE_LONGS_BIG_ENDIAN)
end

#pack_unsigned_chars(data) ⇒ Object



28
29
30
# File 'lib/spark/helper/serialize.rb', line 28

def pack_unsigned_chars(data)
  data.pack(DIRECTIVE_UNSIGNED_CHARS)
end

#unpack_chars(data) ⇒ Object



57
58
59
# File 'lib/spark/helper/serialize.rb', line 57

def unpack_chars(data)
  data.unpack(DIRECTIVE_CHARS)
end

#unpack_int(data) ⇒ Object

Unpacking



49
50
51
# File 'lib/spark/helper/serialize.rb', line 49

def unpack_int(data)
  data.unpack(DIRECTIVE_INTEGER_BIG_ENDIAN)[0]
end

#unpack_long(data) ⇒ Object



53
54
55
# File 'lib/spark/helper/serialize.rb', line 53

def unpack_long(data)
  data.unpack(DIRECTIVE_LONG_BIG_ENDIAN)[0]
end