Skip to content

Commit 270fbb9

Browse files
committed
[df] Improve naming of column to bitmask mapping
The object saved together with the output dataset by Snapshot with variations now features `column` rather than `branch` in the name, to be more generic. We also avoid mixing snake_case with CamelCase in the name, opting for the first.
1 parent 6ca16e6 commit 270fbb9

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

tree/dataframe/src/RDFSnapshotHelpers.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ struct SnapshotOutputWriter {
10351035
{
10361036
if (!fBranchToBitmaskMapping.empty()) {
10371037
fFile->WriteObject(&fBranchToBitmaskMapping,
1038-
(std::string{"R_rdf_branchToBitmaskMapping_"} + fTree->GetName()).c_str());
1038+
(std::string{"R_rdf_column_to_bitmask_mapping_"} + fTree->GetName()).c_str());
10391039
}
10401040
if (fTree) {
10411041
// use AutoSave to flush TTree contents because TTree::Write writes in gDirectory, not in fDirectory

tree/dataframe/src/RDataFrame.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,10 +1270,10 @@ dataset as a `std::uin64_t`. For every 64 columns, a new bitmask column is added
12701270
12711271
Each column that might contain invalid values is connected to exactly one bit in one bitmask. A mapping of column names
12721272
to the corresponding bitmask is placed in the same file as the output dataset, with a name that follows the pattern
1273-
`"R_rdf_branchToBitmaskMapping_<NAME_OF_THE_DATASET>"`. It is of type
1273+
`"R_rdf_column_to_bitmask_mapping_<NAME_OF_THE_DATASET>"`. It is of type
12741274
`std::unordered_map<std::string, std::pair<std::string, unsigned int>>`, and maps a column name to the name of the
12751275
bitmask column and the index of the relevant bit. For example, in the same file as the dataset "Events" there would be
1276-
an object named `R_rdf_branchToBitmaskMapping_Events`. This object for example would describe a connection such as:
1276+
an object named `R_rdf_column_to_bitmask_mapping_Events`. This object for example would describe a connection such as:
12771277
12781278
~~~
12791279
muon_pt --> (R_rdf_mask_Events_0, 42)

tree/dataframe/src/RTTreeDS.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ ROOT::Internal::RDF::RTTreeDS::CreateColumnReader(unsigned int /*slot*/, std::st
522522
if (TDirectory *treeDir = treeReader->GetTree()->GetDirectory(); treeDir) {
523523
using Map_t = std::unordered_map<std::string, std::pair<std::string, unsigned int>>;
524524
const std::string bitmaskMapName =
525-
std::string{"R_rdf_branchToBitmaskMapping_"} + treeReader->GetTree()->GetName();
525+
std::string{"R_rdf_column_to_bitmask_mapping_"} + treeReader->GetTree()->GetName();
526526
if (Map_t const *columnMaskMap = treeDir->Get<Map_t>(bitmaskMapName.c_str()); columnMaskMap) {
527527
if (auto it = columnMaskMap->find(std::string(col)); it != columnMaskMap->end()) {
528528
colReader = std::make_unique<RMaskedColumnReader>(*treeReader, std::move(colReader), it->second.first,

tree/dataframe/test/dataframe_snapshotWithVariations.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ TEST(RDFVarySnapshot, Bitmask)
219219
ASSERT_NE(branch, nullptr);
220220

221221
auto *branchToIndexMap = file.Get<std::unordered_map<std::string, std::pair<std::string, unsigned int>>>(
222-
("R_rdf_branchToBitmaskMapping_" + treename).c_str());
222+
("R_rdf_column_to_bitmask_mapping_" + treename).c_str());
223223
ASSERT_NE(branchToIndexMap, nullptr);
224224
for (const auto branchName : {"x", "y", "x__xVar_0", "x__xVar_1", "y__xVar_0", "y__xVar_0"}) {
225225
ASSERT_NE(branchToIndexMap->find(branchName), branchToIndexMap->end());
@@ -339,8 +339,8 @@ TEST(RDFVarySnapshot, TwoVariationsInSameFile)
339339
auto snap2 = rdf.Filter(cuts2, {"x", "y"}).Snapshot(treename2, filename, {"x", "y"}, options);
340340

341341
std::unique_ptr<TFile> file{TFile::Open(filename)};
342-
EXPECT_NE(file->GetKey(("R_rdf_branchToBitmaskMapping_" + treename1).c_str()), nullptr);
343-
EXPECT_NE(file->GetKey(("R_rdf_branchToBitmaskMapping_" + treename2).c_str()), nullptr);
342+
EXPECT_NE(file->GetKey(("R_rdf_column_to_bitmask_mapping_" + treename1).c_str()), nullptr);
343+
EXPECT_NE(file->GetKey(("R_rdf_column_to_bitmask_mapping_" + treename2).c_str()), nullptr);
344344

345345
// In Windows, an exception is thrown as expected, but it cannot be caught for the time being:
346346
#if !defined(_MSC_VER) || defined(R__ENABLE_BROKEN_WIN_TESTS)

0 commit comments

Comments
 (0)