Skip to content

Commit 516dd85

Browse files
committed
Add tests for compression algorithms
1 parent a91c84c commit 516dd85

File tree

12 files changed

+111
-0
lines changed

12 files changed

+111
-0
lines changed

compression/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Compression
2+
3+
In this category, all tests write a single `Int64` field with type `std::int64_t`.
4+
The entries have ascending values and the reference `.json` files only contain the sum of all elements.
5+
6+
* [`algorithms`](algorithms): `zlib`, `lzma`, `lz4`, `zstd`

compression/algorithms/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Compression Algorithms
2+
3+
* [`zlib`](zlib): compression settings `101`
4+
* [`lzma`](lzma): level 7 (`207`)
5+
* [`lz4`](lz4): level 4 (`404`)
6+
* [`zstd`](zstd): level 5 (`505`)

compression/algorithms/lz4/read.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "../../read_compression.hxx"
2+
3+
void read(std::string_view input = "compression.algorithms.lz4.root",
4+
std::string_view output = "compression.algorithms.lz4.json") {
5+
read_compression(input, output);
6+
}

compression/algorithms/lz4/write.C

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "../write_algorithm.hxx"
2+
3+
void write(std::string_view filename = "compression.algorithms.lz4.root") {
4+
write_algorithm(filename, 404);
5+
}

compression/algorithms/lzma/read.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "../../read_compression.hxx"
2+
3+
void read(std::string_view input = "compression.algorithms.lzma.root",
4+
std::string_view output = "compression.algorithms.lzma.json") {
5+
read_compression(input, output);
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "../write_algorithm.hxx"
2+
3+
void write(std::string_view filename = "compression.algorithms.lzma.root") {
4+
write_algorithm(filename, 207);
5+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <ROOT/RNTupleModel.hxx>
2+
#include <ROOT/RNTupleWriteOptions.hxx>
3+
#include <ROOT/RNTupleWriter.hxx>
4+
5+
using ROOT::Experimental::RNTupleModel;
6+
using ROOT::Experimental::RNTupleWriteOptions;
7+
using ROOT::Experimental::RNTupleWriter;
8+
9+
#include <cstdint>
10+
#include <memory>
11+
#include <string_view>
12+
13+
void write_algorithm(std::string_view filename, std::uint32_t compression) {
14+
auto model = RNTupleModel::Create();
15+
16+
auto Int64 = model->MakeField<std::int64_t>("Int64");
17+
18+
RNTupleWriteOptions options;
19+
options.SetCompression(compression);
20+
auto writer =
21+
RNTupleWriter::Recreate(std::move(model), "ntpl", filename, options);
22+
23+
// Write 32 entries to make sure the compression block is not too small.
24+
for (int i = 0; i < 32; i++) {
25+
*Int64 = i;
26+
writer->Fill();
27+
}
28+
}

compression/algorithms/zlib/read.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "../../read_compression.hxx"
2+
3+
void read(std::string_view input = "compression.algorithms.zlib.root",
4+
std::string_view output = "compression.algorithms.zlib.json") {
5+
read_compression(input, output);
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "../write_algorithm.hxx"
2+
3+
void write(std::string_view filename = "compression.algorithms.zlib.root") {
4+
write_algorithm(filename, 101);
5+
}

compression/algorithms/zstd/read.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "../../read_compression.hxx"
2+
3+
void read(std::string_view input = "compression.algorithms.zstd.root",
4+
std::string_view output = "compression.algorithms.zstd.json") {
5+
read_compression(input, output);
6+
}

0 commit comments

Comments
 (0)