Skip to content

Commit 1e8e53f

Browse files
committed
[ntuple] merge version to/from in extra type info
1 parent ef2b5ef commit 1e8e53f

File tree

6 files changed

+18
-36
lines changed

6 files changed

+18
-36
lines changed

tree/ntuple/v7/doc/specifications.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,13 +592,11 @@ The type information record frame has the following contents followed by a strin
592592
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
593593
+ Content Identifier +
594594
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
595-
| Type Version From |
596-
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
597-
| Type Version To |
595+
| Type Version |
598596
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
599597
```
600598

601-
The combination of type version from/to, type name, and content identifier should be unique in the list.
599+
The combination of type version, type name, and content identifier should be unique in the list.
602600
However, not every type needs to provide additional type information.
603601

604602
The following kinds of content are supported:
@@ -609,7 +607,7 @@ The following kinds of content are supported:
609607

610608
The serialized ROOT streamer info is not bound to a specific type.
611609
It is the combined streamer information from all fields serialized by the ROOT streamer.
612-
Writers set version from/to to zero and use an empty type name.
610+
Writers set the version to zero and use an empty type name.
613611
Readers should ignore the type-specific information.
614612
The format of the content is a ROOT streamed `TList` of `TStreamerInfo` objects.
615613

tree/ntuple/v7/inc/ROOT/RNTupleDescriptor.hxx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,8 @@ class RExtraTypeInfoDescriptor {
481481
private:
482482
/// Specifies the meaning of the extra information
483483
EExtraTypeInfoIds fContentId = EExtraTypeInfoIds::kInvalid;
484-
/// Extra type information restricted to a certain version range of the type
485-
std::uint32_t fTypeVersionFrom = 0;
486-
std::uint32_t fTypeVersionTo = 0;
484+
/// Type version the extra type information is bound to
485+
std::uint32_t fTypeVersion = 0;
487486
/// The type name the extra information refers to; empty for RNTuple-wide extra information
488487
std::string fTypeName;
489488
/// The content format depends on the content ID and may be binary
@@ -501,8 +500,7 @@ public:
501500
RExtraTypeInfoDescriptor Clone() const;
502501

503502
EExtraTypeInfoIds GetContentId() const { return fContentId; }
504-
std::uint32_t GetTypeVersionFrom() const { return fTypeVersionFrom; }
505-
std::uint32_t GetTypeVersionTo() const { return fTypeVersionTo; }
503+
std::uint32_t GetTypeVersion() const { return fTypeVersion; }
506504
const std::string &GetTypeName() const { return fTypeName; }
507505
const std::string &GetContent() const { return fContent; }
508506
};
@@ -1325,14 +1323,9 @@ public:
13251323
fExtraTypeInfo.fContentId = contentId;
13261324
return *this;
13271325
}
1328-
RExtraTypeInfoDescriptorBuilder &TypeVersionFrom(std::uint32_t typeVersionFrom)
1329-
{
1330-
fExtraTypeInfo.fTypeVersionFrom = typeVersionFrom;
1331-
return *this;
1332-
}
1333-
RExtraTypeInfoDescriptorBuilder &TypeVersionTo(std::uint32_t typeVersionTo)
1326+
RExtraTypeInfoDescriptorBuilder &TypeVersion(std::uint32_t typeVersion)
13341327
{
1335-
fExtraTypeInfo.fTypeVersionTo = typeVersionTo;
1328+
fExtraTypeInfo.fTypeVersion = typeVersion;
13361329
return *this;
13371330
}
13381331
RExtraTypeInfoDescriptorBuilder &TypeName(const std::string &typeName)

tree/ntuple/v7/src/RField.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,8 +2212,7 @@ ROOT::Experimental::RExtraTypeInfoDescriptor ROOT::Experimental::RUnsplitField::
22122212
{
22132213
Internal::RExtraTypeInfoDescriptorBuilder extraTypeInfoBuilder;
22142214
extraTypeInfoBuilder.ContentId(EExtraTypeInfoIds::kStreamerInfo)
2215-
.TypeVersionFrom(GetTypeVersion())
2216-
.TypeVersionTo(GetTypeVersion())
2215+
.TypeVersion(GetTypeVersion())
22172216
.TypeName(GetTypeName())
22182217
.Content(Internal::RNTupleSerializer::SerializeStreamerInfos(fStreamerInfos));
22192218
return extraTypeInfoBuilder.MoveDescriptor().Unwrap();

tree/ntuple/v7/src/RNTupleDescriptor.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,14 @@ ROOT::Experimental::RClusterDescriptor ROOT::Experimental::RClusterDescriptor::C
240240

241241
bool ROOT::Experimental::RExtraTypeInfoDescriptor::operator==(const RExtraTypeInfoDescriptor &other) const
242242
{
243-
return fContentId == other.fContentId && fTypeName == other.fTypeName &&
244-
fTypeVersionFrom == other.fTypeVersionFrom && fTypeVersionTo == other.fTypeVersionTo;
243+
return fContentId == other.fContentId && fTypeName == other.fTypeName && fTypeVersion == other.fTypeVersion;
245244
}
246245

247246
ROOT::Experimental::RExtraTypeInfoDescriptor ROOT::Experimental::RExtraTypeInfoDescriptor::Clone() const
248247
{
249248
RExtraTypeInfoDescriptor clone;
250249
clone.fContentId = fContentId;
251-
clone.fTypeVersionFrom = fTypeVersionFrom;
252-
clone.fTypeVersionTo = fTypeVersionTo;
250+
clone.fTypeVersion = fTypeVersion;
253251
clone.fTypeName = fTypeName;
254252
clone.fContent = fContent;
255253
return clone;

tree/ntuple/v7/src/RNTupleSerialize.cxx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,7 @@ std::uint32_t SerializeExtraTypeInfo(const ROOT::Experimental::RExtraTypeInfoDes
337337
pos += RNTupleSerializer::SerializeRecordFramePreamble(*where);
338338

339339
pos += RNTupleSerializer::SerializeExtraTypeInfoId(desc.GetContentId(), *where);
340-
pos += RNTupleSerializer::SerializeUInt32(desc.GetTypeVersionFrom(), *where);
341-
pos += RNTupleSerializer::SerializeUInt32(desc.GetTypeVersionTo(), *where);
340+
pos += RNTupleSerializer::SerializeUInt32(desc.GetTypeVersion(), *where);
342341
pos += RNTupleSerializer::SerializeString(desc.GetTypeName(), *where);
343342
pos += RNTupleSerializer::SerializeString(desc.GetContent(), *where);
344343

@@ -376,17 +375,15 @@ RResult<std::uint32_t> DeserializeExtraTypeInfo(const void *buffer, std::uint64_
376375
bytes += result.Unwrap();
377376

378377
EExtraTypeInfoIds contentId{EExtraTypeInfoIds::kInvalid};
379-
std::uint32_t typeVersionFrom;
380-
std::uint32_t typeVersionTo;
381-
if (fnFrameSizeLeft() < 3 * sizeof(std::uint32_t)) {
378+
std::uint32_t typeVersion;
379+
if (fnFrameSizeLeft() < 2 * sizeof(std::uint32_t)) {
382380
return R__FAIL("extra type info record frame too short");
383381
}
384382
result = RNTupleSerializer::DeserializeExtraTypeInfoId(bytes, contentId);
385383
if (!result)
386384
return R__FORWARD_ERROR(result);
387385
bytes += result.Unwrap();
388-
bytes += RNTupleSerializer::DeserializeUInt32(bytes, typeVersionFrom);
389-
bytes += RNTupleSerializer::DeserializeUInt32(bytes, typeVersionTo);
386+
bytes += RNTupleSerializer::DeserializeUInt32(bytes, typeVersion);
390387

391388
std::string typeName;
392389
std::string content;
@@ -400,8 +397,7 @@ RResult<std::uint32_t> DeserializeExtraTypeInfo(const void *buffer, std::uint64_
400397
bytes += result.Unwrap();
401398

402399
desc.ContentId(contentId)
403-
.TypeVersionFrom(typeVersionFrom)
404-
.TypeVersionTo(typeVersionTo)
400+
.TypeVersion(typeVersion)
405401
.TypeName(typeName)
406402
.Content(content);
407403

tree/ntuple/v7/test/ntuple_serialize.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,7 @@ TEST(RNTuple, SerializeHeader)
649649
EXPECT_EQ(1u, desc.GetNExtraTypeInfos());
650650
const auto &extraTypeInfoDesc = *desc.GetExtraTypeInfoIterable().begin();
651651
EXPECT_EQ(EExtraTypeInfoIds::kStreamerInfo, extraTypeInfoDesc.GetContentId());
652-
EXPECT_EQ(0u, extraTypeInfoDesc.GetTypeVersionFrom());
653-
EXPECT_EQ(0u, extraTypeInfoDesc.GetTypeVersionTo());
652+
EXPECT_EQ(0u, extraTypeInfoDesc.GetTypeVersion());
654653
EXPECT_TRUE(extraTypeInfoDesc.GetTypeName().empty());
655654
EXPECT_STREQ("xyz", extraTypeInfoDesc.GetContent().c_str());
656655
}
@@ -922,8 +921,7 @@ TEST(RNTuple, SerializeFooterXHeader)
922921
EXPECT_EQ(1u, desc.GetNExtraTypeInfos());
923922
const auto &extraTypeInfoDesc = *desc.GetExtraTypeInfoIterable().begin();
924923
EXPECT_EQ(EExtraTypeInfoIds::kStreamerInfo, extraTypeInfoDesc.GetContentId());
925-
EXPECT_EQ(0u, extraTypeInfoDesc.GetTypeVersionFrom());
926-
EXPECT_EQ(0u, extraTypeInfoDesc.GetTypeVersionTo());
924+
EXPECT_EQ(0u, extraTypeInfoDesc.GetTypeVersion());
927925
EXPECT_TRUE(extraTypeInfoDesc.GetTypeName().empty());
928926
EXPECT_STREQ("xyz", extraTypeInfoDesc.GetContent().c_str());
929927
}

0 commit comments

Comments
 (0)