@@ -1049,6 +1049,57 @@ ROOT::Internal::RPagePersistentSink::InitFromDescriptor(const ROOT::RNTupleDescr
10491049 return model;
10501050}
10511051
1052+ void ROOT::Internal::RPagePersistentSink::AddColumnRepresentation (const ROOT ::RFieldDescriptor &field,
1053+ std::span<const ENTupleColumnType> newRepresentation)
1054+ {
1055+ R__ASSERT (field.GetColumnCardinality () > 0 );
1056+ R__ASSERT (!field.GetLogicalColumnIds ().empty ());
1057+ R__ASSERT (newRepresentation.size () == field.GetColumnCardinality ());
1058+
1059+ const auto firstPhysicalIndex = fDescriptorBuilder .GetDescriptor ().GetNPhysicalColumns ();
1060+ const auto reprIndex = field.GetLogicalColumnIds ().size () / field.GetColumnCardinality ();
1061+
1062+ fDescriptorBuilder .ShiftAliasColumns (newRepresentation.size ());
1063+
1064+ std::uint16_t columnIndex = 0 ; // index into the representation
1065+ for (auto columnType : newRepresentation) {
1066+ // Extending columns with variable bit width is currently unsupported.
1067+ const auto [rangeMin, rangeMax] = ROOT::Internal::RColumnElementBase::GetValidBitRange (columnType);
1068+ R__ASSERT (rangeMin == rangeMax);
1069+
1070+ const auto firstReprColumnId = field.GetLogicalColumnIds ()[columnIndex];
1071+ const auto &firstReprColumnRange = fOpenColumnRanges .at (firstReprColumnId);
1072+ const auto columnId = firstPhysicalIndex + columnIndex;
1073+
1074+ RColumnDescriptorBuilder columnBuilder;
1075+ columnBuilder.LogicalColumnId (columnId)
1076+ .PhysicalColumnId (columnId)
1077+ .FieldId (field.GetId ())
1078+ .BitsOnStorage (rangeMax)
1079+ .Type (columnType)
1080+ .Index (columnIndex)
1081+ // NOTE: marking this column as suppressed with the minus sign
1082+ .FirstElementIndex (-firstReprColumnRange.GetFirstElementIndex ())
1083+ .RepresentationIndex (reprIndex);
1084+ fDescriptorBuilder .AddColumn (columnBuilder.MakeDescriptor ().Unwrap ());
1085+
1086+ ROOT ::RClusterDescriptor::RColumnRange columnRange;
1087+ columnRange.SetPhysicalColumnId (columnId);
1088+ columnRange.SetFirstElementIndex (firstReprColumnRange.GetFirstElementIndex ());
1089+ columnRange.SetNElements (0 );
1090+ columnRange.SetCompressionSettings (GetWriteOptions ().GetCompression ());
1091+ fOpenColumnRanges .emplace_back (columnRange);
1092+
1093+ ROOT ::RClusterDescriptor::RPageRange pageRange;
1094+ pageRange.SetPhysicalColumnId (columnId);
1095+ fOpenPageRanges .emplace_back (std::move (pageRange));
1096+
1097+ fSerializationContext .MapPhysicalColumnId (columnId);
1098+
1099+ ++columnIndex;
1100+ }
1101+ }
1102+
10521103void ROOT::Internal::RPagePersistentSink::CommitSuppressedColumn (ColumnHandle_t columnHandle)
10531104{
10541105 fOpenColumnRanges .at (columnHandle.fPhysicalId ).SetIsSuppressed (true );
0 commit comments