22 static const std::unordered_set<std::string> allowedTypes = {
"std::int8_t",
"std::int16_t",
"std::int32_t",
23 "std::int64_t",
"std::uint8_t",
"std::uint16_t",
24 "std::uint32_t",
"std::uint64_t"};
29 std::vector<std::unique_ptr<ROOT::RFieldBase>> fields;
30 std::vector<ROOT::RFieldBase::RValue> fieldValues;
34 auto fieldId = desc->FindFieldId(fieldName);
36 throw RException(
R__FAIL(
"could not find join field \"" + std::string(fieldName) +
"\" in RNTuple \"" +
39 const auto &fieldDesc = desc->GetFieldDescriptor(fieldId);
41 if (allowedTypes.find(fieldDesc.GetTypeName()) == allowedTypes.end()) {
42 throw RException(
R__FAIL(
"cannot use field \"" + fieldName +
"\" with type \"" + fieldDesc.GetTypeName() +
43 "\" in join table: only integral types are allowed"));
46 auto field = std::make_unique<ROOT::RField<JoinValue_t>>(fieldDesc.GetFieldName());
47 field->SetOnDiskId(fieldDesc.GetId());
50 fieldValues.emplace_back(field->CreateValue());
52 fields.emplace_back(std::move(field));
55 std::vector<JoinValue_t> castJoinValues;
59 castJoinValues.clear();
61 for (
auto &fieldValue : fieldValues) {
64 castJoinValues.push_back(fieldValue.GetRef<
JoinValue_t>());
71const std::vector<ROOT::NTupleSize_t> *ROOT ::Experimental::Internal::RNTupleJoinTable::REntryMapping::GetEntryIndexes(
72 const std::vector<JoinValue_t> &joinValues)
const
75 throw RException(
R__FAIL(
"number of value pointers must match number of join fields"));
78 return &entries->second;
86std::unique_ptr<ROOT::Experimental::Internal::RNTupleJoinTable>
97 fPartitions[partitionKey].emplace_back(std::move(joinMapping));
106 for (
const auto &joinMapping : partition.second) {
107 auto entriesForMapping = joinMapping->GetEntryIndexes(joinValues);
108 if (entriesForMapping) {
109 return (*entriesForMapping)[0];
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Provides a mapping from one or several join field values to an entry index.
REntryMapping(ROOT::Internal::RPageSource &pageSource, const std::vector< std::string > &joinFieldNames, ROOT::NTupleSize_t entryOffset=0)
Create a new entry mapping.
std::vector< std::size_t > fJoinFieldValueSizes
The size (in bytes) for each join field, corresponding to fJoinFieldNames.
std::vector< std::string > fJoinFieldNames
Names of the join fields used for the mapping to their respective entry indexes.
std::unordered_map< RCombinedJoinFieldValue, std::vector< ROOT::NTupleSize_t >, RCombinedJoinFieldValueHash > fMapping
The mapping itself.
Builds a join table on one or several fields of an RNTuple so it can be joined onto other RNTuples.
static std::unique_ptr< RNTupleJoinTable > Create(const std::vector< std::string > &joinFieldNames)
Create an RNTupleJoinTable from an existing RNTuple.
std::vector< std::string > fJoinFieldNames
Names of the join fields used for the mapping to their respective entry indexes.
ROOT::NTupleSize_t GetEntryIndex(const std::vector< JoinValue_t > &joinValues) const
Get an entry index (if it exists) for the given join field value(s), from any partition.
std::uint64_t PartitionKey_t
std::uint64_t JoinValue_t
RNTupleJoinTable & Add(ROOT::Internal::RPageSource &pageSource, PartitionKey_t partitionKey=kDefaultPartitionKey, ROOT::NTupleSize_t entryOffset=0)
Add an entry mapping to the join table.
RNTupleJoinTable(const std::vector< std::string > &joinFieldNames)
Create an a new RNTupleJoinTable for the RNTuple represented by the provided page source.
std::unordered_map< PartitionKey_t, std::vector< std::unique_ptr< REntryMapping > > > fPartitions
Partitions of one or multiple entry mappings.
Abstract interface to read data from an ntuple.
void Attach(ROOT::Internal::RNTupleSerializer::EDescriptorDeserializeMode mode=ROOT::Internal::RNTupleSerializer::EDescriptorDeserializeMode::kForReading)
Open the physical storage container and deserialize header and footer.
const RSharedDescriptorGuard GetSharedDescriptorGuard() const
Takes the read lock for the descriptor. Multiple threads can take the lock concurrently....
ROOT::NTupleSize_t GetNEntries()
const std::string & GetNTupleName() const
Returns the NTuple name.
Base class for all ROOT issued exceptions.
void CallConnectPageSourceOnField(RFieldBase &, ROOT::Internal::RPageSource &)
constexpr NTupleSize_t kInvalidNTupleIndex
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr DescriptorId_t kInvalidDescriptorId
Container for the combined hashes of join field values.