Class: RocketJob::Sliced::BZip2OutputSlice
- Defined in:
- lib/rocket_job/sliced/bzip2_output_slice.rb
Overview
This is a specialized output serializer that renders each output slice as a single BZip2 compressed stream. BZip2 allows multiple output streams to be written into a single BZip2 file.
Notes:
-
The ‘bzip2` linux command line utility supports multiple embedded BZip2 stream, but some other custom implementations may not. They may only read the first slice and stop.
-
It is only designed for use on output collections.
Class Method Summary collapse
-
.binary_format ⇒ Object
This is a specialized binary slice for creating BZip2 binary data from each slice that must be downloaded as-is into output files.
-
.to_binary(records, record_delimiter = "\n") ⇒ Object
Compress the supplied records with BZip2.
Methods inherited from Slice
#as_attributes, #current_record_number, #fail_on_exception!, #failed_record, #inspect, #records, #records=, #set_exception
Class Method Details
.binary_format ⇒ Object
This is a specialized binary slice for creating BZip2 binary data from each slice that must be downloaded as-is into output files.
13 14 15 |
# File 'lib/rocket_job/sliced/bzip2_output_slice.rb', line 13 def self.binary_format :bz2 end |
.to_binary(records, record_delimiter = "\n") ⇒ Object
Compress the supplied records with BZip2
18 19 20 21 22 23 24 25 |
# File 'lib/rocket_job/sliced/bzip2_output_slice.rb', line 18 def self.to_binary(records, record_delimiter = "\n") return [] if records.blank? lines = Array(records).join(record_delimiter) + record_delimiter s = StringIO.new IOStreams::Bzip2::Writer.stream(s) { |io| io.write(lines) } s.string end |