Convert an index iterator value (i.e., an encoded BlockHandle) into an iterator over the contents of the corresponding block.
| 92 | // Convert an index iterator value (i.e., an encoded BlockHandle) |
| 93 | // into an iterator over the contents of the corresponding block. |
| 94 | Iterator* Table::BlockReader(void* arg, const StringPiece& index_value) { |
| 95 | Table* table = reinterpret_cast<Table*>(arg); |
| 96 | // Cache* block_cache = table->rep_->options.block_cache; |
| 97 | Block* block = nullptr; |
| 98 | // Cache::Handle* cache_handle = NULL; |
| 99 | |
| 100 | BlockHandle handle; |
| 101 | StringPiece input = index_value; |
| 102 | Status s = handle.DecodeFrom(&input); |
| 103 | // We intentionally allow extra stuff in index_value so that we |
| 104 | // can add more features in the future. |
| 105 | |
| 106 | if (s.ok()) { |
| 107 | BlockContents contents; |
| 108 | s = ReadBlock(table->rep_->file, handle, &contents); |
| 109 | if (s.ok()) { |
| 110 | block = new Block(contents); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | Iterator* iter; |
| 115 | if (block != nullptr) { |
| 116 | iter = block->NewIterator(); |
| 117 | iter->RegisterCleanup(&DeleteBlock, block, nullptr); |
| 118 | } else { |
| 119 | iter = NewErrorIterator(s); |
| 120 | } |
| 121 | return iter; |
| 122 | } |
| 123 | |
| 124 | Iterator* Table::NewIterator() const { |
| 125 | return NewTwoLevelIterator(rep_->index_block->NewIterator(), |
nothing calls this directly
no test coverage detected