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

Method LookupSegment

tensorflow/core/util/tensor_bundle/tensor_bundle.cc:1113–1137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1111}
1112
1113Status BundleReader::LookupSegment(StringPiece key, size_t buffer_size, char* destination, size_t& real_bytes_read) {
1114 LookupSegItem& seg_item = tmp_lookupseg_items_[string(key)];
1115 const size_t desired_bytes = std::min(buffer_size, seg_item.total_size);
1116 if (desired_bytes == 0) {
1117 real_bytes_read = 0;
1118 return Status::OK();
1119 }
1120
1121 io::InputBuffer* buffered_file = data_[seg_item.entry.shard_id()];
1122 StringPiece result;
1123 Status status = buffered_file->file()->Read(seg_item.entry.offset() + seg_item.bytes_read, desired_bytes, &result, destination);
1124
1125 if (!status.ok()) {
1126 return errors::InvalidArgument("Read Error! ", buffer_size, " ", seg_item.total_size, " ", seg_item.entry.offset() + seg_item.bytes_read, " ", desired_bytes, " ", status.ToString());
1127 }
1128 if (result.size() != desired_bytes) {
1129 return errors::DataLoss("Requested ", desired_bytes, " bytes but read ",
1130 result.size(), " bytes.");
1131 }
1132 // Data is already in the correct location.
1133 seg_item.bytes_read += result.size();
1134 seg_item.total_size -= result.size();
1135 real_bytes_read = result.size();
1136 return Status::OK();
1137}
1138
1139Status BundleReader::LookupSegmentOffset(StringPiece key, uint64_t offset, size_t buffer_size, char* destination, size_t& real_bytes_read) {
1140 LookupSegItem& seg_item = tmp_lookupseg_items_[string(key)];

Callers 2

LookupSegmentInternalFunction · 0.80
ReadRecordFunction · 0.80

Calls 8

InvalidArgumentFunction · 0.85
minFunction · 0.50
ReadMethod · 0.45
fileMethod · 0.45
offsetMethod · 0.45
okMethod · 0.45
ToStringMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected