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

Function forDecodeRangeAsDoubles

pj_datastore/src/encoding.cpp:253–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253void forDecodeRangeAsDoubles(const FrameOfReferenceEncoded& enc, Span<double> out, std::size_t row_start) {
254 const std::size_t count = out.size();
255 const double ref = static_cast<double>(enc.reference);
256 const uint8_t* base = enc.offsets.data();
257
258 switch (enc.offset_bytes) {
259 case 1: {
260 const uint8_t* src = base + row_start;
261 for (std::size_t i = 0; i < count; ++i) {
262 out[i] = ref + static_cast<double>(src[i]);
263 }
264 break;
265 }
266 case 2: {
267 const uint8_t* src = base + row_start * 2;
268 for (std::size_t i = 0; i < count; ++i) {
269 uint16_t v{};
270 std::memcpy(&v, src + i * 2, sizeof(v));
271 out[i] = ref + static_cast<double>(v);
272 }
273 break;
274 }
275 default: {
276 const uint8_t* src = base + row_start * 4;
277 for (std::size_t i = 0; i < count; ++i) {
278 uint32_t v{};
279 std::memcpy(&v, src + i * 4, sizeof(v));
280 out[i] = ref + static_cast<double>(v);
281 }
282 break;
283 }
284 }
285}
286
287// ---------------------------------------------------------------------------
288// Dictionary encoding for strings

Callers 2

readColumnAsDoublesMethod · 0.85
TESTFunction · 0.85

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by 1

TESTFunction · 0.68