Skip to content
Merged
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
3 changes: 0 additions & 3 deletions tree/ntuple/inc/ROOT/RFieldBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class RFieldVisitor;

namespace Experimental {

class RNTupleJoinProcessor;

namespace Detail {
class RRawPtrWriteEntry;
} // namespace Detail
Expand Down Expand Up @@ -82,7 +80,6 @@ This is and can only be partially enforced through C++.
// clang-format on
class RFieldBase {
friend class ROOT::RClassField; // to mark members as artificial
friend class ROOT::Experimental::RNTupleJoinProcessor; // needs ConstructValue
friend class ROOT::Experimental::Detail::RRawPtrWriteEntry; // to call Append()
friend struct ROOT::Internal::RFieldCallbackInjector; // used for unit tests
friend struct ROOT::Internal::RFieldRepresentationModifier; // used for unit tests
Expand Down
22 changes: 20 additions & 2 deletions tree/ntuple/inc/ROOT/RNTupleJoinTable.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ private:
///
/// \param[in] pageSource The page source of the RNTuple with the entries to map.
/// \param[in] joinFieldNames Names of the join fields to use in the mapping.
REntryMapping(ROOT::Internal::RPageSource &pageSource, const std::vector<std::string> &joinFieldNames);
/// \param[in] entryOffset Offset to add to each entry index in the mapping. This can can be used when the
/// RNTuple represented by the provided page source is part of a chain of RNTuples.
REntryMapping(ROOT::Internal::RPageSource &pageSource, const std::vector<std::string> &joinFieldNames,
ROOT::NTupleSize_t entryOffset = 0);
};
/// Names of the join fields used for the mapping to their respective entry indexes.
std::vector<std::string> fJoinFieldNames;
Expand Down Expand Up @@ -187,9 +190,24 @@ public:
/// \param[in] pageSource The page source of the RNTuple with the entries to map.
/// \param[in] partitionKey Which partition to add the mapping to. If not provided, it will be added to the default
/// partition.
/// \param[in] entryOffset Offset to add to each entry index in the mapping. This can can be used when the
/// RNTuple represented by the provided page source is part of a chain of RNTuples.
///
/// \return A reference to the updated join table.
RNTupleJoinTable &Add(ROOT::Internal::RPageSource &pageSource, PartitionKey_t partitionKey = kDefaultPartitionKey);
RNTupleJoinTable &Add(ROOT::Internal::RPageSource &pageSource, PartitionKey_t partitionKey = kDefaultPartitionKey,
ROOT::NTupleSize_t entryOffset = 0);

/////////////////////////////////////////////////////////////////////////////
/// \brief Get an entry index (if it exists) for the given join field value(s), from any partition.
///
/// \param[in] valuePtrs A vector of pointers to the join field values to look up.
///
/// \note If one or more corresponding entries exist for the given value(s), the first entry index found in the join
/// table is returned. To get *all* the entry indexes, use GetEntryIndexes.
///
/// \return An entry number that corresponds to `valuePtrs`. When there are no corresponding entries,
/// `kInvalidNTupleIndex` is returned.
ROOT::NTupleSize_t GetEntryIndex(const std::vector<void *> &valuePtrs) const;

/////////////////////////////////////////////////////////////////////////////
/// \brief Get all entry indexes for the given join field value(s) within a partition.
Expand Down
221 changes: 124 additions & 97 deletions tree/ntuple/inc/ROOT/RNTupleProcessor.hxx

Large diffs are not rendered by default.

25 changes: 21 additions & 4 deletions tree/ntuple/src/RNTupleJoinTable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ ROOT::Experimental::Internal::RNTupleJoinTable::JoinValue_t CastValuePtr(void *v
} // anonymous namespace

ROOT::Experimental::Internal::RNTupleJoinTable::REntryMapping::REntryMapping(
ROOT::Internal::RPageSource &pageSource, const std::vector<std::string> &joinFieldNames)
ROOT::Internal::RPageSource &pageSource, const std::vector<std::string> &joinFieldNames,
ROOT::NTupleSize_t entryOffset)
: fJoinFieldNames(joinFieldNames)
{
static const std::unordered_set<std::string> allowedTypes = {"std::int8_t", "std::int16_t", "std::int32_t",
Expand Down Expand Up @@ -82,7 +83,7 @@ ROOT::Experimental::Internal::RNTupleJoinTable::REntryMapping::REntryMapping(
castJoinValues.push_back(CastValuePtr(valuePtr.get(), fieldValue.GetField().GetValueSize()));
}

fMapping[RCombinedJoinFieldValue(castJoinValues)].push_back(i);
fMapping[RCombinedJoinFieldValue(castJoinValues)].push_back(i + entryOffset);
}
}

Expand Down Expand Up @@ -116,14 +117,30 @@ ROOT::Experimental::Internal::RNTupleJoinTable::Create(const std::vector<std::st

ROOT::Experimental::Internal::RNTupleJoinTable &
ROOT::Experimental::Internal::RNTupleJoinTable::Add(ROOT::Internal::RPageSource &pageSource,
PartitionKey_t partitionKey)
PartitionKey_t partitionKey, ROOT::NTupleSize_t entryOffset)
{
auto joinMapping = std::unique_ptr<REntryMapping>(new REntryMapping(pageSource, fJoinFieldNames));
auto joinMapping = std::unique_ptr<REntryMapping>(new REntryMapping(pageSource, fJoinFieldNames, entryOffset));
fPartitions[partitionKey].emplace_back(std::move(joinMapping));

return *this;
}

ROOT::NTupleSize_t
ROOT::Experimental::Internal::RNTupleJoinTable::GetEntryIndex(const std::vector<void *> &valuePtrs) const
{

for (const auto &partition : fPartitions) {
for (const auto &joinMapping : partition.second) {
auto entriesForMapping = joinMapping->GetEntryIndexes(valuePtrs);
if (entriesForMapping) {
return (*entriesForMapping)[0];
}
}
}

return kInvalidNTupleIndex;
}

std::vector<ROOT::NTupleSize_t>
ROOT::Experimental::Internal::RNTupleJoinTable::GetEntryIndexes(const std::vector<void *> &valuePtrs,
PartitionKey_t partitionKey) const
Expand Down
Loading
Loading