| 81 | } |
| 82 | |
| 83 | bool Reader::SkipToInitialBlock() { |
| 84 | size_t offset_in_block = initial_offset_ % block_size_; |
| 85 | uint64_t block_start_location = initial_offset_ - offset_in_block; |
| 86 | |
| 87 | // Don't search a block if we'd be in the trailer |
| 88 | if (offset_in_block > (size_t)(block_size_ - 6)) { |
| 89 | block_start_location += block_size_; |
| 90 | } |
| 91 | |
| 92 | end_of_buffer_offset_ = block_start_location; |
| 93 | |
| 94 | // Skip to start of first block that can contain the initial record |
| 95 | if (block_start_location > 0) { |
| 96 | Status skip_status = file_->Skip(block_start_location); |
| 97 | if (!skip_status.ok()) { |
| 98 | ReportDrop(block_start_location, skip_status); |
| 99 | return false; |
| 100 | } |
| 101 | } |
| 102 | return true; |
| 103 | } |
| 104 | |
| 105 | Status Reader::ReadRecord(Slice* record, std::string* scratch) { |
| 106 | if (last_record_offset_ < initial_offset_) { |