25 case 1:
value = *
reinterpret_cast<std::uint8_t *
>(valuePtr);
break;
26 case 2:
value = *
reinterpret_cast<std::uint16_t *
>(valuePtr);
break;
27 case 4:
value = *
reinterpret_cast<std::uint32_t *
>(valuePtr);
break;
28 case 8:
value = *
reinterpret_cast<std::uint64_t *
>(valuePtr);
break;
38 : fPageSource(pageSource.Clone())
41 auto desc =
fPageSource->GetSharedDescriptorGuard();
45 for (
const auto &fieldName : fieldNames) {
46 auto fieldId = desc->FindFieldId(fieldName);
48 throw RException(
R__FAIL(
"could not find join field \"" + std::string(fieldName) +
"\" in RNTuple \"" +
51 const auto &fieldDesc = desc->GetFieldDescriptor(fieldId);
52 auto field = fieldDesc.CreateField(desc.GetRef());
66std::unique_ptr<ROOT::Experimental::Internal::RNTupleIndex>
70 auto index = std::unique_ptr<RNTupleIndex>(
new RNTupleIndex(fieldNames, pageSource));
83 static const std::unordered_set<std::string> allowedTypes = {
"std::int8_t",
"std::int16_t",
"std::int32_t",
84 "std::int64_t",
"std::uint8_t",
"std::uint16_t",
85 "std::uint32_t",
"std::uint64_t"};
87 std::vector<RFieldBase::RValue> fieldValues;
88 fieldValues.reserve(fIndexFields.size());
90 for (
const auto &field : fIndexFields) {
91 if (allowedTypes.find(field->
GetTypeName()) == allowedTypes.end()) {
93 field->
GetTypeName() +
"\" for indexing: only integral types are allowed"));
98 std::vector<NTupleIndexValue_t> indexValues;
99 indexValues.reserve(fIndexFields.size());
101 for (
unsigned i = 0; i < fPageSource->GetNEntries(); ++i) {
103 for (
auto &fieldValue : fieldValues) {
107 auto valuePtr = fieldValue.GetPtr<
void>();
108 indexValues.push_back(CastValuePtr(valuePtr.get(), fieldValue.GetField()));
119 const auto entryIndices = GetAllEntryNumbers(valuePtrs);
122 return entryIndices->front();
125const std::vector<ROOT::Experimental::NTupleSize_t> *
128 if (valuePtrs.size() != fIndexFields.size())
129 throw RException(
R__FAIL(
"number of value pointers must match number of indexed fields"));
133 std::vector<NTupleIndexValue_t> indexValues;
134 indexValues.reserve(fIndexFields.size());
136 for (
unsigned i = 0; i < valuePtrs.size(); ++i) {
137 indexValues.push_back(CastValuePtr(valuePtrs[i], *fIndexFields[i]));
140 auto entryNumber = fIndex.find(
RIndexValue(indexValues));
142 if (entryNumber == fIndex.end())
145 return &(entryNumber->second);
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Container for the hashes of the indexed fields.
Builds an index on one or several fields of an RNTuple so it can be joined onto other RNTuples.
std::unique_ptr< RPageSource > fPageSource
The page source belonging to the RNTuple for which to build the index.
static std::unique_ptr< RNTupleIndex > Create(const std::vector< std::string > &fieldNames, const RPageSource &pageSource, bool deferBuild=false)
Create an RNTupleIndex from an existing RNTuple.
const std::vector< NTupleSize_t > * GetAllEntryNumbers(const std::vector< void * > &valuePtrs) const
Get all entry numbers for the given index.
NTupleSize_t GetFirstEntryNumber(const std::vector< void * > &valuePtrs) const
Get the first entry number containing the given index value.
RNTupleIndex(const std::vector< std::string > &fieldNames, const RPageSource &pageSource)
Create an a new RNTupleIndex for the RNTuple represented by the provided page source.
void EnsureBuilt() const
Ensure the RNTupleIndex has been built.
std::vector< std::unique_ptr< RFieldBase > > fIndexFields
The fields for which the index is built. Used to compute the hashes for each entry value.
std::uint64_t NTupleIndexValue_t
void Build()
Build the index.
Abstract interface to read data from an ntuple.
A field translates read and write calls from/to underlying columns to/from tree values.
const std::string & GetFieldName() const
const std::string & GetTypeName() const
RValue CreateValue()
Generates an object of the field type and wraps the created object in a shared pointer and returns it...
virtual size_t GetValueSize() const =0
The number of bytes taken by a value of the appropriate type.
Base class for all ROOT issued exceptions.
void CallConnectPageSourceOnField(RFieldBase &, RPageSource &)
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr NTupleSize_t kInvalidNTupleIndex
constexpr DescriptorId_t kInvalidDescriptorId