38#include <unordered_map>
55 auto base =
reinterpret_cast<unsigned char *
>(buffer);
59 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
61 pos += RNTupleSerializer::SerializeUInt32(
fieldDesc.GetFieldVersion(), *
where);
62 pos += RNTupleSerializer::SerializeUInt32(
fieldDesc.GetTypeVersion(), *
where);
64 if (
auto res = RNTupleSerializer::SerializeFieldStructure(
fieldDesc.GetStructure(), *
where)) {
70 std::uint16_t flags = 0;
72 flags |= RNTupleSerializer::kFlagRepetitiveField;
74 flags |= RNTupleSerializer::kFlagProjectedField;
75 if (
fieldDesc.GetTypeChecksum().has_value())
76 flags |= RNTupleSerializer::kFlagHasTypeChecksum;
78 flags |= RNTupleSerializer::kFlagIsSoACollection;
79 pos += RNTupleSerializer::SerializeUInt16(flags, *
where);
81 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetFieldName(), *
where);
82 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetTypeName(), *
where);
83 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetTypeAlias(), *
where);
84 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetFieldDescription(), *
where);
86 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
87 pos += RNTupleSerializer::SerializeUInt64(
fieldDesc.GetNRepetitions(), *
where);
89 if (flags & RNTupleSerializer::kFlagProjectedField) {
92 if (flags & RNTupleSerializer::kFlagHasTypeChecksum) {
93 pos += RNTupleSerializer::SerializeUInt32(
fieldDesc.GetTypeChecksum().value(), *
where);
96 auto size = pos - base;
97 RNTupleSerializer::SerializeFramePostscript(base,
size);
113 auto base =
reinterpret_cast<unsigned char *
>(buffer);
141 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
146 bytes += res.Unwrap();
155 ENTupleStructure structure{ENTupleStructure::kPlain};
158 if (
auto res = RNTupleSerializer::SerializeFieldStructure(structure,
nullptr)) {
164 return R__FAIL(
"field record frame too short");
169 if (
auto res = RNTupleSerializer::DeserializeFieldStructure(
bytes, structure)) {
170 bytes += res.Unwrap();
174 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
178 std::string typeName;
182 bytes += res.Unwrap();
187 bytes += res.Unwrap();
192 bytes += res.Unwrap();
197 bytes += res.Unwrap();
203 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
205 return R__FAIL(
"field record frame too short");
211 if (flags & RNTupleSerializer::kFlagProjectedField) {
213 return R__FAIL(
"field record frame too short");
219 if (flags & RNTupleSerializer::kFlagHasTypeChecksum) {
221 return R__FAIL(
"field record frame too short");
227 if (flags & RNTupleSerializer::kFlagIsSoACollection) {
240 auto base =
reinterpret_cast<unsigned char *
>(buffer);
244 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
246 if (
auto res = RNTupleSerializer::SerializeColumnType(
columnDesc.GetType(), *
where)) {
251 pos += RNTupleSerializer::SerializeUInt16(
columnDesc.GetBitsOnStorage(), *
where);
253 std::uint16_t flags = 0;
255 flags |= RNTupleSerializer::kFlagDeferredColumn;
257 flags |= RNTupleSerializer::kFlagHasValueRange;
261 pos += RNTupleSerializer::SerializeUInt16(flags, *
where);
262 pos += RNTupleSerializer::SerializeUInt16(
columnDesc.GetRepresentationIndex(), *
where);
263 if (flags & RNTupleSerializer::kFlagDeferredColumn)
265 if (flags & RNTupleSerializer::kFlagHasValueRange) {
266 auto [min, max] = *
columnDesc.GetValueRange();
268 static_assert(
sizeof(min) ==
sizeof(
intMin) &&
sizeof(max) ==
sizeof(
intMax));
271 pos += RNTupleSerializer::SerializeUInt64(
intMin, *
where);
272 pos += RNTupleSerializer::SerializeUInt64(
intMax, *
where);
275 if (
auto res = RNTupleSerializer::SerializeFramePostscript(buffer ? base : nullptr, pos - base)) {
285 std::span<const ROOT::DescriptorId_t>
fieldList,
289 auto base =
reinterpret_cast<unsigned char *
>(buffer);
302 for (
const auto &
c : desc.GetColumnIterable(
parentId)) {
303 if (
c.IsAliasColumn() || (
xHeader &&
xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
322 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
327 bytes += res.Unwrap();
339 if (
fnFrameSizeLeft() < RNTupleSerializer::SerializeColumnType(
type,
nullptr).Unwrap() +
sizeof(std::uint16_t) +
340 2 *
sizeof(std::uint32_t)) {
341 return R__FAIL(
"column record frame too short");
343 if (
auto res = RNTupleSerializer::DeserializeColumnType(
bytes,
type)) {
344 bytes += res.Unwrap();
350 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
352 if (flags & RNTupleSerializer::kFlagDeferredColumn) {
354 return R__FAIL(
"column record frame too short");
357 if (flags & RNTupleSerializer::kFlagHasValueRange) {
359 return R__FAIL(
"field record frame too short");
379 auto base =
reinterpret_cast<unsigned char *
>(buffer);
383 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
385 if (
auto res = RNTupleSerializer::SerializeExtraTypeInfoId(desc.
GetContentId(), *
where)) {
394 auto size = pos - base;
395 RNTupleSerializer::SerializeFramePostscript(base,
size);
402 auto base =
reinterpret_cast<unsigned char *
>(buffer);
422 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
431 EExtraTypeInfoIds
contentId{EExtraTypeInfoIds::kInvalid};
434 return R__FAIL(
"extra type info record frame too short");
442 std::string typeName;
461 RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), buffer);
462 RNTupleSerializer::SerializeUInt64(
locator.GetPosition<std::uint64_t>(), buffer +
sizeof(std::uint64_t));
464 return sizeof(std::uint64_t) +
sizeof(std::uint64_t);
470 std::uint64_t position;
472 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), position);
481 ?
sizeof(std::uint64_t)
482 :
sizeof(std::uint32_t);
485 RNTupleSerializer::SerializeUInt32(
locator.GetNBytesOnStorage(), buffer);
487 RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), buffer);
497 std::uint64_t location;
502 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint32_t), location);
507 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), location);
520 auto base =
reinterpret_cast<unsigned char *
>(buffer);
524 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
529 pos += RNTupleSerializer::SerializeFramePostscript(buffer ? base : nullptr, pos - base).Unwrap();
535 std::span<const ROOT::DescriptorId_t>
fieldList,
539 auto base =
reinterpret_cast<unsigned char *
>(buffer);
549 for (
const auto &
c : desc.GetColumnIterable(
parentId)) {
550 if (!
c.IsAliasColumn() || (
xHeader &&
xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
563 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
573 return R__FAIL(
"alias column record frame too short");
585 std::uint64_t &
xxhash3,
void *buffer)
587 if (buffer !=
nullptr) {
600 return R__FAIL(
"XxHash-3 checksum mismatch");
612 if (buffer !=
nullptr) {
613 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
614 bytes[0] = (val & 0x00FF);
615 bytes[1] = (val & 0xFF00) >> 8;
622 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
623 val = std::int16_t(
bytes[0]) + (std::int16_t(
bytes[1]) << 8);
629 return SerializeInt16(val, buffer);
634 return DeserializeInt16(buffer, *
reinterpret_cast<std::int16_t *
>(&val));
639 if (buffer !=
nullptr) {
640 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
641 bytes[0] = (val & 0x000000FF);
642 bytes[1] = (val & 0x0000FF00) >> 8;
643 bytes[2] = (val & 0x00FF0000) >> 16;
644 bytes[3] = (val & 0xFF000000) >> 24;
651 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
652 val = std::int32_t(
bytes[0]) + (std::int32_t(
bytes[1]) << 8) + (std::int32_t(
bytes[2]) << 16) +
653 (std::int32_t(
bytes[3]) << 24);
659 return SerializeInt32(val, buffer);
664 return DeserializeInt32(buffer, *
reinterpret_cast<std::int32_t *
>(&val));
669 if (buffer !=
nullptr) {
670 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
671 bytes[0] = (val & 0x00000000000000FF);
672 bytes[1] = (val & 0x000000000000FF00) >> 8;
673 bytes[2] = (val & 0x0000000000FF0000) >> 16;
674 bytes[3] = (val & 0x00000000FF000000) >> 24;
675 bytes[4] = (val & 0x000000FF00000000) >> 32;
676 bytes[5] = (val & 0x0000FF0000000000) >> 40;
677 bytes[6] = (val & 0x00FF000000000000) >> 48;
678 bytes[7] = (val & 0xFF00000000000000) >> 56;
685 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
686 val = std::int64_t(
bytes[0]) + (std::int64_t(
bytes[1]) << 8) + (std::int64_t(
bytes[2]) << 16) +
687 (std::int64_t(
bytes[3]) << 24) + (std::int64_t(
bytes[4]) << 32) + (std::int64_t(
bytes[5]) << 40) +
688 (std::int64_t(
bytes[6]) << 48) + (std::int64_t(
bytes[7]) << 56);
694 return SerializeInt64(val, buffer);
699 return DeserializeInt64(buffer, *
reinterpret_cast<std::int64_t *
>(&val));
705 auto pos =
reinterpret_cast<unsigned char *
>(buffer);
706 pos += SerializeUInt32(val.length(), pos);
707 memcpy(pos, val.data(), val.length());
709 return sizeof(std::uint32_t) + val.length();
715 if (
bufSize <
sizeof(std::uint32_t))
716 return R__FAIL(
"string buffer too short");
717 bufSize -=
sizeof(std::uint32_t);
719 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
724 return R__FAIL(
"string buffer too short");
728 return sizeof(std::uint32_t) +
length;
766 return SerializeUInt16(0x99, buffer);
767 return R__FAIL(
"unexpected column type");
828 return SerializeUInt16(0x99, buffer);
829 return R__FAIL(
"unexpected field structure type");
856 default:
return R__FAIL(
"unexpected extra type info id");
876 auto base =
reinterpret_cast<unsigned char *
>(buffer);
878 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
889 if (
size <
sizeof(std::uint64_t))
890 return R__FAIL(
"envelope size too small");
891 if (
size >=
static_cast<uint64_t
>(1) << 48)
892 return R__FAIL(
"envelope size too big");
913 const std::uint64_t
minEnvelopeSize =
sizeof(std::uint64_t) +
sizeof(std::uint64_t);
915 return R__FAIL(
"invalid envelope buffer, too short");
917 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
925 return R__FAIL(
"envelope type mismatch: expected " + std::to_string(
expectedType) +
", found " +
931 return R__FAIL(
"envelope buffer size too small");
933 return R__FAIL(
"invalid envelope, too short");
953 return SerializeInt64(1, buffer);
958 auto base =
reinterpret_cast<unsigned char *
>(buffer);
960 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
963 pos += SerializeInt64(-1, *
where);
973 return R__FAIL(
"frame too short: " + std::to_string(
size));
976 DeserializeInt64(frame, marker);
978 return R__FAIL(
"frame too short: " + std::to_string(
size));
979 SerializeInt64(marker *
static_cast<int64_t
>(
size), frame);
988 std::uint64_t
minSize =
sizeof(std::int64_t);
990 return R__FAIL(
"frame too short");
992 std::int64_t *
ssize =
reinterpret_cast<std::int64_t *
>(&
frameSize);
993 DeserializeInt64(buffer, *
ssize);
995 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1003 minSize +=
sizeof(std::uint32_t);
1005 return R__FAIL(
"frame too short");
1011 return R__FAIL(
"corrupt frame size");
1013 return R__FAIL(
"frame too short");
1015 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1030 return SerializeUInt64(0, buffer);
1033 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
1035 for (
unsigned i = 0; i < flags.size(); ++i) {
1036 if (flags[i] & 0x8000000000000000)
1037 return R__FAIL(
"feature flag out of bounds");
1040 if (i == (flags.size() - 1))
1041 SerializeUInt64(flags[i],
bytes);
1043 bytes += SerializeUInt64(flags[i] | 0x8000000000000000,
bytes);
1046 return (flags.size() *
sizeof(std::int64_t));
1051 std::vector<std::uint64_t> &flags)
1053 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1058 if (
bufSize <
sizeof(std::uint64_t))
1059 return R__FAIL(
"feature flag buffer too short");
1061 bufSize -=
sizeof(std::uint64_t);
1062 flags.emplace_back(
f & ~0x8000000000000000);
1063 }
while (
f & 0x8000000000000000);
1065 return (flags.size() *
sizeof(std::uint64_t));
1072 return R__FAIL(
"locator is not serializable");
1074 std::uint32_t
size = 0;
1076 (
locator.GetNBytesOnStorage() <= std::numeric_limits<std::int32_t>::max())) {
1077 size += SerializeUInt32(
locator.GetNBytesOnStorage(), buffer);
1078 size += SerializeUInt64(
locator.GetPosition<std::uint64_t>(),
1079 buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1084 auto payloadp = buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
sizeof(std::int32_t) :
nullptr;
1102 return R__FAIL(
"locator has unknown type");
1105 std::int32_t head =
sizeof(std::int32_t) +
size;
1106 head |=
locator.GetReserved() << 16;
1107 head |=
static_cast<int>(
locatorType & 0x7F) << 24;
1117 if (
bufSize <
sizeof(std::int32_t))
1118 return R__FAIL(
"too short locator");
1120 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1124 bufSize -=
sizeof(std::int32_t);
1127 const int type = head >> 24;
1128 const std::uint32_t
payloadSize = (
static_cast<std::uint32_t
>(head) & 0x0000FFFF) -
sizeof(std::int32_t);
1130 return R__FAIL(
"too short locator");
1132 locator.SetReserved(
static_cast<std::uint32_t
>(head >> 16) & 0xFF);
1146 if (
bufSize <
sizeof(std::uint64_t))
1147 return R__FAIL(
"too short locator");
1151 locator.SetNBytesOnStorage(head);
1155 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1163 SerializeLocator(
envelopeLink.fLocator, buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1165 size += res.Unwrap();
1175 if (
bufSize <
sizeof(std::int64_t))
1176 return R__FAIL(
"too short envelope link");
1178 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1180 bufSize -=
sizeof(std::uint64_t);
1182 bytes += res.Unwrap();
1186 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1192 if (
clusterSummary.fNEntries >= (
static_cast<std::uint64_t
>(1) << 56)) {
1193 return R__FAIL(
"number of entries in cluster exceeds maximum of 2^56");
1196 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1198 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1201 pos += SerializeRecordFramePreamble(*
where);
1207 auto size = pos - frame;
1208 if (
auto res = SerializeFramePostscript(frame,
size)) {
1209 pos += res.Unwrap();
1220 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1224 bytes += res.Unwrap();
1231 return R__FAIL(
"too short cluster summary");
1241 return R__FAIL(
"sharded cluster flag set in cluster summary; sharded clusters are currently unsupported.");
1253 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1255 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1258 pos += SerializeRecordFramePreamble(*
where);
1262 if (
auto res = SerializeEnvelopeLink(
clusterGroup.fPageListEnvelopeLink, *
where)) {
1263 pos += res.Unwrap();
1267 auto size = pos - frame;
1268 if (
auto res = SerializeFramePostscript(frame,
size)) {
1279 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1284 bytes += res.Unwrap();
1290 if (
fnFrameSizeLeft() <
sizeof(std::uint32_t) + 2 *
sizeof(std::uint64_t))
1291 return R__FAIL(
"too short cluster group");
1297 bytes += res.Unwrap();
1325 std::vector<ROOT::DescriptorId_t>
fieldTrees;
1334 if (!
c.IsAliasColumn()) {
1335 MapPhysicalColumnId(
c.GetPhysicalId());
1346 MapPhysicalColumnId(
columnDesc.GetPhysicalId());
1356 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1358 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1362 std::vector<std::reference_wrapper<const ROOT::RColumnDescriptor>>
extraColumns;
1382 (
xHeader->GetNLogicalColumns() -
xHeader->GetNPhysicalColumns());
1397 pos += res.Unwrap();
1401 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1402 pos += res.Unwrap();
1410 pos += res.Unwrap();
1415 if (!
c.get().IsAliasColumn()) {
1417 pos += res.Unwrap();
1423 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1424 pos += res.Unwrap();
1433 if (
c.get().IsAliasColumn()) {
1437 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1438 pos += res.Unwrap();
1448 pos += res.Unwrap();
1453 pos += SerializeListFramePreamble(0, *
where);
1455 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1456 pos += res.Unwrap();
1461 return static_cast<std::uint32_t
>(pos - base);
1468 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1478 bytes += res.Unwrap();
1484 for (
unsigned i = 0; i <
nFields; ++i) {
1488 bytes += res.Unwrap();
1525 bytes += res.Unwrap();
1530 if (
descBuilder.GetDescriptor().GetNLogicalColumns() >
descBuilder.GetDescriptor().GetNPhysicalColumns())
1534 for (
unsigned i = 0; i <
nColumns; ++i) {
1538 bytes += res.Unwrap();
1558 bytes += res.Unwrap();
1567 bytes += res.Unwrap();
1593 bytes += res.Unwrap();
1600 bytes += res.Unwrap();
1612 return bytes - base;
1620 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1622 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1624 pos += SerializeEnvelopePreamble(kEnvelopeTypeHeader, *
where);
1626 pos += res.Unwrap();
1636 if (
auto res = SerializeSchemaDescription(*
where, desc, context)) {
1637 pos += res.Unwrap();
1642 std::uint64_t
size = pos - base;
1644 if (
auto res = SerializeEnvelopePostscript(base,
size,
xxhash3)) {
1645 size += res.Unwrap();
1660 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1662 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1664 pos += SerializeEnvelopePreamble(kEnvelopeTypePageList, *
where);
1675 if (
auto res = SerializeClusterSummary(
summary, *
where)) {
1676 pos += res.Unwrap();
1682 pos += res.Unwrap();
1707 pos += SerializeListFramePreamble(0, *
where);
1708 pos += SerializeInt64(kSuppressedColumnMarker, *
where);
1711 pos += SerializeListFramePreamble(
pageRange.GetPageInfos().size(), *
where);
1713 for (
const auto &pi :
pageRange.GetPageInfos()) {
1715 pi.HasChecksum() ? -
static_cast<std::int32_t
>(pi.GetNElements()) : pi.GetNElements();
1717 if (
auto res = SerializeLocator(pi.GetLocator(), *
where)) {
1718 pos += res.Unwrap();
1724 pos += SerializeUInt32(
columnRange.GetCompressionSettings().value(), *
where);
1728 pos += res.Unwrap();
1734 pos += res.Unwrap();
1741 pos += res.Unwrap();
1745 std::uint64_t
size = pos - base;
1746 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1747 size += res.Unwrap();
1758 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1760 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1762 pos += SerializeEnvelopePreamble(kEnvelopeTypeFooter, *
where);
1767 pos += res.Unwrap();
1775 pos += SerializeRecordFramePreamble(*
where);
1776 if (
auto res = SerializeSchemaDescription(*
where, desc, context,
true)) {
1777 pos += res.Unwrap();
1781 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1782 pos += res.Unwrap();
1800 pos += res.Unwrap();
1805 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1806 pos += res.Unwrap();
1816 "back in the future (but your main data is)";
1820 if (
auto res = SerializeAttributeSet(
attrSet, *
where)) {
1821 pos += res.Unwrap();
1826 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1827 pos += res.Unwrap();
1832 std::uint32_t
size = pos - base;
1833 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1834 size += res.Unwrap();
1845 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1847 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1851 pos += SerializeUInt16(
attrDesc.GetSchemaVersionMajor(), *
where);
1852 pos += SerializeUInt16(
attrDesc.GetSchemaVersionMinor(), *
where);
1854 if (
auto res = SerializeLocator(
attrDesc.GetAnchorLocator(), *
where)) {
1855 pos += res.Unwrap();
1860 auto size = pos - frame;
1861 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr,
size)) {
1870 for (std::size_t i = 0; i <
featureFlags.size(); ++i) {
1884 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1890 bytes += res.Unwrap();
1898 bytes += res.Unwrap();
1910 bytes += res.Unwrap();
1915 bytes += res.Unwrap();
1920 bytes += res.Unwrap();
1928 .FieldId(kZeroFieldId)
1942 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1946 bytes += res.Unwrap();
1953 bytes += res.Unwrap();
1962 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
1963 return R__FAIL(
"footer too short");
1966 return R__FAIL(
"XxHash-3 mismatch between header and footer");
1973 bytes += res.Unwrap();
1989 bytes += res.Unwrap();
1996 bytes += res.Unwrap();
2004 .PageListLocator(
clusterGroup.fPageListEnvelopeLink.fLocator)
2005 .PageListLength(
clusterGroup.fPageListEnvelopeLink.fLength)
2020 bytes += res.Unwrap();
2026 "back in the future (but your main data is)";
2032 bytes += res.Unwrap();
2046 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2052 bytes += res.Unwrap();
2056 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2057 return R__FAIL(
"record frame too short");
2065 bytes += res.Unwrap();
2071 bytes += res.Unwrap();
2086 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2091 bytes += res.Unwrap();
2097 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2098 return R__FAIL(
"page list too short");
2101 return R__FAIL(
"XxHash-3 mismatch between header and page list");
2115 bytes += res.Unwrap();
2122 bytes += res.Unwrap();
2139 bytes += res.Unwrap();
2145 return R__FAIL(
"mismatch between number of clusters and number of cluster summaries");
2147 for (std::uint32_t i = 0; i <
nClusters; ++i) {
2154 bytes += res.Unwrap();
2166 bytes += res.Unwrap();
2173 for (std::uint32_t k = 0; k <
nPages; ++k) {
2175 return R__FAIL(
"inner frame too short");
2185 bytes += res.Unwrap();
2193 return R__FAIL(
"page list frame too short");
2198 return R__FAIL(
"unexpected non-empty page list");
2202 return R__FAIL(
"page list frame too short");
2228 std::vector<ROOT::RClusterDescriptor>
clusters;
2233 case EDescriptorDeserializeMode::kForReading:
2235 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2237 builder.AddExtendedColumnRanges(desc);
2238 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2241 case EDescriptorDeserializeMode::kForWriting:
2243 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2245 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2248 case EDescriptorDeserializeMode::kRaw:
2250 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,...)
static ROOT::RResult< void > CheckFeatureFlags(const std::vector< std::uint64_t > &featureFlags)
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.
Metadata stored for every Attribute Set linked to an RNTuple.
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 > SerializeAttributeSet(const Experimental::RNTupleAttrSetDescriptor &attrSetDesc, 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 > DeserializeAttributeSet(const void *buffer, std::uint64_t bufSize, Experimental::Internal::RNTupleAttrSetDescriptorBuilder &attrSetDescBld)
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 GetNAttributeSets() const
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)
ROOT::Experimental::RNTupleAttrSetDescriptorIterable GetAttrSetIterable() const
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.
void SetType(ELocatorType type)
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
std::size_t LeadingZeroes(T x)
Given an integer x, returns the number of leading 0-bits starting at the most significant bit positio...
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 RNTuple data model tree can carry different structural information about the type s...