Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tree/dataframe/src/RLoopManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ void RLoopManager::RunDataSource()
ROOT::Internal::RDF::RDSRangeRAII __{*this, 0u, 0ull};

ranges = fDataSource->GetEntryRanges();
if (ranges.empty())
break;

fSampleInfos[0] = ROOT::Internal::RDF::CreateSampleInfo(*fDataSource, /*slot*/ 0, fSampleMap);

Expand Down
17 changes: 14 additions & 3 deletions tree/dataframe/src/RNTupleDS.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,12 @@ ROOT::Internal::RDF::GetClustersAndEntries(std::string_view ntupleName, std::str
// TODO(jblomer): improve MT scheduling such that not all page lists are required right away
source->LoadAllPageLists();
auto descGuard = source->GetSharedDescriptorGuard();
return std::make_pair(ROOT::Internal::GetClusterBoundaries(descGuard.GetConstRef()), descGuard->GetNEntries());
ROOT::NTupleSize_t nEntries = descGuard->GetNEntries();
// TODO: In ROOT 6.42.00, writing an empty RNTuple with the RNTupleParallelWriter results in a RNTuple which
// cluster boundaries cannot be properly retrieved. Avoid that scenario for now with an early return.
if (nEntries == 0)
return {{}, nEntries};
return std::make_pair(ROOT::Internal::GetClusterBoundaries(descGuard.GetConstRef()), nEntries);
}

#ifdef R__USE_IMT
Expand Down Expand Up @@ -1120,9 +1125,15 @@ void ROOT::RDF::RNTupleDS::ScheduleTasksForFile(std::size_t fileIdx, ROOT::TThre
source->Attach();
// TODO: improve MT scheduling such that not all page lists are required right away
source->LoadAllPageLists();
const auto clustersAndEntries = [&]() {
const auto clustersAndEntries =
[&]() -> std::pair<std::vector<ROOT::Internal::RNTupleClusterBoundaries>, ROOT::NTupleSize_t> {
const auto descGuard = source->GetSharedDescriptorGuard();
return std::make_pair(ROOT::Internal::GetClusterBoundaries(descGuard.GetConstRef()), descGuard->GetNEntries());
ROOT::NTupleSize_t nEntries = descGuard->GetNEntries();
// TODO: In ROOT 6.42.00, writing an empty RNTuple with the RNTupleParallelWriter results in a RNTuple which
// cluster boundaries cannot be properly retrieved. Avoid that scenario for now with an early return.
if (nEntries == 0)
return {{}, nEntries};
return std::make_pair(ROOT::Internal::GetClusterBoundaries(descGuard.GetConstRef()), nEntries);
}();
const ROOT::NTupleSize_t nEntries = clustersAndEntries.second;
if (nEntries == 0)
Expand Down
37 changes: 37 additions & 0 deletions tree/dataframe/test/datasource_ntuple.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -915,3 +915,40 @@ TEST_F(RNTupleDSTest, GetTopLevelFieldNames)
std::vector<std::string>{"VecElectron", "VecElectron.pt", "electron", "electron.pt", "energy", "jets",
"nElectron", "nnlo", "pt", "rvec", "tag"});
}

void ReadSingleEmptyRNTuple(const std::string &dataset_name, const std::string &file_name)
{
FileRAII fileGuard(file_name);
{
ROOT::RDataFrame df{1};
// Filter away everything creating an output with zero entries
auto flt = df.Define("x", []() -> int { return 42; }).Filter([](int x) { return x > 42; }, {"x"});

ROOT::RDF::RSnapshotOptions opts;
opts.fOutputFormat = ROOT::RDF::ESnapshotOutputFormat::kRNTuple;

flt.Snapshot(dataset_name, file_name, {"x"}, opts);
}
{
ROOT::RDataFrame df{dataset_name, fileGuard.GetPath()};
EXPECT_EQ(df.Count().GetValue(), 0);
}
}

TEST(EmptyRNTupleTest, Seq)
{
std::string dataset_name{"ReadSingleEmptyRNTuple"};
std::string file_name{"ReadSingleEmptyRNTuple.root"};
ReadSingleEmptyRNTuple(dataset_name, file_name);
}

#ifdef R__USE_IMT
TEST(EmptyRNTupleTest, MT)
{
IMTRAII _;

std::string dataset_name{"ReadSingleEmptyRNTupleMT"};
std::string file_name{"ReadSingleEmptyRNTupleMT.root"};
ReadSingleEmptyRNTuple(dataset_name, file_name);
}
#endif
Loading