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 field \"" + std::string(fieldName) +
"."));
50 const auto &fieldDesc = desc->GetFieldDescriptor(fieldId);
51 auto field = fieldDesc.CreateField(desc.GetRef());
65std::unique_ptr<ROOT::Experimental::Internal::RNTupleIndex>
69 auto index = std::unique_ptr<RNTupleIndex>(
new RNTupleIndex(fieldNames, pageSource));
82 static const std::unordered_set<std::string> allowedTypes = {
"std::int8_t",
"std::int16_t",
"std::int32_t",
83 "std::int64_t",
"std::uint8_t",
"std::uint16_t",
84 "std::uint32_t",
"std::uint64_t"};
86 std::vector<RFieldBase::RValue> fieldValues;
87 fieldValues.reserve(fIndexFields.size());
89 for (
const auto &field : fIndexFields) {
90 if (allowedTypes.find(field->
GetTypeName()) == allowedTypes.end()) {
92 field->
GetTypeName() +
"\" for indexing. Only integral types are allowed."));
97 std::vector<NTupleIndexValue_t> indexValues;
98 indexValues.reserve(fIndexFields.size());
100 for (
unsigned i = 0; i < fPageSource->GetNEntries(); ++i) {
102 for (
auto &fieldValue : fieldValues) {
106 auto valuePtr = fieldValue.GetPtr<
void>();
107 indexValues.push_back(CastValuePtr(valuePtr.get(), fieldValue.GetField()));
118 const auto entryIndices = GetAllEntryNumbers(valuePtrs);
121 return entryIndices->front();
124const std::vector<ROOT::Experimental::NTupleSize_t> *
127 if (valuePtrs.size() != fIndexFields.size())
128 throw RException(
R__FAIL(
"Number of value pointers must match number of indexed fields."));
132 std::vector<NTupleIndexValue_t> indexValues;
133 indexValues.reserve(fIndexFields.size());
135 for (
unsigned i = 0; i < valuePtrs.size(); ++i) {
136 indexValues.push_back(CastValuePtr(valuePtrs[i], *fIndexFields[i]));
139 auto entryNumber = fIndex.find(
RIndexValue(indexValues));
141 if (entryNumber == fIndex.end())
144 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.
Base class for all ROOT issued exceptions.
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.
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