Class: Spark::Serializer::Compressed

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

Instance Method Summary collapse

Methods inherited from Base

#==, #batched?, #check_each, #error, #inspect, #load_from_file, #load_from_io, #name, #to_s, #unbatch!

Constructor Details

#initialize(serializer) ⇒ Compressed

Returns a new instance of Compressed.



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

def initialize(serializer)
  @serializer = serializer
end

Instance Method Details

#dump(data) ⇒ Object



9
10
11
# File 'lib/spark/serializer/compressed.rb', line 9

def dump(data)
  Zlib::Deflate.deflate(@serializer.dump(data))
end

#load(data) ⇒ Object



13
14
15
# File 'lib/spark/serializer/compressed.rb', line 13

def load(data)
  @serializer.load(Zlib::Inflate.inflate(data))
end