45#include <unordered_map>
49static const std::unordered_map<std::string_view, std::string_view> typeTranslationMap{
52 {
"Double_t",
"double"},
53 {
"string",
"std::string"},
56 {
"int8_t",
"std::int8_t"},
57 {
"signed char",
"char"},
58 {
"UChar_t",
"std::uint8_t"},
59 {
"unsigned char",
"std::uint8_t"},
60 {
"uint8_t",
"std::uint8_t"},
62 {
"Short_t",
"std::int16_t"},
63 {
"int16_t",
"std::int16_t"},
64 {
"short",
"std::int16_t"},
65 {
"UShort_t",
"std::uint16_t"},
66 {
"unsigned short",
"std::uint16_t"},
67 {
"uint16_t",
"std::uint16_t"},
69 {
"Int_t",
"std::int32_t"},
70 {
"int32_t",
"std::int32_t"},
71 {
"int",
"std::int32_t"},
72 {
"UInt_t",
"std::uint32_t"},
73 {
"unsigned",
"std::uint32_t"},
74 {
"unsigned int",
"std::uint32_t"},
75 {
"uint32_t",
"std::uint32_t"},
77 {
"Long_t",
"std::int64_t"},
78 {
"Long64_t",
"std::int64_t"},
79 {
"int64_t",
"std::int64_t"},
80 {
"long",
"std::int64_t"},
81 {
"ULong64_t",
"std::uint64_t"},
82 {
"unsigned long",
"std::uint64_t"},
83 {
"uint64_t",
"std::uint64_t"}
88std::vector<std::string> TokenizeTypeList(std::string templateType) {
89 std::vector<std::string>
result;
90 if (templateType.empty())
93 const char *eol = templateType.data() + templateType.length();
94 const char *typeBegin = templateType.data();
95 const char *typeCursor = templateType.data();
96 unsigned int nestingLevel = 0;
97 while (typeCursor != eol) {
98 switch (*typeCursor) {
106 if (nestingLevel == 0) {
107 result.push_back(std::string(typeBegin, typeCursor - typeBegin));
108 typeBegin = typeCursor + 1;
114 result.push_back(std::string(typeBegin, typeCursor - typeBegin));
119 std::string normalizedType(
123 auto translatedType = typeTranslationMap.find(normalizedType);
124 if (translatedType != typeTranslationMap.end())
125 normalizedType = translatedType->second;
127 if (normalizedType.substr(0, 7) ==
"vector<") normalizedType =
"std::" + normalizedType;
128 if (normalizedType.substr(0, 6) ==
"array<") normalizedType =
"std::" + normalizedType;
129 if (normalizedType.substr(0, 8) ==
"variant<") normalizedType =
"std::" + normalizedType;
130 if (normalizedType.substr(0, 5) ==
"pair<") normalizedType =
"std::" + normalizedType;
131 if (normalizedType.substr(0, 6) ==
"tuple<") normalizedType =
"std::" + normalizedType;
133 return normalizedType;
138std::tuple<void **, std::int32_t *, std::int32_t *> GetRVecDataMembers(
void *rvecPtr)
140 void **begin =
reinterpret_cast<void **
>(rvecPtr);
142 std::int32_t *
size =
reinterpret_cast<std::int32_t *
>(begin + 1);
145 std::int32_t *capacity =
size + 1;
147 return {begin,
size, capacity};
158 : fName(
name), fType(
type), fStructure(structure), fNRepetitions(nRepetitions), fIsSimple(isSimple),
159 fParent(nullptr), fPrincipalColumn(nullptr)
171 if (normalizedType.empty())
172 return R__FAIL(
"no type name specified for Field " + fieldName);
174 std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
result;
176 if (normalizedType ==
"ROOT::Experimental::ClusterSize_t") {
177 result = std::make_unique<RField<ClusterSize_t>>(fieldName);
178 }
else if (normalizedType ==
"bool") {
179 result = std::make_unique<RField<bool>>(fieldName);
180 }
else if (normalizedType ==
"char") {
181 result = std::make_unique<RField<char>>(fieldName);
182 }
else if (normalizedType ==
"std::int8_t") {
183 result = std::make_unique<RField<std::int8_t>>(fieldName);
184 }
else if (normalizedType ==
"std::uint8_t") {
185 result = std::make_unique<RField<std::uint8_t>>(fieldName);
186 }
else if (normalizedType ==
"std::int16_t") {
187 result = std::make_unique<RField<std::int16_t>>(fieldName);
188 }
else if (normalizedType ==
"std::uint16_t") {
189 result = std::make_unique<RField<std::uint16_t>>(fieldName);
190 }
else if (normalizedType ==
"std::int32_t") {
191 result = std::make_unique<RField<std::int32_t>>(fieldName);
192 }
else if (normalizedType ==
"std::uint32_t") {
193 result = std::make_unique<RField<std::uint32_t>>(fieldName);
194 }
else if (normalizedType ==
"std::int64_t") {
195 result = std::make_unique<RField<std::int64_t>>(fieldName);
196 }
else if (normalizedType ==
"std::uint64_t") {
197 result = std::make_unique<RField<std::uint64_t>>(fieldName);
198 }
else if (normalizedType ==
"float") {
199 result = std::make_unique<RField<float>>(fieldName);
200 }
else if (normalizedType ==
"double") {
201 result = std::make_unique<RField<double>>(fieldName);
202 }
else if (normalizedType ==
"std::string") {
203 result = std::make_unique<RField<std::string>>(fieldName);
204 }
else if (normalizedType ==
"std::vector<bool>") {
205 result = std::make_unique<RField<std::vector<bool>>>(fieldName);
206 }
else if (normalizedType.substr(0, 12) ==
"std::vector<") {
207 std::string itemTypeName = normalizedType.substr(12, normalizedType.length() - 13);
208 auto itemField = Create(
"_0", itemTypeName);
209 result = std::make_unique<RVectorField>(fieldName, itemField.Unwrap());
210 }
else if (normalizedType.substr(0, 19) ==
"ROOT::VecOps::RVec<") {
211 std::string itemTypeName = normalizedType.substr(19, normalizedType.length() - 20);
212 auto itemField = Create(
"_0", itemTypeName);
213 result = std::make_unique<RRVecField>(fieldName, itemField.Unwrap());
214 }
else if (normalizedType.substr(0, 11) ==
"std::array<") {
215 auto arrayDef = TokenizeTypeList(normalizedType.substr(11, normalizedType.length() - 12));
217 auto arrayLength = std::stoi(arrayDef[1]);
219 result = std::make_unique<RArrayField>(fieldName, itemField.Unwrap(), arrayLength);
221 if (normalizedType.substr(0, 13) ==
"std::variant<") {
222 auto innerTypes = TokenizeTypeList(normalizedType.substr(13, normalizedType.length() - 14));
223 std::vector<RFieldBase *> items;
224 for (
unsigned int i = 0; i < innerTypes.size(); ++i) {
225 items.emplace_back(Create(
"_" + std::to_string(i), innerTypes[i]).Unwrap().release());
227 result = std::make_unique<RVariantField>(fieldName, items);
229 if (normalizedType.substr(0, 10) ==
"std::pair<") {
230 auto innerTypes = TokenizeTypeList(normalizedType.substr(10, normalizedType.length() - 11));
231 if (innerTypes.size() != 2)
232 return R__FAIL(
"the type list for std::pair must have exactly two elements");
233 std::array<std::unique_ptr<RFieldBase>, 2> items{Create(
"_0", innerTypes[0]).Unwrap(),
234 Create(
"_1", innerTypes[1]).Unwrap()};
235 result = std::make_unique<RPairField>(fieldName, items);
237 if (normalizedType.substr(0, 11) ==
"std::tuple<") {
238 auto innerTypes = TokenizeTypeList(normalizedType.substr(11, normalizedType.length() - 12));
239 std::vector<std::unique_ptr<RFieldBase>> items;
240 for (
unsigned int i = 0; i < innerTypes.size(); ++i) {
241 items.emplace_back(Create(
"_" + std::to_string(i), innerTypes[i]).Unwrap());
243 result = std::make_unique<RTupleField>(fieldName, items);
246 if (normalizedType ==
":Collection:")
247 result = std::make_unique<RField<ClusterSize_t>>(fieldName);
252 result = std::make_unique<RClassField>(fieldName, normalizedType);
258 return R__FAIL(std::string(
"Field ") + fieldName +
" has unknown type " + normalizedType);
264 if (fieldName ==
"") {
265 return R__FAIL(
"name cannot be empty string \"\"");
266 }
else if (fieldName.find(
".") != std::string::npos) {
267 return R__FAIL(
"name '" + std::string(fieldName) +
"' cannot contain dot characters '.'");
272std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
275 auto clone = CloneImpl(newName);
276 clone->fOnDiskId = fOnDiskId;
277 clone->fDescription = fDescription;
283 R__ASSERT(
false &&
"A non-simple RField must implement its own AppendImpl");
296 void *where =
malloc(GetValueSize());
298 return GenerateValue(where);
307std::vector<ROOT::Experimental::Detail::RFieldValue>
310 return std::vector<RFieldValue>();
314 std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
child)
316 child->fParent =
this;
317 fSubFields.emplace_back(std::move(
child));
323 std::vector<RFieldBase *>
result;
324 for (
const auto &
f : fSubFields) {
333 for (
auto& column : fColumns) {
340 const std::vector<EColumnType> &requestedTypes,
unsigned int columnIndex,
const RNTupleDescriptor &desc)
343 auto columnId = desc.
FindColumnId(fOnDiskId, columnIndex);
345 throw RException(
R__FAIL(
"Column missing: column #" + std::to_string(columnIndex) +
346 " for field " + fName));
350 for (
auto type : requestedTypes) {
351 if (
type == columnDesc.GetModel().GetType())
356 "` of column #" + std::to_string(columnIndex) +
" for field `" + fName +
357 "` is not convertible to the requested type" + [&]{
358 std::string typeStr = requestedTypes.size() > 1 ?
"s " :
" ";
359 for (std::size_t i = 0; i < requestedTypes.size(); i++) {
360 typeStr +=
"`" + RColumnElementBase::GetTypeName(requestedTypes[i]) +
"`";
361 if (i != requestedTypes.size() - 1) {
368 return columnDesc.GetModel().GetType();
375 GenerateColumnsImpl();
376 if (!fColumns.empty())
377 fPrincipalColumn = fColumns[0].get();
378 for (
auto& column : fColumns)
379 column->Connect(fOnDiskId, &pageSink);
388 GenerateColumnsImpl(descriptorGuard.GetRef());
390 if (!fColumns.empty())
391 fPrincipalColumn = fColumns[0].get();
392 for (
auto& column : fColumns)
393 column->Connect(fOnDiskId, &pageSource);
421 auto itr = fStack.rbegin();
422 if (!itr->fFieldPtr->fSubFields.empty()) {
423 fStack.emplace_back(
Position(itr->fFieldPtr->fSubFields[0].get(), 0));
427 unsigned int nextIdxInParent = ++(itr->fIdxInParent);
428 while (nextIdxInParent >= itr->fFieldPtr->fParent->fSubFields.size()) {
429 if (fStack.size() == 1) {
430 itr->fFieldPtr = itr->fFieldPtr->fParent;
431 itr->fIdxInParent = -1;
435 itr = fStack.rbegin();
436 nextIdxInParent = ++(itr->fIdxInParent);
438 itr->fFieldPtr = itr->fFieldPtr->fParent->fSubFields[nextIdxInParent].get();
445std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
448 auto result = std::make_unique<RFieldZero>();
449 for (
auto &
f : fSubFields)
450 result->Attach(
f->Clone(
f->GetName()));
467 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
468 Detail::RColumn::Create<ClusterSize_t, EColumnType::kIndex>(model, 0)));
474 GenerateColumnsImpl();
479 visitor.VisitClusterSizeField(*
this);
494 GenerateColumnsImpl();
514 GenerateColumnsImpl();
519 visitor.VisitInt8Field(*
this);
534 GenerateColumnsImpl();
539 visitor.VisitUInt8Field(*
this);
548 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
549 Detail::RColumn::Create<bool, EColumnType::kBit>(model, 0)));
555 GenerateColumnsImpl();
569 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
570 Detail::RColumn::Create<float, EColumnType::kReal32>(model, 0)));
576 GenerateColumnsImpl();
590 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
591 Detail::RColumn::Create<double, EColumnType::kReal64>(model, 0)));
597 GenerateColumnsImpl();
617 GenerateColumnsImpl();
622 visitor.VisitInt16Field(*
this);
637 GenerateColumnsImpl();
642 visitor.VisitUInt16Field(*
this);
657 GenerateColumnsImpl();
662 visitor.VisitIntField(*
this);
670 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
671 Detail::RColumn::Create<std::uint32_t, EColumnType::kInt32>(model, 0)));
677 GenerateColumnsImpl();
682 visitor.VisitUInt32Field(*
this);
690 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
691 Detail::RColumn::Create<std::uint64_t, EColumnType::kInt64>(model, 0)));
697 GenerateColumnsImpl();
702 visitor.VisitUInt64Field(*
this);
710 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
711 Detail::RColumn::Create<std::int64_t, EColumnType::kInt64>(model, 0)));
717 RColumnModel model(
type,
false );
719 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
720 Detail::RColumn::Create<std::int64_t, EColumnType::kInt64>(model, 0)));
722 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
723 Detail::RColumn::Create<std::int64_t, EColumnType::kInt32>(model, 0)));
729 visitor.VisitInt64Field(*
this);
737 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
738 Detail::RColumn::Create<ClusterSize_t, EColumnType::kIndex>(modelIndex, 0)));
741 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
742 Detail::RColumn::Create<char, EColumnType::kChar>(modelChars, 1)));
749 GenerateColumnsImpl();
754 auto typedValue =
value.Get<std::string>();
755 auto length = typedValue->length();
756 Detail::RColumnElement<char> elemChars(
const_cast<char*
>(typedValue->data()));
757 fColumns[1]->AppendV(elemChars,
length);
759 fColumns[0]->Append(fElemIndex);
760 return length +
sizeof(fElemIndex);
766 auto typedValue =
value->Get<std::string>();
767 RClusterIndex collectionStart;
769 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nChars);
773 typedValue->resize(nChars);
774 Detail::RColumnElement<char> elemChars(
const_cast<char*
>(typedValue->data()));
775 fColumns[1]->ReadV(collectionStart, nChars, &elemChars);
786 visitor.VisitStringField(*
this);
802 throw RException(
R__FAIL(
"RField: no I/O support for type " + std::string(className)));
811 TClass *
c = baseClass->GetClassPointer();
813 c->GetName()).Unwrap();
814 Attach(std::move(subField),
820 if (!dataMember->IsPersistent())
826 Attach(std::move(subField),
833 fMaxAlignment = std::max(fMaxAlignment,
child->GetAlignment());
834 fSubFieldsInfo.push_back(info);
835 RFieldBase::Attach(std::move(
child));
838std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
845 std::size_t nbytes = 0;
846 for (
unsigned i = 0; i < fSubFields.size(); i++) {
847 auto memberValue = fSubFields[i]->CaptureValue(
value.Get<
unsigned char>() + fSubFieldsInfo[i].fOffset);
848 nbytes += fSubFields[i]->Append(memberValue);
855 for (
unsigned i = 0; i < fSubFields.size(); i++) {
856 auto memberValue = fSubFields[i]->CaptureValue(
value->Get<
unsigned char>() + fSubFieldsInfo[i].fOffset);
857 fSubFields[i]->Read(globalIndex, &memberValue);
863 for (
unsigned i = 0; i < fSubFields.size(); i++) {
864 auto memberValue = fSubFields[i]->CaptureValue(
value->Get<
unsigned char>() + fSubFieldsInfo[i].fOffset);
865 fSubFields[i]->Read(clusterIndex, &memberValue);
895std::vector<ROOT::Experimental::Detail::RFieldValue>
898 std::vector<Detail::RFieldValue>
result;
899 for (
unsigned i = 0; i < fSubFields.size(); i++) {
900 auto memberValue = fSubFields[i]->CaptureValue(
value.Get<
unsigned char>() + fSubFieldsInfo[i].fOffset);
901 result.emplace_back(memberValue);
909 return fClass->GetClassSize();
920 std::vector<std::unique_ptr<Detail::RFieldBase>> &&itemFields,
925 for (
auto &item : itemFields) {
933 std::vector<std::unique_ptr<Detail::RFieldBase>> &&itemFields)
936 for (
auto &item : itemFields) {
940 fSize += item->GetValueSize();
949 std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields)
956 if (itemAlignment > 1) {
957 auto remainder = baseOffset % itemAlignment;
964std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
967 std::vector<std::unique_ptr<Detail::RFieldBase>> cloneItems;
968 for (
auto &item : fSubFields)
969 cloneItems.emplace_back(item->Clone(item->GetName()));
970 return std::unique_ptr<RRecordField>(
new RRecordField(newName, std::move(cloneItems), fOffsets,
GetType()));
974 std::size_t nbytes = 0;
975 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
976 auto memberValue = fSubFields[i]->CaptureValue(
value.Get<
unsigned char>() + fOffsets[i]);
977 nbytes += fSubFields[i]->Append(memberValue);
984 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
985 auto memberValue = fSubFields[i]->CaptureValue(
value->Get<
unsigned char>() + fOffsets[i]);
986 fSubFields[i]->Read(globalIndex, &memberValue);
992 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
993 auto memberValue = fSubFields[i]->CaptureValue(
value->Get<
unsigned char>() + fOffsets[i]);
994 fSubFields[i]->Read(clusterIndex, &memberValue);
1000 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
1001 fSubFields[i]->GenerateValue(
static_cast<unsigned char *
>(where) + fOffsets[i]);
1008 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
1009 auto memberValue = fSubFields[i]->CaptureValue(
value.Get<
unsigned char>() + fOffsets[i]);
1010 fSubFields[i]->DestroyValue(memberValue,
true );
1023std::vector<ROOT::Experimental::Detail::RFieldValue>
1026 std::vector<Detail::RFieldValue>
result;
1027 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
1028 result.emplace_back(fSubFields[i]->CaptureValue(
value.Get<
unsigned char>() + fOffsets[i]));
1046 , fItemSize(itemField->GetValueSize()), fNWritten(0)
1048 Attach(std::move(itemField));
1051std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
1054 auto newItemField = fSubFields[0]->Clone(fSubFields[0]->GetName());
1055 return std::make_unique<RVectorField>(newName, std::move(newItemField));
1059 auto typedValue =
value.Get<std::vector<char>>();
1060 R__ASSERT((typedValue->size() % fItemSize) == 0);
1061 std::size_t nbytes = 0;
1062 auto count = typedValue->size() / fItemSize;
1063 for (
unsigned i = 0; i < count; ++i) {
1064 auto itemValue = fSubFields[0]->CaptureValue(typedValue->data() + (i * fItemSize));
1065 nbytes += fSubFields[0]->Append(itemValue);
1069 fColumns[0]->Append(elemIndex);
1070 return nbytes +
sizeof(elemIndex);
1075 auto typedValue =
value->Get<std::vector<char>>();
1079 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
1081 auto oldNItems = typedValue->size() / fItemSize;
1082 for (std::size_t i = nItems; i < oldNItems; ++i) {
1083 auto itemValue = fSubFields[0]->CaptureValue(typedValue->data() + (i * fItemSize));
1084 fSubFields[0]->DestroyValue(itemValue,
true );
1086 typedValue->resize(nItems * fItemSize);
1087 for (std::size_t i = oldNItems; i < nItems; ++i) {
1088 fSubFields[0]->GenerateValue(typedValue->data() + (i * fItemSize));
1091 for (std::size_t i = 0; i < nItems; ++i) {
1092 auto itemValue = fSubFields[0]->CaptureValue(typedValue->data() + (i * fItemSize));
1093 fSubFields[0]->Read(collectionStart + i, &itemValue);
1100 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
1101 Detail::RColumn::Create<ClusterSize_t, EColumnType::kIndex>(modelIndex, 0)));
1107 GenerateColumnsImpl();
1117 auto vec =
static_cast<std::vector<char>*
>(
value.GetRawPtr());
1119 auto nItems =
vec->size() / fItemSize;
1120 for (
unsigned i = 0; i < nItems; ++i) {
1121 auto itemValue = fSubFields[0]->CaptureValue(
vec->data() + (i * fItemSize));
1122 fSubFields[0]->DestroyValue(itemValue,
true );
1134std::vector<ROOT::Experimental::Detail::RFieldValue>
1137 auto vec =
static_cast<std::vector<char>*
>(
value.GetRawPtr());
1139 auto nItems =
vec->size() / fItemSize;
1140 std::vector<Detail::RFieldValue>
result;
1141 for (
unsigned i = 0; i < nItems; ++i) {
1142 result.emplace_back(fSubFields[0]->CaptureValue(
vec->data() + (i * fItemSize)));
1161 :
ROOT::Experimental::Detail::
RFieldBase(fieldName,
"ROOT::VecOps::RVec<" + itemField->
GetType() +
">",
1163 fItemSize(itemField->GetValueSize()), fNWritten(0)
1165 Attach(std::move(itemField));
1169std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
1172 auto newItemField = fSubFields[0]->Clone(fSubFields[0]->GetName());
1173 return std::make_unique<RRVecField>(newName, std::move(newItemField));
1178 auto [beginPtr, sizePtr,
_] = GetRVecDataMembers(
value.GetRawPtr());
1180 std::size_t nbytes = 0;
1181 char *begin =
reinterpret_cast<char *
>(*beginPtr);
1182 for (std::int32_t i = 0; i < *sizePtr; ++i) {
1183 auto elementValue = fSubFields[0]->CaptureValue(begin + i * fItemSize);
1184 nbytes += fSubFields[0]->Append(elementValue);
1188 fNWritten += *sizePtr;
1189 fColumns[0]->Append(elemIndex);
1190 return nbytes +
sizeof(elemIndex);
1198 auto [beginPtr, sizePtr, capacityPtr] = GetRVecDataMembers(
value->GetRawPtr());
1203 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
1204 char *begin =
reinterpret_cast<char *
>(*beginPtr);
1205 const std::size_t oldSize = *sizePtr;
1208 for (std::size_t i = nItems; i < oldSize; ++i) {
1209 auto itemValue = fSubFields[0]->CaptureValue(begin + (i * fItemSize));
1210 fSubFields[0]->DestroyValue(itemValue,
true );
1214 if (std::int32_t(nItems) > *capacityPtr) {
1217 for (std::size_t i = 0u; i < oldSize; ++i) {
1218 auto itemValue = fSubFields[0]->CaptureValue(begin + (i * fItemSize));
1219 fSubFields[0]->DestroyValue(itemValue,
true );
1226 *beginPtr =
malloc(nItems * fItemSize);
1228 begin =
reinterpret_cast<char *
>(*beginPtr);
1229 *capacityPtr = nItems;
1232 for (std::size_t i = 0u; i < oldSize; ++i)
1233 fSubFields[0]->GenerateValue(begin + (i * fItemSize));
1238 for (std::size_t i = oldSize; i < nItems; ++i)
1239 fSubFields[0]->GenerateValue(begin + (i * fItemSize));
1242 for (std::size_t i = 0; i < nItems; ++i) {
1243 auto itemValue = fSubFields[0]->CaptureValue(begin + (i * fItemSize));
1244 fSubFields[0]->Read(collectionStart + i, &itemValue);
1251 fColumns.emplace_back(
1252 std::unique_ptr<Detail::RColumn>(Detail::RColumn::Create<ClusterSize_t, EColumnType::kIndex>(modelIndex, 0)));
1258 GenerateColumnsImpl();
1265 void **beginPtr =
new (where)(
void *)(
nullptr);
1266 std::int32_t *sizePtr =
new (
reinterpret_cast<void *
>(beginPtr + 1)) std::int32_t(0);
1267 new (sizePtr + 1) std::int32_t(0);
1274 auto [beginPtr, sizePtr, capacityPtr] = GetRVecDataMembers(
value.GetRawPtr());
1276 char *begin =
reinterpret_cast<char *
>(*beginPtr);
1277 for (std::int32_t i = 0; i < *sizePtr; ++i) {
1278 auto elementValue = fSubFields[0]->CaptureValue(begin + i * fItemSize);
1279 fSubFields[0]->DestroyValue(elementValue,
true );
1284 constexpr auto dataMemberSz =
sizeof(
void *) + 2 *
sizeof(std::int32_t);
1285 const auto alignOfT = fSubFields[0]->GetAlignment();
1286 auto paddingMiddle = dataMemberSz % alignOfT;
1287 if (paddingMiddle != 0)
1288 paddingMiddle = alignOfT - paddingMiddle;
1289 const bool isSmall = (
reinterpret_cast<void *
>(begin) == (beginPtr + dataMemberSz + paddingMiddle));
1291 const bool owns = (*capacityPtr != -1);
1292 if (!isSmall && owns)
1304std::vector<ROOT::Experimental::Detail::RFieldValue>
1307 auto [beginPtr, sizePtr,
_] = GetRVecDataMembers(
value.GetRawPtr());
1309 std::vector<Detail::RFieldValue>
result;
1310 char *begin =
reinterpret_cast<char *
>(*beginPtr);
1311 for (std::int32_t i = 0; i < *sizePtr; ++i) {
1312 auto elementValue = fSubFields[0]->CaptureValue(begin + i * fItemSize);
1313 result.emplace_back(std::move(elementValue));
1332 constexpr auto dataMemberSz =
sizeof(
void *) + 2 *
sizeof(std::int32_t);
1333 const auto alignOfT = fSubFields[0]->GetAlignment();
1334 const auto sizeOfT = fSubFields[0]->GetValueSize();
1337 const auto inlineStorageSz = [&] {
1338#ifdef R__HAS_HARDWARE_INTERFERENCE_SIZE
1340 constexpr unsigned cacheLineSize = std::hardware_destructive_interference_size;
1342 constexpr unsigned cacheLineSize = 64u;
1344 const unsigned elementsPerCacheLine = (cacheLineSize - dataMemberSz) / sizeOfT;
1345 constexpr unsigned maxInlineByteSize = 1024;
1346 const unsigned nElements =
1347 elementsPerCacheLine >= 8 ? elementsPerCacheLine : (sizeOfT * 8 > maxInlineByteSize ? 0 : 8);
1348 return nElements * sizeOfT;
1353 auto paddingMiddle = dataMemberSz % alignOfT;
1354 if (paddingMiddle != 0)
1355 paddingMiddle = alignOfT - paddingMiddle;
1358 const auto alignOfRVecT = GetAlignment();
1359 auto paddingEnd = (dataMemberSz + paddingMiddle + inlineStorageSz) % alignOfRVecT;
1360 if (paddingEnd != 0)
1361 paddingEnd = alignOfRVecT - paddingEnd;
1363 return dataMemberSz + inlineStorageSz + paddingMiddle + paddingEnd;
1375 return std::max({
alignof(
void *),
alignof(std::int32_t), fSubFields[0]->GetAlignment()});
1398 auto typedValue =
value.Get<std::vector<bool>>();
1399 auto count = typedValue->size();
1400 for (
unsigned i = 0; i < count; ++i) {
1401 bool bval = (*typedValue)[i];
1402 auto itemValue = fSubFields[0]->CaptureValue(&bval);
1403 fSubFields[0]->Append(itemValue);
1405 Detail::RColumnElement<ClusterSize_t> elemIndex(&fNWritten);
1407 fColumns[0]->Append(elemIndex);
1408 return count +
sizeof(elemIndex);
1413 auto typedValue =
value->Get<std::vector<bool>>();
1416 RClusterIndex collectionStart;
1417 fPrincipalColumn->GetCollectionInfo(globalIndex, &collectionStart, &nItems);
1419 typedValue->resize(nItems);
1420 for (
unsigned i = 0; i < nItems; ++i) {
1422 auto itemValue = fSubFields[0]->GenerateValue(&bval);
1423 fSubFields[0]->Read(collectionStart + i, &itemValue);
1424 (*typedValue)[i] = bval;
1431 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
1432 Detail::RColumn::Create<ClusterSize_t, EColumnType::kIndex>(modelIndex, 0)));
1438 GenerateColumnsImpl();
1441std::vector<ROOT::Experimental::Detail::RFieldValue>
1444 const static bool trueValue =
true;
1445 const static bool falseValue =
false;
1447 auto typedValue =
value.Get<std::vector<bool>>();
1448 auto count = typedValue->size();
1449 std::vector<Detail::RFieldValue>
result;
1450 for (
unsigned i = 0; i < count; ++i) {
1451 if ((*typedValue)[i])
1452 result.emplace_back(fSubFields[0]->CaptureValue(
const_cast<bool *
>(&trueValue)));
1454 result.emplace_back(fSubFields[0]->CaptureValue(
const_cast<bool *
>(&falseValue)));
1462 auto vec =
static_cast<std::vector<bool>*
>(
value.GetRawPtr());
1470 visitor.VisitVectorBoolField(*
this);
1478 std::string_view fieldName, std::unique_ptr<Detail::RFieldBase> itemField, std::size_t arrayLength)
1480 fieldName,
"std::array<" + itemField->
GetType() +
"," + std::to_string(arrayLength) +
">",
1482 , fItemSize(itemField->GetValueSize()), fArrayLength(arrayLength)
1484 Attach(std::move(itemField));
1487std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
1490 auto newItemField = fSubFields[0]->Clone(fSubFields[0]->GetName());
1491 return std::make_unique<RArrayField>(newName, std::move(newItemField), fArrayLength);
1495 std::size_t nbytes = 0;
1496 auto arrayPtr =
value.Get<
unsigned char>();
1497 for (
unsigned i = 0; i < fArrayLength; ++i) {
1498 auto itemValue = fSubFields[0]->CaptureValue(arrayPtr + (i * fItemSize));
1499 nbytes += fSubFields[0]->Append(itemValue);
1506 auto arrayPtr =
value->Get<
unsigned char>();
1507 for (
unsigned i = 0; i < fArrayLength; ++i) {
1508 auto itemValue = fSubFields[0]->GenerateValue(arrayPtr + (i * fItemSize));
1509 fSubFields[0]->Read(globalIndex * fArrayLength + i, &itemValue);
1515 auto arrayPtr =
value->Get<
unsigned char>();
1516 for (
unsigned i = 0; i < fArrayLength; ++i) {
1517 auto itemValue = fSubFields[0]->GenerateValue(arrayPtr + (i * fItemSize));
1533 auto arrayPtr =
reinterpret_cast<unsigned char *
>(where);
1534 for (
unsigned i = 0; i < fArrayLength; ++i) {
1535 fSubFields[0]->GenerateValue(arrayPtr + (i * fItemSize));
1542 auto arrayPtr =
value.Get<
unsigned char>();
1543 for (
unsigned i = 0; i < fArrayLength; ++i) {
1544 auto itemValue = fSubFields[0]->CaptureValue(arrayPtr + (i * fItemSize));
1545 fSubFields[0]->DestroyValue(itemValue,
true );
1556std::vector<ROOT::Experimental::Detail::RFieldValue>
1559 auto arrayPtr =
value.Get<
unsigned char>();
1560 std::vector<Detail::RFieldValue>
result;
1561 for (
unsigned i = 0; i < fArrayLength; ++i) {
1562 auto itemValue = fSubFields[0]->CaptureValue(arrayPtr + (i * fItemSize));
1563 result.emplace_back(itemValue);
1578 for (
size_t i = 0; i < itemFields.size(); ++i) {
1579 result += itemFields[i]->GetType() +
",";
1587 std::string_view fieldName,
const std::vector<Detail::RFieldBase *> &itemFields)
1591 auto nFields = itemFields.size();
1594 for (
unsigned int i = 0; i < nFields; ++i) {
1597 Attach(std::unique_ptr<Detail::RFieldBase>(itemFields[i]));
1602std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
1605 auto nFields = fSubFields.size();
1606 std::vector<Detail::RFieldBase *> itemFields;
1607 for (
unsigned i = 0; i < nFields; ++i) {
1609 itemFields.emplace_back(fSubFields[i]->Clone(fSubFields[i]->GetName()).release());
1611 return std::make_unique<RVariantField>(newName, itemFields);
1616 auto index = *(
reinterpret_cast<char *
>(variantPtr) + fTagOffset);
1622 auto index =
reinterpret_cast<char *
>(variantPtr) + fTagOffset;
1623 *
index =
static_cast<char>(tag - 1);
1628 auto tag = GetTag(
value.GetRawPtr());
1629 std::size_t nbytes = 0;
1632 auto itemValue = fSubFields[tag - 1]->CaptureValue(
value.GetRawPtr());
1633 nbytes += fSubFields[tag - 1]->Append(itemValue);
1634 index = fNWritten[tag - 1]++;
1638 fColumns[0]->Append(elemSwitch);
1646 fPrincipalColumn->GetSwitchInfo(globalIndex, &variantIndex, &tag);
1649 auto itemValue = fSubFields[tag - 1]->GenerateValue(
value->GetRawPtr());
1650 fSubFields[tag - 1]->Read(variantIndex, &itemValue);
1651 SetTag(
value->GetRawPtr(), tag);
1657 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
1658 Detail::RColumn::Create<RColumnSwitch, EColumnType::kSwitch>(modelSwitch, 0)));
1664 GenerateColumnsImpl();
1669 memset(where, 0, GetValueSize());
1670 fSubFields[0]->GenerateValue(where);
1677 auto variantPtr =
value.GetRawPtr();
1678 auto tag = GetTag(variantPtr);
1680 auto itemValue = fSubFields[tag - 1]->CaptureValue(variantPtr);
1681 fSubFields[tag - 1]->DestroyValue(itemValue,
true );
1694 return fMaxItemSize + fMaxAlignment;
1699 std::fill(fNWritten.begin(), fNWritten.end(), 0);
1704std::string ROOT::Experimental::RPairField::RPairField::GetTypeList(
1705 const std::array<std::unique_ptr<Detail::RFieldBase>, 2> &itemFields)
1707 return itemFields[0]->GetType() +
"," + itemFields[1]->GetType();
1711 std::array<std::unique_ptr<Detail::RFieldBase>, 2> &&itemFields,
1712 const std::array<std::size_t, 2> &offsets)
1713 :
ROOT::Experimental::
RRecordField(fieldName, std::move(itemFields), offsets,
1714 "std::pair<" + GetTypeList(itemFields) +
">")
1719 std::array<std::unique_ptr<Detail::RFieldBase>, 2> &itemFields)
1721 "std::pair<" + GetTypeList(itemFields) +
">")
1728 fOffsets[0] =
fClass->GetDataMember(
"first")->GetOffset();
1729 fOffsets[1] =
fClass->GetDataMember(
"second")->GetOffset();
1732std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
1735 std::array<std::unique_ptr<Detail::RFieldBase>, 2> items{fSubFields[0]->Clone(fSubFields[0]->GetName()),
1736 fSubFields[1]->Clone(fSubFields[1]->GetName())};
1738 std::unique_ptr<RPairField>
result(
new RPairField(newName, std::move(items), {fOffsets[0], fOffsets[1]}));
1757std::string ROOT::Experimental::RTupleField::RTupleField::GetTypeList(
1758 const std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields)
1761 if (itemFields.empty())
1762 throw RException(
R__FAIL(
"the type list for std::tuple must have at least one element"));
1763 for (
size_t i = 0; i < itemFields.size(); ++i) {
1764 result += itemFields[i]->GetType() +
",";
1771 std::vector<std::unique_ptr<Detail::RFieldBase>> &&itemFields,
1772 const std::vector<std::size_t> &offsets)
1773 :
ROOT::Experimental::
RRecordField(fieldName, std::move(itemFields), offsets,
1774 "std::tuple<" + GetTypeList(itemFields) +
">")
1779 std::vector<std::unique_ptr<Detail::RFieldBase>> &itemFields)
1781 "std::tuple<" + GetTypeList(itemFields) +
">")
1793 for (
unsigned i = 0; i < fSubFields.size(); ++i) {
1794 std::string memberName(
"_" + std::to_string(i));
1795 auto member =
fClass->GetRealData(memberName.c_str());
1798 fOffsets.push_back(member->GetThisOffset());
1802std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
1805 std::vector<std::unique_ptr<Detail::RFieldBase>> items;
1806 for (
const auto &item : fSubFields)
1807 items.push_back(item->Clone(item->GetName()));
1809 std::unique_ptr<RTupleField>
result(
new RTupleField(newName, std::move(items), fOffsets));
1830 std::shared_ptr<RCollectionNTupleWriter> collectionNTuple,
1831 std::unique_ptr<RNTupleModel> collectionModel)
1833 , fCollectionNTuple(collectionNTuple)
1835 for (
unsigned i = 0; i < collectionModel->GetFieldZero()->
fSubFields.size(); ++i) {
1836 auto& subField = collectionModel->GetFieldZero()->fSubFields[i];
1837 Attach(std::move(subField));
1846 fColumns.emplace_back(std::unique_ptr<Detail::RColumn>(
1847 Detail::RColumn::Create<ClusterSize_t, EColumnType::kIndex>(modelIndex, 0)));
1853 GenerateColumnsImpl();
1857std::unique_ptr<ROOT::Experimental::Detail::RFieldBase>
1861 for (
auto&
f : fSubFields) {
1862 auto clone =
f->Clone(
f->GetName());
1863 result->Attach(std::move(clone));
1870 *fCollectionNTuple->GetOffsetPtr() = 0;
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
ROOT::Experimental::RField< T > RField
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
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 char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
static std::string GetTypeName(EColumnType type)
Pairs of C++ type and column type, like float and EColumnType::kReal32.
static RColumn * Create(const RColumnModel &model, std::uint32_t index)
Iterates over the sub tree of fields in depth-first search order.
void Advance()
Given that the iterator points to a valid field which is not the end iterator, go to the next field i...
std::vector< std::unique_ptr< RFieldBase > > fSubFields
Collections and classes own sub fields.
RFieldBase(std::string_view name, std::string_view type, ENTupleStructure structure, bool isSimple, std::size_t nRepetitions=0)
The constructor creates the underlying column objects and connects them to either a sink or a source.
virtual void DestroyValue(const RFieldValue &value, bool dtorOnly=false)
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
void ConnectPageSink(RPageSink &pageSink)
Fields and their columns live in the void until connected to a physical page storage.
ROOT::Experimental::EColumnType EnsureColumnType(const std::vector< EColumnType > &requestedTypes, unsigned int columnIndex, const RNTupleDescriptor &desc)
Throws an exception if the column given by fOnDiskId and the columnIndex in the provided descriptor i...
void Flush() const
Ensure that all received items are written from page buffers to the storage.
virtual void CommitCluster()
Perform housekeeping tasks for global to cluster-local index translation.
void SetDescription(std::string_view description)
virtual std::vector< RFieldValue > SplitValue(const RFieldValue &value) const
Creates the list of direct child values given a value for this field.
static RResult< void > EnsureValidFieldName(std::string_view fieldName)
Check whether a given string is a valid field name.
static RResult< std::unique_ptr< RFieldBase > > Create(const std::string &fieldName, const std::string &typeName)
Factory method to resurrect a field from the stored on-disk type information.
void ConnectPageSource(RPageSource &pageSource)
virtual std::size_t AppendImpl(const RFieldValue &value)
Operations on values of complex types, e.g.
std::unique_ptr< RFieldBase > Clone(std::string_view newName) const
Copies the field and its sub fields using a possibly new name and a new, unconnected set of columns.
virtual void AcceptVisitor(RFieldVisitor &visitor) const
virtual void ReadGlobalImpl(NTupleSize_t globalIndex, RFieldValue *value)
void Attach(std::unique_ptr< Detail::RFieldBase > child)
Add a new subfield to the list of nested fields.
std::vector< RFieldBase * > GetSubFields() const
RFieldValue GenerateValue()
Generates an object of the field type and allocates new initialized memory according to the type.
Abstract base class for classes implementing the visitor design pattern.
virtual void VisitBoolField(const RField< bool > &field)
virtual void VisitFieldZero(const RFieldZero &field)
virtual void VisitRVecField(const RRVecField &field)
virtual void VisitField(const Detail::RFieldBase &field)=0
virtual void VisitDoubleField(const RField< double > &field)
virtual void VisitCharField(const RField< char > &field)
virtual void VisitArrayField(const RArrayField &field)
virtual void VisitClassField(const RClassField &field)
virtual void VisitRecordField(const RRecordField &field)
virtual void VisitVectorField(const RVectorField &field)
virtual void VisitFloatField(const RField< float > &field)
Abstract interface to write data into an ntuple.
Abstract interface to read data from an ntuple.
const RSharedDescriptorGuard GetSharedDescriptorGuard() const
Takes the read lock for the descriptor.
The available trivial, native content types of a column.
std::vector< Detail::RFieldValue > SplitValue(const Detail::RFieldValue &value) const final
Creates the list of direct child values given a value for this field.
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
void ReadInClusterImpl(const RClusterIndex &clusterIndex, Detail::RFieldValue *value) final
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
RArrayField(std::string_view fieldName, std::unique_ptr< Detail::RFieldBase > itemField, std::size_t arrayLength)
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
The field for a class with dictionary.
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
static constexpr const char * kPrefixInherited
Prefix used in the subfield names generated for base classes.
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
void Attach(std::unique_ptr< Detail::RFieldBase > child, RSubFieldInfo info)
std::vector< Detail::RFieldValue > SplitValue(const Detail::RFieldValue &value) const final
Creates the list of direct child values given a value for this field.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const override
void ReadInClusterImpl(const RClusterIndex &clusterIndex, Detail::RFieldValue *value) final
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
RClassField(std::string_view fieldName, std::string_view className, TClass *classp)
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
DescriptorId_t GetClusterId() const
ClusterSize_t::ValueType GetIndex() const
void CommitCluster() final
Perform housekeeping tasks for global to cluster-local index translation.
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
RCollectionField(std::string_view name, std::shared_ptr< RCollectionNTupleWriter > collectionNTuple, std::unique_ptr< RNTupleModel > collectionModel)
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
Holds the static meta-data of a column in a tree.
Holds the index and the tag of a kSwitch column.
Base class for all ROOT issued exceptions.
A field translates read and write calls from/to underlying columns to/from tree values.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const
Called by Clone(), which additionally copies the on-disk ID.
Classes with dictionaries that can be inspected by TClass.
The on-storage meta-data of an ntuple.
const RColumnDescriptor & GetColumnDescriptor(DescriptorId_t columnId) const
DescriptorId_t FindColumnId(DescriptorId_t fieldId, std::uint32_t columnIndex) const
static std::unique_ptr< RNTupleModel > Create()
The generic field for std::pair<T1, T2> types.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) override
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
RPairField(std::string_view fieldName, std::array< std::unique_ptr< Detail::RFieldBase >, 2 > &&itemFields, const std::array< std::size_t, 2 > &offsets)
Detail::RFieldValue CaptureValue(void *where) override
Creates a value from a memory location with an already constructed object.
std::size_t EvalValueSize() const
Evaluate the constant returned by GetValueSize.
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) override
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
RRVecField(std::string_view fieldName, std::unique_ptr< Detail::RFieldBase > itemField)
void CommitCluster() final
Perform housekeeping tasks for global to cluster-local index translation.
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) override
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
size_t GetAlignment() const override
For many types, the alignment requirement is equal to the size; otherwise override.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
size_t GetValueSize() const override
The number of bytes taken by a value of the appropriate type.
std::size_t AppendImpl(const Detail::RFieldValue &value) override
Operations on values of complex types, e.g.
std::vector< Detail::RFieldValue > SplitValue(const Detail::RFieldValue &value) const final
Creates the list of direct child values given a value for this field.
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
The field for an untyped record.
std::size_t fMaxAlignment
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
std::vector< std::size_t > fOffsets
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
RRecordField(std::string_view fieldName, std::vector< std::unique_ptr< Detail::RFieldBase > > &&itemFields, const std::vector< std::size_t > &offsets, std::string_view typeName="")
std::size_t GetItemPadding(std::size_t baseOffset, std::size_t itemAlignment) const
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
std::vector< Detail::RFieldValue > SplitValue(const Detail::RFieldValue &value) const final
Creates the list of direct child values given a value for this field.
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) override
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
void ReadInClusterImpl(const RClusterIndex &clusterIndex, Detail::RFieldValue *value) final
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
RResult<void> has no data member and no Inspect() method but instead a Success() factory method.
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
The generic field for std::tuple<Ts...> types.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const override
Called by Clone(), which additionally copies the on-disk ID.
RTupleField(std::string_view fieldName, std::vector< std::unique_ptr< Detail::RFieldBase > > &&itemFields, const std::vector< std::size_t > &offsets)
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) override
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
size_t GetValueSize() const final
The number of bytes taken by a value of the appropriate type.
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
std::vector< ClusterSize_t::ValueType > fNWritten
size_t fTagOffset
In the std::variant memory layout, at which byte number is the index stored.
void SetTag(void *variantPtr, std::uint32_t tag) const
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
std::uint32_t GetTag(void *variantPtr) const
Extracts the index from an std::variant and transforms it into the 1-based index used for the switch ...
static std::string GetTypeList(const std::vector< Detail::RFieldBase * > &itemFields)
RVariantField(std::string_view fieldName, const std::vector< Detail::RFieldBase * > &itemFields)
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
size_t GetAlignment() const final
For many types, the alignment requirement is equal to the size; otherwise override.
Detail::RFieldValue CaptureValue(void *where) final
Creates a value from a memory location with an already constructed object.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void CommitCluster() final
Perform housekeeping tasks for global to cluster-local index translation.
Detail::RFieldValue CaptureValue(void *where) override
Creates a value from a memory location with an already constructed object.
void CommitCluster() final
Perform housekeeping tasks for global to cluster-local index translation.
std::unique_ptr< Detail::RFieldBase > CloneImpl(std::string_view newName) const final
Called by Clone(), which additionally copies the on-disk ID.
void AcceptVisitor(Detail::RFieldVisitor &visitor) const final
std::vector< Detail::RFieldValue > SplitValue(const Detail::RFieldValue &value) const final
Creates the list of direct child values given a value for this field.
void ReadGlobalImpl(NTupleSize_t globalIndex, Detail::RFieldValue *value) final
void GenerateColumnsImpl() final
Creates the backing columns corresponsing to the field type for writing.
RVectorField(std::string_view fieldName, std::unique_ptr< Detail::RFieldBase > itemField)
void DestroyValue(const Detail::RFieldValue &value, bool dtorOnly=false) final
Releases the resources acquired during GenerateValue (memory and constructor) This implementation wor...
std::size_t AppendImpl(const Detail::RFieldValue &value) final
Operations on values of complex types, e.g.
TClass instances represent classes, structs and namespaces in the ROOT type system.
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
RVec< PromoteTypes< T0, T1 > > remainder(const T0 &x, const RVec< T1 > &v)
basic_string_view< char > string_view
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
RClusterSize ClusterSize_t
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
constexpr DescriptorId_t kInvalidDescriptorId
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Type GetType(const std::string &Name)
std::string ResolveTypedef(const char *tname, bool resolveAll=false)
std::string CleanType(const char *typeDesc, int mode=0, const char **tail=0)
Cleanup type description, redundant blanks removed and redundant tail ignored return *tail = pointer ...
Wrap the 32bit integer in a struct in order to avoid template specialization clash with std::uint32_t...