MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / makeStringColumn

Function makeStringColumn

pj_datastore/tests/encoding_test.cpp:30–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28};
29
30StringColumnData makeStringColumn(const std::vector<std::string>& strings) {
31 StringColumnData col;
32
33 // offsets: (strings.size() + 1) uint32_t entries
34 col.offsets.resize((strings.size() + 1) * sizeof(uint32_t));
35 uint32_t running = 0;
36 for (std::size_t i = 0; i < strings.size(); ++i) {
37 std::memcpy(col.offsets.data() + i * sizeof(uint32_t), &running, sizeof(uint32_t));
38 running += static_cast<uint32_t>(strings[i].size());
39 }
40 std::memcpy(col.offsets.data() + strings.size() * sizeof(uint32_t), &running, sizeof(uint32_t));
41
42 // values: concatenated string bytes
43 col.values.reserve(running);
44 for (const auto& s : strings) {
45 col.values.insert(col.values.end(), s.begin(), s.end());
46 }
47
48 return col;
49}
50
51// ==========================================================================
52// Dictionary encoding tests

Callers 1

TESTFunction · 0.85

Calls 7

reserveMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected