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);
302 for (
const auto &
c : desc.GetColumnIterable(
parentId)) {
303 if (
c.IsAliasColumn() || (
xHeader &&
xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
313 return context.GetOnDiskColumnId(a->GetPhysicalId()) < context.GetOnDiskColumnId(b->GetPhysicalId());
332 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
337 bytes += res.Unwrap();
349 if (
fnFrameSizeLeft() < RNTupleSerializer::SerializeColumnType(
type,
nullptr).Unwrap() +
sizeof(std::uint16_t) +
350 2 *
sizeof(std::uint32_t)) {
351 return R__FAIL(
"column record frame too short");
353 if (
auto res = RNTupleSerializer::DeserializeColumnType(
bytes,
type)) {
354 bytes += res.Unwrap();
360 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
362 if (flags & RNTupleSerializer::kFlagDeferredColumn) {
364 return R__FAIL(
"column record frame too short");
367 if (flags & RNTupleSerializer::kFlagHasValueRange) {
369 return R__FAIL(
"field record frame too short");
389 auto base =
reinterpret_cast<unsigned char *
>(buffer);
393 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
395 if (
auto res = RNTupleSerializer::SerializeExtraTypeInfoId(desc.
GetContentId(), *
where)) {
404 auto size = pos - base;
405 RNTupleSerializer::SerializeFramePostscript(base,
size);
412 auto base =
reinterpret_cast<unsigned char *
>(buffer);
432 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
441 EExtraTypeInfoIds
contentId{EExtraTypeInfoIds::kInvalid};
444 return R__FAIL(
"extra type info record frame too short");
452 std::string typeName;
471 RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), buffer);
472 RNTupleSerializer::SerializeUInt64(
locator.GetPosition<std::uint64_t>(), buffer +
sizeof(std::uint64_t));
474 return sizeof(std::uint64_t) +
sizeof(std::uint64_t);
480 std::uint64_t position;
482 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), position);
491 ?
sizeof(std::uint64_t)
492 :
sizeof(std::uint32_t);
495 RNTupleSerializer::SerializeUInt32(
locator.GetNBytesOnStorage(), buffer);
497 RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), buffer);
507 std::uint64_t location;
512 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint32_t), location);
517 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), location);
534 if (
locator.GetNBytesOnStorage() > std::numeric_limits<std::uint32_t>::max()) {
535 pos += RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), *
where);
537 pos += RNTupleSerializer::SerializeUInt32(
locator.GetNBytesOnStorage(), *
where);
539 pos += RNTupleSerializer::SerializeUInt32(
data.GetObjectId(), *
where);
540 pos += RNTupleSerializer::SerializeUInt32(
data.GetOffset(), *
where);
548 const unsigned char *pos = buffer;
562 pos += RNTupleSerializer::DeserializeUInt32(pos,
objectId);
563 RNTupleSerializer::DeserializeUInt32(pos,
offset);
573 auto base =
reinterpret_cast<unsigned char *
>(buffer);
577 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
582 pos += RNTupleSerializer::SerializeFramePostscript(buffer ? base : nullptr, pos - base).Unwrap();
588 std::span<const ROOT::DescriptorId_t>
fieldList,
592 auto base =
reinterpret_cast<unsigned char *
>(buffer);
602 for (
const auto &
c : desc.GetColumnIterable(
parentId)) {
603 if (!
c.IsAliasColumn() || (
xHeader &&
xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
616 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
626 return R__FAIL(
"alias column record frame too short");
638 std::uint64_t &
xxhash3,
void *buffer)
640 if (buffer !=
nullptr) {
653 return R__FAIL(
"XxHash-3 checksum mismatch");
665 if (buffer !=
nullptr) {
666 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
667 bytes[0] = (val & 0x00FF);
668 bytes[1] = (val & 0xFF00) >> 8;
675 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
676 val = std::int16_t(
bytes[0]) + (std::int16_t(
bytes[1]) << 8);
682 return SerializeInt16(val, buffer);
687 return DeserializeInt16(buffer, *
reinterpret_cast<std::int16_t *
>(&val));
692 if (buffer !=
nullptr) {
693 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
694 bytes[0] = (val & 0x000000FF);
695 bytes[1] = (val & 0x0000FF00) >> 8;
696 bytes[2] = (val & 0x00FF0000) >> 16;
697 bytes[3] = (val & 0xFF000000) >> 24;
704 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
705 val = std::int32_t(
bytes[0]) + (std::int32_t(
bytes[1]) << 8) + (std::int32_t(
bytes[2]) << 16) +
706 (std::int32_t(
bytes[3]) << 24);
712 return SerializeInt32(val, buffer);
717 return DeserializeInt32(buffer, *
reinterpret_cast<std::int32_t *
>(&val));
722 if (buffer !=
nullptr) {
723 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
724 bytes[0] = (val & 0x00000000000000FF);
725 bytes[1] = (val & 0x000000000000FF00) >> 8;
726 bytes[2] = (val & 0x0000000000FF0000) >> 16;
727 bytes[3] = (val & 0x00000000FF000000) >> 24;
728 bytes[4] = (val & 0x000000FF00000000) >> 32;
729 bytes[5] = (val & 0x0000FF0000000000) >> 40;
730 bytes[6] = (val & 0x00FF000000000000) >> 48;
731 bytes[7] = (val & 0xFF00000000000000) >> 56;
738 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
739 val = std::int64_t(
bytes[0]) + (std::int64_t(
bytes[1]) << 8) + (std::int64_t(
bytes[2]) << 16) +
740 (std::int64_t(
bytes[3]) << 24) + (std::int64_t(
bytes[4]) << 32) + (std::int64_t(
bytes[5]) << 40) +
741 (std::int64_t(
bytes[6]) << 48) + (std::int64_t(
bytes[7]) << 56);
747 return SerializeInt64(val, buffer);
752 return DeserializeInt64(buffer, *
reinterpret_cast<std::int64_t *
>(&val));
758 auto pos =
reinterpret_cast<unsigned char *
>(buffer);
759 pos += SerializeUInt32(val.length(), pos);
760 memcpy(pos, val.data(), val.length());
762 return sizeof(std::uint32_t) + val.length();
768 if (
bufSize <
sizeof(std::uint32_t))
769 return R__FAIL(
"string buffer too short");
770 bufSize -=
sizeof(std::uint32_t);
772 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
777 return R__FAIL(
"string buffer too short");
781 return sizeof(std::uint32_t) +
length;
819 return SerializeUInt16(0x99, buffer);
820 return R__FAIL(
"unexpected column type");
881 return SerializeUInt16(0x99, buffer);
882 return R__FAIL(
"unexpected field structure type");
909 default:
return R__FAIL(
"unexpected extra type info id");
929 auto base =
reinterpret_cast<unsigned char *
>(buffer);
931 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
942 if (
size <
sizeof(std::uint64_t))
943 return R__FAIL(
"envelope size too small");
944 if (
size >=
static_cast<uint64_t
>(1) << 48)
945 return R__FAIL(
"envelope size too big");
966 const std::uint64_t
minEnvelopeSize =
sizeof(std::uint64_t) +
sizeof(std::uint64_t);
968 return R__FAIL(
"invalid envelope buffer, too short");
970 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
978 return R__FAIL(
"envelope type mismatch: expected " + std::to_string(
expectedType) +
", found " +
984 return R__FAIL(
"envelope buffer size too small");
986 return R__FAIL(
"invalid envelope, too short");
1006 return SerializeInt64(1, buffer);
1011 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1013 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1016 pos += SerializeInt64(-1, *
where);
1026 return R__FAIL(
"frame too short: " + std::to_string(
size));
1028 std::int64_t marker;
1029 DeserializeInt64(frame, marker);
1031 return R__FAIL(
"frame too short: " + std::to_string(
size));
1032 SerializeInt64(marker *
static_cast<int64_t
>(
size), frame);
1041 std::uint64_t
minSize =
sizeof(std::int64_t);
1043 return R__FAIL(
"frame too short");
1045 std::int64_t *
ssize =
reinterpret_cast<std::int64_t *
>(&
frameSize);
1046 DeserializeInt64(buffer, *
ssize);
1048 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1056 minSize +=
sizeof(std::uint32_t);
1058 return R__FAIL(
"frame too short");
1064 return R__FAIL(
"corrupt frame size");
1066 return R__FAIL(
"frame too short");
1068 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1083 return SerializeUInt64(0, buffer);
1086 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
1088 for (
unsigned i = 0; i < flags.size(); ++i) {
1089 if (flags[i] & 0x8000000000000000)
1090 return R__FAIL(
"feature flag out of bounds");
1093 if (i == (flags.size() - 1))
1094 SerializeUInt64(flags[i],
bytes);
1096 bytes += SerializeUInt64(flags[i] | 0x8000000000000000,
bytes);
1099 return (flags.size() *
sizeof(std::int64_t));
1104 std::vector<std::uint64_t> &flags)
1106 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1111 if (
bufSize <
sizeof(std::uint64_t))
1112 return R__FAIL(
"feature flag buffer too short");
1114 bufSize -=
sizeof(std::uint64_t);
1115 flags.emplace_back(
f & ~0x8000000000000000);
1116 }
while (
f & 0x8000000000000000);
1118 return (flags.size() *
sizeof(std::uint64_t));
1125 return R__FAIL(
"locator is not serializable");
1127 std::uint32_t
size = 0;
1129 (
locator.GetNBytesOnStorage() <= std::numeric_limits<std::int32_t>::max())) {
1130 size += SerializeUInt32(
locator.GetNBytesOnStorage(), buffer);
1131 size += SerializeUInt64(
locator.GetPosition<std::uint64_t>(),
1132 buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1137 auto payloadp = buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
sizeof(std::int32_t) :
nullptr;
1159 return R__FAIL(
"locator has unknown type");
1162 std::int32_t head =
sizeof(std::int32_t) +
size;
1163 head |=
locator.GetReserved() << 16;
1164 head |=
static_cast<int>(
locatorType & 0x7F) << 24;
1174 if (
bufSize <
sizeof(std::int32_t))
1175 return R__FAIL(
"too short locator");
1177 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1181 bufSize -=
sizeof(std::int32_t);
1184 const int type = head >> 24;
1185 const std::uint32_t
payloadSize = (
static_cast<std::uint32_t
>(head) & 0x0000FFFF) -
sizeof(std::int32_t);
1187 return R__FAIL(
"too short locator");
1189 locator.SetReserved(
static_cast<std::uint32_t
>(head >> 16) & 0xFF);
1213 if (
bufSize <
sizeof(std::uint64_t))
1214 return R__FAIL(
"too short locator");
1218 locator.SetNBytesOnStorage(head);
1222 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1230 SerializeLocator(
envelopeLink.fLocator, buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1232 size += res.Unwrap();
1242 if (
bufSize <
sizeof(std::int64_t))
1243 return R__FAIL(
"too short envelope link");
1245 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1247 bufSize -=
sizeof(std::uint64_t);
1249 bytes += res.Unwrap();
1253 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1259 if (
clusterSummary.fNEntries >= (
static_cast<std::uint64_t
>(1) << 56)) {
1260 return R__FAIL(
"number of entries in cluster exceeds maximum of 2^56");
1263 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1265 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1268 pos += SerializeRecordFramePreamble(*
where);
1274 auto size = pos - frame;
1275 if (
auto res = SerializeFramePostscript(frame,
size)) {
1276 pos += res.Unwrap();
1287 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1291 bytes += res.Unwrap();
1298 return R__FAIL(
"too short cluster summary");
1308 return R__FAIL(
"sharded cluster flag set in cluster summary; sharded clusters are currently unsupported.");
1320 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1322 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1325 pos += SerializeRecordFramePreamble(*
where);
1329 if (
auto res = SerializeEnvelopeLink(
clusterGroup.fPageListEnvelopeLink, *
where)) {
1330 pos += res.Unwrap();
1334 auto size = pos - frame;
1335 if (
auto res = SerializeFramePostscript(frame,
size)) {
1346 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1351 bytes += res.Unwrap();
1357 if (
fnFrameSizeLeft() <
sizeof(std::uint32_t) + 2 *
sizeof(std::uint64_t))
1358 return R__FAIL(
"too short cluster group");
1364 bytes += res.Unwrap();
1392 std::vector<ROOT::DescriptorId_t>
fieldTrees;
1401 if (!
c.IsAliasColumn()) {
1402 MapPhysicalColumnId(
c.GetPhysicalId());
1413 MapPhysicalColumnId(
columnDesc.GetPhysicalId());
1423 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1425 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1429 std::vector<std::reference_wrapper<const ROOT::RColumnDescriptor>>
extraColumns;
1449 (
xHeader->GetNLogicalColumns() -
xHeader->GetNPhysicalColumns());
1464 pos += res.Unwrap();
1468 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1469 pos += res.Unwrap();
1477 pos += res.Unwrap();
1482 if (!
c.get().IsAliasColumn()) {
1484 pos += res.Unwrap();
1490 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1491 pos += res.Unwrap();
1500 if (
c.get().IsAliasColumn()) {
1504 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1505 pos += res.Unwrap();
1515 pos += res.Unwrap();
1520 pos += SerializeListFramePreamble(0, *
where);
1522 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1523 pos += res.Unwrap();
1528 return static_cast<std::uint32_t
>(pos - base);
1535 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1545 bytes += res.Unwrap();
1551 for (
unsigned i = 0; i <
nFields; ++i) {
1555 bytes += res.Unwrap();
1592 bytes += res.Unwrap();
1597 if (
descBuilder.GetDescriptor().GetNLogicalColumns() >
descBuilder.GetDescriptor().GetNPhysicalColumns())
1601 for (
unsigned i = 0; i <
nColumns; ++i) {
1605 bytes += res.Unwrap();
1625 bytes += res.Unwrap();
1634 bytes += res.Unwrap();
1660 bytes += res.Unwrap();
1667 bytes += res.Unwrap();
1679 return bytes - base;
1687 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1689 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1691 pos += SerializeEnvelopePreamble(kEnvelopeTypeHeader, *
where);
1693 pos += res.Unwrap();
1703 if (
auto res = SerializeSchemaDescription(*
where, desc, context)) {
1704 pos += res.Unwrap();
1709 std::uint64_t
size = pos - base;
1711 if (
auto res = SerializeEnvelopePostscript(base,
size,
xxhash3)) {
1712 size += res.Unwrap();
1727 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1729 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1731 pos += SerializeEnvelopePreamble(kEnvelopeTypePageList, *
where);
1742 if (
auto res = SerializeClusterSummary(
summary, *
where)) {
1743 pos += res.Unwrap();
1749 pos += res.Unwrap();
1774 pos += SerializeListFramePreamble(0, *
where);
1775 pos += SerializeInt64(kSuppressedColumnMarker, *
where);
1778 pos += SerializeListFramePreamble(
pageRange.GetPageInfos().size(), *
where);
1780 for (
const auto &pi :
pageRange.GetPageInfos()) {
1782 pi.HasChecksum() ? -
static_cast<std::int32_t
>(pi.GetNElements()) : pi.GetNElements();
1784 if (
auto res = SerializeLocator(pi.GetLocator(), *
where)) {
1785 pos += res.Unwrap();
1791 pos += SerializeUInt32(
columnRange.GetCompressionSettings().value(), *
where);
1795 pos += res.Unwrap();
1801 pos += res.Unwrap();
1808 pos += res.Unwrap();
1812 std::uint64_t
size = pos - base;
1813 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1814 size += res.Unwrap();
1825 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1827 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1829 pos += SerializeEnvelopePreamble(kEnvelopeTypeFooter, *
where);
1834 pos += res.Unwrap();
1842 pos += SerializeRecordFramePreamble(*
where);
1843 if (
auto res = SerializeSchemaDescription(*
where, desc, context,
true)) {
1844 pos += res.Unwrap();
1848 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1849 pos += res.Unwrap();
1867 pos += res.Unwrap();
1872 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1873 pos += res.Unwrap();
1883 "back in the future (but your main data is)";
1887 if (
auto res = SerializeAttributeSet(
attrSet, *
where)) {
1888 pos += res.Unwrap();
1893 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1894 pos += res.Unwrap();
1899 std::uint32_t
size = pos - base;
1900 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1901 size += res.Unwrap();
1912 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1914 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1918 pos += SerializeUInt16(
attrDesc.GetSchemaVersionMajor(), *
where);
1919 pos += SerializeUInt16(
attrDesc.GetSchemaVersionMinor(), *
where);
1921 if (
auto res = SerializeLocator(
attrDesc.GetAnchorLocator(), *
where)) {
1922 pos += res.Unwrap();
1927 auto size = pos - frame;
1928 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr,
size)) {
1937 for (std::size_t i = 0; i <
featureFlags.size(); ++i) {
1951 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1957 bytes += res.Unwrap();
1965 bytes += res.Unwrap();
1977 bytes += res.Unwrap();
1982 bytes += res.Unwrap();
1987 bytes += res.Unwrap();
1995 .FieldId(kZeroFieldId)
2009 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2013 bytes += res.Unwrap();
2020 bytes += res.Unwrap();
2029 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2030 return R__FAIL(
"footer too short");
2033 return R__FAIL(
"XxHash-3 mismatch between header and footer");
2040 bytes += res.Unwrap();
2056 bytes += res.Unwrap();
2063 bytes += res.Unwrap();
2071 .PageListLocator(
clusterGroup.fPageListEnvelopeLink.fLocator)
2072 .PageListLength(
clusterGroup.fPageListEnvelopeLink.fLength)
2087 bytes += res.Unwrap();
2093 "back in the future (but your main data is)";
2099 bytes += res.Unwrap();
2113 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2119 bytes += res.Unwrap();
2123 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2124 return R__FAIL(
"record frame too short");
2132 bytes += res.Unwrap();
2138 bytes += res.Unwrap();
2153 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2158 bytes += res.Unwrap();
2164 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2165 return R__FAIL(
"page list too short");
2168 return R__FAIL(
"XxHash-3 mismatch between header and page list");
2182 bytes += res.Unwrap();
2189 bytes += res.Unwrap();
2206 bytes += res.Unwrap();
2212 return R__FAIL(
"mismatch between number of clusters and number of cluster summaries");
2214 for (std::uint32_t i = 0; i <
nClusters; ++i) {
2221 bytes += res.Unwrap();
2233 bytes += res.Unwrap();
2240 for (std::uint32_t k = 0; k <
nPages; ++k) {
2242 return R__FAIL(
"inner frame too short");
2252 bytes += res.Unwrap();
2260 return R__FAIL(
"page list frame too short");
2265 return R__FAIL(
"unexpected non-empty page list");
2269 return R__FAIL(
"page list frame too short");
2295 std::vector<ROOT::RClusterDescriptor>
clusters;
2300 case EDescriptorDeserializeMode::kForReading:
2302 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2304 builder.AddExtendedColumnRanges(desc);
2305 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2308 case EDescriptorDeserializeMode::kForWriting:
2310 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2312 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2315 case EDescriptorDeserializeMode::kRaw:
2317 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...