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;
76 pos += RNTupleSerializer::SerializeUInt16(flags, *
where);
78 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetFieldName(), *
where);
79 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetTypeName(), *
where);
80 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetTypeAlias(), *
where);
81 pos += RNTupleSerializer::SerializeString(
fieldDesc.GetFieldDescription(), *
where);
83 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
84 pos += RNTupleSerializer::SerializeUInt64(
fieldDesc.GetNRepetitions(), *
where);
86 if (flags & RNTupleSerializer::kFlagProjectedField) {
89 if (flags & RNTupleSerializer::kFlagHasTypeChecksum) {
90 pos += RNTupleSerializer::SerializeUInt32(
fieldDesc.GetTypeChecksum().value(), *
where);
93 auto size = pos - base;
94 RNTupleSerializer::SerializeFramePostscript(base,
size);
110 auto base =
reinterpret_cast<unsigned char *
>(buffer);
138 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
143 bytes += res.Unwrap();
152 ENTupleStructure structure{ENTupleStructure::kPlain};
155 if (
auto res = RNTupleSerializer::SerializeFieldStructure(structure,
nullptr)) {
161 return R__FAIL(
"field record frame too short");
166 if (
auto res = RNTupleSerializer::DeserializeFieldStructure(
bytes, structure)) {
167 bytes += res.Unwrap();
171 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
175 std::string typeName;
179 bytes += res.Unwrap();
184 bytes += res.Unwrap();
189 bytes += res.Unwrap();
194 bytes += res.Unwrap();
200 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
202 return R__FAIL(
"field record frame too short");
208 if (flags & RNTupleSerializer::kFlagProjectedField) {
210 return R__FAIL(
"field record frame too short");
216 if (flags & RNTupleSerializer::kFlagHasTypeChecksum) {
218 return R__FAIL(
"field record frame too short");
233 auto base =
reinterpret_cast<unsigned char *
>(buffer);
237 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
239 if (
auto res = RNTupleSerializer::SerializeColumnType(
columnDesc.GetType(), *
where)) {
244 pos += RNTupleSerializer::SerializeUInt16(
columnDesc.GetBitsOnStorage(), *
where);
246 std::uint16_t flags = 0;
248 flags |= RNTupleSerializer::kFlagDeferredColumn;
250 flags |= RNTupleSerializer::kFlagHasValueRange;
254 pos += RNTupleSerializer::SerializeUInt16(flags, *
where);
255 pos += RNTupleSerializer::SerializeUInt16(
columnDesc.GetRepresentationIndex(), *
where);
256 if (flags & RNTupleSerializer::kFlagDeferredColumn)
258 if (flags & RNTupleSerializer::kFlagHasValueRange) {
259 auto [min, max] = *
columnDesc.GetValueRange();
261 static_assert(
sizeof(min) ==
sizeof(
intMin) &&
sizeof(max) ==
sizeof(
intMax));
264 pos += RNTupleSerializer::SerializeUInt64(
intMin, *
where);
265 pos += RNTupleSerializer::SerializeUInt64(
intMax, *
where);
268 if (
auto res = RNTupleSerializer::SerializeFramePostscript(buffer ? base : nullptr, pos - base)) {
278 std::span<const ROOT::DescriptorId_t>
fieldList,
282 auto base =
reinterpret_cast<unsigned char *
>(buffer);
295 for (
const auto &
c : desc.GetColumnIterable(
parentId)) {
296 if (
c.IsAliasColumn() || (
xHeader &&
xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
315 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
320 bytes += res.Unwrap();
332 if (
fnFrameSizeLeft() < RNTupleSerializer::SerializeColumnType(
type,
nullptr).Unwrap() +
sizeof(std::uint16_t) +
333 2 *
sizeof(std::uint32_t)) {
334 return R__FAIL(
"column record frame too short");
336 if (
auto res = RNTupleSerializer::DeserializeColumnType(
bytes,
type)) {
337 bytes += res.Unwrap();
343 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
345 if (flags & RNTupleSerializer::kFlagDeferredColumn) {
347 return R__FAIL(
"column record frame too short");
350 if (flags & RNTupleSerializer::kFlagHasValueRange) {
352 return R__FAIL(
"field record frame too short");
372 auto base =
reinterpret_cast<unsigned char *
>(buffer);
376 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
378 if (
auto res = RNTupleSerializer::SerializeExtraTypeInfoId(desc.
GetContentId(), *
where)) {
387 auto size = pos - base;
388 RNTupleSerializer::SerializeFramePostscript(base,
size);
395 auto base =
reinterpret_cast<unsigned char *
>(buffer);
415 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
424 EExtraTypeInfoIds
contentId{EExtraTypeInfoIds::kInvalid};
427 return R__FAIL(
"extra type info record frame too short");
435 std::string typeName;
454 RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), buffer);
455 RNTupleSerializer::SerializeUInt64(
locator.GetPosition<std::uint64_t>(), buffer +
sizeof(std::uint64_t));
457 return sizeof(std::uint64_t) +
sizeof(std::uint64_t);
463 std::uint64_t position;
465 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), position);
474 ?
sizeof(std::uint64_t)
475 :
sizeof(std::uint32_t);
478 RNTupleSerializer::SerializeUInt32(
locator.GetNBytesOnStorage(), buffer);
480 RNTupleSerializer::SerializeUInt64(
locator.GetNBytesOnStorage(), buffer);
490 std::uint64_t location;
495 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint32_t), location);
500 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), location);
513 auto base =
reinterpret_cast<unsigned char *
>(buffer);
517 pos += RNTupleSerializer::SerializeRecordFramePreamble(*
where);
522 pos += RNTupleSerializer::SerializeFramePostscript(buffer ? base : nullptr, pos - base).Unwrap();
528 std::span<const ROOT::DescriptorId_t>
fieldList,
532 auto base =
reinterpret_cast<unsigned char *
>(buffer);
542 for (
const auto &
c : desc.GetColumnIterable(
parentId)) {
543 if (!
c.IsAliasColumn() || (
xHeader &&
xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
556 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
566 return R__FAIL(
"alias column record frame too short");
578 std::uint64_t &
xxhash3,
void *buffer)
580 if (buffer !=
nullptr) {
593 return R__FAIL(
"XxHash-3 checksum mismatch");
605 if (buffer !=
nullptr) {
606 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
607 bytes[0] = (val & 0x00FF);
608 bytes[1] = (val & 0xFF00) >> 8;
615 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
616 val = std::int16_t(
bytes[0]) + (std::int16_t(
bytes[1]) << 8);
622 return SerializeInt16(val, buffer);
627 return DeserializeInt16(buffer, *
reinterpret_cast<std::int16_t *
>(&val));
632 if (buffer !=
nullptr) {
633 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
634 bytes[0] = (val & 0x000000FF);
635 bytes[1] = (val & 0x0000FF00) >> 8;
636 bytes[2] = (val & 0x00FF0000) >> 16;
637 bytes[3] = (val & 0xFF000000) >> 24;
644 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
645 val = std::int32_t(
bytes[0]) + (std::int32_t(
bytes[1]) << 8) + (std::int32_t(
bytes[2]) << 16) +
646 (std::int32_t(
bytes[3]) << 24);
652 return SerializeInt32(val, buffer);
657 return DeserializeInt32(buffer, *
reinterpret_cast<std::int32_t *
>(&val));
662 if (buffer !=
nullptr) {
663 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
664 bytes[0] = (val & 0x00000000000000FF);
665 bytes[1] = (val & 0x000000000000FF00) >> 8;
666 bytes[2] = (val & 0x0000000000FF0000) >> 16;
667 bytes[3] = (val & 0x00000000FF000000) >> 24;
668 bytes[4] = (val & 0x000000FF00000000) >> 32;
669 bytes[5] = (val & 0x0000FF0000000000) >> 40;
670 bytes[6] = (val & 0x00FF000000000000) >> 48;
671 bytes[7] = (val & 0xFF00000000000000) >> 56;
678 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
679 val = std::int64_t(
bytes[0]) + (std::int64_t(
bytes[1]) << 8) + (std::int64_t(
bytes[2]) << 16) +
680 (std::int64_t(
bytes[3]) << 24) + (std::int64_t(
bytes[4]) << 32) + (std::int64_t(
bytes[5]) << 40) +
681 (std::int64_t(
bytes[6]) << 48) + (std::int64_t(
bytes[7]) << 56);
687 return SerializeInt64(val, buffer);
692 return DeserializeInt64(buffer, *
reinterpret_cast<std::int64_t *
>(&val));
698 auto pos =
reinterpret_cast<unsigned char *
>(buffer);
699 pos += SerializeUInt32(val.length(), pos);
700 memcpy(pos, val.data(), val.length());
702 return sizeof(std::uint32_t) + val.length();
708 if (
bufSize <
sizeof(std::uint32_t))
709 return R__FAIL(
"string buffer too short");
710 bufSize -=
sizeof(std::uint32_t);
712 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
717 return R__FAIL(
"string buffer too short");
721 return sizeof(std::uint32_t) +
length;
759 return SerializeUInt16(0x99, buffer);
760 return R__FAIL(
"unexpected column type");
821 return SerializeUInt16(0x99, buffer);
822 return R__FAIL(
"unexpected field structure type");
849 default:
return R__FAIL(
"unexpected extra type info id");
869 auto base =
reinterpret_cast<unsigned char *
>(buffer);
871 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
882 if (
size <
sizeof(std::uint64_t))
883 return R__FAIL(
"envelope size too small");
884 if (
size >=
static_cast<uint64_t
>(1) << 48)
885 return R__FAIL(
"envelope size too big");
906 const std::uint64_t
minEnvelopeSize =
sizeof(std::uint64_t) +
sizeof(std::uint64_t);
908 return R__FAIL(
"invalid envelope buffer, too short");
910 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
918 return R__FAIL(
"envelope type mismatch: expected " + std::to_string(
expectedType) +
", found " +
924 return R__FAIL(
"envelope buffer size too small");
926 return R__FAIL(
"invalid envelope, too short");
946 return SerializeInt64(1, buffer);
951 auto base =
reinterpret_cast<unsigned char *
>(buffer);
953 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
956 pos += SerializeInt64(-1, *
where);
966 return R__FAIL(
"frame too short: " + std::to_string(
size));
969 DeserializeInt64(frame, marker);
971 return R__FAIL(
"frame too short: " + std::to_string(
size));
972 SerializeInt64(marker *
static_cast<int64_t
>(
size), frame);
981 std::uint64_t
minSize =
sizeof(std::int64_t);
983 return R__FAIL(
"frame too short");
985 std::int64_t *
ssize =
reinterpret_cast<std::int64_t *
>(&
frameSize);
986 DeserializeInt64(buffer, *
ssize);
988 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
996 minSize +=
sizeof(std::uint32_t);
998 return R__FAIL(
"frame too short");
1004 return R__FAIL(
"corrupt frame size");
1006 return R__FAIL(
"frame too short");
1008 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1023 return SerializeUInt64(0, buffer);
1026 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
1028 for (
unsigned i = 0; i < flags.size(); ++i) {
1029 if (flags[i] & 0x8000000000000000)
1030 return R__FAIL(
"feature flag out of bounds");
1033 if (i == (flags.size() - 1))
1034 SerializeUInt64(flags[i],
bytes);
1036 bytes += SerializeUInt64(flags[i] | 0x8000000000000000,
bytes);
1039 return (flags.size() *
sizeof(std::int64_t));
1044 std::vector<std::uint64_t> &flags)
1046 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1051 if (
bufSize <
sizeof(std::uint64_t))
1052 return R__FAIL(
"feature flag buffer too short");
1054 bufSize -=
sizeof(std::uint64_t);
1055 flags.emplace_back(
f & ~0x8000000000000000);
1056 }
while (
f & 0x8000000000000000);
1058 return (flags.size() *
sizeof(std::uint64_t));
1065 return R__FAIL(
"locator is not serializable");
1067 std::uint32_t
size = 0;
1069 (
locator.GetNBytesOnStorage() <= std::numeric_limits<std::int32_t>::max())) {
1070 size += SerializeUInt32(
locator.GetNBytesOnStorage(), buffer);
1071 size += SerializeUInt64(
locator.GetPosition<std::uint64_t>(),
1072 buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1077 auto payloadp = buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
sizeof(std::int32_t) :
nullptr;
1093 return R__FAIL(
"locator has unknown type");
1096 std::int32_t head =
sizeof(std::int32_t) +
size;
1097 head |=
locator.GetReserved() << 16;
1098 head |=
static_cast<int>(
locatorType & 0x7F) << 24;
1108 if (
bufSize <
sizeof(std::int32_t))
1109 return R__FAIL(
"too short locator");
1111 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1115 bufSize -=
sizeof(std::int32_t);
1118 const int type = head >> 24;
1119 const std::uint32_t
payloadSize = (
static_cast<std::uint32_t
>(head) & 0x0000FFFF) -
sizeof(std::int32_t);
1121 return R__FAIL(
"too short locator");
1123 locator.SetReserved(
static_cast<std::uint32_t
>(head >> 16) & 0xFF);
1137 if (
bufSize <
sizeof(std::uint64_t))
1138 return R__FAIL(
"too short locator");
1142 locator.SetNBytesOnStorage(head);
1146 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1154 SerializeLocator(
envelopeLink.fLocator, buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1156 size += res.Unwrap();
1166 if (
bufSize <
sizeof(std::int64_t))
1167 return R__FAIL(
"too short envelope link");
1169 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1171 bufSize -=
sizeof(std::uint64_t);
1173 bytes += res.Unwrap();
1177 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1183 if (
clusterSummary.fNEntries >= (
static_cast<std::uint64_t
>(1) << 56)) {
1184 return R__FAIL(
"number of entries in cluster exceeds maximum of 2^56");
1187 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1189 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1192 pos += SerializeRecordFramePreamble(*
where);
1198 auto size = pos - frame;
1199 if (
auto res = SerializeFramePostscript(frame,
size)) {
1200 pos += res.Unwrap();
1211 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1215 bytes += res.Unwrap();
1222 return R__FAIL(
"too short cluster summary");
1232 return R__FAIL(
"sharded cluster flag set in cluster summary; sharded clusters are currently unsupported.");
1244 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1246 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1249 pos += SerializeRecordFramePreamble(*
where);
1253 if (
auto res = SerializeEnvelopeLink(
clusterGroup.fPageListEnvelopeLink, *
where)) {
1254 pos += res.Unwrap();
1258 auto size = pos - frame;
1259 if (
auto res = SerializeFramePostscript(frame,
size)) {
1270 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1275 bytes += res.Unwrap();
1281 if (
fnFrameSizeLeft() <
sizeof(std::uint32_t) + 2 *
sizeof(std::uint64_t))
1282 return R__FAIL(
"too short cluster group");
1288 bytes += res.Unwrap();
1316 std::vector<ROOT::DescriptorId_t>
fieldTrees;
1325 if (!
c.IsAliasColumn()) {
1326 MapPhysicalColumnId(
c.GetPhysicalId());
1337 MapPhysicalColumnId(
columnDesc.GetPhysicalId());
1347 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1349 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1353 std::vector<std::reference_wrapper<const ROOT::RColumnDescriptor>>
extraColumns;
1373 (
xHeader->GetNLogicalColumns() -
xHeader->GetNPhysicalColumns());
1388 pos += res.Unwrap();
1392 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1393 pos += res.Unwrap();
1401 pos += res.Unwrap();
1406 if (!
c.get().IsAliasColumn()) {
1408 pos += res.Unwrap();
1414 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1415 pos += res.Unwrap();
1424 if (
c.get().IsAliasColumn()) {
1428 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1429 pos += res.Unwrap();
1439 pos += res.Unwrap();
1444 pos += SerializeListFramePreamble(0, *
where);
1446 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1447 pos += res.Unwrap();
1452 return static_cast<std::uint32_t
>(pos - base);
1459 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1469 bytes += res.Unwrap();
1475 for (
unsigned i = 0; i <
nFields; ++i) {
1479 bytes += res.Unwrap();
1516 bytes += res.Unwrap();
1521 if (
descBuilder.GetDescriptor().GetNLogicalColumns() >
descBuilder.GetDescriptor().GetNPhysicalColumns())
1525 for (
unsigned i = 0; i <
nColumns; ++i) {
1529 bytes += res.Unwrap();
1549 bytes += res.Unwrap();
1558 bytes += res.Unwrap();
1584 bytes += res.Unwrap();
1591 bytes += res.Unwrap();
1603 return bytes - base;
1611 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1613 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1615 pos += SerializeEnvelopePreamble(kEnvelopeTypeHeader, *
where);
1618 pos += res.Unwrap();
1628 if (
auto res = SerializeSchemaDescription(*
where, desc, context)) {
1629 pos += res.Unwrap();
1634 std::uint64_t
size = pos - base;
1636 if (
auto res = SerializeEnvelopePostscript(base,
size,
xxhash3)) {
1637 size += res.Unwrap();
1652 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1654 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1656 pos += SerializeEnvelopePreamble(kEnvelopeTypePageList, *
where);
1667 if (
auto res = SerializeClusterSummary(
summary, *
where)) {
1668 pos += res.Unwrap();
1674 pos += res.Unwrap();
1699 pos += SerializeListFramePreamble(0, *
where);
1700 pos += SerializeInt64(kSuppressedColumnMarker, *
where);
1703 pos += SerializeListFramePreamble(
pageRange.GetPageInfos().size(), *
where);
1705 for (
const auto &pi :
pageRange.GetPageInfos()) {
1707 pi.HasChecksum() ? -
static_cast<std::int32_t
>(pi.GetNElements()) : pi.GetNElements();
1709 if (
auto res = SerializeLocator(pi.GetLocator(), *
where)) {
1710 pos += res.Unwrap();
1716 pos += SerializeUInt32(
columnRange.GetCompressionSettings().value(), *
where);
1720 pos += res.Unwrap();
1726 pos += res.Unwrap();
1733 pos += res.Unwrap();
1737 std::uint64_t
size = pos - base;
1738 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1739 size += res.Unwrap();
1750 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1752 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1754 pos += SerializeEnvelopePreamble(kEnvelopeTypeFooter, *
where);
1757 if (
auto res = SerializeFeatureFlags(std::vector<std::uint64_t>(), *
where)) {
1758 pos += res.Unwrap();
1766 pos += SerializeRecordFramePreamble(*
where);
1767 if (
auto res = SerializeSchemaDescription(*
where, desc, context,
true)) {
1768 pos += res.Unwrap();
1772 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1773 pos += res.Unwrap();
1791 pos += res.Unwrap();
1796 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1797 pos += res.Unwrap();
1802 std::uint32_t
size = pos - base;
1803 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1804 size += res.Unwrap();
1814 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1820 bytes += res.Unwrap();
1828 bytes += res.Unwrap();
1832 for (std::size_t i = 0; i <
featureFlags.size(); ++i) {
1835 unsigned int bit = 0;
1838 return R__FAIL(
"unsupported format feature: " + std::to_string(i * 64 +
bit));
1845 bytes += res.Unwrap();
1850 bytes += res.Unwrap();
1855 bytes += res.Unwrap();
1863 .FieldId(kZeroFieldId)
1877 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1881 bytes += res.Unwrap();
1888 bytes += res.Unwrap();
1898 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
1899 return R__FAIL(
"footer too short");
1902 return R__FAIL(
"XxHash-3 mismatch between header and footer");
1909 bytes += res.Unwrap();
1924 bytes += res.Unwrap();
1931 bytes += res.Unwrap();
1939 .PageListLocator(
clusterGroup.fPageListEnvelopeLink.fLocator)
1940 .PageListLength(
clusterGroup.fPageListEnvelopeLink.fLength)
1956 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1961 bytes += res.Unwrap();
1967 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
1968 return R__FAIL(
"page list too short");
1971 return R__FAIL(
"XxHash-3 mismatch between header and page list");
1985 bytes += res.Unwrap();
1992 bytes += res.Unwrap();
2009 bytes += res.Unwrap();
2015 return R__FAIL(
"mismatch between number of clusters and number of cluster summaries");
2017 for (std::uint32_t i = 0; i <
nClusters; ++i) {
2024 bytes += res.Unwrap();
2036 bytes += res.Unwrap();
2043 for (std::uint32_t k = 0; k <
nPages; ++k) {
2045 return R__FAIL(
"inner frame too short");
2055 bytes += res.Unwrap();
2063 return R__FAIL(
"page list frame too short");
2068 return R__FAIL(
"unexpected non-empty page list");
2072 return R__FAIL(
"page list frame too short");
2098 std::vector<ROOT::RClusterDescriptor>
clusters;
2103 case EDescriptorDeserializeMode::kForReading:
2105 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2107 builder.AddExtendedColumnRanges(desc);
2108 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2111 case EDescriptorDeserializeMode::kForWriting:
2113 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2115 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2118 case EDescriptorDeserializeMode::kRaw:
2120 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
#define R__FORWARD_ERROR(res)
Short-hand to return an RResult<T> in an error state (i.e. after checking)
#define R__FORWARD_RESULT(res)
Short-hand to return an RResult<T> value from a subroutine to the calling stack frame.
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
#define R__LOG_WARNING(...)
#define R__LOG_DEBUG(DEBUGLEVEL,...)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t nitems
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t bytes
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
The available trivial, native content types of a column.
A helper class for piece-wise construction of an RClusterDescriptor.
RClusterDescriptorBuilder & NEntries(std::uint64_t nEntries)
RClusterDescriptorBuilder & ClusterId(ROOT::DescriptorId_t clusterId)
RClusterDescriptorBuilder & FirstEntryIndex(std::uint64_t firstEntryIndex)
A helper class for piece-wise construction of an RClusterGroupDescriptor.
A helper class for piece-wise construction of an RColumnDescriptor.
A helper class for piece-wise construction of an RFieldDescriptor.
A helper class for piece-wise construction of an RNTupleDescriptor.
The serialization context is used for the piecewise serialization of a descriptor.
ROOT::DescriptorId_t GetOnDiskFieldId(ROOT::DescriptorId_t memId) const
ROOT::DescriptorId_t GetMemColumnId(ROOT::DescriptorId_t onDiskId) const
ROOT::DescriptorId_t GetMemClusterGroupId(ROOT::DescriptorId_t onDiskId) const
ROOT::DescriptorId_t GetOnDiskColumnId(ROOT::DescriptorId_t memId) const
std::uint64_t GetHeaderXxHash3() const
void MapSchema(const RNTupleDescriptor &desc, bool forHeaderExtension)
Map in-memory field and column IDs to their on-disk counterparts.
void SetHeaderSize(std::uint64_t size)
void SetHeaderXxHash3(std::uint64_t xxhash3)
ROOT::DescriptorId_t GetMemClusterId(ROOT::DescriptorId_t onDiskId) const
const std::vector< ROOT::DescriptorId_t > & GetOnDiskFieldList() const
Return a vector containing the in-memory field ID for each on-disk counterpart, in order,...
A helper class for serializing and deserialization of the RNTuple binary format.
static std::uint32_t SerializeXxHash3(const unsigned char *data, std::uint64_t length, std::uint64_t &xxhash3, void *buffer)
Writes a XxHash-3 64bit checksum of the byte range given by data and length.
static RResult< std::vector< ROOT::Internal::RClusterDescriptorBuilder > > DeserializePageListRaw(const void *buffer, std::uint64_t bufSize, ROOT::DescriptorId_t clusterGroupId, const RNTupleDescriptor &desc)
static RResult< std::uint32_t > SerializeSchemaDescription(void *buffer, const RNTupleDescriptor &desc, const RContext &context, bool forHeaderExtension=false)
Serialize the schema description in desc into buffer.
static RResult< std::uint32_t > DeserializeString(const void *buffer, std::uint64_t bufSize, std::string &val)
static RResult< std::uint32_t > SerializeEnvelopeLink(const REnvelopeLink &envelopeLink, void *buffer)
static std::uint32_t SerializeInt32(std::int32_t val, void *buffer)
static RResult< std::uint32_t > DeserializeEnvelopeLink(const void *buffer, std::uint64_t bufSize, REnvelopeLink &envelopeLink)
static std::uint32_t SerializeUInt32(std::uint32_t val, void *buffer)
static RResult< std::uint32_t > SerializeFieldStructure(ROOT::ENTupleStructure structure, void *buffer)
While we could just interpret the enums as ints, we make the translation explicit in order to avoid a...
static RResult< std::uint32_t > SerializeEnvelopePostscript(unsigned char *envelope, std::uint64_t size)
static RResult< std::uint32_t > SerializeFeatureFlags(const std::vector< std::uint64_t > &flags, void *buffer)
static std::uint32_t DeserializeUInt32(const void *buffer, std::uint32_t &val)
static RResult< std::uint32_t > DeserializeFrameHeader(const void *buffer, std::uint64_t bufSize, std::uint64_t &frameSize, std::uint32_t &nitems)
static RResult< std::uint32_t > DeserializeEnvelope(const void *buffer, std::uint64_t bufSize, std::uint16_t expectedType)
static RResult< std::uint32_t > SerializeColumnType(ROOT::ENTupleColumnType type, void *buffer)
static std::uint32_t SerializeListFramePreamble(std::uint32_t nitems, void *buffer)
static std::uint32_t SerializeInt16(std::int16_t val, void *buffer)
static RResult< std::uint32_t > SerializeFramePostscript(void *frame, std::uint64_t size)
static RResult< std::uint32_t > DeserializeClusterGroup(const void *buffer, std::uint64_t bufSize, RClusterGroup &clusterGroup)
static RResult< std::uint32_t > DeserializeLocator(const void *buffer, std::uint64_t bufSize, RNTupleLocator &locator)
static std::uint32_t SerializeUInt16(std::uint16_t val, void *buffer)
static RResult< void > DeserializePageList(const void *buffer, std::uint64_t bufSize, ROOT::DescriptorId_t clusterGroupId, RNTupleDescriptor &desc, EDescriptorDeserializeMode mode)
static RResult< void > DeserializeFooter(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RNTupleDescriptorBuilder &descBuilder)
static std::uint32_t DeserializeInt64(const void *buffer, std::int64_t &val)
static std::uint32_t SerializeEnvelopePreamble(std::uint16_t envelopeType, void *buffer)
static std::uint32_t DeserializeInt32(const void *buffer, std::int32_t &val)
static std::uint32_t SerializeString(const std::string &val, void *buffer)
std::map< Int_t, TVirtualStreamerInfo * > StreamerInfoMap_t
static RResult< std::uint32_t > SerializeExtraTypeInfoId(ROOT::EExtraTypeInfoIds id, void *buffer)
static RResult< StreamerInfoMap_t > DeserializeStreamerInfos(const std::string &extraTypeInfoContent)
static std::uint32_t DeserializeUInt16(const void *buffer, std::uint16_t &val)
static RResult< void > VerifyXxHash3(const unsigned char *data, std::uint64_t length, std::uint64_t &xxhash3)
Expects an xxhash3 checksum in the 8 bytes following data + length and verifies it.
static RResult< std::uint32_t > SerializeClusterSummary(const RClusterSummary &clusterSummary, void *buffer)
static RResult< std::uint32_t > DeserializeColumnType(const void *buffer, ROOT::ENTupleColumnType &type)
static std::uint32_t DeserializeInt16(const void *buffer, std::int16_t &val)
static RResult< std::uint32_t > DeserializeExtraTypeInfoId(const void *buffer, ROOT::EExtraTypeInfoIds &id)
static RResult< std::uint32_t > DeserializeClusterSummary(const void *buffer, std::uint64_t bufSize, RClusterSummary &clusterSummary)
EDescriptorDeserializeMode
static RResult< std::uint32_t > SerializeClusterGroup(const RClusterGroup &clusterGroup, void *buffer)
static std::uint32_t SerializeRecordFramePreamble(void *buffer)
static RResult< std::uint32_t > SerializePageList(void *buffer, const RNTupleDescriptor &desc, std::span< ROOT::DescriptorId_t > physClusterIDs, const RContext &context)
static RResult< std::uint32_t > DeserializeFieldStructure(const void *buffer, ROOT::ENTupleStructure &structure)
static std::uint32_t SerializeInt64(std::int64_t val, void *buffer)
static RResult< void > DeserializeHeader(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RNTupleDescriptorBuilder &descBuilder)
static RResult< std::uint32_t > SerializeFooter(void *buffer, const RNTupleDescriptor &desc, const RContext &context)
static std::uint32_t DeserializeUInt64(const void *buffer, std::uint64_t &val)
static RResult< std::uint32_t > SerializeLocator(const RNTupleLocator &locator, void *buffer)
static RResult< std::uint32_t > DeserializeSchemaDescription(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RNTupleDescriptorBuilder &descBuilder)
static std::uint32_t SerializeUInt64(std::uint64_t val, void *buffer)
static RResult< std::uint32_t > DeserializeFeatureFlags(const void *buffer, std::uint64_t bufSize, std::vector< std::uint64_t > &flags)
static RResult< RContext > SerializeHeader(void *buffer, const RNTupleDescriptor &desc)
static std::string SerializeStreamerInfos(const StreamerInfoMap_t &infos)
Metadata stored for every column of an RNTuple.
Metadata stored for every field of an RNTuple.
The on-storage metadata of an RNTuple.
const RClusterGroupDescriptor & GetClusterGroupDescriptor(ROOT::DescriptorId_t clusterGroupId) const
const RColumnDescriptor & GetColumnDescriptor(ROOT::DescriptorId_t columnId) const
RFieldDescriptorIterable GetFieldIterable(const RFieldDescriptor &fieldDesc) const
const RFieldDescriptor & GetFieldDescriptor(ROOT::DescriptorId_t fieldId) const
std::size_t GetNExtraTypeInfos() const
RColumnDescriptorIterable GetColumnIterable() const
const std::string & GetName() const
std::vector< std::uint64_t > GetFeatureFlags() const
ROOT::DescriptorId_t GetFieldZeroId() const
Returns the logical parent of all top-level RNTuple data fields.
std::size_t GetNPhysicalColumns() const
const RHeaderExtension * GetHeaderExtension() const
Return header extension information; if the descriptor does not have a header extension,...
const RClusterDescriptor & GetClusterDescriptor(ROOT::DescriptorId_t clusterId) const
std::uint64_t GetOnDiskHeaderXxHash3() const
std::size_t GetNFields() const
RResult< void > AddClusterGroupDetails(ROOT::DescriptorId_t clusterGroupId, std::vector< RClusterDescriptor > &clusterDescs)
Methods to load and drop cluster group details (cluster IDs and page locations)
std::size_t GetNLogicalColumns() const
std::size_t GetNClusterGroups() const
const std::string & GetDescription() const
RNTupleLocator payload that is common for object stores using 64bit location information.
Generic information about the physical location of data.
const_iterator begin() const
const_iterator end() const
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
TObject * ReadObject(const TClass *cl) override
Read object from I/O buffer.
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
Wrapper around a TObject so it can be stored in a TList.
Describes a persistent version of a class.
constexpr ROOT::ENTupleStructure kTestFutureFieldStructure
ROOT::RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
constexpr ENTupleColumnType kTestFutureColumnType
constexpr RNTupleLocator::ELocatorType kTestLocatorType
EExtraTypeInfoIds
Used in RExtraTypeInfoDescriptor.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr DescriptorId_t kInvalidDescriptorId
ENTupleStructure
The fields in the RNTuple data model tree can carry different structural information about the type s...