@@ -849,18 +849,20 @@ const ROOT::RFieldBase::RColumnRepresentations &ROOT::RNullableField::GetColumnR
849849 {ENTupleColumnType::kIndex64 },
850850 {ENTupleColumnType::kSplitIndex32 },
851851 {ENTupleColumnType::kIndex32 }},
852- {});
852+ {{} });
853853 return representations;
854854}
855855
856856void ROOT::RNullableField::GenerateColumns ()
857857{
858+ R__ASSERT (!fIsEvolvedFromInnerType );
858859 GenerateColumnsImpl<ROOT::Internal::RColumnIndex>();
859860}
860861
861862void ROOT::RNullableField::GenerateColumns (const ROOT::RNTupleDescriptor &desc)
862863{
863- GenerateColumnsImpl<ROOT::Internal::RColumnIndex>(desc);
864+ if (!fIsEvolvedFromInnerType )
865+ GenerateColumnsImpl<ROOT::Internal::RColumnIndex>(desc);
864866}
865867
866868std::size_t ROOT::RNullableField::AppendNull ()
@@ -881,8 +883,16 @@ void ROOT::RNullableField::ReconcileOnDiskField(const RNTupleDescriptor &desc)
881883{
882884 static const std::vector<std::string> prefixes = {" std::optional<" , " std::unique_ptr<" };
883885
884- EnsureMatchingOnDiskField (desc, kDiffTypeName ).ThrowOnError ();
885- EnsureMatchingTypePrefix (desc, prefixes).ThrowOnError ();
886+ auto success = EnsureMatchingOnDiskField (desc, kDiffTypeName );
887+ if (!success) {
888+ fIsEvolvedFromInnerType = true ;
889+ } else {
890+ success = EnsureMatchingTypePrefix (desc, prefixes);
891+ fIsEvolvedFromInnerType = !success;
892+ }
893+
894+ if (fIsEvolvedFromInnerType )
895+ fSubfields [0 ]->SetOnDiskId (GetOnDiskId ());
886896}
887897
888898ROOT::RNTupleLocalIndex ROOT::RNullableField::GetItemIndex (ROOT::NTupleSize_t globalIndex)
@@ -951,16 +961,28 @@ void *ROOT::RUniquePtrField::PrepareRead(void *to, bool hasOnDiskValue)
951961
952962void ROOT::RUniquePtrField::ReadGlobalImpl (ROOT::NTupleSize_t globalIndex, void *to)
953963{
954- auto itemIndex = GetItemIndex (globalIndex);
955- const bool hasOnDiskValue = itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
964+ RNTupleLocalIndex itemIndex;
965+ if (!fIsEvolvedFromInnerType )
966+ itemIndex = GetItemIndex (globalIndex);
967+ const bool hasOnDiskValue = fIsEvolvedFromInnerType || itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
956968 auto valuePtr = PrepareRead (to, hasOnDiskValue);
957- if (hasOnDiskValue)
958- CallReadOn (*fSubfields [0 ], itemIndex, valuePtr);
969+ if (hasOnDiskValue) {
970+ if (fIsEvolvedFromInnerType ) {
971+ CallReadOn (*fSubfields [0 ], globalIndex, valuePtr);
972+ } else {
973+ CallReadOn (*fSubfields [0 ], itemIndex, valuePtr);
974+ }
975+ }
959976}
960977
961978void ROOT::RUniquePtrField::ReadInClusterImpl (ROOT::RNTupleLocalIndex localIndex, void *to)
962979{
963- auto itemIndex = GetItemIndex (localIndex);
980+ RNTupleLocalIndex itemIndex;
981+ if (!fIsEvolvedFromInnerType ) {
982+ itemIndex = GetItemIndex (localIndex);
983+ } else {
984+ itemIndex = localIndex;
985+ }
964986 const bool hasOnDiskValue = itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
965987 auto valuePtr = PrepareRead (to, hasOnDiskValue);
966988 if (hasOnDiskValue)
@@ -1043,16 +1065,28 @@ void ROOT::ROptionalField::PrepareRead(void *to, bool hasOnDiskValue)
10431065
10441066void ROOT::ROptionalField::ReadGlobalImpl (ROOT::NTupleSize_t globalIndex, void *to)
10451067{
1046- auto itemIndex = GetItemIndex (globalIndex);
1047- const bool hasOnDiskValue = itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
1068+ RNTupleLocalIndex itemIndex;
1069+ if (!fIsEvolvedFromInnerType )
1070+ itemIndex = GetItemIndex (globalIndex);
1071+ const bool hasOnDiskValue = fIsEvolvedFromInnerType || itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
10481072 PrepareRead (to, hasOnDiskValue);
1049- if (hasOnDiskValue)
1050- CallReadOn (*fSubfields [0 ], itemIndex, to);
1073+ if (hasOnDiskValue) {
1074+ if (fIsEvolvedFromInnerType ) {
1075+ CallReadOn (*fSubfields [0 ], globalIndex, to);
1076+ } else {
1077+ CallReadOn (*fSubfields [0 ], itemIndex, to);
1078+ }
1079+ }
10511080}
10521081
10531082void ROOT::ROptionalField::ReadInClusterImpl (ROOT::RNTupleLocalIndex localIndex, void *to)
10541083{
1055- auto itemIndex = GetItemIndex (localIndex);
1084+ RNTupleLocalIndex itemIndex;
1085+ if (!fIsEvolvedFromInnerType ) {
1086+ itemIndex = GetItemIndex (localIndex);
1087+ } else {
1088+ itemIndex = localIndex;
1089+ }
10561090 const bool hasOnDiskValue = itemIndex.GetIndexInCluster () != ROOT::kInvalidNTupleIndex ;
10571091 PrepareRead (to, hasOnDiskValue);
10581092 if (hasOnDiskValue)
0 commit comments