@@ -797,7 +797,7 @@ const ROOT::RFieldBase::RColumnRepresentations &ROOT::RNullableField::GetColumnR
797797 {ENTupleColumnType::kIndex64 },
798798 {ENTupleColumnType::kSplitIndex32 },
799799 {ENTupleColumnType::kIndex32 }},
800- {});
800+ {{} });
801801 return representations;
802802}
803803
@@ -808,7 +808,8 @@ void ROOT::RNullableField::GenerateColumns()
808808
809809void ROOT::RNullableField::GenerateColumns (const ROOT::RNTupleDescriptor &desc)
810810{
811- GenerateColumnsImpl<ROOT::Internal::RColumnIndex>(desc);
811+ if (!fIsEvolvedFromInnerType )
812+ GenerateColumnsImpl<ROOT::Internal::RColumnIndex>(desc);
812813}
813814
814815std::size_t ROOT::RNullableField::AppendNull ()
@@ -830,8 +831,13 @@ void ROOT::RNullableField::ReconcileOnDiskField(const RNTupleDescriptor &desc)
830831 static const std::vector<std::string> prefixes = {" std::optional<" , " std::unique_ptr<" };
831832
832833 const auto &fieldDesc = desc.GetFieldDescriptor (GetOnDiskId ());
833- EnsureMatchingOnDiskField (fieldDesc, kDiffTypeName );
834- EnsureMatchingTypePrefix (fieldDesc, prefixes);
834+ try {
835+ EnsureMatchingOnDiskField (fieldDesc, kDiffTypeName );
836+ EnsureMatchingTypePrefix (fieldDesc, prefixes);
837+ } catch (const RException &) {
838+ fSubfields [0 ]->SetOnDiskId (GetOnDiskId ());
839+ fIsEvolvedFromInnerType = true ;
840+ }
835841}
836842
837843ROOT::RNTupleLocalIndex ROOT::RNullableField::GetItemIndex (ROOT::NTupleSize_t globalIndex)
@@ -900,16 +906,28 @@ void *ROOT::RUniquePtrField::PrepareRead(void *to, bool hasOnDiskValue)
900906
901907void ROOT::RUniquePtrField::ReadGlobalImpl (ROOT::NTupleSize_t globalIndex, void *to)
902908{
903- auto itemIndex = GetItemIndex (globalIndex);
904- const bool hasOnDiskValue = itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
909+ RNTupleLocalIndex itemIndex;
910+ if (!fIsEvolvedFromInnerType )
911+ itemIndex = GetItemIndex (globalIndex);
912+ const bool hasOnDiskValue = fIsEvolvedFromInnerType || itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
905913 auto valuePtr = PrepareRead (to, hasOnDiskValue);
906- if (hasOnDiskValue)
907- CallReadOn (*fSubfields [0 ], itemIndex, valuePtr);
914+ if (hasOnDiskValue) {
915+ if (fIsEvolvedFromInnerType ) {
916+ CallReadOn (*fSubfields [0 ], globalIndex, valuePtr);
917+ } else {
918+ CallReadOn (*fSubfields [0 ], itemIndex, valuePtr);
919+ }
920+ }
908921}
909922
910923void ROOT::RUniquePtrField::ReadInClusterImpl (ROOT::RNTupleLocalIndex localIndex, void *to)
911924{
912- auto itemIndex = GetItemIndex (localIndex);
925+ RNTupleLocalIndex itemIndex;
926+ if (!fIsEvolvedFromInnerType ) {
927+ itemIndex = GetItemIndex (localIndex);
928+ } else {
929+ itemIndex = localIndex;
930+ }
913931 const bool hasOnDiskValue = itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
914932 auto valuePtr = PrepareRead (to, hasOnDiskValue);
915933 if (hasOnDiskValue)
@@ -992,16 +1010,28 @@ void ROOT::ROptionalField::PrepareRead(void *to, bool hasOnDiskValue)
9921010
9931011void ROOT::ROptionalField::ReadGlobalImpl (ROOT::NTupleSize_t globalIndex, void *to)
9941012{
995- auto itemIndex = GetItemIndex (globalIndex);
996- const bool hasOnDiskValue = itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
1013+ RNTupleLocalIndex itemIndex;
1014+ if (!fIsEvolvedFromInnerType )
1015+ itemIndex = GetItemIndex (globalIndex);
1016+ const bool hasOnDiskValue = fIsEvolvedFromInnerType || itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
9971017 PrepareRead (to, hasOnDiskValue);
998- if (hasOnDiskValue)
999- CallReadOn (*fSubfields [0 ], itemIndex, to);
1018+ if (hasOnDiskValue) {
1019+ if (fIsEvolvedFromInnerType ) {
1020+ CallReadOn (*fSubfields [0 ], globalIndex, to);
1021+ } else {
1022+ CallReadOn (*fSubfields [0 ], itemIndex, to);
1023+ }
1024+ }
10001025}
10011026
10021027void ROOT::ROptionalField::ReadInClusterImpl (ROOT::RNTupleLocalIndex localIndex, void *to)
10031028{
1004- auto itemIndex = GetItemIndex (localIndex);
1029+ RNTupleLocalIndex itemIndex;
1030+ if (!fIsEvolvedFromInnerType ) {
1031+ itemIndex = GetItemIndex (localIndex);
1032+ } else {
1033+ itemIndex = localIndex;
1034+ }
10051035 const bool hasOnDiskValue = itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
10061036 PrepareRead (to, hasOnDiskValue);
10071037 if (hasOnDiskValue)
0 commit comments