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
17 changes: 4 additions & 13 deletions tree/ntuple/inc/ROOT/RNTupleProcessor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@ protected:
/// interface.
ROOT::NTupleSize_t fNEntries = kInvalidNTupleIndex;

ROOT::NTupleSize_t fNEntriesProcessed = 0; //< Total number of entries processed so far
ROOT::NTupleSize_t fCurrentEntryNumber = 0; //< Current processor entry number
std::size_t fCurrentProcessorNumber = 0; //< Number of the currently open inner processor
ROOT::NTupleSize_t fNEntriesProcessed = 0; //< Total number of entries processed so far

/////////////////////////////////////////////////////////////////////////////
/// \brief Initialize the processor by creating an (initially empty) `fEntry`, or setting an existing one.
Expand Down Expand Up @@ -367,16 +365,6 @@ public:
/// \brief Get the total number of entries processed so far.
ROOT::NTupleSize_t GetNEntriesProcessed() const { return fNEntriesProcessed; }

/////////////////////////////////////////////////////////////////////////////
/// \brief Get the entry number that is currently being processed.
ROOT::NTupleSize_t GetCurrentEntryNumber() const { return fCurrentEntryNumber; }

/////////////////////////////////////////////////////////////////////////////
/// \brief Get the number of the inner processor currently being read.
///
/// This method is only relevant for the RNTupleChainProcessor. For the other processors, 0 is always returned.
std::size_t GetCurrentProcessorNumber() const { return fCurrentProcessorNumber; }

/////////////////////////////////////////////////////////////////////////////
/// \brief Request access to a field for reading during processing.
///
Expand Down Expand Up @@ -691,6 +679,9 @@ private:
std::vector<std::unique_ptr<RNTupleProcessor>> fInnerProcessors;
std::vector<ROOT::NTupleSize_t> fInnerNEntries;

ROOT::NTupleSize_t fLastLoadedEntry = 0; //< Last (global) entry number that was loaded

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe last -> latest?

std::size_t fCurrentProcessorNumber = 0; //< Number of the currently open inner processor

Internal::RNTupleProcessorProvenance fProvenance;

/////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 2 additions & 4 deletions tree/ntuple/src/RNTupleProcessor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ ROOT::NTupleSize_t ROOT::Experimental::RNTupleSingleProcessor::LoadEntry(ROOT::N
}

fNEntriesProcessed++;
fCurrentEntryNumber = entryNumber;
return entryNumber;
}

Expand Down Expand Up @@ -351,7 +350,7 @@ ROOT::NTupleSize_t ROOT::Experimental::RNTupleChainProcessor::LoadEntry(ROOT::NT
// If the requested entry number is lower than the current entry number, we have to again localise the correct local
// entry number starting from the first processor in the chain. Otherwise, we can continue looking from the inner
// processor that is currently connected, which is much faster when the chain consists of many inner processors.
if (entryNumber < fCurrentEntryNumber) {
if (entryNumber < fLastLoadedEntry) {
fCurrentProcessorNumber = 0;
ConnectInnerProcessor(fCurrentProcessorNumber);
}
Expand Down Expand Up @@ -384,7 +383,7 @@ ROOT::NTupleSize_t ROOT::Experimental::RNTupleChainProcessor::LoadEntry(ROOT::NT

fCurrentProcessorNumber = currProcessorNumber;
fNEntriesProcessed++;
fCurrentEntryNumber = entryNumber;
fLastLoadedEntry = entryNumber;
return entryNumber;
}

Expand Down Expand Up @@ -526,7 +525,6 @@ ROOT::NTupleSize_t ROOT::Experimental::RNTupleJoinProcessor::LoadEntry(ROOT::NTu
return kInvalidNTupleIndex;
}

fCurrentEntryNumber = entryNumber;
fNEntriesProcessed++;

if (!fJoinTable) {
Expand Down
37 changes: 10 additions & 27 deletions tree/ntuple/test/ntuple_processor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ TEST(RNTupleProcessor, TMemFile)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());

EXPECT_FLOAT_EQ(static_cast<float>(idx), *x);
}
Expand Down Expand Up @@ -79,7 +78,6 @@ TEST(RNTupleProcessor, TDirectory)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());

EXPECT_FLOAT_EQ(static_cast<float>(idx), *x);
}
Expand Down Expand Up @@ -186,7 +184,6 @@ TEST_F(RNTupleProcessorTest, Base)
}

for (auto idx : *proc) {
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());

EXPECT_FLOAT_EQ(static_cast<float>(idx), *x);
Expand Down Expand Up @@ -258,7 +255,6 @@ TEST_F(RNTupleProcessorTest, RequestFieldWithTypeString)
auto y = proc->RequestField("y", "std::vector<float>", yPtr.get());

for (auto idx : *proc) {
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());

EXPECT_FLOAT_EQ(static_cast<float>(idx), *std::static_pointer_cast<float>(x.GetPtr()));
Expand Down Expand Up @@ -286,7 +282,6 @@ TEST_F(RNTupleProcessorTest, AlternativeTypes)
auto yAsRVec = proc->RequestField<ROOT::RVec<float>>("y");

for (auto idx : *proc) {
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());

EXPECT_FLOAT_EQ(static_cast<double>(idx), *xAsDouble);
EXPECT_FLOAT_EQ(idx, *xAsFloat);
Expand Down Expand Up @@ -341,7 +336,6 @@ TEST_F(RNTupleProcessorTest, ChainedChain)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
if ((idx >= 5 && idx < 10) || idx >= 15) {
EXPECT_EQ(*i, 4 - idx % 5);
EXPECT_EQ(*z, (4 - idx % 5) * 3.f);
Expand All @@ -361,7 +355,6 @@ TEST_F(RNTupleProcessorTest, ChainedChain)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1 + 20, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());

if ((idx >= 5 && idx < 10) || idx >= 15) {
EXPECT_EQ(*i, 4 - idx % 5);
Expand Down Expand Up @@ -395,8 +388,7 @@ TEST_F(RNTupleProcessorTest, ChainedJoin)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(*i, proc->GetCurrentEntryNumber() % 5);
EXPECT_EQ(*i, idx % 5);

EXPECT_EQ(static_cast<float>(*i), *x);
EXPECT_EQ(*x * 2, *z);
Expand All @@ -422,8 +414,7 @@ TEST_F(RNTupleProcessorTest, ChainedJoinUnaligned)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(*i, proc->GetCurrentEntryNumber() % 5);
EXPECT_EQ(*i, idx % 5);

EXPECT_EQ(static_cast<float>(*i), *x);
EXPECT_EQ(*x * 3, *z);
Expand All @@ -449,8 +440,7 @@ TEST_F(RNTupleProcessorTest, ChainedJoinMissingEntries)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(*i, proc->GetCurrentEntryNumber() % 5);
EXPECT_EQ(*i, idx % 5);

EXPECT_EQ(static_cast<float>(*i), *x);

Expand Down Expand Up @@ -484,8 +474,7 @@ TEST_F(RNTupleProcessorTest, JoinedChain)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(*i, proc->GetCurrentEntryNumber() % 5);
EXPECT_EQ(*i, idx % 5);

EXPECT_EQ(static_cast<float>(*i), *x);
EXPECT_EQ(*x * 2, *z);
Expand All @@ -511,8 +500,7 @@ TEST_F(RNTupleProcessorTest, JoinedChainUnaligned)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(*i, proc->GetCurrentEntryNumber() % 5);
EXPECT_EQ(*i, idx % 5);

EXPECT_EQ(static_cast<float>(*i), *x);
EXPECT_EQ(*x * 3, *z);
Expand All @@ -538,8 +526,7 @@ TEST_F(RNTupleProcessorTest, JoinedChainMissingEntries)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(*i, proc->GetCurrentEntryNumber() % 5);
EXPECT_EQ(*i, idx % 5);

EXPECT_EQ(static_cast<float>(*i), *x);

Expand Down Expand Up @@ -662,8 +649,7 @@ TEST_F(RNTupleProcessorTest, JoinedJoinComposedPrimary)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(*i, proc->GetCurrentEntryNumber() % 5);
EXPECT_EQ(*i, idx % 5);

EXPECT_EQ(static_cast<float>(*i), *x);
EXPECT_EQ(*x * 2, *z1);
Expand Down Expand Up @@ -694,8 +680,7 @@ TEST_F(RNTupleProcessorTest, JoinedJoinComposedPrimaryMissingEntries)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(*i, proc->GetCurrentEntryNumber() % 5);
EXPECT_EQ(*i, idx % 5);

EXPECT_EQ(static_cast<float>(*i), *x);
EXPECT_EQ(*x * 2, *z1);
Expand Down Expand Up @@ -736,8 +721,7 @@ TEST_F(RNTupleProcessorTest, JoinedJoinComposedAuxiliary)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(*i, proc->GetCurrentEntryNumber() % 5);
EXPECT_EQ(*i, idx % 5);

EXPECT_EQ(static_cast<float>(*i), *x);
EXPECT_EQ(*x * 2, *z1);
Expand Down Expand Up @@ -771,8 +755,7 @@ TEST_F(RNTupleProcessorTest, JoinedJoinComposedAuxiliaryMissingEntries)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());
EXPECT_EQ(*i, proc->GetCurrentEntryNumber() % 5);
EXPECT_EQ(*i, idx % 5);

EXPECT_EQ(static_cast<float>(*i), *x);
EXPECT_EQ(*x * 2, *z1);
Expand Down
12 changes: 1 addition & 11 deletions tree/ntuple/test/ntuple_processor_chain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ TEST_F(RNTupleChainProcessorTest, SingleNTuple)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());

EXPECT_FLOAT_EQ(static_cast<float>(proc->GetCurrentEntryNumber()), *x);
EXPECT_FLOAT_EQ(static_cast<float>(idx), *x);
}
EXPECT_EQ(5, proc->GetNEntriesProcessed());
}
Expand All @@ -115,8 +113,6 @@ TEST_F(RNTupleChainProcessorTest, Basic)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());

EXPECT_EQ(static_cast<float>(idx), *x);

std::vector<float> yExp = {static_cast<float>(idx), static_cast<float>((idx) * 2)};
Expand Down Expand Up @@ -196,19 +192,15 @@ TEST_F(RNTupleChainProcessorTest, LoadRandomEntry)

RNTupleProcessorEntryLoader::LoadEntry(*proc, 3);
EXPECT_EQ(3.f, *x);
EXPECT_EQ(0, proc->GetCurrentProcessorNumber());

RNTupleProcessorEntryLoader::LoadEntry(*proc, 9);
EXPECT_EQ(9.f, *x);
EXPECT_EQ(1, proc->GetCurrentProcessorNumber());

RNTupleProcessorEntryLoader::LoadEntry(*proc, 6);
EXPECT_EQ(6.f, *x);
EXPECT_EQ(1, proc->GetCurrentProcessorNumber());

RNTupleProcessorEntryLoader::LoadEntry(*proc, 2);
EXPECT_EQ(2.f, *x);
EXPECT_EQ(0, proc->GetCurrentProcessorNumber());

EXPECT_EQ(ROOT::kInvalidNTupleIndex, RNTupleProcessorEntryLoader::LoadEntry(*proc, 10));
}
Expand All @@ -235,8 +227,6 @@ TEST_F(RNTupleChainProcessorTest, TMemFile)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());

EXPECT_EQ(static_cast<float>(idx), *x);
}
EXPECT_EQ(10, proc->GetNEntriesProcessed());
Expand Down
5 changes: 2 additions & 3 deletions tree/ntuple/test/ntuple_processor_join.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ TEST_F(RNTupleJoinProcessorTest, Aligned)

for (auto idx : *proc) {
EXPECT_EQ(idx + 1, proc->GetNEntriesProcessed());
EXPECT_EQ(idx, proc->GetCurrentEntryNumber());

yExpected = {static_cast<float>(*i * 0.2), 3.14, static_cast<float>(*i * 1.3)};
EXPECT_EQ(yExpected, *y);
Expand Down Expand Up @@ -234,9 +233,9 @@ TEST_F(RNTupleJoinProcessorTest, UnalignedMultipleJoinFields)
auto a = proc->RequestField<float>("ntuple4.a");

for (auto idx : *proc) {
EXPECT_EQ(proc->GetCurrentEntryNumber(), idx);
EXPECT_EQ(proc->GetNEntriesProcessed(), idx + 1);

EXPECT_FLOAT_EQ(proc->GetCurrentEntryNumber() * 2, *i);
EXPECT_FLOAT_EQ(idx * 2, *i);
EXPECT_FLOAT_EQ(*i * 0.5f, *x);
EXPECT_EQ(*i * 0.1f, *a);
}
Expand Down
7 changes: 0 additions & 7 deletions tutorials/io/ntuple/ntpl012_processor_chain.C
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ void Read(const std::vector<RNTupleOpenSpec> &ntuples)

// The iterator value is the index of the current entry being processed.
for (auto idx : *processor) {
// The RNTupleProcessor provides some additional bookkeeping information, such as the current processor number.
if (static_cast<int>(processor->GetCurrentProcessorNumber()) > prevProcessorNumber) {
prevProcessorNumber = processor->GetCurrentProcessorNumber();
std::cout << "Processing `ntuple" << prevProcessorNumber + 1 << "` (" << idx + 1
<< " total entries processed so far)" << std::endl;
}

// We use the value returned from requesting the field to read its data for the current entry.
for (auto x : *px) {
hPx.Fill(x);
Expand Down
Loading