37#include <unordered_map>
54 auto base =
reinterpret_cast<unsigned char *
>(buffer);
56 void **where = (buffer ==
nullptr) ? &buffer : reinterpret_cast<void **>(&pos);
58 pos += RNTupleSerializer::SerializeRecordFramePreamble(*where);
60 pos += RNTupleSerializer::SerializeUInt32(fieldDesc.
GetFieldVersion(), *where);
61 pos += RNTupleSerializer::SerializeUInt32(fieldDesc.
GetTypeVersion(), *where);
62 pos += RNTupleSerializer::SerializeUInt32(onDiskParentId, *where);
63 if (
auto res = RNTupleSerializer::SerializeFieldStructure(fieldDesc.
GetStructure(), *where)) {
69 std::uint16_t flags = 0;
71 flags |= RNTupleSerializer::kFlagRepetitiveField;
73 flags |= RNTupleSerializer::kFlagProjectedField;
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);
85 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
86 pos += RNTupleSerializer::SerializeUInt64(fieldDesc.
GetNRepetitions(), *where);
88 if (flags & RNTupleSerializer::kFlagProjectedField) {
89 pos += RNTupleSerializer::SerializeUInt32(onDiskProjectionSourceId, *where);
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);
114 void **where = (buffer ==
nullptr) ? &buffer : reinterpret_cast<void **>(&pos);
118 for (
auto fieldId : fieldList) {
120 auto onDiskParentId =
121 (
f.GetParentId() == fieldZeroId) ? onDiskFieldId : context.GetOnDiskFieldId(
f.GetParentId());
122 auto onDiskProjectionSourceId =
124 if (
auto res = SerializeField(
f, onDiskParentId, onDiskProjectionSourceId, *where)) {
140 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
142 std::uint64_t frameSize;
143 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
144 if (
auto res = RNTupleSerializer::DeserializeFrameHeader(
bytes, bufSize, frameSize)) {
145 bytes += res.Unwrap();
150 std::uint32_t fieldVersion;
151 std::uint32_t typeVersion;
152 std::uint32_t parentId;
154 ENTupleStructure structure{ENTupleStructure::kPlain};
157 if (
auto res = RNTupleSerializer::SerializeFieldStructure(structure,
nullptr)) {
162 if (fnFrameSizeLeft() < 3 *
sizeof(std::uint32_t) +
result +
sizeof(std::uint16_t)) {
163 return R__FAIL(
"field record frame too short");
165 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, fieldVersion);
166 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, typeVersion);
167 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, parentId);
168 if (
auto res = RNTupleSerializer::DeserializeFieldStructure(
bytes, structure)) {
169 bytes += res.Unwrap();
173 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
176 std::string fieldName;
177 std::string typeName;
178 std::string aliasName;
179 std::string description;
180 if (
auto res = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), fieldName)) {
181 bytes += res.Unwrap();
185 if (
auto res = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), typeName)) {
186 bytes += res.Unwrap();
190 if (
auto res = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), aliasName)) {
191 bytes += res.Unwrap();
195 if (
auto res = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), description)) {
196 bytes += res.Unwrap();
202 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
203 if (fnFrameSizeLeft() <
sizeof(std::uint64_t))
204 return R__FAIL(
"field record frame too short");
205 std::uint64_t nRepetitions;
206 bytes += RNTupleSerializer::DeserializeUInt64(
bytes, nRepetitions);
210 if (flags & RNTupleSerializer::kFlagProjectedField) {
211 if (fnFrameSizeLeft() <
sizeof(std::uint32_t))
212 return R__FAIL(
"field record frame too short");
213 std::uint32_t projectionSourceId;
214 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, projectionSourceId);
218 if (flags & RNTupleSerializer::kFlagHasTypeChecksum) {
219 if (fnFrameSizeLeft() <
sizeof(std::uint32_t))
220 return R__FAIL(
"field record frame too short");
221 std::uint32_t typeChecksum;
222 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, typeChecksum);
226 if (flags & RNTupleSerializer::kFlagIsSoACollection) {
239 auto base =
reinterpret_cast<unsigned char *
>(buffer);
241 void **where = (buffer ==
nullptr) ? &buffer : reinterpret_cast<void **>(&pos);
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;
259 firstElementIdx = -firstElementIdx;
260 pos += RNTupleSerializer::SerializeUInt16(flags, *where);
262 if (flags & RNTupleSerializer::kFlagDeferredColumn)
263 pos += RNTupleSerializer::SerializeInt64(firstElementIdx, *where);
264 if (flags & RNTupleSerializer::kFlagHasValueRange) {
266 std::uint64_t intMin, intMax;
267 static_assert(
sizeof(min) ==
sizeof(intMin) &&
sizeof(max) ==
sizeof(intMax));
268 memcpy(&intMin, &min,
sizeof(min));
269 memcpy(&intMax, &max,
sizeof(max));
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,
286 void *buffer,
bool forHeaderExtension)
288 auto base =
reinterpret_cast<unsigned char *
>(buffer);
290 void **where = (buffer ==
nullptr) ? &buffer : reinterpret_cast<void **>(&pos);
294 std::vector<const ROOT::RColumnDescriptor *> columnsToSerialize;
295 for (
auto parentId : fieldList) {
299 if (xHeader && xHeader->ContainsField(parentId))
302 for (
const auto &
c : desc.GetColumnIterable(parentId)) {
303 if (
c.IsAliasColumn() || (xHeader && xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
305 columnsToSerialize.push_back(&
c);
312 std::sort(columnsToSerialize.begin(), columnsToSerialize.end(), [&context](
const auto *
a,
const auto *
b) {
313 return context.GetOnDiskColumnId(a->GetPhysicalId()) < context.GetOnDiskColumnId(b->GetPhysicalId());
316 for (
const auto *
c : columnsToSerialize) {
317 if (
auto res = SerializePhysicalColumn(*
c, context, *where)) {
332 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
334 std::uint64_t frameSize;
335 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
336 if (
auto res = RNTupleSerializer::DeserializeFrameHeader(
bytes, bufSize, frameSize)) {
337 bytes += res.Unwrap();
344 std::uint16_t bitsOnStorage;
345 std::uint32_t fieldId;
347 std::uint16_t representationIndex;
348 std::int64_t firstElementIdx = 0;
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();
358 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, bitsOnStorage);
359 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, fieldId);
360 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
361 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, representationIndex);
362 if (flags & RNTupleSerializer::kFlagDeferredColumn) {
363 if (fnFrameSizeLeft() <
sizeof(std::uint64_t))
364 return R__FAIL(
"column record frame too short");
365 bytes += RNTupleSerializer::DeserializeInt64(
bytes, firstElementIdx);
367 if (flags & RNTupleSerializer::kFlagHasValueRange) {
368 if (fnFrameSizeLeft() < 2 *
sizeof(std::uint64_t))
369 return R__FAIL(
"field record frame too short");
370 std::uint64_t minInt, maxInt;
371 bytes += RNTupleSerializer::DeserializeUInt64(
bytes, minInt);
372 bytes += RNTupleSerializer::DeserializeUInt64(
bytes, maxInt);
374 memcpy(&min, &minInt,
sizeof(min));
375 memcpy(&max, &maxInt,
sizeof(max));
381 if (firstElementIdx < 0)
389 auto base =
reinterpret_cast<unsigned char *
>(buffer);
391 void **where = (buffer ==
nullptr) ? &buffer : reinterpret_cast<void **>(&pos);
393 pos += RNTupleSerializer::SerializeRecordFramePreamble(*where);
395 if (
auto res = RNTupleSerializer::SerializeExtraTypeInfoId(desc.
GetContentId(), *where)) {
400 pos += RNTupleSerializer::SerializeUInt32(desc.
GetTypeVersion(), *where);
401 pos += RNTupleSerializer::SerializeString(desc.
GetTypeName(), *where);
402 pos += RNTupleSerializer::SerializeString(desc.
GetContent(), *where);
404 auto size = pos - base;
405 RNTupleSerializer::SerializeFramePostscript(base,
size);
412 auto base =
reinterpret_cast<unsigned char *
>(buffer);
414 void **where = (buffer ==
nullptr) ? &buffer : reinterpret_cast<void **>(&pos);
416 for (
const auto &extraTypeInfoDesc : ntplDesc.GetExtraTypeInfoIterable()) {
417 if (
auto res = SerializeExtraTypeInfo(extraTypeInfoDesc, *where)) {
432 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
434 std::uint64_t frameSize;
435 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
436 auto result = RNTupleSerializer::DeserializeFrameHeader(
bytes, bufSize, frameSize);
441 EExtraTypeInfoIds contentId{EExtraTypeInfoIds::kInvalid};
442 std::uint32_t typeVersion;
443 if (fnFrameSizeLeft() < 2 *
sizeof(std::uint32_t)) {
444 return R__FAIL(
"extra type info record frame too short");
446 result = RNTupleSerializer::DeserializeExtraTypeInfoId(
bytes, contentId);
450 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, typeVersion);
452 std::string typeName;
454 result = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), typeName).Unwrap();
458 result = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), content).Unwrap();
468std::uint32_t SerializeLocatorPayloadLarge(
const ROOT::RNTupleLocator &locator,
unsigned char *buffer)
472 RNTupleSerializer::SerializeUInt64(locator.
GetPosition<std::uint64_t>(), buffer +
sizeof(std::uint64_t));
474 return sizeof(std::uint64_t) +
sizeof(std::uint64_t);
479 std::uint64_t nBytesOnStorage;
480 std::uint64_t position;
481 RNTupleSerializer::DeserializeUInt64(buffer, nBytesOnStorage);
482 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), position);
487std::uint32_t SerializeLocatorPayloadObject64(
const ROOT::RNTupleLocator &locator,
unsigned char *buffer)
490 const uint32_t sizeofNBytesOnStorage = (locator.
GetNBytesOnStorage() > std::numeric_limits<std::uint32_t>::max())
491 ?
sizeof(std::uint64_t)
492 :
sizeof(std::uint32_t);
494 if (sizeofNBytesOnStorage ==
sizeof(std::uint32_t)) {
499 RNTupleSerializer::SerializeUInt64(
data.GetLocation(), buffer + sizeofNBytesOnStorage);
501 return sizeofNBytesOnStorage +
sizeof(std::uint64_t);
504ROOT::RResult<void> DeserializeLocatorPayloadObject64(
const unsigned char *buffer, std::uint32_t sizeofLocatorPayload,
507 std::uint64_t location;
508 if (sizeofLocatorPayload == 12) {
509 std::uint32_t nBytesOnStorage;
510 RNTupleSerializer::DeserializeUInt32(buffer, nBytesOnStorage);
512 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint32_t), location);
513 }
else if (sizeofLocatorPayload == 16) {
514 std::uint64_t nBytesOnStorage;
515 RNTupleSerializer::DeserializeUInt64(buffer, nBytesOnStorage);
517 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint64_t), location);
519 return R__FAIL(
"invalid Object64 locator payload size: " + std::to_string(sizeofLocatorPayload));
525std::uint32_t SerializeLocatorPayloadMulti(
const ROOT::RNTupleLocator &locator,
unsigned char *buffer)
529 void *bufferVoid = buffer;
532 void **where = (buffer ==
nullptr) ? &bufferVoid : reinterpret_cast<void **>(&pos);
539 pos += RNTupleSerializer::SerializeUInt32(
data.GetObjectId(), *where);
540 pos += RNTupleSerializer::SerializeUInt32(
data.GetOffset(), *where);
545ROOT::RResult<void> DeserializeLocatorPayloadMulti(
const unsigned char *buffer, std::uint32_t sizeofLocatorPayload,
548 const unsigned char *pos = buffer;
549 if (sizeofLocatorPayload == 12) {
550 std::uint32_t nBytesOnStorage;
551 pos += RNTupleSerializer::DeserializeUInt32(pos, nBytesOnStorage);
553 }
else if (sizeofLocatorPayload == 16) {
554 std::uint64_t nBytesOnStorage;
555 pos += RNTupleSerializer::DeserializeUInt64(pos, nBytesOnStorage);
558 return R__FAIL(
"invalid Multi locator payload size: " + std::to_string(sizeofLocatorPayload));
560 std::uint32_t objectId;
562 pos += RNTupleSerializer::DeserializeUInt32(pos, objectId);
563 RNTupleSerializer::DeserializeUInt32(pos,
offset);
573 auto base =
reinterpret_cast<unsigned char *
>(buffer);
575 void **where = (buffer ==
nullptr) ? &buffer : reinterpret_cast<void **>(&pos);
577 pos += RNTupleSerializer::SerializeRecordFramePreamble(*where);
582 pos += RNTupleSerializer::SerializeFramePostscript(buffer ? base : nullptr, pos - base).Unwrap();
588 std::span<const ROOT::DescriptorId_t> fieldList,
590 bool forHeaderExtension)
592 auto base =
reinterpret_cast<unsigned char *
>(buffer);
594 void **where = (buffer ==
nullptr) ? &buffer : reinterpret_cast<void **>(&pos);
598 for (
auto parentId : fieldList) {
599 if (xHeader && xHeader->ContainsField(parentId))
602 for (
const auto &
c : desc.GetColumnIterable(parentId)) {
603 if (!
c.IsAliasColumn() || (xHeader && xHeader->ContainsExtendedColumnRepresentation(
c.GetLogicalId())))
606 pos += SerializeAliasColumn(
c, context, *where);
614 std::uint32_t &physicalColumnId, std::uint32_t &fieldId)
616 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
618 std::uint64_t frameSize;
619 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
620 auto result = RNTupleSerializer::DeserializeFrameHeader(
bytes, bufSize, frameSize);
625 if (fnFrameSizeLeft() < 2 *
sizeof(std::uint32_t)) {
626 return R__FAIL(
"alias column record frame too short");
629 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, physicalColumnId);
630 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, fieldId);
638 std::uint64_t &xxhash3,
void *buffer)
640 if (buffer !=
nullptr) {
648 std::uint64_t &xxhash3)
650 auto checksumReal = XXH3_64bits(
data,
length);
652 if (xxhash3 != checksumReal)
653 return R__FAIL(
"XxHash-3 checksum mismatch");
659 std::uint64_t xxhash3;
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");
827 std::uint16_t onDiskType;
828 auto result = DeserializeUInt16(buffer, onDiskType);
830 switch (onDiskType) {
881 return SerializeUInt16(0x99, buffer);
882 return R__FAIL(
"unexpected field structure type");
890 std::uint16_t onDiskValue;
891 auto result = DeserializeUInt16(buffer, onDiskValue);
892 switch (onDiskValue) {
909 default:
return R__FAIL(
"unexpected extra type info id");
916 std::uint32_t onDiskValue;
917 auto result = DeserializeUInt32(buffer, onDiskValue);
918 switch (onDiskValue) {
929 auto base =
reinterpret_cast<unsigned char *
>(buffer);
931 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
933 pos += SerializeUInt64(envelopeType, *where);
940 std::uint64_t &xxhash3)
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");
947 std::uint64_t typeAndSize;
948 DeserializeUInt64(envelope, typeAndSize);
949 typeAndSize |= (
size + 8) << 16;
950 SerializeUInt64(typeAndSize, envelope);
952 return SerializeXxHash3(envelope,
size, xxhash3, envelope ? (envelope +
size) :
nullptr);
958 std::uint64_t xxhash3;
964 std::uint16_t expectedType, std::uint64_t &xxhash3)
966 const std::uint64_t minEnvelopeSize =
sizeof(std::uint64_t) +
sizeof(std::uint64_t);
967 if (bufSize < minEnvelopeSize)
968 return R__FAIL(
"invalid envelope buffer, too short");
970 const auto *
bytes =
reinterpret_cast<const unsigned char *
>(buffer);
971 const auto *base =
bytes;
973 std::uint64_t typeAndSize;
974 DeserializeUInt64(
bytes, typeAndSize);
976 std::uint16_t envelopeType = typeAndSize & 0xFFFF;
977 if (envelopeType != expectedType) {
978 return R__FAIL(
"envelope type mismatch: expected " + std::to_string(expectedType) +
", found " +
979 std::to_string(envelopeType));
982 std::uint64_t envelopeSize = typeAndSize >> 16;
983 if (bufSize < envelopeSize)
984 return R__FAIL(
"envelope buffer size too small");
985 if (envelopeSize < minEnvelopeSize)
986 return R__FAIL(
"invalid envelope, too short");
988 auto result = VerifyXxHash3(base, envelopeSize - 8, xxhash3);
992 return sizeof(typeAndSize);
996 std::uint64_t bufSize,
997 std::uint16_t expectedType)
999 std::uint64_t xxhash3;
1000 return R__FORWARD_RESULT(DeserializeEnvelope(buffer, bufSize, expectedType, xxhash3));
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);
1017 pos += SerializeUInt32(
nitems, *where);
1024 auto preambleSize =
sizeof(std::int64_t);
1025 if (
size < preambleSize)
1026 return R__FAIL(
"frame too short: " + std::to_string(
size));
1028 std::int64_t marker;
1029 DeserializeInt64(frame, marker);
1030 if ((marker < 0) && (
size < (
sizeof(std::uint32_t) + preambleSize)))
1031 return R__FAIL(
"frame too short: " + std::to_string(
size));
1032 SerializeInt64(marker *
static_cast<int64_t
>(
size), frame);
1039 std::uint64_t &frameSize, std::uint32_t &
nitems)
1041 std::uint64_t minSize =
sizeof(std::int64_t);
1042 if (bufSize < minSize)
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);
1057 if (bufSize < minSize)
1058 return R__FAIL(
"frame too short");
1063 if (frameSize < minSize)
1064 return R__FAIL(
"corrupt frame size");
1065 if (bufSize < frameSize)
1066 return R__FAIL(
"frame too short");
1068 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1072 std::uint64_t bufSize,
1073 std::uint64_t &frameSize)
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;
1132 buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1136 std::uint8_t locatorType = 0;
1137 auto payloadp = buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
sizeof(std::int32_t) :
nullptr;
1140 size += SerializeLocatorPayloadLarge(locator, payloadp);
1144 size += SerializeLocatorPayloadObject64(locator, payloadp);
1148 size += SerializeLocatorPayloadMulti(locator, payloadp);
1156 size += SerializeLocatorPayloadObject64(dummy, payloadp);
1159 return R__FAIL(
"locator has unknown type");
1162 std::int32_t head =
sizeof(std::int32_t) +
size;
1164 head |=
static_cast<int>(locatorType & 0x7F) << 24;
1171 std::uint64_t bufSize,
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);
1186 if (bufSize < payloadSize)
1187 return R__FAIL(
"too short locator");
1189 locator.
SetReserved(
static_cast<std::uint32_t
>(head >> 16) & 0xFF);
1193 DeserializeLocatorPayloadLarge(
bytes, locator);
1197 auto res = DeserializeLocatorPayloadObject64(
bytes, payloadSize, locator);
1204 auto res = DeserializeLocatorPayloadMulti(
bytes, payloadSize, locator);
1211 bytes += payloadSize;
1213 if (bufSize <
sizeof(std::uint64_t))
1214 return R__FAIL(
"too short locator");
1222 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
1228 auto size = SerializeUInt64(envelopeLink.
fLength, buffer);
1230 SerializeLocator(envelopeLink.
fLocator, buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
1232 size += res.Unwrap();
1239 std::uint64_t bufSize,
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);
1248 if (
auto res = DeserializeLocator(
bytes, bufSize, envelopeLink.
fLocator)) {
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");
1261 }
else if (clusterSummary.
fNEntries == 0) {
1262 return R__FAIL(
"invalid serialization of empty cluster");
1265 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1267 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1270 pos += SerializeRecordFramePreamble(*where);
1271 pos += SerializeUInt64(clusterSummary.
fFirstEntry, *where);
1272 const std::uint64_t nEntriesAndFlags =
1273 (
static_cast<std::uint64_t
>(clusterSummary.
fFlags) << 56) | clusterSummary.
fNEntries;
1274 pos += SerializeUInt64(nEntriesAndFlags, *where);
1276 auto size = pos - frame;
1277 if (
auto res = SerializeFramePostscript(frame,
size)) {
1278 pos += res.Unwrap();
1289 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1291 std::uint64_t frameSize;
1292 if (
auto res = DeserializeFrameHeader(
bytes, bufSize, frameSize)) {
1293 bytes += res.Unwrap();
1298 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
1299 if (fnFrameSizeLeft() < 2 *
sizeof(std::uint64_t))
1300 return R__FAIL(
"too short cluster summary");
1303 std::uint64_t nEntriesAndFlags;
1304 bytes += DeserializeUInt64(
bytes, nEntriesAndFlags);
1306 const std::uint64_t nEntries = (nEntriesAndFlags << 8) >> 8;
1307 const std::uint8_t flags = nEntriesAndFlags >> 56;
1310 return R__FAIL(
"sharded cluster flag set in cluster summary; sharded clusters are currently unsupported.");
1314 clusterSummary.
fFlags = flags;
1323 return R__FAIL(
"invalid serialization of empty cluster group");
1326 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1328 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1331 pos += SerializeRecordFramePreamble(*where);
1332 pos += SerializeUInt64(clusterGroup.
fMinEntry, *where);
1333 pos += SerializeUInt64(clusterGroup.
fEntrySpan, *where);
1334 pos += SerializeUInt32(clusterGroup.
fNClusters, *where);
1336 pos += res.Unwrap();
1340 auto size = pos - frame;
1341 if (
auto res = SerializeFramePostscript(frame,
size)) {
1349 std::uint64_t bufSize,
1352 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1355 std::uint64_t frameSize;
1356 if (
auto res = DeserializeFrameHeader(
bytes, bufSize, frameSize)) {
1357 bytes += res.Unwrap();
1362 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
1363 if (fnFrameSizeLeft() <
sizeof(std::uint32_t) + 2 *
sizeof(std::uint64_t))
1364 return R__FAIL(
"too short cluster group");
1370 bytes += res.Unwrap();
1379 bool forHeaderExtension)
1382 auto depthFirstTraversal = [&](std::span<ROOT::DescriptorId_t> fieldTrees,
auto doForEachField) {
1383 std::deque<ROOT::DescriptorId_t> idQueue{fieldTrees.begin(), fieldTrees.end()};
1384 while (!idQueue.empty()) {
1385 auto fieldId = idQueue.front();
1386 idQueue.pop_front();
1388 if (fieldId != fieldZeroId)
1389 doForEachField(fieldId);
1392 idQueue.insert(idQueue.begin() + i++,
f.GetId());
1398 std::vector<ROOT::DescriptorId_t> fieldTrees;
1399 if (!forHeaderExtension) {
1400 fieldTrees.emplace_back(fieldZeroId);
1402 fieldTrees = xHeader->GetTopMostFields(desc);
1407 if (!
c.IsAliasColumn()) {
1408 MapPhysicalColumnId(
c.GetPhysicalId());
1413 if (forHeaderExtension) {
1427 const RContext &context,
bool forHeaderExtension)
1429 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1431 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1433 std::size_t nFields = 0, nColumns = 0, nAliasColumns = 0, fieldListOffset = 0;
1435 std::vector<std::reference_wrapper<const ROOT::RColumnDescriptor>> extraColumns;
1436 if (forHeaderExtension) {
1440 nFields = xHeader->GetNFields();
1441 nColumns = xHeader->GetNPhysicalColumns();
1442 nAliasColumns = xHeader->GetNLogicalColumns() - xHeader->GetNPhysicalColumns();
1443 fieldListOffset = desc.
GetNFields() - nFields - 1;
1445 extraColumns.reserve(xHeader->GetExtendedColumnRepresentations().size());
1446 for (
auto columnId : xHeader->GetExtendedColumnRepresentations()) {
1452 nFields = desc.
GetNFields() - xHeader->GetNFields() - 1;
1455 (xHeader->GetNLogicalColumns() - xHeader->GetNPhysicalColumns());
1464 R__ASSERT(onDiskFields.size() >= fieldListOffset);
1465 std::span<const ROOT::DescriptorId_t> fieldList{onDiskFields.data() + fieldListOffset, nFields};
1468 pos += SerializeListFramePreamble(nFields, *where);
1469 if (
auto res = SerializeFieldList(desc, fieldList, fieldListOffset, context, *where)) {
1470 pos += res.Unwrap();
1474 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1475 pos += res.Unwrap();
1481 pos += SerializeListFramePreamble(nColumns, *where);
1482 if (
auto res = SerializeColumnsOfFields(desc, fieldList, context, *where, forHeaderExtension)) {
1483 pos += res.Unwrap();
1487 for (
const auto &
c : extraColumns) {
1488 if (!
c.get().IsAliasColumn()) {
1489 if (
auto res = SerializePhysicalColumn(
c.get(), context, *where)) {
1490 pos += res.Unwrap();
1496 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1497 pos += res.Unwrap();
1503 pos += SerializeListFramePreamble(nAliasColumns, *where);
1504 pos += SerializeAliasColumnsOfFields(desc, fieldList, context, *where, forHeaderExtension);
1505 for (
const auto &
c : extraColumns) {
1506 if (
c.get().IsAliasColumn()) {
1507 pos += SerializeAliasColumn(
c.get(), context, *where);
1510 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1511 pos += res.Unwrap();
1518 if (forHeaderExtension) {
1519 pos += SerializeListFramePreamble(nExtraTypeInfos, *where);
1520 if (
auto res = SerializeExtraTypeInfoList(desc, *where)) {
1521 pos += res.Unwrap();
1526 pos += SerializeListFramePreamble(0, *where);
1528 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1529 pos += res.Unwrap();
1534 return static_cast<std::uint32_t
>(pos - base);
1541 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1543 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1545 std::uint64_t frameSize;
1547 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - frame); };
1549 std::uint32_t nFields;
1550 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nFields)) {
1551 bytes += res.Unwrap();
1557 for (
unsigned i = 0; i < nFields; ++i) {
1558 std::uint32_t fieldId = fieldIdRangeBegin + i;
1560 if (
auto res = DeserializeField(
bytes, fnFrameSizeLeft(), fieldBuilder)) {
1561 bytes += res.Unwrap();
1566 fieldBuilder.
ParentId(kZeroFieldId);
1570 const auto parentId = fieldDesc.Inspect().
GetParentId();
1571 const auto projectionSourceId = fieldDesc.Inspect().GetProjectionSourceId();
1572 descBuilder.
AddField(fieldDesc.Unwrap());
1573 auto resVoid = descBuilder.
AddFieldLink(parentId, fieldId);
1582 bytes = frame + frameSize;
1587 std::uint16_t representationIndex) -> std::uint32_t {
1589 if (existingColumns.empty())
1592 return (representationIndex == lastColumnDesc.GetRepresentationIndex()) ? (lastColumnDesc.GetIndex() + 1) : 0;
1595 std::uint32_t nColumns;
1597 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nColumns)) {
1598 bytes += res.Unwrap();
1607 for (
unsigned i = 0; i < nColumns; ++i) {
1608 std::uint32_t columnId = columnIdRangeBegin + i;
1610 if (
auto res = DeserializeColumn(
bytes, fnFrameSizeLeft(), columnBuilder)) {
1611 bytes += res.Unwrap();
1622 auto resVoid = descBuilder.
AddColumn(columnDesc.Unwrap());
1626 bytes = frame + frameSize;
1628 std::uint32_t nAliasColumns;
1630 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nAliasColumns)) {
1631 bytes += res.Unwrap();
1636 for (
unsigned i = 0; i < nAliasColumns; ++i) {
1637 std::uint32_t physicalId;
1638 std::uint32_t fieldId;
1639 if (
auto res = DeserializeAliasColumn(
bytes, fnFrameSizeLeft(), physicalId, fieldId)) {
1640 bytes += res.Unwrap();
1648 columnBuilder.
BitsOnStorage(physicalColumnDesc.GetBitsOnStorage());
1649 columnBuilder.
ValueRange(physicalColumnDesc.GetValueRange());
1650 columnBuilder.
Type(physicalColumnDesc.GetType());
1655 if (!aliasColumnDesc)
1657 auto resVoid = descBuilder.
AddColumn(aliasColumnDesc.Unwrap());
1661 bytes = frame + frameSize;
1663 std::uint32_t nExtraTypeInfos;
1665 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nExtraTypeInfos)) {
1666 bytes += res.Unwrap();
1670 for (
unsigned i = 0; i < nExtraTypeInfos; ++i) {
1672 if (
auto res = DeserializeExtraTypeInfo(
bytes, fnFrameSizeLeft(), extraTypeInfoBuilder)) {
1673 bytes += res.Unwrap();
1680 if (extraTypeInfoDesc)
1683 bytes = frame + frameSize;
1685 return bytes - base;
1693 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1695 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1697 pos += SerializeEnvelopePreamble(kEnvelopeTypeHeader, *where);
1698 if (
auto res = SerializeFeatureFlags(desc.
GetFeatureFlags(), *where)) {
1699 pos += res.Unwrap();
1703 pos += SerializeString(desc.
GetName(), *where);
1705 pos += SerializeString(std::string(
"ROOT v") +
ROOT_RELEASE, *where);
1709 if (
auto res = SerializeSchemaDescription(*where, desc, context)) {
1710 pos += res.Unwrap();
1715 std::uint64_t
size = pos - base;
1716 std::uint64_t xxhash3 = 0;
1717 if (
auto res = SerializeEnvelopePostscript(base,
size, xxhash3)) {
1718 size += res.Unwrap();
1730 std::span<ROOT::DescriptorId_t> physClusterIDs,
1733 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1735 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1737 pos += SerializeEnvelopePreamble(kEnvelopeTypePageList, *where);
1742 const auto nClusters = physClusterIDs.size();
1743 auto clusterSummaryFrame = pos;
1744 pos += SerializeListFramePreamble(nClusters, *where);
1745 for (
auto clusterId : physClusterIDs) {
1747 RClusterSummary summary{clusterDesc.GetFirstEntryIndex(), clusterDesc.GetNEntries(), 0};
1748 if (
auto res = SerializeClusterSummary(summary, *where)) {
1749 pos += res.Unwrap();
1754 if (
auto res = SerializeFramePostscript(buffer ? clusterSummaryFrame :
nullptr, pos - clusterSummaryFrame)) {
1755 pos += res.Unwrap();
1761 auto topMostFrame = pos;
1762 pos += SerializeListFramePreamble(nClusters, *where);
1764 for (
auto clusterId : physClusterIDs) {
1767 std::set<ROOT::DescriptorId_t> onDiskColumnIds;
1768 for (
const auto &columnRange : clusterDesc.GetColumnRangeIterable())
1769 onDiskColumnIds.insert(context.
GetOnDiskColumnId(columnRange.GetPhysicalColumnId()));
1771 auto outerFrame = pos;
1772 pos += SerializeListFramePreamble(onDiskColumnIds.size(), *where);
1773 for (
auto onDiskId : onDiskColumnIds) {
1775 const auto &columnRange = clusterDesc.GetColumnRange(memId);
1777 auto innerFrame = pos;
1778 if (columnRange.IsSuppressed()) {
1780 pos += SerializeListFramePreamble(0, *where);
1781 pos += SerializeInt64(kSuppressedColumnMarker, *where);
1783 const auto &pageRange = clusterDesc.GetPageRange(memId);
1784 pos += SerializeListFramePreamble(pageRange.GetPageInfos().size(), *where);
1786 for (
const auto &pi : pageRange.GetPageInfos()) {
1787 std::int32_t nElements =
1788 pi.HasChecksum() ? -
static_cast<std::int32_t
>(pi.GetNElements()) : pi.GetNElements();
1789 pos += SerializeUInt32(nElements, *where);
1790 if (
auto res = SerializeLocator(pi.GetLocator(), *where)) {
1791 pos += res.Unwrap();
1796 pos += SerializeInt64(columnRange.GetFirstElementIndex(), *where);
1797 pos += SerializeUInt32(columnRange.GetCompressionSettings().value(), *where);
1800 if (
auto res = SerializeFramePostscript(buffer ? innerFrame :
nullptr, pos - innerFrame)) {
1801 pos += res.Unwrap();
1806 if (
auto res = SerializeFramePostscript(buffer ? outerFrame :
nullptr, pos - outerFrame)) {
1807 pos += res.Unwrap();
1813 if (
auto res = SerializeFramePostscript(buffer ? topMostFrame :
nullptr, pos - topMostFrame)) {
1814 pos += res.Unwrap();
1818 std::uint64_t
size = pos - base;
1819 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1820 size += res.Unwrap();
1831 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1833 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1835 pos += SerializeEnvelopePreamble(kEnvelopeTypeFooter, *where);
1839 if (
auto res = SerializeFeatureFlags(desc.
GetFeatureFlags(), *where)) {
1840 pos += res.Unwrap();
1848 pos += SerializeRecordFramePreamble(*where);
1849 if (
auto res = SerializeSchemaDescription(*where, desc, context,
true)) {
1850 pos += res.Unwrap();
1854 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1855 pos += res.Unwrap();
1863 pos += SerializeListFramePreamble(nClusterGroups, *where);
1864 for (
unsigned int i = 0; i < nClusterGroups; ++i) {
1867 clusterGroup.
fMinEntry = cgDesc.GetMinEntry();
1868 clusterGroup.
fEntrySpan = cgDesc.GetEntrySpan();
1869 clusterGroup.
fNClusters = cgDesc.GetNClusters();
1872 if (
auto res = SerializeClusterGroup(clusterGroup, *where)) {
1873 pos += res.Unwrap();
1878 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1879 pos += res.Unwrap();
1887 if (nAttributeSets > 0) {
1889 "back in the future (but your main data is)";
1891 pos += SerializeListFramePreamble(nAttributeSets, *where);
1893 if (
auto res = SerializeAttributeSet(attrSet, *where)) {
1894 pos += res.Unwrap();
1899 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1900 pos += res.Unwrap();
1905 std::uint32_t
size = pos - base;
1906 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1907 size += res.Unwrap();
1918 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1920 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1928 pos += res.Unwrap();
1932 pos += SerializeString(attrDesc.
GetName(), *where);
1933 auto size = pos - frame;
1934 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr,
size)) {
1943 for (std::size_t i = 0; i < featureFlags.size(); ++i) {
1944 if (!featureFlags[i])
1949 return R__FAIL(
"unsupported format feature: " + std::to_string(highestBitSet));
1957 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1959 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1961 std::uint64_t xxhash3{0};
1962 if (
auto res = DeserializeEnvelope(
bytes, fnBufSizeLeft(), kEnvelopeTypeHeader, xxhash3)) {
1963 bytes += res.Unwrap();
1969 std::vector<std::uint64_t> featureFlags;
1970 if (
auto res = DeserializeFeatureFlags(
bytes, fnBufSizeLeft(), featureFlags)) {
1971 bytes += res.Unwrap();
1980 std::string description;
1982 if (
auto res = DeserializeString(
bytes, fnBufSizeLeft(),
name)) {
1983 bytes += res.Unwrap();
1987 if (
auto res = DeserializeString(
bytes, fnBufSizeLeft(), description)) {
1988 bytes += res.Unwrap();
1992 if (
auto res = DeserializeString(
bytes, fnBufSizeLeft(),
writer)) {
1993 bytes += res.Unwrap();
2005 if (
auto res = DeserializeSchemaDescription(
bytes, fnBufSizeLeft(), descBuilder)) {
2015 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2017 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
2018 if (
auto res = DeserializeEnvelope(
bytes, fnBufSizeLeft(), kEnvelopeTypeFooter)) {
2019 bytes += res.Unwrap();
2024 std::vector<std::uint64_t> featureFlags;
2025 if (
auto res = DeserializeFeatureFlags(
bytes, fnBufSizeLeft(), featureFlags)) {
2026 bytes += res.Unwrap();
2034 std::uint64_t xxhash3{0};
2035 if (fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2036 return R__FAIL(
"footer too short");
2039 return R__FAIL(
"XxHash-3 mismatch between header and footer");
2041 std::uint64_t frameSize;
2043 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - frame); };
2045 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize)) {
2046 bytes += res.Unwrap();
2050 if (fnFrameSizeLeft() > 0) {
2052 if (
auto res = DeserializeSchemaDescription(
bytes, fnFrameSizeLeft(), descBuilder); !res) {
2056 bytes = frame + frameSize;
2059 std::uint32_t nClusterGroups;
2061 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nClusterGroups)) {
2062 bytes += res.Unwrap();
2066 for (std::uint32_t groupId = 0; groupId < nClusterGroups; ++groupId) {
2068 if (
auto res = DeserializeClusterGroup(
bytes, fnFrameSizeLeft(), clusterGroup)) {
2069 bytes += res.Unwrap();
2084 bytes = frame + frameSize;
2089 if (fnBufSizeLeft() > 8) {
2090 std::uint32_t nAttributeSets;
2092 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nAttributeSets)) {
2093 bytes += res.Unwrap();
2097 if (nAttributeSets > 0) {
2099 "back in the future (but your main data is)";
2101 for (std::uint32_t attrSetId = 0; attrSetId < nAttributeSets; ++attrSetId) {
2103 if (
auto res = DeserializeAttributeSet(
bytes, fnBufSizeLeft(), attrSetDescBld)) {
2105 bytes += res.Unwrap();
2110 bytes = frame + frameSize;
2119 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2121 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
2123 std::uint64_t frameSize;
2124 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize)) {
2125 bytes += res.Unwrap();
2129 if (fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2130 return R__FAIL(
"record frame too short");
2131 std::uint16_t vMajor, vMinor;
2134 std::uint32_t anchorLen;
2135 bytes += DeserializeUInt32(
bytes, anchorLen);
2137 if (
auto res = DeserializeLocator(
bytes, fnBufSizeLeft(), anchorLoc)) {
2138 bytes += res.Unwrap();
2143 if (
auto res = DeserializeString(
bytes, fnBufSizeLeft(),
name)) {
2144 bytes += res.Unwrap();
2159 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2161 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
2163 if (
auto res = DeserializeEnvelope(
bytes, fnBufSizeLeft(), kEnvelopeTypePageList)) {
2164 bytes += res.Unwrap();
2169 std::uint64_t xxhash3{0};
2170 if (fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2171 return R__FAIL(
"page list too short");
2174 return R__FAIL(
"XxHash-3 mismatch between header and page list");
2176 std::vector<RClusterDescriptorBuilder> clusterBuilders;
2182 std::uint64_t clusterSummaryFrameSize;
2183 auto clusterSummaryFrame =
bytes;
2184 auto fnClusterSummaryFrameSizeLeft = [&]() {
return clusterSummaryFrameSize - (
bytes - clusterSummaryFrame); };
2186 std::uint32_t nClusterSummaries;
2187 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), clusterSummaryFrameSize, nClusterSummaries)) {
2188 bytes += res.Unwrap();
2192 for (
auto clusterId = firstClusterId; clusterId < firstClusterId + nClusterSummaries; ++clusterId) {
2194 if (
auto res = DeserializeClusterSummary(
bytes, fnClusterSummaryFrameSizeLeft(), clusterSummary)) {
2195 bytes += res.Unwrap();
2202 clusterBuilders.emplace_back(std::move(builder));
2204 bytes = clusterSummaryFrame + clusterSummaryFrameSize;
2206 std::uint64_t topMostFrameSize;
2207 auto topMostFrame =
bytes;
2208 auto fnTopMostFrameSizeLeft = [&]() {
return topMostFrameSize - (
bytes - topMostFrame); };
2210 std::uint32_t nClusters;
2211 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), topMostFrameSize, nClusters)) {
2212 bytes += res.Unwrap();
2217 if (nClusters != nClusterSummaries)
2218 return R__FAIL(
"mismatch between number of clusters and number of cluster summaries");
2220 for (std::uint32_t i = 0; i < nClusters; ++i) {
2221 std::uint64_t outerFrameSize;
2222 auto outerFrame =
bytes;
2223 auto fnOuterFrameSizeLeft = [&]() {
return outerFrameSize - (
bytes - outerFrame); };
2225 std::uint32_t nColumns;
2226 if (
auto res = DeserializeFrameHeader(
bytes, fnTopMostFrameSizeLeft(), outerFrameSize, nColumns)) {
2227 bytes += res.Unwrap();
2232 for (std::uint32_t j = 0; j < nColumns; ++j) {
2233 std::uint64_t innerFrameSize;
2234 auto innerFrame =
bytes;
2235 auto fnInnerFrameSizeLeft = [&]() {
return innerFrameSize - (
bytes - innerFrame); };
2237 std::uint32_t nPages;
2238 if (
auto res = DeserializeFrameHeader(
bytes, fnOuterFrameSizeLeft(), innerFrameSize, nPages)) {
2239 bytes += res.Unwrap();
2246 for (std::uint32_t k = 0; k < nPages; ++k) {
2247 if (fnInnerFrameSizeLeft() <
static_cast<int>(
sizeof(std::uint32_t)))
2248 return R__FAIL(
"inner frame too short");
2249 std::int32_t nElements;
2250 bool hasChecksum =
false;
2253 if (nElements < 0) {
2254 nElements = -nElements;
2257 if (
auto res = DeserializeLocator(
bytes, fnInnerFrameSizeLeft(), locator)) {
2258 bytes += res.Unwrap();
2262 pageRange.
GetPageInfos().push_back({
static_cast<std::uint32_t
>(nElements), locator, hasChecksum});
2265 if (fnInnerFrameSizeLeft() <
static_cast<int>(
sizeof(std::int64_t)))
2266 return R__FAIL(
"page list frame too short");
2267 std::int64_t columnOffset;
2268 bytes += DeserializeInt64(
bytes, columnOffset);
2269 if (columnOffset < 0) {
2271 return R__FAIL(
"unexpected non-empty page list");
2272 clusterBuilders[i].MarkSuppressedColumnRange(j);
2274 if (fnInnerFrameSizeLeft() <
static_cast<int>(
sizeof(std::uint32_t)))
2275 return R__FAIL(
"page list frame too short");
2276 std::uint32_t compressionSettings;
2277 bytes += DeserializeUInt32(
bytes, compressionSettings);
2278 clusterBuilders[i].CommitColumnRange(j, columnOffset, compressionSettings, pageRange);
2281 bytes = innerFrame + innerFrameSize;
2284 bytes = outerFrame + outerFrameSize;
2287 return clusterBuilders;
2296 if (!clusterBuildersRes)
2299 auto clusterBuilders = clusterBuildersRes.Unwrap();
2301 std::vector<ROOT::RClusterDescriptor> clusters;
2302 clusters.reserve(clusterBuilders.size());
2306 case EDescriptorDeserializeMode::kForReading:
2307 for (
auto &builder : clusterBuilders) {
2308 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2310 builder.AddExtendedColumnRanges(desc);
2311 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2314 case EDescriptorDeserializeMode::kForWriting:
2315 for (
auto &builder : clusterBuilders) {
2316 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2318 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2321 case EDescriptorDeserializeMode::kRaw:
2322 for (
auto &builder : clusterBuilders)
2323 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2334 TList streamerInfos;
2335 for (
auto si : infos) {
2336 assert(si.first == si.second->GetNumber());
2337 streamerInfos.
Add(si.second);
2341 assert(buffer.
Length() > 0);
2354 TObjLink *lnk = infoList->FirstLink();
2358 infoMap[info->GetNumber()] = info->GetClass()->GetStreamerInfo(info->GetClassVersion());
2359 assert(info->GetNumber() == infoMap[info->GetNumber()]->GetNumber());
#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
#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.
RClusterGroupDescriptorBuilder & EntrySpan(std::uint64_t entrySpan)
RClusterGroupDescriptorBuilder & PageListLocator(const RNTupleLocator &pageListLocator)
RClusterGroupDescriptorBuilder & PageListLength(std::uint64_t pageListLength)
RClusterGroupDescriptorBuilder & MinEntry(std::uint64_t minEntry)
RResult< RClusterGroupDescriptor > MoveDescriptor()
RClusterGroupDescriptorBuilder & ClusterGroupId(ROOT::DescriptorId_t clusterGroupId)
RClusterGroupDescriptorBuilder & NClusters(std::uint32_t nClusters)
A helper class for piece-wise construction of an RColumnDescriptor.
ROOT::DescriptorId_t GetRepresentationIndex() const
RColumnDescriptorBuilder & SetSuppressedDeferred()
RColumnDescriptorBuilder & LogicalColumnId(ROOT::DescriptorId_t logicalColumnId)
RColumnDescriptorBuilder & FieldId(ROOT::DescriptorId_t fieldId)
RColumnDescriptorBuilder & BitsOnStorage(std::uint16_t bitsOnStorage)
RColumnDescriptorBuilder & ValueRange(double min, double max)
RColumnDescriptorBuilder & Type(ROOT::ENTupleColumnType type)
RColumnDescriptorBuilder & PhysicalColumnId(ROOT::DescriptorId_t physicalColumnId)
RColumnDescriptorBuilder & FirstElementIndex(std::uint64_t firstElementIdx)
RColumnDescriptorBuilder & Index(std::uint32_t index)
RColumnDescriptorBuilder & RepresentationIndex(std::uint16_t representationIndex)
ROOT::DescriptorId_t GetFieldId() const
RResult< RColumnDescriptor > MoveDescriptor()
Attempt to make a column descriptor.
A helper class for piece-wise construction of an RFieldDescriptor.
RResult< RFieldDescriptor > MoveDescriptor()
Attempt to make a field descriptor.
RFieldDescriptorBuilder & NRepetitions(std::uint64_t nRepetitions)
RFieldDescriptorBuilder & Structure(const ROOT::ENTupleStructure &structure)
RFieldDescriptorBuilder & TypeAlias(const std::string &typeAlias)
RFieldDescriptorBuilder & ProjectionSourceId(ROOT::DescriptorId_t id)
RFieldDescriptorBuilder & TypeVersion(std::uint32_t typeVersion)
RFieldDescriptorBuilder & IsSoACollection(bool val)
ROOT::DescriptorId_t GetParentId() const
RFieldDescriptorBuilder & TypeChecksum(const std::optional< std::uint32_t > typeChecksum)
RFieldDescriptorBuilder & ParentId(ROOT::DescriptorId_t id)
RFieldDescriptorBuilder & FieldDescription(const std::string &fieldDescription)
RFieldDescriptorBuilder & FieldVersion(std::uint32_t fieldVersion)
RFieldDescriptorBuilder & FieldName(const std::string &fieldName)
RFieldDescriptorBuilder & FieldId(ROOT::DescriptorId_t fieldId)
RFieldDescriptorBuilder & TypeName(const std::string &typeName)
RNTupleAttrSetDescriptorBuilder & Name(std::string_view name)
RNTupleAttrSetDescriptorBuilder & SchemaVersion(std::uint16_t major, std::uint16_t minor)
RResult< ROOT::RNTupleAttrSetDescriptor > MoveDescriptor()
Attempt to make an AttributeSet descriptor.
RNTupleAttrSetDescriptorBuilder & AnchorLocator(const RNTupleLocator &loc)
RNTupleAttrSetDescriptorBuilder & AnchorLength(std::uint32_t length)
A helper class for piece-wise construction of an RNTupleDescriptor.
void SetNTuple(std::string_view name, std::string_view description)
RResult< void > AddColumn(RColumnDescriptor &&columnDesc)
void AddField(RFieldDescriptor fieldDesc)
RResult< void > AddFieldProjection(ROOT::DescriptorId_t sourceId, ROOT::DescriptorId_t targetId)
RResult< void > AddExtraTypeInfo(RExtraTypeInfoDescriptor &&extraTypeInfoDesc)
RStringPool & GetStringPool()
void ShiftAliasColumns(std::uint32_t offset)
Shift column IDs of alias columns by offset
RResult< void > AddAttributeSet(RNTupleAttrSetDescriptor &&attrSetDesc)
void BeginHeaderExtension()
Mark the beginning of the header extension; any fields and columns added after a call to this functio...
RResult< void > AddFieldLink(ROOT::DescriptorId_t fieldId, ROOT::DescriptorId_t linkId)
RNTupleDescriptor & GetDescriptor()
RResult< void > AddClusterGroup(RClusterGroupDescriptor &&clusterGroup)
void SetOnDiskHeaderXxHash3(std::uint64_t xxhash3)
void AddToOnDiskFooterSize(std::uint64_t size)
The real footer size also include the page list envelopes.
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 RResult< std::uint32_t > SerializeAttributeSet(const RNTupleAttrSetDescriptor &attrSetDesc, void *buffer)
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 > DeserializeAttributeSet(const void *buffer, std::uint64_t bufSize, Internal::RNTupleAttrSetDescriptorBuilder &attrSetDescBld)
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)
std::uint32_t GetNClusters() const
Metadata stored for every column of an RNTuple.
bool IsSuppressedDeferredColumn() const
std::optional< RValueRange > GetValueRange() const
std::uint64_t GetFirstElementIndex() const
ROOT::DescriptorId_t GetFieldId() const
bool IsAliasColumn() const
ROOT::ENTupleColumnType GetType() const
ROOT::DescriptorId_t GetPhysicalId() const
std::uint16_t GetRepresentationIndex() const
bool IsDeferredColumn() const
std::uint16_t GetBitsOnStorage() const
Metadata stored for every field of an RNTuple.
const std::string & GetTypeAlias() const
std::uint32_t GetFieldVersion() const
const std::vector< ROOT::DescriptorId_t > & GetLogicalColumnIds() const
ROOT::ENTupleStructure GetStructure() const
std::uint64_t GetNRepetitions() const
bool IsSoACollection() const
bool IsProjectedField() const
const std::string & GetFieldDescription() const
std::optional< std::uint32_t > GetTypeChecksum() const
std::uint32_t GetTypeVersion() const
const std::string & GetFieldName() const
const std::string & GetTypeName() const
Metadata stored for every Attribute Set linked to an RNTuple.
std::uint16_t GetSchemaVersionMinor() const
std::uint16_t GetSchemaVersionMajor() const
const std::string & GetName() const
const RNTupleLocator & GetAnchorLocator() const
std::uint32_t GetAnchorLength() const
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
RNTupleAttrSetDescriptorIterable GetAttrSetIterable() const
std::size_t GetNExtraTypeInfos() const
RColumnDescriptorIterable GetColumnIterable() const
const std::string & GetName() const
ROOT::NTupleSize_t R__DEPRECATED(6, 46, "This function is ill-conceived in the descriptor " "as not all cluster descriptors may be present. This interface is no longer publicly exposed.") GetNElements(ROOT ROOT::DescriptorId_t GetFieldZeroId() const
Returns the logical parent of all top-level RNTuple data fields.
std::vector< std::uint64_t > GetFeatureFlags() const
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)
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.
std::uint64_t GetNBytesOnStorage() const
ELocatorType GetType() const
For non-disk locators, the value for the Type field.
std::uint8_t GetReserved() const
We currently only support one of the 8 available reserved bits (none are used so far).
T GetPosition() const
Note that for GetPosition() / SetPosition(), the locator type must correspond (kTypeFile,...
void SetType(ELocatorType type)
void SetPosition(std::uint64_t position)
void SetReserved(std::uint8_t reserved)
See GetReserved(): we ignore the reserved flag since we don't use it anywhere currently.
void SetNBytesOnStorage(std::uint64_t nBytesOnStorage)
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.
void Add(TObject *obj) override
Wrapper around a TObject so it can be stored in a TList.
TObject * GetObject() const
Describes a persistent version of a class.
void BuildCheck(TFile *file=nullptr, Bool_t load=kTRUE) override
Check if built and consistent with the class dictionary.
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...
REnvelopeLink fPageListEnvelopeLink
std::uint64_t fFirstEntry