Skip to content

Commit

Permalink
[ntuple] Throw when inconsistent compression is encountered
Browse files Browse the repository at this point in the history
  • Loading branch information
enirolf authored and jblomer committed Sep 5, 2023
1 parent 536b978 commit fcb2132
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 9 additions & 3 deletions tree/ntupleutil/v7/inc/ROOT/RNTupleInspector.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ private:
/// information will be stored in `fColumnInfo`, and the RNTuple-level information
/// in `fCompressionSettings`, `fOnDiskSize` and `fInMemorySize`.
///
/// This method is called when the `RNTupleInspector` is initially created.
/// This method is called when the `RNTupleInspector` is initially created. This means that anything unexpected about
/// the RNTuple itself (e.g. inconsistent compression settings across clusters) will be detected here. Therefore, any
/// related exceptions will be thrown on creation of the inspector.
void CollectColumnInfo();

/// Recursively gather field-level information and store it in `fFieldTreeInfo`.
Expand All @@ -133,15 +135,19 @@ public:
RNTupleInspector &operator=(RNTupleInspector &&other) = delete;
~RNTupleInspector() = default;

/// Create a new inspector for a given RNTuple.
/// Create a new inspector for a given RNTuple. When this factory method is called, all required static information
/// is collected from the RNTuple's fields and underlying columns are collected at ones. This means that when any
/// inconsistencies are encountered (e.g. inconsistent compression across clusters), it will throw an error here.
static std::unique_ptr<RNTupleInspector> Create(std::unique_ptr<Detail::RPageSource> pageSource);
static std::unique_ptr<RNTupleInspector> Create(RNTuple *sourceNTuple);
static std::unique_ptr<RNTupleInspector> Create(std::string_view ntupleName, std::string_view storage);

/// Get the descriptor for the RNTuple being inspected.
RNTupleDescriptor *GetDescriptor() const { return fDescriptor.get(); }

/// Get the compression settings of the RNTuple being inspected.
/// Get the compression settings of the RNTuple being inspected. Here, we assume that the compression settings are
/// consistent across all clusters and columns. If this is not the case, an exception will be thrown upon
/// `RNTupleInspector::Create`.
int GetCompressionSettings() const { return fCompressionSettings; }

/// Get the on-disk, compressed size of the RNTuple being inspected, in bytes.
Expand Down
9 changes: 7 additions & 2 deletions tree/ntupleutil/v7/src/RNTupleInspector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ void ROOT::Experimental::RNTupleInspector::CollectColumnInfo()

if (fCompressionSettings == -1) {
fCompressionSettings = columnRange.fCompressionSettings;
} else {
R__ASSERT(columnRange.fCompressionSettings == fCompressionSettings);
} else if (fCompressionSettings != columnRange.fCompressionSettings) {
// Note that currently all clusters and columns are compressed with the same settings and it is not yet
// possible to do otherwise. This measn that currently, this exception should never be thrown, but this
// could change in the future.
throw RException(R__FAIL("compression setting mismatch between column ranges (" +
std::to_string(fCompressionSettings) + " vs " +
std::to_string(columnRange.fCompressionSettings) + ")"));
}

const auto &pageRange = clusterDescriptor.GetPageRange(colId);
Expand Down

0 comments on commit fcb2132

Please sign in to comment.