| 18 | } |
| 19 | |
| 20 | void InMemorySSTableReader::Init() { |
| 21 | cached_block_.reset(new hfile::DataBlock(impl_->file_trailer_->compress_type())); |
| 22 | std::vector<std::string> values; |
| 23 | std::string ori_key = ""; |
| 24 | for (int block_id = 0; block_id < impl_->file_trailer_->data_index_count(); block_id++) { |
| 25 | impl_->LoadDataBlock(block_id, cached_block_.get()); |
| 26 | for (int data_idx = 0; data_idx < cached_block_->GetDataItemSize(); data_idx++) { |
| 27 | if (block_id == 0 && data_idx == 0) { |
| 28 | ori_key = cached_block_->GetKey(0); |
| 29 | } |
| 30 | std::string key = cached_block_->GetKey(data_idx); |
| 31 | std::string value = cached_block_->GetValue(data_idx); |
| 32 | if (key != ori_key) { |
| 33 | data_.push_back(make_pair(ori_key, values)); |
| 34 | ori_key = key; |
| 35 | values.clear(); |
| 36 | } |
| 37 | values.push_back(value); |
| 38 | } |
| 39 | } |
| 40 | data_.push_back(make_pair(ori_key, values)); |
| 41 | // index_.resize(data_.size() * 2); |
| 42 | for (DataVector::iterator it = data_.begin(); it != data_.end(); it++) { |
| 43 | index_.insert(make_pair(it->first, it)); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | InMemoryIterator::InMemoryIterator(InMemorySSTableReader *sstable, const std::string &key) |
| 48 | : sstable_(sstable) { |
no test coverage detected