15#include <catch_amalgamated.hpp>
25std::vector<uint8_t> bigEndian(std::vector<T>
const&
values)
29 w.put(std::bit_cast<std::conditional_t<
sizeof(T) == 4,
uint32_t, std::conditional_t<
sizeof(T) == 8, uint64_t, std::conditional_t<
sizeof(T) == 2,
uint16_t,
uint8_t>>>>(
v));
36 std::vector<uint8_t>
file = std::vector<uint8_t>(100, 0);
39 BranchBuilder(
char leafClass,
int fixedLen = 1)
48 void add(
Algo algo, std::vector<uint8_t>
const&
values, int32_t
nEntries,
size_t tail = 0,
size_t chunkSize = 0xffffff,
bool ioBits =
false)
52 file.insert(
file.end(), basket.begin(), basket.end());
56 void addEmbedded(std::vector<uint8_t>
const&
values, int32_t
nEntries)
66 std::vector<uint8_t>
v{1, 2, 3, 4, 5, 6, 7, 8};
68 CHECK(
v == std::vector<uint8_t>{4, 3, 2, 1, 8, 7, 6, 5});
70 CHECK(
v == std::vector<uint8_t>{5, 6, 7, 8, 1, 2, 3, 4});
72 CHECK(
v == std::vector<uint8_t>{6, 5, 8, 7, 2, 1, 4, 3});
75TEST_CASE(
"float values across codecs, uncompressed and embedded baskets")
80 for (
auto algo : {Algo::ZSTD, Algo::None, Algo::ZLIB, Algo::LZMA, Algo::LZ4}) {
82 for (
int i = 0;
i < 1000; ++
i) {
89 std::vector<float> tail{-1.f, -2.f, -3.f};
90 b.addEmbedded(bigEndian(tail), tail.size());
93 for (
bool mappable : {
true,
false}) {
94 for (
int threads : {1, 4}) {
97 options.threads = threads;
99 std::vector<float> out(
expected.size(), 42.f);
100 decoder.decodeValues(
b.branch, (
uint8_t*)out.data(), out.size() *
sizeof(
float));
106TEST_CASE(
"baskets with fIOBits in their header decode like the others")
108 BranchBuilder
b{
'F'};
110 for (
auto [algo, ioBits] : {std::pair{Algo::ZSTD,
true}, std::pair{Algo::None,
false}, std::pair{Algo::LZ4,
true}}) {
111 std::vector<float>
values;
112 for (
int i = 0;
i < 100; ++
i) {
115 b.add(algo, bigEndian(
values),
values.size(), 404, 0xffffff, ioBits);
120 std::vector<float> out(
expected.size(), 42.f);
121 decoder.decodeValues(
b.branch, (
uint8_t*)out.data(), out.size() *
sizeof(
float));
125TEST_CASE(
"decoding stops exactly at the value region for every codec")
130 for (
auto algo : {Algo::ZSTD, Algo::ZLIB, Algo::LZMA, Algo::LZ4, Algo::None}) {
131 for (
size_t chunkSize : {size_t(100000), size_t(0xffffff)}) {
132 INFO(
"algorithm " << (
int)algo <<
", chunk size " << chunkSize);
133 BranchBuilder
b{
'D'};
134 std::vector<double>
values(70001);
135 for (
size_t i = 0;
i <
values.size(); ++
i) {
141 std::vector<double> out(
values.size() + 16, 1e300);
142 decoder.decodeValues(
b.branch, (
uint8_t*)out.data(),
values.size() *
sizeof(
double));
144 CHECK(std::all_of(out.begin() +
values.size(), out.end(), [](
double v) { return v == 1e300; }));
149TEST_CASE(
"fixed-size arrays and wrong destination sizes")
151 BranchBuilder
b{
'S', 3};
152 std::vector<int16_t>
values{1, 2, 3, -4, -5, -6};
153 b.add(Algo::ZSTD, bigEndian(
values), 2);
156 std::vector<int16_t> out(6);
157 decoder.decodeValues(
b.branch, (
uint8_t*)out.data(), 12);
162TEST_CASE(
"booleans are packed across basket and window boundaries")
166 BranchBuilder
b{
'O'};
169 std::vector<uint8_t>
bytes;
170 for (
int i = 0;
i <
size; ++
i) {
171 bool v = ((
expected.size() * 7) % 3) == 0;
174 bytes.push_back(
v ? (
i % 2 ? 1 : 0x80) : 0);
180 std::vector<uint8_t> bitmap((
expected.size() + 7) / 8, 0xFF);
181 decoder.decodeBooleans(
b.branch, bitmap.data(), bitmap.size());
187 for (
size_t i =
expected.size();
i < bitmap.size() * 8; ++
i) {
188 CHECK(((bitmap[
i / 8] >> (
i % 8)) & 1) == 0);
194 BranchBuilder
sizes{
'I'};
195 sizes.branch.name =
"fY_size";
196 std::vector<int32_t>
s1{2, 0, 3}, s2{1};
197 sizes.add(Algo::ZLIB, bigEndian(
s1), 3);
198 sizes.add(Algo::None, bigEndian(s2), 1);
201 BranchBuilder
values{
'D'};
202 values.branch.name =
"fY";
203 values.branch.countBranch =
"fY_size";
204 std::vector<double>
v1{1.5, 2.5},
v2{3.5, 4.5, 5.5, 6.5};
205 values.add(Algo::LZ4, bigEndian(
v1), 2);
206 values.add(Algo::ZSTD, bigEndian(
v2), 2);
210 auto shift =
file.size() - 100;
212 for (
auto& basket :
values.branch.baskets) {
213 basket.seek += shift;
220 std::vector<double> out(6);
221 decoder.decodeVLAValues(
values.branch,
offsets, (
uint8_t*)out.data(), out.size() *
sizeof(
double));
222 CHECK(out == std::vector<double>{1.5, 2.5, 3.5, 4.5, 5.5, 6.5});
227 BranchBuilder
b{
'I'};
228 std::vector<int32_t>
values{1, 2, 3};
229 b.add(Algo::ZSTD, bigEndian(
values), 3);
232 std::vector<int32_t> out(3);
234 SECTION(
"entry count in the header differs from the TBranch")
236 auto branch =
b.branch;
237 branch.
baskets[0].nEntries = 2;
241 SECTION(
"baskets do not cover the entries")
243 auto branch =
b.branch;
245 std::vector<int32_t> big(4);
248 SECTION(
"basket size differs from the TBranch")
250 auto branch =
b.branch;
254 SECTION(
"basket location past the end of the file")
256 auto branch =
b.branch;
257 branch.
baskets[0].seek =
b.file.size();
unsigned short int uint16_t
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font Renderer for event Frontend to use for event ROOT macros used as track filter Console script file
static constexpr size_t kBooleanWindow
Size of the boolean window, the only decode-side scratch memory.
A file made of concatenated in-memory buffers.
GLuint GLsizei const GLuint const GLintptr * offsets
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLboolean GLboolean GLboolean b
GLsizei GLsizei GLchar * source
GLenum GLsizei GLsizei GLint * values
GLubyte GLubyte GLubyte GLubyte w
GLfloat GLfloat GLfloat v2
std::vector< uint8_t > makeBasket(Algo algo, std::span< const uint8_t > values, int32_t nevbuf, size_t tailBytes=0, size_t chunkSize=0xffffff, bool ioBits=false)
void byteswapInPlace(uint8_t *data, size_t count, size_t typeSize)
Byteswaps count big-endian values of typeSize bytes in place.
int32_t const char * file
std::vector< BasketRef > baskets
std::map< std::string, ID > expected
TEST_CASE("byteswapInPlace")