Module: Rubcask::Tombstone
Overview
The prev_file_id is stored to support merge of subset of directory files, that is currently not implemented
Constant Summary collapse
- PREFIX =
"TOMBSTONE".b
- PREFIX_SIZE =
PREFIX.bytesize
- FILE_ID_FORMAT =
"N"- FULL_BYTE_SIZE =
PREFIX_SIZE + 4
Instance Method Summary collapse
- #is_tombstone?(value) ⇒ Boolean
-
#new_tombstone(current_file_id, prev_file_id) ⇒ String
Creates a new tombstone value.
-
#tombstone_file_id(value) ⇒ Integer?
Gets file id from tombstone value.
Instance Method Details
#is_tombstone?(value) ⇒ Boolean
19 20 21 |
# File 'lib/rubcask/tombstone.rb', line 19 def is_tombstone?(value) value.bytesize <= FULL_BYTE_SIZE && value.start_with?(PREFIX) end |
#new_tombstone(current_file_id, prev_file_id) ⇒ String
Creates a new tombstone value
27 28 29 30 |
# File 'lib/rubcask/tombstone.rb', line 27 def new_tombstone(current_file_id, prev_file_id) return PREFIX if prev_file_id == current_file_id PREFIX.b << [prev_file_id].pack(FILE_ID_FORMAT) end |
#tombstone_file_id(value) ⇒ Integer?
Gets file id from tombstone value
35 36 37 38 |
# File 'lib/rubcask/tombstone.rb', line 35 def tombstone_file_id(value) return nil if value.bytesize < FULL_BYTE_SIZE value.byteslice(PREFIX_SIZE, 4).unpack1(FILE_ID_FORMAT) end |