MCPcopy Create free account
hub / github.com/TileDB-Inc/TileDB / dataAndOffsetToStrings

Function dataAndOffsetToStrings

test/src/unit-cppapi-string-dims.cc:42–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40using namespace tiledb;
41
42std::vector<std::string> dataAndOffsetToStrings(
43 Query query,
44 std::string col,
45 std::vector<uint64_t> offsets,
46 std::string data) {
47 // Get the string sizes
48 auto result_el_map = query.result_buffer_elements();
49 auto result_el_off = result_el_map[col].first;
50 std::vector<uint64_t> str_sizes;
51 if (result_el_off > 1) {
52 for (size_t i = 0; i < result_el_off - 1; ++i) {
53 if (i >= offsets.size()) {
54 std::stringstream msg;
55 msg << "i " << i << ", offsets.size() " << offsets.size();
56 LOG_TRACE(msg.str());
57 }
58 str_sizes.push_back(offsets[i + 1] - offsets[i]);
59 if (str_sizes.size() > data.size()) {
60 std::stringstream msg;
61 msg << "str_sizes.size() " << str_sizes.size() << ", data.size() "
62 << data.size();
63 LOG_TRACE(msg.str());
64 }
65 }
66 }
67 if (result_el_off >= 1) {
68 auto result_data_size = result_el_map[col].second * sizeof(char);
69 str_sizes.push_back(result_data_size - offsets[result_el_off - 1]);
70 }
71
72 // Get the strings
73 std::vector<std::string> vstr;
74 for (size_t i = 0; i < result_el_off; ++i)
75 vstr.push_back(std::string(&data[offsets[i]], str_sizes[i]));
76 return vstr;
77}
78
79void write_array_1(
80 const Context& ctx,

Callers 1

Calls 5

LOG_TRACEFunction · 0.85
strMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected