Skip to content

Commit

Permalink
[ntuple] kUnknownCompressionSettings --> kNTupleUnknownCompression
Browse files Browse the repository at this point in the history
  • Loading branch information
jblomer committed Jan 7, 2025
1 parent 1b4422e commit d2d61ea
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion tree/ntuple/v7/inc/ROOT/RNTupleDescriptor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public:
NTupleSize_t fNElements = kInvalidNTupleIndex;
/// The usual format for ROOT compression settings (see Compression.h).
/// The pages of a particular column in a particular cluster are all compressed with the same settings.
int fCompressionSettings = kUnknownCompressionSettings;
int fCompressionSettings = kNTupleUnknownCompression;
/// Suppressed columns have an empty page range and unknown compression settings.
/// Their element index range, however, is aligned with the corresponding column of the
/// primary column representation (see Section "Suppressed Columns" in the specification)
Expand Down
4 changes: 2 additions & 2 deletions tree/ntuple/v7/inc/ROOT/RNTupleMerger.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ struct RSealedPageMergeData;
class RClusterPool;

struct RNTupleMergeOptions {
/// If `fCompressionSettings == kUnknownCompressionSettings` (the default), the merger will not change the
/// If `fCompressionSettings == kNTupleUnknownCompression` (the default), the merger will not change the
/// compression of any of its sources (fast merging). Otherwise, all sources will be converted to the specified
/// compression algorithm and level.
int fCompressionSettings = kUnknownCompressionSettings;
int fCompressionSettings = kNTupleUnknownCompression;
/// Determines how the merging treats sources with different models (\see ENTupleMergingMode).
ENTupleMergingMode fMergingMode = ENTupleMergingMode::kFilter;
/// Determines how the Merge function behaves upon merging errors
Expand Down
3 changes: 2 additions & 1 deletion tree/ntuple/v7/inc/ROOT/RNTupleUtil.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ enum ENTupleStructure : std::uint16_t { kInvalid, kLeaf, kCollection, kRecord, k
using NTupleSize_t = std::uint64_t;
constexpr NTupleSize_t kInvalidNTupleIndex = std::uint64_t(-1);

constexpr int kUnknownCompressionSettings = -1;
/// Regular, known compression settings have the form algorithm * 100 + level, e.g. 101, 505, ...
constexpr int kNTupleUnknownCompression = -1;

/// Distriniguishes elements of the same type within a descriptor, e.g. different fields
using DescriptorId_t = std::uint64_t;
Expand Down
2 changes: 1 addition & 1 deletion tree/ntuple/v7/src/RNTupleDescriptor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ ROOT::Experimental::Internal::RClusterDescriptorBuilder::MarkSuppressedColumnRan

RClusterDescriptor::RColumnRange columnRange;
columnRange.fPhysicalColumnId = physicalId;
columnRange.fCompressionSettings = kUnknownCompressionSettings;
columnRange.fCompressionSettings = kNTupleUnknownCompression;
columnRange.fIsSuppressed = true;
fCluster.fColumnRanges[physicalId] = columnRange;
return RResult<void>::Success();
Expand Down
8 changes: 4 additions & 4 deletions tree/ntuple/v7/src/RNTupleMerger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ try {
"RNTuple::Merge",
"Passed both options \"default_compression\" and \"first_source_compression\": only the latter will apply.");
}
int compression = kUnknownCompressionSettings;
int compression = kNTupleUnknownCompression;
if (firstSrcComp) {
// user passed -ff or -fk: use the same compression as the first RNTuple we find in the sources.
// (do nothing here, the compression will be fetched below)
Expand All @@ -113,7 +113,7 @@ try {
}

auto source = RPageSourceFile::CreateFromAnchor(*anchor);
if (compression == kUnknownCompressionSettings) {
if (compression == kNTupleUnknownCompression) {
// Get the compression of this RNTuple and use it as the output compression.
// We currently assume all column ranges have the same compression, so we just peek at the first one.
source->Attach();
Expand Down Expand Up @@ -145,7 +145,7 @@ try {
}

RNTupleWriteOptions writeOpts;
assert(compression != kUnknownCompressionSettings);
assert(compression != kNTupleUnknownCompression);
writeOpts.SetCompression(compression);
auto destination = std::make_unique<RPageSinkFile>(ntupleName, *outFile, writeOpts);

Expand Down Expand Up @@ -886,7 +886,7 @@ RNTupleMerger::Merge(std::span<RPageSource *> sources, RPageSink &destination, c
RNTupleMergeOptions mergeOpts = mergeOptsIn;
{
const auto dstCompSettings = destination.GetWriteOptions().GetCompression();
if (mergeOpts.fCompressionSettings == kUnknownCompressionSettings) {
if (mergeOpts.fCompressionSettings == kNTupleUnknownCompression) {
mergeOpts.fCompressionSettings = dstCompSettings;
} else if (mergeOpts.fCompressionSettings != dstCompSettings) {
return R__FAIL(std::string("The compression given to RNTupleMergeOptions is different from that of the "
Expand Down
11 changes: 4 additions & 7 deletions tree/ntuple/v7/test/ntuple_multi_column.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

TEST(RNTuple, MultiColumnRepresentationSimple)
{
using ROOT::Experimental::kUnknownCompressionSettings;
using ROOT::Experimental::kNTupleUnknownCompression;
FileRaii fileGuard("test_ntuple_multi_column_representation_simple.root");

{
Expand Down Expand Up @@ -53,7 +53,7 @@ TEST(RNTuple, MultiColumnRepresentationSimple)
EXPECT_TRUE(clusterDesc0.GetColumnRange(colDesc16.GetPhysicalId()).fIsSuppressed);
EXPECT_EQ(1u, clusterDesc0.GetColumnRange(colDesc16.GetPhysicalId()).fNElements);
EXPECT_EQ(0u, clusterDesc0.GetColumnRange(colDesc16.GetPhysicalId()).fFirstElementIndex);
EXPECT_EQ(kUnknownCompressionSettings, clusterDesc0.GetColumnRange(colDesc16.GetPhysicalId()).fCompressionSettings);
EXPECT_EQ(kNTupleUnknownCompression, clusterDesc0.GetColumnRange(colDesc16.GetPhysicalId()).fCompressionSettings);

const auto &clusterDesc1 = desc.GetClusterDescriptor(1);
EXPECT_FALSE(clusterDesc1.GetColumnRange(colDesc16.GetPhysicalId()).fIsSuppressed);
Expand All @@ -62,7 +62,7 @@ TEST(RNTuple, MultiColumnRepresentationSimple)
EXPECT_TRUE(clusterDesc1.GetColumnRange(colDesc32.GetPhysicalId()).fIsSuppressed);
EXPECT_EQ(1u, clusterDesc1.GetColumnRange(colDesc32.GetPhysicalId()).fNElements);
EXPECT_EQ(1u, clusterDesc1.GetColumnRange(colDesc32.GetPhysicalId()).fFirstElementIndex);
EXPECT_EQ(kUnknownCompressionSettings, clusterDesc1.GetColumnRange(colDesc32.GetPhysicalId()).fCompressionSettings);
EXPECT_EQ(kNTupleUnknownCompression, clusterDesc1.GetColumnRange(colDesc32.GetPhysicalId()).fCompressionSettings);

const auto &clusterDesc2 = desc.GetClusterDescriptor(2);
EXPECT_FALSE(clusterDesc2.GetColumnRange(colDesc32.GetPhysicalId()).fIsSuppressed);
Expand All @@ -71,7 +71,7 @@ TEST(RNTuple, MultiColumnRepresentationSimple)
EXPECT_TRUE(clusterDesc2.GetColumnRange(colDesc16.GetPhysicalId()).fIsSuppressed);
EXPECT_EQ(1u, clusterDesc2.GetColumnRange(colDesc16.GetPhysicalId()).fNElements);
EXPECT_EQ(2u, clusterDesc2.GetColumnRange(colDesc16.GetPhysicalId()).fFirstElementIndex);
EXPECT_EQ(kUnknownCompressionSettings, clusterDesc2.GetColumnRange(colDesc16.GetPhysicalId()).fCompressionSettings);
EXPECT_EQ(kNTupleUnknownCompression, clusterDesc2.GetColumnRange(colDesc16.GetPhysicalId()).fCompressionSettings);

auto ptrPx = reader->GetModel().GetDefaultEntry().GetPtr<float>("px");
reader->LoadEntry(0);
Expand Down Expand Up @@ -142,7 +142,6 @@ TEST(RNTuple, MultiColumnRepresentationSimple)

TEST(RNTuple, MultiColumnRepresentationString)
{
using ROOT::Experimental::kUnknownCompressionSettings;
FileRaii fileGuard("test_ntuple_multi_column_representation_string.root");

{
Expand Down Expand Up @@ -186,7 +185,6 @@ TEST(RNTuple, MultiColumnRepresentationString)

TEST(RNTuple, MultiColumnRepresentationVector)
{
using ROOT::Experimental::kUnknownCompressionSettings;
FileRaii fileGuard("test_ntuple_multi_column_representation_vector.root");

{
Expand Down Expand Up @@ -233,7 +231,6 @@ TEST(RNTuple, MultiColumnRepresentationVector)

TEST(RNTuple, MultiColumnRepresentationMany)
{
using ROOT::Experimental::kUnknownCompressionSettings;
FileRaii fileGuard("test_ntuple_multi_column_representation_many.root");

{
Expand Down
8 changes: 4 additions & 4 deletions tree/ntuple/v7/test/ntuple_parallel_writer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ TEST(RNTupleParallelWriter, Staged)
TEST(RNTupleParallelWriter, StagedMultiColumn)
{
// Based on MultiColumnRepresentationSimple from ntuple_multi_column.cxx
using ROOT::Experimental::kUnknownCompressionSettings;
using ROOT::Experimental::kNTupleUnknownCompression;
FileRaii fileGuard("test_ntuple_parallel_staged_multi_column.root");

{
Expand Down Expand Up @@ -217,7 +217,7 @@ TEST(RNTupleParallelWriter, StagedMultiColumn)
EXPECT_TRUE(clusterDesc0.GetColumnRange(colDesc16.GetPhysicalId()).fIsSuppressed);
EXPECT_EQ(1u, clusterDesc0.GetColumnRange(colDesc16.GetPhysicalId()).fNElements);
EXPECT_EQ(0u, clusterDesc0.GetColumnRange(colDesc16.GetPhysicalId()).fFirstElementIndex);
EXPECT_EQ(kUnknownCompressionSettings, clusterDesc0.GetColumnRange(colDesc16.GetPhysicalId()).fCompressionSettings);
EXPECT_EQ(kNTupleUnknownCompression, clusterDesc0.GetColumnRange(colDesc16.GetPhysicalId()).fCompressionSettings);

const auto &clusterDesc1 = desc.GetClusterDescriptor(1);
EXPECT_FALSE(clusterDesc1.GetColumnRange(colDesc16.GetPhysicalId()).fIsSuppressed);
Expand All @@ -226,7 +226,7 @@ TEST(RNTupleParallelWriter, StagedMultiColumn)
EXPECT_TRUE(clusterDesc1.GetColumnRange(colDesc32.GetPhysicalId()).fIsSuppressed);
EXPECT_EQ(1u, clusterDesc1.GetColumnRange(colDesc32.GetPhysicalId()).fNElements);
EXPECT_EQ(1u, clusterDesc1.GetColumnRange(colDesc32.GetPhysicalId()).fFirstElementIndex);
EXPECT_EQ(kUnknownCompressionSettings, clusterDesc1.GetColumnRange(colDesc32.GetPhysicalId()).fCompressionSettings);
EXPECT_EQ(kNTupleUnknownCompression, clusterDesc1.GetColumnRange(colDesc32.GetPhysicalId()).fCompressionSettings);

const auto &clusterDesc2 = desc.GetClusterDescriptor(2);
EXPECT_FALSE(clusterDesc2.GetColumnRange(colDesc32.GetPhysicalId()).fIsSuppressed);
Expand All @@ -235,7 +235,7 @@ TEST(RNTupleParallelWriter, StagedMultiColumn)
EXPECT_TRUE(clusterDesc2.GetColumnRange(colDesc16.GetPhysicalId()).fIsSuppressed);
EXPECT_EQ(1u, clusterDesc2.GetColumnRange(colDesc16.GetPhysicalId()).fNElements);
EXPECT_EQ(2u, clusterDesc2.GetColumnRange(colDesc16.GetPhysicalId()).fFirstElementIndex);
EXPECT_EQ(kUnknownCompressionSettings, clusterDesc2.GetColumnRange(colDesc16.GetPhysicalId()).fCompressionSettings);
EXPECT_EQ(kNTupleUnknownCompression, clusterDesc2.GetColumnRange(colDesc16.GetPhysicalId()).fCompressionSettings);

auto ptrPx = reader->GetModel().GetDefaultEntry().GetPtr<float>("px");
reader->LoadEntry(0);
Expand Down
2 changes: 1 addition & 1 deletion tree/ntupleutil/v7/src/RNTupleInspector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void ROOT::Experimental::RNTupleInspector::CollectColumnInfo()
if (fCompressionSettings == -1) {
fCompressionSettings = columnRange.fCompressionSettings;
} else if (fCompressionSettings != columnRange.fCompressionSettings &&
columnRange.fCompressionSettings != kUnknownCompressionSettings) {
columnRange.fCompressionSettings != kNTupleUnknownCompression) {
// Note that currently all clusters and columns are compressed with the same settings and it is not yet
// possible to do otherwise. This means that currently, this exception should never be thrown, but this
// could change in the future.
Expand Down

0 comments on commit d2d61ea

Please sign in to comment.