Class: Nearline::Models::FileSequencer
- Inherits:
-
Object
- Object
- Nearline::Models::FileSequencer
- Defined in:
- lib/nearline/file_sequencer.rb
Overview
Used for mass block entry and sequencing
Constant Summary collapse
- @@max_blocks =
Number of blocks to serialize in a batch
500
Instance Attribute Summary collapse
-
#file_size ⇒ Object
readonly
Returns the value of attribute file_size.
Instance Method Summary collapse
- #fingerprint ⇒ Object
-
#initialize(io, file_content) ⇒ FileSequencer
constructor
A new instance of FileSequencer.
- #persist_segment ⇒ Object
Constructor Details
#initialize(io, file_content) ⇒ FileSequencer
Returns a new instance of FileSequencer.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/nearline/file_sequencer.rb', line 12 def initialize(io, file_content) @io = io @file_content = file_content if (@file_content.id.nil?) @file_content.save! end @s = [] # sequence array @b = [] # blocks read and fingerprinted @file_size = 0 @offset = 0 # TODO: split out SHA1 into its own file read @whole_file_hash = Digest::SHA1.new end |
Instance Attribute Details
#file_size ⇒ Object (readonly)
Returns the value of attribute file_size.
6 7 8 |
# File 'lib/nearline/file_sequencer.rb', line 6 def file_size @file_size end |
Instance Method Details
#fingerprint ⇒ Object
26 27 28 |
# File 'lib/nearline/file_sequencer.rb', line 26 def fingerprint @whole_file_hash.hexdigest end |
#persist_segment ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/nearline/file_sequencer.rb', line 30 def persist_segment pull_blocks sequence_known_blocks attempt_compression_of_remaining_blocks insert_new_blocks sequence_known_blocks insert_sequences clear_for_next_persist end |