@@ -1096,19 +1096,21 @@ std::uint32_t
10961096ROOT::Experimental::Internal::RNTupleSerializer::SerializeClusterSummary (const RClusterSummary &clusterSummary,
10971097 void *buffer)
10981098{
1099+ if (clusterSummary.fNEntries >= (static_cast <std::uint64_t >(1 ) << 56 )) {
1100+ throw RException (R__FAIL (" number of entries in cluster exceeds maximum of 2^56" ));
1101+ }
1102+
10991103 auto base = reinterpret_cast <unsigned char *>(buffer);
11001104 auto pos = base;
11011105 void **where = (buffer == nullptr ) ? &buffer : reinterpret_cast <void **>(&pos);
11021106
11031107 auto frame = pos;
11041108 pos += SerializeRecordFramePreamble (*where);
11051109 pos += SerializeUInt64 (clusterSummary.fFirstEntry , *where);
1106- if (clusterSummary.fColumnGroupID >= 0 ) {
1107- pos += SerializeInt64 (-static_cast <int64_t >(clusterSummary.fNEntries ), *where);
1108- pos += SerializeUInt32 (clusterSummary.fColumnGroupID , *where);
1109- } else {
1110- pos += SerializeInt64 (static_cast <int64_t >(clusterSummary.fNEntries ), *where);
1111- }
1110+ const std::uint64_t nEntriesAndFlags =
1111+ (static_cast <std::uint64_t >(clusterSummary.fFlags ) << 56 ) | clusterSummary.fNEntries ;
1112+ pos += SerializeUInt64 (nEntriesAndFlags, *where);
1113+
11121114 auto size = pos - frame;
11131115 pos += SerializeFramePostscript (frame, size);
11141116 return size;
@@ -1131,21 +1133,20 @@ ROOT::Experimental::Internal::RNTupleSerializer::DeserializeClusterSummary(const
11311133 return R__FAIL (" too short cluster summary" );
11321134
11331135 bytes += DeserializeUInt64 (bytes, clusterSummary.fFirstEntry );
1134- std::int64_t nEntries ;
1135- bytes += DeserializeInt64 (bytes, nEntries );
1136+ std::uint64_t nEntriesAndFlags ;
1137+ bytes += DeserializeUInt64 (bytes, nEntriesAndFlags );
11361138
1137- if (nEntries < 0 ) {
1138- if (fnFrameSizeLeft () < sizeof (std::uint32_t ))
1139- return R__FAIL (" too short cluster summary" );
1140- clusterSummary.fNEntries = -nEntries;
1141- std::uint32_t columnGroupID;
1142- bytes += DeserializeUInt32 (bytes, columnGroupID);
1143- clusterSummary.fColumnGroupID = columnGroupID;
1144- } else {
1145- clusterSummary.fNEntries = nEntries;
1146- clusterSummary.fColumnGroupID = -1 ;
1139+ const std::uint64_t nEntries = (nEntriesAndFlags << 8 ) >> 8 ;
1140+ const std::uint8_t flags = nEntriesAndFlags >> 56 ;
1141+
1142+ if (flags & 0x01 ) {
1143+ return R__FAIL (" sharded cluster flag set in cluster summary; sharded clusters are currently unsupported." );
11471144 }
11481145
1146+ clusterSummary.fNEntries = nEntries;
1147+ clusterSummary.fFlags = flags;
1148+ clusterSummary.fColumnGroupID = -1 ;
1149+
11491150 return frameSize;
11501151}
11511152
@@ -1511,7 +1512,7 @@ ROOT::Experimental::Internal::RNTupleSerializer::SerializePageList(void *buffer,
15111512 pos += SerializeListFramePreamble (nClusters, *where);
15121513 for (auto clusterId : physClusterIDs) {
15131514 const auto &clusterDesc = desc.GetClusterDescriptor (context.GetMemClusterId (clusterId));
1514- RClusterSummary summary{clusterDesc.GetFirstEntryIndex (), clusterDesc.GetNEntries (), -1 };
1515+ RClusterSummary summary{clusterDesc.GetFirstEntryIndex (), clusterDesc.GetNEntries (), 0 , -1 };
15151516 pos += SerializeClusterSummary (summary, *where);
15161517 }
15171518 pos += SerializeFramePostscript (buffer ? clusterSummaryFrame : nullptr , pos - clusterSummaryFrame);
0 commit comments