MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ApproximateOffsetOf

Method ApproximateOffsetOf

tensorflow/core/lib/io/table.cc:151–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151uint64 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

Callers

nothing calls this directly

Calls 7

DecodeFromMethod · 0.80
NewIteratorMethod · 0.45
SeekMethod · 0.45
ValidMethod · 0.45
valueMethod · 0.45
okMethod · 0.45
offsetMethod · 0.45

Tested by

no test coverage detected