MCPcopy Create free account
hub / github.com/chen3feng/toft / LoadDataBlock

Method LoadDataBlock

storage/sstable/reader/sstable_reader_impl.cpp:173–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173bool SSTableReader::Impl::LoadDataBlock(int block_id, hfile::DataBlock *block) {
174 CHECK(block_id >= 0 && block_id < data_index_->GetBlockSize())
175 << "invalid block_id: " << block_id;
176
177 // Get length for this block
178 int64_t next_offset = 0;
179 if (block_id + 1 < data_index_->GetBlockSize()) {
180 next_offset = data_index_->GetOffset(block_id + 1);
181 } else {
182 next_offset = file_trailer_->file_info_offset();
183 }
184 int64_t cur_offset = data_index_->GetOffset(block_id);
185 int length = next_offset - cur_offset;
186
187 std::string buffer;
188 {
189 MutexLocker l(&mutex_);
190 if (!file_base_->Seek(cur_offset, SEEK_SET)) {
191 return false;
192 }
193 buffer.resize(length);
194 int64_t size = file_base_->Read((void*) buffer.c_str(), length);
195 if (size != length) {
196 return false;
197 }
198 }
199 return block->DecodeFromString(buffer);
200}
201
202} // namespace toft

Callers 1

InitMethod · 0.45

Calls 7

GetOffsetMethod · 0.80
file_info_offsetMethod · 0.80
resizeMethod · 0.80
GetBlockSizeMethod · 0.45
SeekMethod · 0.45
ReadMethod · 0.45
DecodeFromStringMethod · 0.45

Tested by

no test coverage detected