Skip to content

Commit b0b5e30

Browse files
committed
[ntuple] add multiply operator to RNTupleLocalIndex
Used to scale and index by the repetition count of a field (i.e., for fixed-size array index arithmetic).
1 parent ab90aa7 commit b0b5e30

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tree/ntuple/inc/ROOT/RNTupleTypes.hxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ public:
163163
return RNTupleLocalIndex(fClusterId, fIndexInCluster - off);
164164
}
165165

166+
RNTupleLocalIndex operator*(ROOT::NTupleSize_t repetitionFactor) const
167+
{
168+
return RNTupleLocalIndex(fClusterId, fIndexInCluster * repetitionFactor);
169+
}
170+
166171
RNTupleLocalIndex operator++(int) /* postfix */
167172
{
168173
auto r = *this;

tree/ntuple/src/RFieldSequenceContainer.cxx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -809,19 +809,14 @@ void ROOT::RArrayAsRVecField::ReadInClusterImpl(RNTupleLocalIndex localIndex, vo
809809
{
810810
auto begin = RRVecField::ResizeRVec(to, fArrayLength, fItemSize, fSubfields[0].get(), fItemDeleter.get());
811811

812-
const auto &clusterId = localIndex.GetClusterId();
813-
const auto &indexInCluster = localIndex.GetIndexInCluster();
814-
815812
if (fSubfields[0]->IsSimple()) {
816-
GetPrincipalColumnOf(*fSubfields[0])
817-
->ReadV(RNTupleLocalIndex(clusterId, indexInCluster * fArrayLength), fArrayLength, begin);
813+
GetPrincipalColumnOf(*fSubfields[0])->ReadV(localIndex * fArrayLength, fArrayLength, begin);
818814
return;
819815
}
820816

821817
// Read the new values into the collection elements
822818
for (std::size_t i = 0; i < fArrayLength; ++i) {
823-
CallReadOn(*fSubfields[0], RNTupleLocalIndex(clusterId, indexInCluster * fArrayLength + i),
824-
begin + (i * fItemSize));
819+
CallReadOn(*fSubfields[0], localIndex * fArrayLength + i, begin + (i * fItemSize));
825820
}
826821
}
827822

0 commit comments

Comments
 (0)