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;
1095 return R__FAIL(
"locator has unknown type");
1098 std::int32_t head =
sizeof(std::int32_t) +
size;
1099 head |=
locator.GetReserved() << 16;
1100 head |=
static_cast<int>(
locatorType & 0x7F) << 24;
1110 if (
bufSize <
sizeof(std::int32_t))
1111 return R__FAIL(
"too short locator");
1113 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1117 bufSize -=
sizeof(std::int32_t);
1120 const int type = head >> 24;
1121 const std::uint32_t
payloadSize = (
static_cast<std::uint32_t
>(head) & 0x0000FFFF) -
sizeof(std::int32_t);
1123 return R__FAIL(
"too short locator");
1125 locator.SetReserved(
static_cast<std::uint32_t
>(head >> 16) & 0xFF);
1139 if (
bufSize <
sizeof(std::uint64_t))
1140 return R__FAIL(
"too short locator");
1144 locator.SetNBytesOnStorage(head);
1148 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1156 SerializeLocator(
envelopeLink.fLocator, buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1158 size += res.Unwrap();
1168 if (
bufSize <
sizeof(std::int64_t))
1169 return R__FAIL(
"too short envelope link");
1171 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
1173 bufSize -=
sizeof(std::uint64_t);
1175 bytes += res.Unwrap();
1179 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1185 if (
clusterSummary.fNEntries >= (
static_cast<std::uint64_t
>(1) << 56)) {
1186 return R__FAIL(
"number of entries in cluster exceeds maximum of 2^56");
1189 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1191 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1194 pos += SerializeRecordFramePreamble(*
where);
1200 auto size = pos - frame;
1201 if (
auto res = SerializeFramePostscript(frame,
size)) {
1202 pos += res.Unwrap();
1213 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1217 bytes += res.Unwrap();
1224 return R__FAIL(
"too short cluster summary");
1234 return R__FAIL(
"sharded cluster flag set in cluster summary; sharded clusters are currently unsupported.");
1246 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1248 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1251 pos += SerializeRecordFramePreamble(*
where);
1255 if (
auto res = SerializeEnvelopeLink(
clusterGroup.fPageListEnvelopeLink, *
where)) {
1256 pos += res.Unwrap();
1260 auto size = pos - frame;
1261 if (
auto res = SerializeFramePostscript(frame,
size)) {
1272 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1277 bytes += res.Unwrap();
1283 if (
fnFrameSizeLeft() <
sizeof(std::uint32_t) + 2 *
sizeof(std::uint64_t))
1284 return R__FAIL(
"too short cluster group");
1290 bytes += res.Unwrap();
1318 std::vector<ROOT::DescriptorId_t>
fieldTrees;
1327 if (!
c.IsAliasColumn()) {
1328 MapPhysicalColumnId(
c.GetPhysicalId());
1339 MapPhysicalColumnId(
columnDesc.GetPhysicalId());
1349 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1351 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1355 std::vector<std::reference_wrapper<const ROOT::RColumnDescriptor>>
extraColumns;
1375 (
xHeader->GetNLogicalColumns() -
xHeader->GetNPhysicalColumns());
1390 pos += res.Unwrap();
1394 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1395 pos += res.Unwrap();
1403 pos += res.Unwrap();
1408 if (!
c.get().IsAliasColumn()) {
1410 pos += res.Unwrap();
1416 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1417 pos += res.Unwrap();
1426 if (
c.get().IsAliasColumn()) {
1430 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1431 pos += res.Unwrap();
1441 pos += res.Unwrap();
1446 pos += SerializeListFramePreamble(0, *
where);
1448 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1449 pos += res.Unwrap();
1454 return static_cast<std::uint32_t
>(pos - base);
1461 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1471 bytes += res.Unwrap();
1477 for (
unsigned i = 0; i <
nFields; ++i) {
1481 bytes += res.Unwrap();
1518 bytes += res.Unwrap();
1523 if (
descBuilder.GetDescriptor().GetNLogicalColumns() >
descBuilder.GetDescriptor().GetNPhysicalColumns())
1527 for (
unsigned i = 0; i <
nColumns; ++i) {
1531 bytes += res.Unwrap();
1551 bytes += res.Unwrap();
1560 bytes += res.Unwrap();
1586 bytes += res.Unwrap();
1593 bytes += res.Unwrap();
1605 return bytes - base;
1613 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1615 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1617 pos += SerializeEnvelopePreamble(kEnvelopeTypeHeader, *
where);
1620 pos += res.Unwrap();
1630 if (
auto res = SerializeSchemaDescription(*
where, desc, context)) {
1631 pos += res.Unwrap();
1636 std::uint64_t
size = pos - base;
1638 if (
auto res = SerializeEnvelopePostscript(base,
size,
xxhash3)) {
1639 size += res.Unwrap();
1654 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1656 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1658 pos += SerializeEnvelopePreamble(kEnvelopeTypePageList, *
where);
1669 if (
auto res = SerializeClusterSummary(
summary, *
where)) {
1670 pos += res.Unwrap();
1676 pos += res.Unwrap();
1701 pos += SerializeListFramePreamble(0, *
where);
1702 pos += SerializeInt64(kSuppressedColumnMarker, *
where);
1705 pos += SerializeListFramePreamble(
pageRange.GetPageInfos().size(), *
where);
1707 for (
const auto &pi :
pageRange.GetPageInfos()) {
1709 pi.HasChecksum() ? -
static_cast<std::int32_t
>(pi.GetNElements()) : pi.GetNElements();
1711 if (
auto res = SerializeLocator(pi.GetLocator(), *
where)) {
1712 pos += res.Unwrap();
1718 pos += SerializeUInt32(
columnRange.GetCompressionSettings().value(), *
where);
1722 pos += res.Unwrap();
1728 pos += res.Unwrap();
1735 pos += res.Unwrap();
1739 std::uint64_t
size = pos - base;
1740 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1741 size += res.Unwrap();
1752 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1754 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1756 pos += SerializeEnvelopePreamble(kEnvelopeTypeFooter, *
where);
1759 if (
auto res = SerializeFeatureFlags(std::vector<std::uint64_t>(), *
where)) {
1760 pos += res.Unwrap();
1768 pos += SerializeRecordFramePreamble(*
where);
1769 if (
auto res = SerializeSchemaDescription(*
where, desc, context,
true)) {
1770 pos += res.Unwrap();
1774 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1775 pos += res.Unwrap();
1793 pos += res.Unwrap();
1798 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1799 pos += res.Unwrap();
1809 "back in the future (but your main data is)";
1813 if (
auto res = SerializeAttributeSet(
attrSet, *
where)) {
1814 pos += res.Unwrap();
1819 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1820 pos += res.Unwrap();
1825 std::uint32_t
size = pos - base;
1826 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1827 size += res.Unwrap();
1838 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1840 void **
where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1844 pos += SerializeUInt16(
attrDesc.GetSchemaVersionMajor(), *
where);
1845 pos += SerializeUInt16(
attrDesc.GetSchemaVersionMinor(), *
where);
1847 if (
auto res = SerializeLocator(
attrDesc.GetAnchorLocator(), *
where)) {
1848 pos += res.Unwrap();
1853 auto size = pos - frame;
1854 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr,
size)) {
1864 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1870 bytes += res.Unwrap();
1878 bytes += res.Unwrap();
1882 for (std::size_t i = 0; i <
featureFlags.size(); ++i) {
1885 unsigned int bit = 0;
1888 return R__FAIL(
"unsupported format feature: " + std::to_string(i * 64 +
bit));
1895 bytes += res.Unwrap();
1900 bytes += res.Unwrap();
1905 bytes += res.Unwrap();
1913 .FieldId(kZeroFieldId)
1927 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1931 bytes += res.Unwrap();
1938 bytes += res.Unwrap();
1948 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
1949 return R__FAIL(
"footer too short");
1952 return R__FAIL(
"XxHash-3 mismatch between header and footer");
1959 bytes += res.Unwrap();
1975 bytes += res.Unwrap();
1982 bytes += res.Unwrap();
1990 .PageListLocator(
clusterGroup.fPageListEnvelopeLink.fLocator)
1991 .PageListLength(
clusterGroup.fPageListEnvelopeLink.fLength)
2006 bytes += res.Unwrap();
2012 "back in the future (but your main data is)";
2018 bytes += res.Unwrap();
2032 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2038 bytes += res.Unwrap();
2042 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2043 return R__FAIL(
"record frame too short");
2051 bytes += res.Unwrap();
2057 bytes += res.Unwrap();
2072 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2077 bytes += res.Unwrap();
2083 if (
fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2084 return R__FAIL(
"page list too short");
2087 return R__FAIL(
"XxHash-3 mismatch between header and page list");
2101 bytes += res.Unwrap();
2108 bytes += res.Unwrap();
2125 bytes += res.Unwrap();
2131 return R__FAIL(
"mismatch between number of clusters and number of cluster summaries");
2133 for (std::uint32_t i = 0; i <
nClusters; ++i) {
2140 bytes += res.Unwrap();
2152 bytes += res.Unwrap();
2159 for (std::uint32_t k = 0; k <
nPages; ++k) {
2161 return R__FAIL(
"inner frame too short");
2171 bytes += res.Unwrap();
2179 return R__FAIL(
"page list frame too short");
2184 return R__FAIL(
"unexpected non-empty page list");
2188 return R__FAIL(
"page list frame too short");
2214 std::vector<ROOT::RClusterDescriptor>
clusters;
2219 case EDescriptorDeserializeMode::kForReading:
2221 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2223 builder.AddExtendedColumnRanges(desc);
2224 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2227 case EDescriptorDeserializeMode::kForWriting:
2229 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2231 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2234 case EDescriptorDeserializeMode::kRaw:
2236 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.
Metadata stored for every Attribute Set linked to an RNTuple.
A helper class for piece-wise construction of an RClusterDescriptor.
RClusterDescriptorBuilder & NEntries(std::uint64_t nEntries)
RClusterDescriptorBuilder & ClusterId(ROOT::DescriptorId_t clusterId)
RClusterDescriptorBuilder & FirstEntryIndex(std::uint64_t firstEntryIndex)
A helper class for piece-wise construction of an RClusterGroupDescriptor.
A helper class for piece-wise construction of an RColumnDescriptor.
A helper class for piece-wise construction of an RFieldDescriptor.
A helper class for piece-wise construction of an RNTupleDescriptor.
The serialization context is used for the piecewise serialization of a descriptor.
ROOT::DescriptorId_t GetOnDiskFieldId(ROOT::DescriptorId_t memId) const
ROOT::DescriptorId_t GetMemColumnId(ROOT::DescriptorId_t onDiskId) const
ROOT::DescriptorId_t GetMemClusterGroupId(ROOT::DescriptorId_t onDiskId) const
ROOT::DescriptorId_t GetOnDiskColumnId(ROOT::DescriptorId_t memId) const
std::uint64_t GetHeaderXxHash3() const
void MapSchema(const RNTupleDescriptor &desc, bool forHeaderExtension)
Map in-memory field and column IDs to their on-disk counterparts.
void SetHeaderSize(std::uint64_t size)
void SetHeaderXxHash3(std::uint64_t xxhash3)
ROOT::DescriptorId_t GetMemClusterId(ROOT::DescriptorId_t onDiskId) const
const std::vector< ROOT::DescriptorId_t > & GetOnDiskFieldList() const
Return a vector containing the in-memory field ID for each on-disk counterpart, in order,...
A helper class for serializing and deserialization of the RNTuple binary format.
static std::uint32_t SerializeXxHash3(const unsigned char *data, std::uint64_t length, std::uint64_t &xxhash3, void *buffer)
Writes a XxHash-3 64bit checksum of the byte range given by data and length.
static RResult< std::vector< ROOT::Internal::RClusterDescriptorBuilder > > DeserializePageListRaw(const void *buffer, std::uint64_t bufSize, ROOT::DescriptorId_t clusterGroupId, const RNTupleDescriptor &desc)
static RResult< std::uint32_t > SerializeSchemaDescription(void *buffer, const RNTupleDescriptor &desc, const RContext &context, bool forHeaderExtension=false)
Serialize the schema description in desc into buffer.
static RResult< std::uint32_t > DeserializeString(const void *buffer, std::uint64_t bufSize, std::string &val)
static RResult< std::uint32_t > SerializeEnvelopeLink(const REnvelopeLink &envelopeLink, void *buffer)
static std::uint32_t SerializeInt32(std::int32_t val, void *buffer)
static RResult< std::uint32_t > DeserializeEnvelopeLink(const void *buffer, std::uint64_t bufSize, REnvelopeLink &envelopeLink)
static std::uint32_t SerializeUInt32(std::uint32_t val, void *buffer)
static RResult< std::uint32_t > SerializeAttributeSet(const Experimental::RNTupleAttrSetDescriptor &attrSetDesc, void *buffer)
static RResult< std::uint32_t > SerializeFieldStructure(ROOT::ENTupleStructure structure, void *buffer)
While we could just interpret the enums as ints, we make the translation explicit in order to avoid a...
static RResult< std::uint32_t > SerializeEnvelopePostscript(unsigned char *envelope, std::uint64_t size)
static RResult< std::uint32_t > SerializeFeatureFlags(const std::vector< std::uint64_t > &flags, void *buffer)
static std::uint32_t DeserializeUInt32(const void *buffer, std::uint32_t &val)
static RResult< std::uint32_t > DeserializeFrameHeader(const void *buffer, std::uint64_t bufSize, std::uint64_t &frameSize, std::uint32_t &nitems)
static RResult< std::uint32_t > DeserializeAttributeSet(const void *buffer, std::uint64_t bufSize, Experimental::Internal::RNTupleAttrSetDescriptorBuilder &attrSetDescBld)
static RResult< std::uint32_t > DeserializeEnvelope(const void *buffer, std::uint64_t bufSize, std::uint16_t expectedType)
static RResult< std::uint32_t > SerializeColumnType(ROOT::ENTupleColumnType type, void *buffer)
static std::uint32_t SerializeListFramePreamble(std::uint32_t nitems, void *buffer)
static std::uint32_t SerializeInt16(std::int16_t val, void *buffer)
static RResult< std::uint32_t > SerializeFramePostscript(void *frame, std::uint64_t size)
static RResult< std::uint32_t > DeserializeClusterGroup(const void *buffer, std::uint64_t bufSize, RClusterGroup &clusterGroup)
static RResult< std::uint32_t > DeserializeLocator(const void *buffer, std::uint64_t bufSize, RNTupleLocator &locator)
static std::uint32_t SerializeUInt16(std::uint16_t val, void *buffer)
static RResult< void > DeserializePageList(const void *buffer, std::uint64_t bufSize, ROOT::DescriptorId_t clusterGroupId, RNTupleDescriptor &desc, EDescriptorDeserializeMode mode)
static RResult< void > DeserializeFooter(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RNTupleDescriptorBuilder &descBuilder)
static std::uint32_t DeserializeInt64(const void *buffer, std::int64_t &val)
static std::uint32_t SerializeEnvelopePreamble(std::uint16_t envelopeType, void *buffer)
static std::uint32_t DeserializeInt32(const void *buffer, std::int32_t &val)
static std::uint32_t SerializeString(const std::string &val, void *buffer)
std::map< Int_t, TVirtualStreamerInfo * > StreamerInfoMap_t
static RResult< std::uint32_t > SerializeExtraTypeInfoId(ROOT::EExtraTypeInfoIds id, void *buffer)
static RResult< StreamerInfoMap_t > DeserializeStreamerInfos(const std::string &extraTypeInfoContent)
static std::uint32_t DeserializeUInt16(const void *buffer, std::uint16_t &val)
static RResult< void > VerifyXxHash3(const unsigned char *data, std::uint64_t length, std::uint64_t &xxhash3)
Expects an xxhash3 checksum in the 8 bytes following data + length and verifies it.
static RResult< std::uint32_t > SerializeClusterSummary(const RClusterSummary &clusterSummary, void *buffer)
static RResult< std::uint32_t > DeserializeColumnType(const void *buffer, ROOT::ENTupleColumnType &type)
static std::uint32_t DeserializeInt16(const void *buffer, std::int16_t &val)
static RResult< std::uint32_t > DeserializeExtraTypeInfoId(const void *buffer, ROOT::EExtraTypeInfoIds &id)
static RResult< std::uint32_t > DeserializeClusterSummary(const void *buffer, std::uint64_t bufSize, RClusterSummary &clusterSummary)
EDescriptorDeserializeMode
static RResult< std::uint32_t > SerializeClusterGroup(const RClusterGroup &clusterGroup, void *buffer)
static std::uint32_t SerializeRecordFramePreamble(void *buffer)
static RResult< std::uint32_t > SerializePageList(void *buffer, const RNTupleDescriptor &desc, std::span< ROOT::DescriptorId_t > physClusterIDs, const RContext &context)
static RResult< std::uint32_t > DeserializeFieldStructure(const void *buffer, ROOT::ENTupleStructure &structure)
static std::uint32_t SerializeInt64(std::int64_t val, void *buffer)
static RResult< void > DeserializeHeader(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RNTupleDescriptorBuilder &descBuilder)
static RResult< std::uint32_t > SerializeFooter(void *buffer, const RNTupleDescriptor &desc, const RContext &context)
static std::uint32_t DeserializeUInt64(const void *buffer, std::uint64_t &val)
static RResult< std::uint32_t > SerializeLocator(const RNTupleLocator &locator, void *buffer)
static RResult< std::uint32_t > DeserializeSchemaDescription(const void *buffer, std::uint64_t bufSize, ROOT::Internal::RNTupleDescriptorBuilder &descBuilder)
static std::uint32_t SerializeUInt64(std::uint64_t val, void *buffer)
static RResult< std::uint32_t > DeserializeFeatureFlags(const void *buffer, std::uint64_t bufSize, std::vector< std::uint64_t > &flags)
static RResult< RContext > SerializeHeader(void *buffer, const RNTupleDescriptor &desc)
static std::string SerializeStreamerInfos(const StreamerInfoMap_t &infos)
Metadata stored for every column of an RNTuple.
Metadata stored for every field of an RNTuple.
The on-storage metadata of an RNTuple.
const RClusterGroupDescriptor & GetClusterGroupDescriptor(ROOT::DescriptorId_t clusterGroupId) const
const RColumnDescriptor & GetColumnDescriptor(ROOT::DescriptorId_t columnId) const
RFieldDescriptorIterable GetFieldIterable(const RFieldDescriptor &fieldDesc) const
const RFieldDescriptor & GetFieldDescriptor(ROOT::DescriptorId_t fieldId) const
std::size_t GetNExtraTypeInfos() const
RColumnDescriptorIterable GetColumnIterable() const
const std::string & GetName() const
std::vector< std::uint64_t > GetFeatureFlags() const
ROOT::DescriptorId_t GetFieldZeroId() const
Returns the logical parent of all top-level RNTuple data fields.
std::size_t GetNAttributeSets() const
std::size_t GetNPhysicalColumns() const
const RHeaderExtension * GetHeaderExtension() const
Return header extension information; if the descriptor does not have a header extension,...
const RClusterDescriptor & GetClusterDescriptor(ROOT::DescriptorId_t clusterId) const
std::uint64_t GetOnDiskHeaderXxHash3() const
std::size_t GetNFields() const
RResult< void > AddClusterGroupDetails(ROOT::DescriptorId_t clusterGroupId, std::vector< RClusterDescriptor > &clusterDescs)
Methods to load and drop cluster group details (cluster IDs and page locations)
ROOT::Experimental::RNTupleAttrSetDescriptorIterable GetAttrSetIterable() const
std::size_t GetNLogicalColumns() const
std::size_t GetNClusterGroups() const
const std::string & GetDescription() const
RNTupleLocator payload that is common for object stores using 64bit location information.
Generic information about the physical location of data.
void SetType(ELocatorType type)
const_iterator begin() const
const_iterator end() const
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
TObject * ReadObject(const TClass *cl) override
Read object from I/O buffer.
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
Wrapper around a TObject so it can be stored in a TList.
Describes a persistent version of a class.
constexpr ROOT::ENTupleStructure kTestFutureFieldStructure
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...