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

Function DecodeStringList

tensorflow/core/platform/tensor_coding.cc:46–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46bool DecodeStringList(const string& src, tstring* strings, int64 n) {
47 std::vector<uint32> sizes(n);
48 StringPiece reader(src);
49 int64 tot = 0;
50 for (auto& v : sizes) {
51 if (!core::GetVarint32(&reader, &v)) return false;
52 tot += v;
53 }
54 if (tot != static_cast<int64>(reader.size())) {
55 return false;
56 }
57
58 tstring* data = strings;
59 for (int64 i = 0; i < n; ++i, ++data) {
60 auto size = sizes[i];
61 if (size > reader.size()) {
62 return false;
63 }
64 data->assign(reader.data(), size);
65 reader.remove_prefix(size);
66 }
67
68 return true;
69}
70
71void CopyFromArray(string* s, const char* base, size_t bytes) {
72 s->assign(base, bytes);

Callers 2

DecodeMethod · 0.85

Calls 7

GetVarint32Function · 0.85
string_as_arrayFunction · 0.85
resize_uninitializedMethod · 0.80
sizeMethod · 0.45
assignMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected