37#include <unordered_map>
54 auto base =
reinterpret_cast<unsigned char *
>(buffer);
58 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
60 pos += RNTupleSerializer::SerializeUInt32(
fieldDesc.GetFieldVersion(), *
where);
61 pos += RNTupleSerializer::SerializeUInt32(
fieldDesc.GetTypeVersion(), *
where);
63 if (
auto res = RNTupleSerializer::SerializeFieldStructure(
fieldDesc.GetStructure(), *
where)) {
69 std::uint16_t flags = 0;
71 flags |= RNTupleSerializer::kFlagRepetitiveField;
73 flags |= RNTupleSerializer::kFlagProjectedField;
74 if (
fieldDesc.GetTypeChecksum().has_value())
75 flags |= RNTupleSerializer::kFlagHasTypeChecksum;
77 flags |= RNTupleSerializer::kFlagIsSoACollection;
78 pos += RNTupleSerializer::SerializeUInt16(flags, *
where);
80 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetFieldName(), *
where);
81 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetTypeName(), *
where);
82 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetTypeAlias(), *
where);
83 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetFieldDescription(), *
where);
85 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
86 pos += RNTupleSerializer::SerializeUInt64(
fieldDesc.GetNRepetitions(), *
where);
88 if (flags & RNTupleSerializer::kFlagProjectedField) {
91 if (flags & RNTupleSerializer::kFlagHasTypeChecksum) {
92 pos += RNTupleSerializer::SerializeUInt32(
fieldDesc.GetTypeChecksum().value(), *
where);
95 auto size = pos - base;
96 RNTupleSerializer::SerializeFramePostscript(base,
size);
112 auto base =
reinterpret_cast<unsigned char *
>(buffer);
140 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
145 bytes += res.Unwrap();
154 ENTupleStructure structure{ENTupleStructure::kPlain};
157 if (
auto res = RNTupleSerializer::SerializeFieldStructure(structure,
nullptr)) {
163 return R__FAIL(
"field record frame too short");
168 if (
auto res = RNTupleSerializer::DeserializeFieldStructure(
bytes, structure)) {
169 bytes += res.Unwrap();
173 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
177 std::string typeName;
181 bytes += res.Unwrap();
186 bytes += res.Unwrap();
191 bytes += res.Unwrap();
196 bytes += res.Unwrap();
202 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
204 return R__FAIL(
"field record frame too short");
210 if (flags & RNTupleSerializer::kFlagProjectedField) {
212 return R__FAIL(
"field record frame too short");
218 if (flags & RNTupleSerializer::kFlagHasTypeChecksum) {
220 return R__FAIL(
"field record frame too short");
226 if (flags & RNTupleSerializer::kFlagIsSoACollection) {
239 auto base =
reinterpret_cast<unsigned char *
>(buffer);
243 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
245 if (
auto res = RNTupleSerializer::SerializeColumnType(
columnDesc.GetType(), *
where)) {
250 pos += RNTupleSerializer::SerializeUInt16(
columnDesc.GetBitsOnStorage(), *
where);
252 std::uint16_t flags = 0;
254 flags |= RNTupleSerializer::kFlagDeferredColumn;
256 flags |= RNTupleSerializer::kFlagHasValueRange;
260 pos += RNTupleSerializer::SerializeUInt16(flags, *
where);
261 pos += RNTupleSerializer::SerializeUInt16(
columnDesc.GetRepresentationIndex(), *
where);
262 if (flags & RNTupleSerializer::kFlagDeferredColumn)
264 if (flags & RNTupleSerializer::kFlagHasValueRange) {
265 auto [min, max] = *
columnDesc.GetValueRange();
267 static_assert(
sizeof(min) ==
sizeof(
intMin) &&
sizeof(max) ==
sizeof(
intMax));
270 pos += RNTupleSerializer::SerializeUInt64(
intMin, *
where);
271 pos += RNTupleSerializer::SerializeUInt64(
intMax, *
where);
274 if (
auto res = RNTupleSerializer::SerializeFramePostscript(buffer ? base : nullptr, pos - base)) {
284 std::span<const ROOT::DescriptorId_t>
fieldList,
288 auto base =
reinterpret_cast<unsigned char *
>(buffer);
301 for (
const auto &
c : desc.GetColumnIterable(
parentId)) {
302 if (
c.IsAliasColumn() || (
xHeader &&
xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
321 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
326 bytes += res.Unwrap();
338 if (
fnFrameSizeLeft() < RNTupleSerializer::SerializeColumnType(
type,
nullptr).Unwrap() +
sizeof(std::uint16_t) +
339 2 *
sizeof(std::uint32_t)) {
340 return R__FAIL(
"column record frame too short");
342 if (
auto res = RNTupleSerializer::DeserializeColumnType(
bytes,
type)) {
343 bytes += res.Unwrap();
349 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
351 if (flags & RNTupleSerializer::kFlagDeferredColumn) {
353 return R__FAIL(
"column record frame too short");
356 if (flags & RNTupleSerializer::kFlagHasValueRange) {
358 return R__FAIL(
"field record frame too short");
378 auto base =
reinterpret_cast<unsigned char *
>(buffer);
382 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
384 if (
auto res = RNTupleSerializer::SerializeExtraTypeInfoId(desc.
GetContentId(), *
where)) {
393 auto size = pos - base;
394 RNTupleSerializer::SerializeFramePostscript(base,
size);
401 auto base =
reinterpret_cast<unsigned char *
>(buffer);
421 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
430 EExtraTypeInfoIds
contentId{EExtraTypeInfoIds::kInvalid};
433 return R__FAIL(
"extra type info record frame too short");
441 std::string typeName;
460 RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), buffer);
461 RNTupleSerializer::SerializeUInt64(
locator.GetPosition<std::uint64_t>(), buffer +
sizeof(std::uint64_t));
463 return sizeof(std::uint64_t) +
sizeof(std::uint64_t);
469 std::uint64_t position;
471 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), position);
480 ?
sizeof(std::uint64_t)
481 :
sizeof(std::uint32_t);
484 RNTupleSerializer::SerializeUInt32(
locator.GetNBytesOnStorage(), buffer);
486 RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), buffer);
496 std::uint64_t location;
501 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint32_t), location);
506 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), location);
523 if (
locator.GetNBytesOnStorage() > std::numeric_limits<std::uint32_t>::max()) {
524 pos += RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), *
where);
526 pos += RNTupleSerializer::SerializeUInt32(
locator.GetNBytesOnStorage(), *
where);
528 pos += RNTupleSerializer::SerializeUInt32(
data.GetObjectId(), *
where);
529 pos += RNTupleSerializer::SerializeUInt32(
data.GetOffset(), *
where);
537 const unsigned char *pos = buffer;
551 pos += RNTupleSerializer::DeserializeUInt32(pos,
objectId);
552 RNTupleSerializer::DeserializeUInt32(pos,
offset);
562 auto base =
reinterpret_cast<unsigned char *
>(buffer);
566 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
571 pos += RNTupleSerializer::SerializeFramePostscript(buffer ? base : nullptr, pos - base).Unwrap();
577 std::span<const ROOT::DescriptorId_t>
fieldList,
581 auto base =
reinterpret_cast<unsigned char *
>(buffer);
591 for (
const auto &
c : desc.GetColumnIterable(
parentId)) {
592 if (!
c.IsAliasColumn() || (
xHeader &&
xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
605 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
615 return R__FAIL(
"alias column record frame too short");
627 std::uint64_t &
xxhash3,
void *buffer)
629 if (buffer !=
nullptr) {
642 return R__FAIL(
"XxHash-3 checksum mismatch");
654 if (buffer !=
nullptr) {
655 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
656 bytes[0] = (val & 0x00FF);
657 bytes[1] = (val & 0xFF00) >> 8;
664 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
665 val = std::int16_t(
bytes[0]) + (std::int16_t(
bytes[1]) << 8);
671 return SerializeInt16(val, buffer);
676 return DeserializeInt16(buffer, *
reinterpret_cast<std::int16_t *
>(&val));
681 if (buffer !=
nullptr) {
682 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
683 bytes[0] = (val & 0x000000FF);
684 bytes[1] = (val & 0x0000FF00) >> 8;
685 bytes[2] = (val & 0x00FF0000) >> 16;
686 bytes[3] = (val & 0xFF000000) >> 24;
693 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
694 val = std::int32_t(
bytes[0]) + (std::int32_t(
bytes[1]) << 8) + (std::int32_t(
bytes[2]) << 16) +
695 (std::int32_t(
bytes[3]) << 24);
701 return SerializeInt32(val, buffer);
706 return DeserializeInt32(buffer, *
reinterpret_cast<std::int32_t *
>(&val));
711 if (buffer !=
nullptr) {
712 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
713 bytes[0] = (val & 0x00000000000000FF);
714 bytes[1] = (val & 0x000000000000FF00) >> 8;
715 bytes[2] = (val & 0x0000000000FF0000) >> 16;
716 bytes[3] = (val & 0x00000000FF000000) >> 24;
717 bytes[4] = (val & 0x000000FF00000000) >> 32;
718 bytes[5] = (val & 0x0000FF0000000000) >> 40;
719 bytes[6] = (val & 0x00FF000000000000) >> 48;
720 bytes[7] = (val & 0xFF00000000000000) >> 56;
727 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
728 val = std::int64_t(
bytes[0]) + (std::int64_t(
bytes[1]) << 8) + (std::int64_t(
bytes[2]) << 16) +
729 (std::int64_t(
bytes[3]) << 24) + (std::int64_t(
bytes[4]) << 32) + (std::int64_t(
bytes[5]) << 40) +
730 (std::int64_t(
bytes[6]) << 48) + (std::int64_t(
bytes[7]) << 56);
736 return SerializeInt64(val, buffer);
741 return DeserializeInt64(buffer, *
reinterpret_cast<std::int64_t *
>(&val));
747 auto pos =
reinterpret_cast<unsigned char *
>(buffer);
748 pos += SerializeUInt32(val.length(), pos);
749 memcpy(pos, val.data(), val.length());
751 return sizeof(std::uint32_t) + val.length();
757 if (
bufSize <
sizeof(std::uint32_t))
758 return R__FAIL(
"string buffer too short");
759 bufSize -=
sizeof(std::uint32_t);
761 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
766 return R__FAIL(
"string buffer too short");
770 return sizeof(std::uint32_t) +
length;
808 return SerializeUInt16(0x99, buffer);
809 return R__FAIL(
"unexpected column type");
870 return SerializeUInt16(0x99, buffer);
871 return R__FAIL(
"unexpected field structure type");
898 default:
return R__FAIL(
"unexpected extra type info id");
918 auto base =
reinterpret_cast<unsigned char *
>(buffer);
920 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
931 if (
size <
sizeof(std::uint64_t))
932 return R__FAIL(
"envelope size too small");
933 if (
size >=
static_cast<uint64_t
>(1) << 48)
934 return R__FAIL(
"envelope size too big");
955 const std::uint64_t
minEnvelopeSize =
sizeof(std::uint64_t) +
sizeof(std::uint64_t);
957 return R__FAIL(
"invalid envelope buffer, too short");
959 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
967 return R__FAIL(
"envelope type mismatch: expected " + std::to_string(
expectedType) +
", found " +
973 return R__FAIL(
"envelope buffer size too small");
975 return R__FAIL(
"invalid envelope, too short");
995 return SerializeInt64(1, buffer);
1000 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1002 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1005 pos += SerializeInt64(-1, *
where);
1015 return R__FAIL(
"frame too short: " + std::to_string(
size));
1017 std::int64_t marker;
1018 DeserializeInt64(frame, marker);
1020 return R__FAIL(
"frame too short: " + std::to_string(
size));
1021 SerializeInt64(marker *
static_cast<int64_t
>(
size), frame);
1030 std::uint64_t
minSize =
sizeof(std::int64_t);
1032 return R__FAIL(
"frame too short");
1034 std::int64_t *
ssize =
reinterpret_cast<std::int64_t *
>(&
frameSize);
1035 DeserializeInt64(buffer, *
ssize);
1037 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1045 minSize +=
sizeof(std::uint32_t);
1047 return R__FAIL(
"frame too short");
1053 return R__FAIL(
"corrupt frame size");
1055 return R__FAIL(
"frame too short");
1057 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1072 return SerializeUInt64(0, buffer);
1075 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
1077 for (
unsigned i = 0; i < flags.size(); ++i) {
1078 if (flags[i] & 0x8000000000000000)
1079 return R__FAIL(
"feature flag out of bounds");
1082 if (i == (flags.size() - 1))
1083 SerializeUInt64(flags[i],
bytes);
1085 bytes += SerializeUInt64(flags[i] | 0x8000000000000000,
bytes);
1088 return (flags.size() *
sizeof(std::int64_t));
1093 std::vector<std::uint64_t> &flags)
1095 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1100 if (
bufSize <
sizeof(std::uint64_t))
1101 return R__FAIL(
"feature flag buffer too short");
1103 bufSize -=
sizeof(std::uint64_t);
1104 flags.emplace_back(
f & ~0x8000000000000000);
1105 }
while (
f & 0x8000000000000000);
1107 return (flags.size() *
sizeof(std::uint64_t));
1114 return R__FAIL(
"locator is not serializable");
1116 std::uint32_t
size = 0;
1118 (
locator.GetNBytesOnStorage() <= std::numeric_limits<std::int32_t>::max())) {
1119 size += SerializeUInt32(
locator.GetNBytesOnStorage(), buffer);
1120 size += SerializeUInt64(
locator.GetPosition<std::uint64_t>(),
1121 buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1126 auto payloadp = buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
sizeof(std::int32_t) :
nullptr;
1148 return R__FAIL(
"locator has unknown type");
1151 std::int32_t head =
sizeof(std::int32_t) +
size;
1152 head |=
locator.GetReserved() << 16;
1153 head |=
static_cast<int>(
locatorType & 0x7F) << 24;
1163 if (
bufSize <
sizeof(std::int32_t))
1164 return R__FAIL(
"too short locator");
1166 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1170 bufSize -=
sizeof(std::int32_t);
1173 const int type = head >> 24;
1174 const std::uint32_t
payloadSize = (
static_cast<std::uint32_t
>(head) & 0x0000FFFF) -
sizeof(std::int32_t);
1176 return R__FAIL(
"too short locator");
1178 locator.SetReserved(
static_cast<std::uint32_t
>(head >> 16) & 0xFF);
1202 if (
bufSize <
sizeof(std::uint64_t))
1203 return R__FAIL(
"too short locator");
1207 locator.SetNBytesOnStorage(head);
1211 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1219 SerializeLocator(
envelopeLink.fLocator, buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1221 size += res.Unwrap();
1231 if (
bufSize <
sizeof(std::int64_t))
1232 return R__FAIL(
"too short envelope link");
1234 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1236 bufSize -=
sizeof(std::uint64_t);
1238 bytes += res.Unwrap();
1242 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1248 if (
clusterSummary.fNEntries >= (
static_cast<std::uint64_t
>(1) << 56)) {
1249 return R__FAIL(
"number of entries in cluster exceeds maximum of 2^56");
1252 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1254 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1257 pos += SerializeRecordFramePreamble(*
where);
1263 auto size = pos - frame;
1264 if (
auto res = SerializeFramePostscript(frame,
size)) {
1265 pos += res.Unwrap();
1276 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1280 bytes += res.Unwrap();
1287 return R__FAIL(
"too short cluster summary");
1297 return R__FAIL(
"sharded cluster flag set in cluster summary; sharded clusters are currently unsupported.");
1309 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1311 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1314 pos += SerializeRecordFramePreamble(*
where);
1318 if (
auto res = SerializeEnvelopeLink(
clusterGroup.fPageListEnvelopeLink, *
where)) {
1319 pos += res.Unwrap();
1323 auto size = pos - frame;
1324 if (
auto res = SerializeFramePostscript(frame,
size)) {
1335 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1340 bytes += res.Unwrap();
1346 if (
fnFrameSizeLeft() <
sizeof(std::uint32_t) + 2 *
sizeof(std::uint64_t))
1347 return R__FAIL(
"too short cluster group");
1353 bytes += res.Unwrap();
1381 std::vector<ROOT::DescriptorId_t>
fieldTrees;
1390 if (!
c.IsAliasColumn()) {
1391 MapPhysicalColumnId(
c.GetPhysicalId());
1402 MapPhysicalColumnId(
columnDesc.GetPhysicalId());
1412 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1414 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1418 std::vector<std::reference_wrapper<const ROOT::RColumnDescriptor>>
extraColumns;
1438 (
xHeader->GetNLogicalColumns() -
xHeader->GetNPhysicalColumns());
1453 pos += res.Unwrap();
1457 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1458 pos += res.Unwrap();
1466 pos += res.Unwrap();
1471 if (!
c.get().IsAliasColumn()) {
1473 pos += res.Unwrap();
1479 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1480 pos += res.Unwrap();
1489 if (
c.get().IsAliasColumn()) {
1493 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1494 pos += res.Unwrap();
1504 pos += res.Unwrap();
1509 pos += SerializeListFramePreamble(0, *
where);
1511 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1512 pos += res.Unwrap();
1517 return static_cast<std::uint32_t
>(pos - base);
1524 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1534 bytes += res.Unwrap();
1540 for (
unsigned i = 0; i <
nFields; ++i) {
1544 bytes += res.Unwrap();
1581 bytes += res.Unwrap();
1586 if (
descBuilder.GetDescriptor().GetNLogicalColumns() >
descBuilder.GetDescriptor().GetNPhysicalColumns())
1590 for (
unsigned i = 0; i <
nColumns; ++i) {
1594 bytes += res.Unwrap();
1614 bytes += res.Unwrap();
1623 bytes += res.Unwrap();
1649 bytes += res.Unwrap();
1656 bytes += res.Unwrap();
1668 return bytes - base;
1676 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1678 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1680 pos += SerializeEnvelopePreamble(kEnvelopeTypeHeader, *
where);
1682 pos += res.Unwrap();
1692 if (
auto res = SerializeSchemaDescription(*
where, desc, context)) {
1693 pos += res.Unwrap();
1698 std::uint64_t
size = pos - base;
1700 if (
auto res = SerializeEnvelopePostscript(base,
size,
xxhash3)) {
1701 size += res.Unwrap();
1716 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1718 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1720 pos += SerializeEnvelopePreamble(kEnvelopeTypePageList, *
where);
1731 if (
auto res = SerializeClusterSummary(
summary, *
where)) {
1732 pos += res.Unwrap();
1738 pos += res.Unwrap();
1763 pos += SerializeListFramePreamble(0, *
where);
1764 pos += SerializeInt64(kSuppressedColumnMarker, *
where);
1767 pos += SerializeListFramePreamble(
pageRange.GetPageInfos().size(), *
where);
1769 for (
const auto &pi :
pageRange.GetPageInfos()) {
1771 pi.HasChecksum() ? -
static_cast<std::int32_t
>(pi.GetNElements()) : pi.GetNElements();
1773 if (
auto res = SerializeLocator(pi.GetLocator(), *
where)) {
1774 pos += res.Unwrap();
1780 pos += SerializeUInt32(
columnRange.GetCompressionSettings().value(), *
where);
1784 pos += res.Unwrap();
1790 pos += res.Unwrap();
1797 pos += res.Unwrap();
1801 std::uint64_t
size = pos - base;
1802 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1803 size += res.Unwrap();
1814 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1816 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1818 pos += SerializeEnvelopePreamble(kEnvelopeTypeFooter, *
where);
1823 pos += res.Unwrap();
1831 pos += SerializeRecordFramePreamble(*
where);
1832 if (
auto res = SerializeSchemaDescription(*
where, desc, context,
true)) {
1833 pos += res.Unwrap();
1837 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1838 pos += res.Unwrap();
1856 pos += res.Unwrap();
1861 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1862 pos += res.Unwrap();
1872 "back in the future (but your main data is)";
1876 if (
auto res = SerializeAttributeSet(
attrSet, *
where)) {
1877 pos += res.Unwrap();
1882 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1883 pos += res.Unwrap();
1888 std::uint32_t
size = pos - base;
1889 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1890 size += res.Unwrap();
1901 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1903 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1907 pos += SerializeUInt16(
attrDesc.GetSchemaVersionMajor(), *
where);
1908 pos += SerializeUInt16(
attrDesc.GetSchemaVersionMinor(), *
where);
1910 if (
auto res = SerializeLocator(
attrDesc.GetAnchorLocator(), *
where)) {
1911 pos += res.Unwrap();
1916 auto size = pos - frame;
1917 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr,
size)) {
1926 for (std::size_t i = 0; i <
featureFlags.size(); ++i) {
1940 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1946 bytes += res.Unwrap();
1954 bytes += res.Unwrap();
1966 bytes += res.Unwrap();
1971 bytes += res.Unwrap();
1976 bytes += res.Unwrap();
1984 .FieldId(kZeroFieldId)
1998 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2002 bytes += res.Unwrap();
2009 bytes += res.Unwrap();
2018 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2019 return R__FAIL(
"footer too short");
2022 return R__FAIL(
"XxHash-3 mismatch between header and footer");
2029 bytes += res.Unwrap();
2045 bytes += res.Unwrap();
2052 bytes += res.Unwrap();
2060 .PageListLocator(
clusterGroup.fPageListEnvelopeLink.fLocator)
2061 .PageListLength(
clusterGroup.fPageListEnvelopeLink.fLength)
2076 bytes += res.Unwrap();
2082 "back in the future (but your main data is)";
2088 bytes += res.Unwrap();
2102 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2108 bytes += res.Unwrap();
2112 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2113 return R__FAIL(
"record frame too short");
2121 bytes += res.Unwrap();
2127 bytes += res.Unwrap();
2142 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2147 bytes += res.Unwrap();
2153 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2154 return R__FAIL(
"page list too short");
2157 return R__FAIL(
"XxHash-3 mismatch between header and page list");
2171 bytes += res.Unwrap();
2178 bytes += res.Unwrap();
2195 bytes += res.Unwrap();
2201 return R__FAIL(
"mismatch between number of clusters and number of cluster summaries");
2203 for (std::uint32_t i = 0; i <
nClusters; ++i) {
2210 bytes += res.Unwrap();
2222 bytes += res.Unwrap();
2229 for (std::uint32_t k = 0; k <
nPages; ++k) {
2231 return R__FAIL(
"inner frame too short");
2241 bytes += res.Unwrap();
2249 return R__FAIL(
"page list frame too short");
2254 return R__FAIL(
"unexpected non-empty page list");
2258 return R__FAIL(
"page list frame too short");
2284 std::vector<ROOT::RClusterDescriptor>
clusters;
2289 case EDescriptorDeserializeMode::kForReading:
2291 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2293 builder.AddExtendedColumnRanges(desc);
2294 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2297 case EDescriptorDeserializeMode::kForWriting:
2299 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2301 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2304 case EDescriptorDeserializeMode::kRaw:
2306 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 for the kTypeMulti locator (type 0x03).
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...