36#include <unordered_map>
53 auto base =
reinterpret_cast<unsigned char *
>(buffer);
57 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
59 pos += RNTupleSerializer::SerializeUInt32(
fieldDesc.GetFieldVersion(), *
where);
60 pos += RNTupleSerializer::SerializeUInt32(
fieldDesc.GetTypeVersion(), *
where);
62 if (
auto res = RNTupleSerializer::SerializeFieldStructure(
fieldDesc.GetStructure(), *
where)) {
68 std::uint16_t flags = 0;
70 flags |= RNTupleSerializer::kFlagRepetitiveField;
72 flags |= RNTupleSerializer::kFlagProjectedField;
73 if (
fieldDesc.GetTypeChecksum().has_value())
74 flags |= RNTupleSerializer::kFlagHasTypeChecksum;
75 pos += RNTupleSerializer::SerializeUInt16(flags, *
where);
77 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetFieldName(), *
where);
78 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetTypeName(), *
where);
79 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetTypeAlias(), *
where);
80 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetFieldDescription(), *
where);
82 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
83 pos += RNTupleSerializer::SerializeUInt64(
fieldDesc.GetNRepetitions(), *
where);
85 if (flags & RNTupleSerializer::kFlagProjectedField) {
88 if (flags & RNTupleSerializer::kFlagHasTypeChecksum) {
89 pos += RNTupleSerializer::SerializeUInt32(
fieldDesc.GetTypeChecksum().value(), *
where);
92 auto size = pos - base;
93 RNTupleSerializer::SerializeFramePostscript(base,
size);
109 auto base =
reinterpret_cast<unsigned char *
>(buffer);
137 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
142 bytes += res.Unwrap();
151 ENTupleStructure structure{ENTupleStructure::kLeaf};
154 if (
auto res = RNTupleSerializer::SerializeFieldStructure(structure,
nullptr)) {
160 return R__FAIL(
"field record frame too short");
165 if (
auto res = RNTupleSerializer::DeserializeFieldStructure(
bytes, structure)) {
166 bytes += res.Unwrap();
170 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
174 std::string typeName;
178 bytes += res.Unwrap();
183 bytes += res.Unwrap();
188 bytes += res.Unwrap();
193 bytes += res.Unwrap();
199 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
201 return R__FAIL(
"field record frame too short");
207 if (flags & RNTupleSerializer::kFlagProjectedField) {
209 return R__FAIL(
"field record frame too short");
215 if (flags & RNTupleSerializer::kFlagHasTypeChecksum) {
217 return R__FAIL(
"field record frame too short");
232 auto base =
reinterpret_cast<unsigned char *
>(buffer);
236 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
238 if (
auto res = RNTupleSerializer::SerializeColumnType(
columnDesc.GetType(), *
where)) {
243 pos += RNTupleSerializer::SerializeUInt16(
columnDesc.GetBitsOnStorage(), *
where);
245 std::uint16_t flags = 0;
247 flags |= RNTupleSerializer::kFlagDeferredColumn;
249 flags |= RNTupleSerializer::kFlagHasValueRange;
253 pos += RNTupleSerializer::SerializeUInt16(flags, *
where);
254 pos += RNTupleSerializer::SerializeUInt16(
columnDesc.GetRepresentationIndex(), *
where);
255 if (flags & RNTupleSerializer::kFlagDeferredColumn)
257 if (flags & RNTupleSerializer::kFlagHasValueRange) {
258 auto [min, max] = *
columnDesc.GetValueRange();
260 static_assert(
sizeof(min) ==
sizeof(
intMin) &&
sizeof(max) ==
sizeof(
intMax));
263 pos += RNTupleSerializer::SerializeUInt64(
intMin, *
where);
264 pos += RNTupleSerializer::SerializeUInt64(
intMax, *
where);
267 if (
auto res = RNTupleSerializer::SerializeFramePostscript(buffer ? base : nullptr, pos - base)) {
277 std::span<const ROOT::DescriptorId_t>
fieldList,
281 auto base =
reinterpret_cast<unsigned char *
>(buffer);
294 for (
const auto &
c : desc.GetColumnIterable(
parentId)) {
295 if (
c.IsAliasColumn() || (
xHeader &&
xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
314 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
319 bytes += res.Unwrap();
331 if (
fnFrameSizeLeft() < RNTupleSerializer::SerializeColumnType(
type,
nullptr).Unwrap() +
sizeof(std::uint16_t) +
332 2 *
sizeof(std::uint32_t)) {
333 return R__FAIL(
"column record frame too short");
335 if (
auto res = RNTupleSerializer::DeserializeColumnType(
bytes,
type)) {
336 bytes += res.Unwrap();
342 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
344 if (flags & RNTupleSerializer::kFlagDeferredColumn) {
346 return R__FAIL(
"column record frame too short");
349 if (flags & RNTupleSerializer::kFlagHasValueRange) {
351 return R__FAIL(
"field record frame too short");
371 auto base =
reinterpret_cast<unsigned char *
>(buffer);
375 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
377 if (
auto res = RNTupleSerializer::SerializeExtraTypeInfoId(desc.
GetContentId(), *
where)) {
386 auto size = pos - base;
387 RNTupleSerializer::SerializeFramePostscript(base,
size);
394 auto base =
reinterpret_cast<unsigned char *
>(buffer);
414 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
423 EExtraTypeInfoIds
contentId{EExtraTypeInfoIds::kInvalid};
426 return R__FAIL(
"extra type info record frame too short");
434 std::string typeName;
453 RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), buffer);
454 RNTupleSerializer::SerializeUInt64(
locator.GetPosition<std::uint64_t>(), buffer +
sizeof(std::uint64_t));
456 return sizeof(std::uint64_t) +
sizeof(std::uint64_t);
462 std::uint64_t position;
464 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), position);
473 ?
sizeof(std::uint64_t)
474 :
sizeof(std::uint32_t);
477 RNTupleSerializer::SerializeUInt32(
locator.GetNBytesOnStorage(), buffer);
479 RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), buffer);
489 std::uint64_t location;
494 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint32_t), location);
499 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), location);
512 auto base =
reinterpret_cast<unsigned char *
>(buffer);
516 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
521 pos += RNTupleSerializer::SerializeFramePostscript(buffer ? base : nullptr, pos - base).Unwrap();
527 std::span<const ROOT::DescriptorId_t>
fieldList,
531 auto base =
reinterpret_cast<unsigned char *
>(buffer);
541 for (
const auto &
c : desc.GetColumnIterable(
parentId)) {
542 if (!
c.IsAliasColumn() || (
xHeader &&
xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
555 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
565 return R__FAIL(
"alias column record frame too short");
577 std::uint64_t &
xxhash3,
void *buffer)
579 if (buffer !=
nullptr) {
592 return R__FAIL(
"XxHash-3 checksum mismatch");
604 if (buffer !=
nullptr) {
605 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
606 bytes[0] = (val & 0x00FF);
607 bytes[1] = (val & 0xFF00) >> 8;
614 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
615 val = std::int16_t(
bytes[0]) + (std::int16_t(
bytes[1]) << 8);
621 return SerializeInt16(val, buffer);
626 return DeserializeInt16(buffer, *
reinterpret_cast<std::int16_t *
>(&val));
631 if (buffer !=
nullptr) {
632 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
633 bytes[0] = (val & 0x000000FF);
634 bytes[1] = (val & 0x0000FF00) >> 8;
635 bytes[2] = (val & 0x00FF0000) >> 16;
636 bytes[3] = (val & 0xFF000000) >> 24;
643 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
644 val = std::int32_t(
bytes[0]) + (std::int32_t(
bytes[1]) << 8) + (std::int32_t(
bytes[2]) << 16) +
645 (std::int32_t(
bytes[3]) << 24);
651 return SerializeInt32(val, buffer);
656 return DeserializeInt32(buffer, *
reinterpret_cast<std::int32_t *
>(&val));
661 if (buffer !=
nullptr) {
662 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
663 bytes[0] = (val & 0x00000000000000FF);
664 bytes[1] = (val & 0x000000000000FF00) >> 8;
665 bytes[2] = (val & 0x0000000000FF0000) >> 16;
666 bytes[3] = (val & 0x00000000FF000000) >> 24;
667 bytes[4] = (val & 0x000000FF00000000) >> 32;
668 bytes[5] = (val & 0x0000FF0000000000) >> 40;
669 bytes[6] = (val & 0x00FF000000000000) >> 48;
670 bytes[7] = (val & 0xFF00000000000000) >> 56;
677 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
678 val = std::int64_t(
bytes[0]) + (std::int64_t(
bytes[1]) << 8) + (std::int64_t(
bytes[2]) << 16) +
679 (std::int64_t(
bytes[3]) << 24) + (std::int64_t(
bytes[4]) << 32) + (std::int64_t(
bytes[5]) << 40) +
680 (std::int64_t(
bytes[6]) << 48) + (std::int64_t(
bytes[7]) << 56);
686 return SerializeInt64(val, buffer);
691 return DeserializeInt64(buffer, *
reinterpret_cast<std::int64_t *
>(&val));
697 auto pos =
reinterpret_cast<unsigned char *
>(buffer);
698 pos += SerializeUInt32(val.length(), pos);
699 memcpy(pos, val.data(), val.length());
701 return sizeof(std::uint32_t) + val.length();
707 if (
bufSize <
sizeof(std::uint32_t))
708 return R__FAIL(
"string buffer too short");
709 bufSize -=
sizeof(std::uint32_t);
711 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
716 return R__FAIL(
"string buffer too short");
720 return sizeof(std::uint32_t) +
length;
758 return SerializeUInt16(0x99, buffer);
759 return R__FAIL(
"unexpected column type");
820 return SerializeUInt16(0x99, buffer);
821 return R__FAIL(
"unexpected field structure type");
848 default:
return R__FAIL(
"unexpected extra type info id");
868 auto base =
reinterpret_cast<unsigned char *
>(buffer);
870 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
881 if (
size <
sizeof(std::uint64_t))
882 return R__FAIL(
"envelope size too small");
883 if (
size >=
static_cast<uint64_t
>(1) << 48)
884 return R__FAIL(
"envelope size too big");
905 const std::uint64_t
minEnvelopeSize =
sizeof(std::uint64_t) +
sizeof(std::uint64_t);
907 return R__FAIL(
"invalid envelope buffer, too short");
909 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
917 return R__FAIL(
"envelope type mismatch: expected " + std::to_string(
expectedType) +
", found " +
923 return R__FAIL(
"envelope buffer size too small");
925 return R__FAIL(
"invalid envelope, too short");
945 return SerializeInt64(1, buffer);
950 auto base =
reinterpret_cast<unsigned char *
>(buffer);
952 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
955 pos += SerializeInt64(-1, *
where);
965 return R__FAIL(
"frame too short: " + std::to_string(
size));
968 DeserializeInt64(frame, marker);
970 return R__FAIL(
"frame too short: " + std::to_string(
size));
971 SerializeInt64(marker *
static_cast<int64_t
>(
size), frame);
980 std::uint64_t
minSize =
sizeof(std::int64_t);
982 return R__FAIL(
"frame too short");
984 std::int64_t *
ssize =
reinterpret_cast<std::int64_t *
>(&
frameSize);
985 DeserializeInt64(buffer, *
ssize);
987 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
995 minSize +=
sizeof(std::uint32_t);
997 return R__FAIL(
"frame too short");
1003 return R__FAIL(
"corrupt frame size");
1005 return R__FAIL(
"frame too short");
1007 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1022 return SerializeUInt64(0, buffer);
1025 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
1027 for (
unsigned i = 0; i < flags.size(); ++i) {
1028 if (flags[i] & 0x8000000000000000)
1029 return R__FAIL(
"feature flag out of bounds");
1032 if (i == (flags.size() - 1))
1033 SerializeUInt64(flags[i],
bytes);
1035 bytes += SerializeUInt64(flags[i] | 0x8000000000000000,
bytes);
1038 return (flags.size() *
sizeof(std::int64_t));
1043 std::vector<std::uint64_t> &flags)
1045 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1050 if (
bufSize <
sizeof(std::uint64_t))
1051 return R__FAIL(
"feature flag buffer too short");
1053 bufSize -=
sizeof(std::uint64_t);
1054 flags.emplace_back(
f & ~0x8000000000000000);
1055 }
while (
f & 0x8000000000000000);
1057 return (flags.size() *
sizeof(std::uint64_t));
1064 return R__FAIL(
"locator is not serializable");
1066 std::uint32_t
size = 0;
1068 (
locator.GetNBytesOnStorage() <= std::numeric_limits<std::int32_t>::max())) {
1069 size += SerializeUInt32(
locator.GetNBytesOnStorage(), buffer);
1070 size += SerializeUInt64(
locator.GetPosition<std::uint64_t>(),
1071 buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1076 auto payloadp = buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
sizeof(std::int32_t) :
nullptr;
1092 return R__FAIL(
"locator has unknown type");
1095 std::int32_t head =
sizeof(std::int32_t) +
size;
1096 head |=
locator.GetReserved() << 16;
1097 head |=
static_cast<int>(
locatorType & 0x7F) << 24;
1107 if (
bufSize <
sizeof(std::int32_t))
1108 return R__FAIL(
"too short locator");
1110 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1114 bufSize -=
sizeof(std::int32_t);
1117 const int type = head >> 24;
1118 const std::uint32_t
payloadSize = (
static_cast<std::uint32_t
>(head) & 0x0000FFFF) -
sizeof(std::int32_t);
1120 return R__FAIL(
"too short locator");
1122 locator.SetReserved(
static_cast<std::uint32_t
>(head >> 16) & 0xFF);
1136 if (
bufSize <
sizeof(std::uint64_t))
1137 return R__FAIL(
"too short locator");
1141 locator.SetNBytesOnStorage(head);
1145 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1153 SerializeLocator(
envelopeLink.fLocator, buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1155 size += res.Unwrap();
1165 if (
bufSize <
sizeof(std::int64_t))
1166 return R__FAIL(
"too short envelope link");
1168 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1170 bufSize -=
sizeof(std::uint64_t);
1172 bytes += res.Unwrap();
1176 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1182 if (
clusterSummary.fNEntries >= (
static_cast<std::uint64_t
>(1) << 56)) {
1183 return R__FAIL(
"number of entries in cluster exceeds maximum of 2^56");
1186 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1188 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1191 pos += SerializeRecordFramePreamble(*
where);
1197 auto size = pos - frame;
1198 if (
auto res = SerializeFramePostscript(frame,
size)) {
1199 pos += res.Unwrap();
1210 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1214 bytes += res.Unwrap();
1221 return R__FAIL(
"too short cluster summary");
1231 return R__FAIL(
"sharded cluster flag set in cluster summary; sharded clusters are currently unsupported.");
1243 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1245 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1248 pos += SerializeRecordFramePreamble(*
where);
1252 if (
auto res = SerializeEnvelopeLink(
clusterGroup.fPageListEnvelopeLink, *
where)) {
1253 pos += res.Unwrap();
1257 auto size = pos - frame;
1258 if (
auto res = SerializeFramePostscript(frame,
size)) {
1269 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1274 bytes += res.Unwrap();
1280 if (
fnFrameSizeLeft() <
sizeof(std::uint32_t) + 2 *
sizeof(std::uint64_t))
1281 return R__FAIL(
"too short cluster group");
1287 bytes += res.Unwrap();
1315 std::vector<ROOT::DescriptorId_t>
fieldTrees;
1324 if (!
c.IsAliasColumn()) {
1325 MapPhysicalColumnId(
c.GetPhysicalId());
1336 MapPhysicalColumnId(
columnDesc.GetPhysicalId());
1346 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1348 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1352 std::vector<std::reference_wrapper<const ROOT::RColumnDescriptor>>
extraColumns;
1372 (
xHeader->GetNLogicalColumns() -
xHeader->GetNPhysicalColumns());
1387 pos += res.Unwrap();
1391 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1392 pos += res.Unwrap();
1400 pos += res.Unwrap();
1405 if (!
c.get().IsAliasColumn()) {
1407 pos += res.Unwrap();
1413 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1414 pos += res.Unwrap();
1423 if (
c.get().IsAliasColumn()) {
1427 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1428 pos += res.Unwrap();
1438 pos += res.Unwrap();
1443 pos += SerializeListFramePreamble(0, *
where);
1445 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1446 pos += res.Unwrap();
1451 return static_cast<std::uint32_t
>(pos - base);
1458 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1468 bytes += res.Unwrap();
1474 for (
unsigned i = 0; i <
nFields; ++i) {
1478 bytes += res.Unwrap();
1515 bytes += res.Unwrap();
1520 if (
descBuilder.GetDescriptor().GetNLogicalColumns() >
descBuilder.GetDescriptor().GetNPhysicalColumns())
1524 for (
unsigned i = 0; i <
nColumns; ++i) {
1528 bytes += res.Unwrap();
1548 bytes += res.Unwrap();
1557 bytes += res.Unwrap();
1583 bytes += res.Unwrap();
1590 bytes += res.Unwrap();
1602 return bytes - base;
1610 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1612 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1614 pos += SerializeEnvelopePreamble(kEnvelopeTypeHeader, *
where);
1617 pos += res.Unwrap();
1627 if (
auto res = SerializeSchemaDescription(*
where, desc, context)) {
1628 pos += res.Unwrap();
1633 std::uint64_t
size = pos - base;
1635 if (
auto res = SerializeEnvelopePostscript(base,
size,
xxhash3)) {
1636 size += res.Unwrap();
1651 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1653 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1655 pos += SerializeEnvelopePreamble(kEnvelopeTypePageList, *
where);
1666 if (
auto res = SerializeClusterSummary(
summary, *
where)) {
1667 pos += res.Unwrap();
1673 pos += res.Unwrap();
1698 pos += SerializeListFramePreamble(0, *
where);
1699 pos += SerializeInt64(kSuppressedColumnMarker, *
where);
1702 pos += SerializeListFramePreamble(
pageRange.GetPageInfos().size(), *
where);
1704 for (
const auto &pi :
pageRange.GetPageInfos()) {
1706 pi.HasChecksum() ? -
static_cast<std::int32_t
>(pi.GetNElements()) : pi.GetNElements();
1708 if (
auto res = SerializeLocator(pi.GetLocator(), *
where)) {
1709 pos += res.Unwrap();
1715 pos += SerializeUInt32(
columnRange.GetCompressionSettings().value(), *
where);
1719 pos += res.Unwrap();
1725 pos += res.Unwrap();
1732 pos += res.Unwrap();
1736 std::uint64_t
size = pos - base;
1737 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1738 size += res.Unwrap();
1749 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1751 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1753 pos += SerializeEnvelopePreamble(kEnvelopeTypeFooter, *
where);
1756 if (
auto res = SerializeFeatureFlags(std::vector<std::uint64_t>(), *
where)) {
1757 pos += res.Unwrap();
1765 pos += SerializeRecordFramePreamble(*
where);
1766 if (
auto res = SerializeSchemaDescription(*
where, desc, context,
true)) {
1767 pos += res.Unwrap();
1771 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1772 pos += res.Unwrap();
1790 pos += res.Unwrap();
1795 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1796 pos += res.Unwrap();
1801 std::uint32_t
size = pos - base;
1802 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1803 size += res.Unwrap();
1813 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1819 bytes += res.Unwrap();
1827 bytes += res.Unwrap();
1831 for (std::size_t i = 0; i <
featureFlags.size(); ++i) {
1834 unsigned int bit = 0;
1837 return R__FAIL(
"unsupported format feature: " + std::to_string(i * 64 +
bit));
1844 bytes += res.Unwrap();
1849 bytes += res.Unwrap();
1854 bytes += res.Unwrap();
1862 .FieldId(kZeroFieldId)
1876 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1880 bytes += res.Unwrap();
1887 bytes += res.Unwrap();
1897 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
1898 return R__FAIL(
"footer too short");
1901 return R__FAIL(
"XxHash-3 mismatch between header and footer");
1908 bytes += res.Unwrap();
1923 bytes += res.Unwrap();
1930 bytes += res.Unwrap();
1938 .PageListLocator(
clusterGroup.fPageListEnvelopeLink.fLocator)
1939 .PageListLength(
clusterGroup.fPageListEnvelopeLink.fLength)
1955 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1960 bytes += res.Unwrap();
1966 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
1967 return R__FAIL(
"page list too short");
1970 return R__FAIL(
"XxHash-3 mismatch between header and page list");
1984 bytes += res.Unwrap();
1991 bytes += res.Unwrap();
2008 bytes += res.Unwrap();
2014 return R__FAIL(
"mismatch between number of clusters and number of cluster summaries");
2016 for (std::uint32_t i = 0; i <
nClusters; ++i) {
2023 bytes += res.Unwrap();
2035 bytes += res.Unwrap();
2042 for (std::uint32_t k = 0; k <
nPages; ++k) {
2044 return R__FAIL(
"inner frame too short");
2054 bytes += res.Unwrap();
2062 return R__FAIL(
"page list frame too short");
2067 return R__FAIL(
"unexpected non-empty page list");
2071 return R__FAIL(
"page list frame too short");
2097 std::vector<ROOT::RClusterDescriptor>
clusters;
2102 case EDescriptorDeserializeMode::kForReading:
2104 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2106 builder.AddExtendedColumnRanges(desc);
2107 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2110 case EDescriptorDeserializeMode::kForWriting:
2112 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2114 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2117 case EDescriptorDeserializeMode::kRaw:
2119 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
#define R__FORWARD_ERROR(res)
Short-hand to return an RResult<T> in an error state (i.e. after checking)
#define R__FORWARD_RESULT(res)
Short-hand to return an RResult<T> value from a subroutine to the calling stack frame.
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
#define R__LOG_WARNING(...)
#define R__LOG_DEBUG(DEBUGLEVEL,...)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t nitems
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t bytes
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
The available trivial, native content types of a column.
A helper class for piece-wise construction of an RClusterDescriptor.
RClusterDescriptorBuilder & NEntries(std::uint64_t nEntries)
RClusterDescriptorBuilder & ClusterId(ROOT::DescriptorId_t clusterId)
RClusterDescriptorBuilder & FirstEntryIndex(std::uint64_t firstEntryIndex)
A helper class for piece-wise construction of an RClusterGroupDescriptor.
A helper class for piece-wise construction of an RColumnDescriptor.
A helper class for piece-wise construction of an RFieldDescriptor.
A helper class for piece-wise construction of an RNTupleDescriptor.
The serialization context is used for the piecewise serialization of a descriptor.
ROOT::DescriptorId_t GetOnDiskFieldId(ROOT::DescriptorId_t memId) const
ROOT::DescriptorId_t GetMemColumnId(ROOT::DescriptorId_t onDiskId) const
ROOT::DescriptorId_t GetMemClusterGroupId(ROOT::DescriptorId_t onDiskId) const
ROOT::DescriptorId_t GetOnDiskColumnId(ROOT::DescriptorId_t memId) const
std::uint64_t GetHeaderXxHash3() const
void MapSchema(const RNTupleDescriptor &desc, bool forHeaderExtension)
Map in-memory field and column IDs to their on-disk counterparts.
void SetHeaderSize(std::uint64_t size)
void SetHeaderXxHash3(std::uint64_t xxhash3)
ROOT::DescriptorId_t GetMemClusterId(ROOT::DescriptorId_t onDiskId) const
const std::vector< ROOT::DescriptorId_t > & GetOnDiskFieldList() const
Return a vector containing the in-memory field ID for each on-disk counterpart, in order,...
A helper class for serializing and deserialization of the RNTuple binary format.
static std::uint32_t SerializeXxHash3(const unsigned char *data, std::uint64_t length, std::uint64_t &xxhash3, void *buffer)
Writes a XxHash-3 64bit checksum of the byte range given by data and length.
static RResult< std::vector< ROOT::Internal::RClusterDescriptorBuilder > > DeserializePageListRaw(const void *buffer, std::uint64_t bufSize, ROOT::DescriptorId_t clusterGroupId, const RNTupleDescriptor &desc)
static RResult< std::uint32_t > SerializeSchemaDescription(void *buffer, const RNTupleDescriptor &desc, const RContext &context, bool forHeaderExtension=false)
Serialize the schema description in desc into buffer.
static RResult< std::uint32_t > DeserializeString(const void *buffer, std::uint64_t bufSize, std::string &val)
static RResult< std::uint32_t > SerializeEnvelopeLink(const REnvelopeLink &envelopeLink, void *buffer)
static std::uint32_t SerializeInt32(std::int32_t val, void *buffer)
static RResult< std::uint32_t > DeserializeEnvelopeLink(const void *buffer, std::uint64_t bufSize, REnvelopeLink &envelopeLink)
static std::uint32_t SerializeUInt32(std::uint32_t val, void *buffer)
static RResult< std::uint32_t > SerializeFieldStructure(ROOT::ENTupleStructure structure, void *buffer)
While we could just interpret the enums as ints, we make the translation explicit in order to avoid a...
static RResult< std::uint32_t > SerializeEnvelopePostscript(unsigned char *envelope, std::uint64_t size)
static RResult< std::uint32_t > SerializeFeatureFlags(const std::vector< std::uint64_t > &flags, void *buffer)
static std::uint32_t DeserializeUInt32(const void *buffer, std::uint32_t &val)
static RResult< std::uint32_t > DeserializeFrameHeader(const void *buffer, std::uint64_t bufSize, std::uint64_t &frameSize, std::uint32_t &nitems)
static RResult< std::uint32_t > DeserializeEnvelope(const void *buffer, std::uint64_t bufSize, std::uint16_t expectedType)
static RResult< std::uint32_t > SerializeColumnType(ROOT::ENTupleColumnType type, void *buffer)
static std::uint32_t SerializeListFramePreamble(std::uint32_t nitems, void *buffer)
static std::uint32_t SerializeInt16(std::int16_t val, void *buffer)
static RResult< std::uint32_t > SerializeFramePostscript(void *frame, std::uint64_t size)
static RResult< std::uint32_t > DeserializeClusterGroup(const void *buffer, std::uint64_t bufSize, RClusterGroup &clusterGroup)
static RResult< std::uint32_t > DeserializeLocator(const void *buffer, std::uint64_t bufSize, RNTupleLocator &locator)
static std::uint32_t SerializeUInt16(std::uint16_t val, void *buffer)
static RResult< void > DeserializePageList(const void *buffer, std::uint64_t bufSize, ROOT::DescriptorId_t clusterGroupId, RNTupleDescriptor &desc, EDescriptorDeserializeMode mode)
static RResult< void > DeserializeFooter(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RNTupleDescriptorBuilder &descBuilder)
static std::uint32_t DeserializeInt64(const void *buffer, std::int64_t &val)
static std::uint32_t SerializeEnvelopePreamble(std::uint16_t envelopeType, void *buffer)
static std::uint32_t DeserializeInt32(const void *buffer, std::int32_t &val)
static std::uint32_t SerializeString(const std::string &val, void *buffer)
std::map< Int_t, TVirtualStreamerInfo * > StreamerInfoMap_t
static RResult< std::uint32_t > SerializeExtraTypeInfoId(ROOT::EExtraTypeInfoIds id, void *buffer)
static RResult< StreamerInfoMap_t > DeserializeStreamerInfos(const std::string &extraTypeInfoContent)
static std::uint32_t DeserializeUInt16(const void *buffer, std::uint16_t &val)
static RResult< void > VerifyXxHash3(const unsigned char *data, std::uint64_t length, std::uint64_t &xxhash3)
Expects an xxhash3 checksum in the 8 bytes following data + length and verifies it.
static RResult< std::uint32_t > SerializeClusterSummary(const RClusterSummary &clusterSummary, void *buffer)
static RResult< std::uint32_t > DeserializeColumnType(const void *buffer, ROOT::ENTupleColumnType &type)
static std::uint32_t DeserializeInt16(const void *buffer, std::int16_t &val)
static RResult< std::uint32_t > DeserializeExtraTypeInfoId(const void *buffer, ROOT::EExtraTypeInfoIds &id)
static RResult< std::uint32_t > DeserializeClusterSummary(const void *buffer, std::uint64_t bufSize, RClusterSummary &clusterSummary)
EDescriptorDeserializeMode
static RResult< std::uint32_t > SerializeClusterGroup(const RClusterGroup &clusterGroup, void *buffer)
static std::uint32_t SerializeRecordFramePreamble(void *buffer)
static RResult< std::uint32_t > SerializePageList(void *buffer, const RNTupleDescriptor &desc, std::span< ROOT::DescriptorId_t > physClusterIDs, const RContext &context)
static RResult< std::uint32_t > DeserializeFieldStructure(const void *buffer, ROOT::ENTupleStructure &structure)
static std::uint32_t SerializeInt64(std::int64_t val, void *buffer)
static RResult< void > DeserializeHeader(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RNTupleDescriptorBuilder &descBuilder)
static RResult< std::uint32_t > SerializeFooter(void *buffer, const RNTupleDescriptor &desc, const RContext &context)
static std::uint32_t DeserializeUInt64(const void *buffer, std::uint64_t &val)
static RResult< std::uint32_t > SerializeLocator(const RNTupleLocator &locator, void *buffer)
static RResult< std::uint32_t > DeserializeSchemaDescription(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RNTupleDescriptorBuilder &descBuilder)
static std::uint32_t SerializeUInt64(std::uint64_t val, void *buffer)
static RResult< std::uint32_t > DeserializeFeatureFlags(const void *buffer, std::uint64_t bufSize, std::vector< std::uint64_t > &flags)
static RResult< RContext > SerializeHeader(void *buffer, const RNTupleDescriptor &desc)
static std::string SerializeStreamerInfos(const StreamerInfoMap_t &infos)
Metadata stored for every column of an RNTuple.
Metadata stored for every field of an RNTuple.
The on-storage metadata of an RNTuple.
const RClusterGroupDescriptor & GetClusterGroupDescriptor(ROOT::DescriptorId_t clusterGroupId) const
const RColumnDescriptor & GetColumnDescriptor(ROOT::DescriptorId_t columnId) const
RFieldDescriptorIterable GetFieldIterable(const RFieldDescriptor &fieldDesc) const
const RFieldDescriptor & GetFieldDescriptor(ROOT::DescriptorId_t fieldId) const
std::size_t GetNExtraTypeInfos() const
RColumnDescriptorIterable GetColumnIterable() const
const std::string & GetName() const
std::vector< std::uint64_t > GetFeatureFlags() const
ROOT::DescriptorId_t GetFieldZeroId() const
Returns the logical parent of all top-level RNTuple data fields.
std::size_t GetNPhysicalColumns() const
const RHeaderExtension * GetHeaderExtension() const
Return header extension information; if the descriptor does not have a header extension,...
const RClusterDescriptor & GetClusterDescriptor(ROOT::DescriptorId_t clusterId) const
std::uint64_t GetOnDiskHeaderXxHash3() const
std::size_t GetNFields() const
RResult< void > AddClusterGroupDetails(ROOT::DescriptorId_t clusterGroupId, std::vector< RClusterDescriptor > &clusterDescs)
Methods to load and drop cluster group details (cluster IDs and page locations)
std::size_t GetNLogicalColumns() const
std::size_t GetNClusterGroups() const
const std::string & GetDescription() const
RNTupleLocator payload that is common for object stores using 64bit location information.
Generic information about the physical location of data.
const_iterator begin() const
const_iterator end() const
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
TObject * ReadObject(const TClass *cl) override
Read object from I/O buffer.
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
Wrapper around a TObject so it can be stored in a TList.
Describes a persistent version of a class.
constexpr ROOT::ENTupleStructure kTestFutureFieldStructure
ROOT::RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
constexpr ENTupleColumnType kTestFutureColumnType
constexpr RNTupleLocator::ELocatorType kTestLocatorType
EExtraTypeInfoIds
Used in RExtraTypeInfoDescriptor.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr DescriptorId_t kInvalidDescriptorId
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.