| 149 | } |
| 150 | |
| 151 | uint64 Table::ApproximateOffsetOf(const StringPiece& key) const { |
| 152 | Iterator* index_iter = rep_->index_block->NewIterator(); |
| 153 | index_iter->Seek(key); |
| 154 | uint64 result; |
| 155 | if (index_iter->Valid()) { |
| 156 | BlockHandle handle; |
| 157 | StringPiece input = index_iter->value(); |
| 158 | Status s = handle.DecodeFrom(&input); |
| 159 | if (s.ok()) { |
| 160 | result = handle.offset(); |
| 161 | } else { |
| 162 | // Strange: we can't decode the block handle in the index block. |
| 163 | // We'll just return the offset of the metaindex block, which is |
| 164 | // close to the whole file size for this case. |
| 165 | result = rep_->metaindex_handle.offset(); |
| 166 | } |
| 167 | } else { |
| 168 | // key is past the last key in the file. Approximate the offset |
| 169 | // by returning the offset of the metaindex block (which is |
| 170 | // right near the end of the file). |
| 171 | result = rep_->metaindex_handle.offset(); |
| 172 | } |
| 173 | delete index_iter; |
| 174 | return result; |
| 175 | } |
| 176 | |
| 177 | } // namespace table |
| 178 | } // namespace tensorflow |
nothing calls this directly
no test coverage detected