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");
1263 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1265 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1268 pos += SerializeRecordFramePreamble(*where);
1269 pos += SerializeUInt64(clusterSummary.
fFirstEntry, *where);
1270 const std::uint64_t nEntriesAndFlags =
1271 (
static_cast<std::uint64_t
>(clusterSummary.
fFlags) << 56) | clusterSummary.
fNEntries;
1272 pos += SerializeUInt64(nEntriesAndFlags, *where);
1274 auto size = pos - frame;
1275 if (
auto res = SerializeFramePostscript(frame,
size)) {
1276 pos += res.Unwrap();
1287 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1289 std::uint64_t frameSize;
1290 if (
auto res = DeserializeFrameHeader(
bytes, bufSize, frameSize)) {
1291 bytes += res.Unwrap();
1296 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
1297 if (fnFrameSizeLeft() < 2 *
sizeof(std::uint64_t))
1298 return R__FAIL(
"too short cluster summary");
1301 std::uint64_t nEntriesAndFlags;
1302 bytes += DeserializeUInt64(
bytes, nEntriesAndFlags);
1304 const std::uint64_t nEntries = (nEntriesAndFlags << 8) >> 8;
1305 const std::uint8_t flags = nEntriesAndFlags >> 56;
1308 return R__FAIL(
"sharded cluster flag set in cluster summary; sharded clusters are currently unsupported.");
1312 clusterSummary.
fFlags = flags;
1320 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1322 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1325 pos += SerializeRecordFramePreamble(*where);
1326 pos += SerializeUInt64(clusterGroup.
fMinEntry, *where);
1327 pos += SerializeUInt64(clusterGroup.
fEntrySpan, *where);
1328 pos += SerializeUInt32(clusterGroup.
fNClusters, *where);
1330 pos += res.Unwrap();
1334 auto size = pos - frame;
1335 if (
auto res = SerializeFramePostscript(frame,
size)) {
1343 std::uint64_t bufSize,
1346 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1349 std::uint64_t frameSize;
1350 if (
auto res = DeserializeFrameHeader(
bytes, bufSize, frameSize)) {
1351 bytes += res.Unwrap();
1356 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
1357 if (fnFrameSizeLeft() <
sizeof(std::uint32_t) + 2 *
sizeof(std::uint64_t))
1358 return R__FAIL(
"too short cluster group");
1364 bytes += res.Unwrap();
1373 bool forHeaderExtension)
1376 auto depthFirstTraversal = [&](std::span<ROOT::DescriptorId_t> fieldTrees,
auto doForEachField) {
1377 std::deque<ROOT::DescriptorId_t> idQueue{fieldTrees.begin(), fieldTrees.end()};
1378 while (!idQueue.empty()) {
1379 auto fieldId = idQueue.front();
1380 idQueue.pop_front();
1382 if (fieldId != fieldZeroId)
1383 doForEachField(fieldId);
1386 idQueue.insert(idQueue.begin() + i++,
f.GetId());
1392 std::vector<ROOT::DescriptorId_t> fieldTrees;
1393 if (!forHeaderExtension) {
1394 fieldTrees.emplace_back(fieldZeroId);
1396 fieldTrees = xHeader->GetTopMostFields(desc);
1401 if (!
c.IsAliasColumn()) {
1402 MapPhysicalColumnId(
c.GetPhysicalId());
1407 if (forHeaderExtension) {
1421 const RContext &context,
bool forHeaderExtension)
1423 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1425 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1427 std::size_t nFields = 0, nColumns = 0, nAliasColumns = 0, fieldListOffset = 0;
1429 std::vector<std::reference_wrapper<const ROOT::RColumnDescriptor>> extraColumns;
1430 if (forHeaderExtension) {
1434 nFields = xHeader->GetNFields();
1435 nColumns = xHeader->GetNPhysicalColumns();
1436 nAliasColumns = xHeader->GetNLogicalColumns() - xHeader->GetNPhysicalColumns();
1437 fieldListOffset = desc.
GetNFields() - nFields - 1;
1439 extraColumns.reserve(xHeader->GetExtendedColumnRepresentations().size());
1440 for (
auto columnId : xHeader->GetExtendedColumnRepresentations()) {
1446 nFields = desc.
GetNFields() - xHeader->GetNFields() - 1;
1449 (xHeader->GetNLogicalColumns() - xHeader->GetNPhysicalColumns());
1458 R__ASSERT(onDiskFields.size() >= fieldListOffset);
1459 std::span<const ROOT::DescriptorId_t> fieldList{onDiskFields.data() + fieldListOffset, nFields};
1462 pos += SerializeListFramePreamble(nFields, *where);
1463 if (
auto res = SerializeFieldList(desc, fieldList, fieldListOffset, context, *where)) {
1464 pos += res.Unwrap();
1468 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1469 pos += res.Unwrap();
1475 pos += SerializeListFramePreamble(nColumns, *where);
1476 if (
auto res = SerializeColumnsOfFields(desc, fieldList, context, *where, forHeaderExtension)) {
1477 pos += res.Unwrap();
1481 for (
const auto &
c : extraColumns) {
1482 if (!
c.get().IsAliasColumn()) {
1483 if (
auto res = SerializePhysicalColumn(
c.get(), context, *where)) {
1484 pos += res.Unwrap();
1490 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1491 pos += res.Unwrap();
1497 pos += SerializeListFramePreamble(nAliasColumns, *where);
1498 pos += SerializeAliasColumnsOfFields(desc, fieldList, context, *where, forHeaderExtension);
1499 for (
const auto &
c : extraColumns) {
1500 if (
c.get().IsAliasColumn()) {
1501 pos += SerializeAliasColumn(
c.get(), context, *where);
1504 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1505 pos += res.Unwrap();
1512 if (forHeaderExtension) {
1513 pos += SerializeListFramePreamble(nExtraTypeInfos, *where);
1514 if (
auto res = SerializeExtraTypeInfoList(desc, *where)) {
1515 pos += res.Unwrap();
1520 pos += SerializeListFramePreamble(0, *where);
1522 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1523 pos += res.Unwrap();
1528 return static_cast<std::uint32_t
>(pos - base);
1535 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1537 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1539 std::uint64_t frameSize;
1541 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - frame); };
1543 std::uint32_t nFields;
1544 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nFields)) {
1545 bytes += res.Unwrap();
1551 for (
unsigned i = 0; i < nFields; ++i) {
1552 std::uint32_t fieldId = fieldIdRangeBegin + i;
1554 if (
auto res = DeserializeField(
bytes, fnFrameSizeLeft(), fieldBuilder)) {
1555 bytes += res.Unwrap();
1560 fieldBuilder.
ParentId(kZeroFieldId);
1564 const auto parentId = fieldDesc.Inspect().
GetParentId();
1565 const auto projectionSourceId = fieldDesc.Inspect().GetProjectionSourceId();
1566 descBuilder.
AddField(fieldDesc.Unwrap());
1567 auto resVoid = descBuilder.
AddFieldLink(parentId, fieldId);
1576 bytes = frame + frameSize;
1581 std::uint16_t representationIndex) -> std::uint32_t {
1583 if (existingColumns.empty())
1586 return (representationIndex == lastColumnDesc.GetRepresentationIndex()) ? (lastColumnDesc.GetIndex() + 1) : 0;
1589 std::uint32_t nColumns;
1591 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nColumns)) {
1592 bytes += res.Unwrap();
1601 for (
unsigned i = 0; i < nColumns; ++i) {
1602 std::uint32_t columnId = columnIdRangeBegin + i;
1604 if (
auto res = DeserializeColumn(
bytes, fnFrameSizeLeft(), columnBuilder)) {
1605 bytes += res.Unwrap();
1616 auto resVoid = descBuilder.
AddColumn(columnDesc.Unwrap());
1620 bytes = frame + frameSize;
1622 std::uint32_t nAliasColumns;
1624 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nAliasColumns)) {
1625 bytes += res.Unwrap();
1630 for (
unsigned i = 0; i < nAliasColumns; ++i) {
1631 std::uint32_t physicalId;
1632 std::uint32_t fieldId;
1633 if (
auto res = DeserializeAliasColumn(
bytes, fnFrameSizeLeft(), physicalId, fieldId)) {
1634 bytes += res.Unwrap();
1642 columnBuilder.
BitsOnStorage(physicalColumnDesc.GetBitsOnStorage());
1643 columnBuilder.
ValueRange(physicalColumnDesc.GetValueRange());
1644 columnBuilder.
Type(physicalColumnDesc.GetType());
1649 if (!aliasColumnDesc)
1651 auto resVoid = descBuilder.
AddColumn(aliasColumnDesc.Unwrap());
1655 bytes = frame + frameSize;
1657 std::uint32_t nExtraTypeInfos;
1659 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nExtraTypeInfos)) {
1660 bytes += res.Unwrap();
1664 for (
unsigned i = 0; i < nExtraTypeInfos; ++i) {
1666 if (
auto res = DeserializeExtraTypeInfo(
bytes, fnFrameSizeLeft(), extraTypeInfoBuilder)) {
1667 bytes += res.Unwrap();
1674 if (extraTypeInfoDesc)
1677 bytes = frame + frameSize;
1679 return bytes - base;
1687 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1689 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1691 pos += SerializeEnvelopePreamble(kEnvelopeTypeHeader, *where);
1692 if (
auto res = SerializeFeatureFlags(desc.
GetFeatureFlags(), *where)) {
1693 pos += res.Unwrap();
1697 pos += SerializeString(desc.
GetName(), *where);
1699 pos += SerializeString(std::string(
"ROOT v") +
ROOT_RELEASE, *where);
1703 if (
auto res = SerializeSchemaDescription(*where, desc, context)) {
1704 pos += res.Unwrap();
1709 std::uint64_t
size = pos - base;
1710 std::uint64_t xxhash3 = 0;
1711 if (
auto res = SerializeEnvelopePostscript(base,
size, xxhash3)) {
1712 size += res.Unwrap();
1724 std::span<ROOT::DescriptorId_t> physClusterIDs,
1727 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1729 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1731 pos += SerializeEnvelopePreamble(kEnvelopeTypePageList, *where);
1736 const auto nClusters = physClusterIDs.size();
1737 auto clusterSummaryFrame = pos;
1738 pos += SerializeListFramePreamble(nClusters, *where);
1739 for (
auto clusterId : physClusterIDs) {
1741 RClusterSummary summary{clusterDesc.GetFirstEntryIndex(), clusterDesc.GetNEntries(), 0};
1742 if (
auto res = SerializeClusterSummary(summary, *where)) {
1743 pos += res.Unwrap();
1748 if (
auto res = SerializeFramePostscript(buffer ? clusterSummaryFrame :
nullptr, pos - clusterSummaryFrame)) {
1749 pos += res.Unwrap();
1755 auto topMostFrame = pos;
1756 pos += SerializeListFramePreamble(nClusters, *where);
1758 for (
auto clusterId : physClusterIDs) {
1761 std::set<ROOT::DescriptorId_t> onDiskColumnIds;
1762 for (
const auto &columnRange : clusterDesc.GetColumnRangeIterable())
1763 onDiskColumnIds.insert(context.
GetOnDiskColumnId(columnRange.GetPhysicalColumnId()));
1765 auto outerFrame = pos;
1766 pos += SerializeListFramePreamble(onDiskColumnIds.size(), *where);
1767 for (
auto onDiskId : onDiskColumnIds) {
1769 const auto &columnRange = clusterDesc.GetColumnRange(memId);
1771 auto innerFrame = pos;
1772 if (columnRange.IsSuppressed()) {
1774 pos += SerializeListFramePreamble(0, *where);
1775 pos += SerializeInt64(kSuppressedColumnMarker, *where);
1777 const auto &pageRange = clusterDesc.GetPageRange(memId);
1778 pos += SerializeListFramePreamble(pageRange.GetPageInfos().size(), *where);
1780 for (
const auto &pi : pageRange.GetPageInfos()) {
1781 std::int32_t nElements =
1782 pi.HasChecksum() ? -
static_cast<std::int32_t
>(pi.GetNElements()) : pi.GetNElements();
1783 pos += SerializeUInt32(nElements, *where);
1784 if (
auto res = SerializeLocator(pi.GetLocator(), *where)) {
1785 pos += res.Unwrap();
1790 pos += SerializeInt64(columnRange.GetFirstElementIndex(), *where);
1791 pos += SerializeUInt32(columnRange.GetCompressionSettings().value(), *where);
1794 if (
auto res = SerializeFramePostscript(buffer ? innerFrame :
nullptr, pos - innerFrame)) {
1795 pos += res.Unwrap();
1800 if (
auto res = SerializeFramePostscript(buffer ? outerFrame :
nullptr, pos - outerFrame)) {
1801 pos += res.Unwrap();
1807 if (
auto res = SerializeFramePostscript(buffer ? topMostFrame :
nullptr, pos - topMostFrame)) {
1808 pos += res.Unwrap();
1812 std::uint64_t
size = pos - base;
1813 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1814 size += res.Unwrap();
1825 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1827 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1829 pos += SerializeEnvelopePreamble(kEnvelopeTypeFooter, *where);
1833 if (
auto res = SerializeFeatureFlags(desc.
GetFeatureFlags(), *where)) {
1834 pos += res.Unwrap();
1842 pos += SerializeRecordFramePreamble(*where);
1843 if (
auto res = SerializeSchemaDescription(*where, desc, context,
true)) {
1844 pos += res.Unwrap();
1848 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1849 pos += res.Unwrap();
1857 pos += SerializeListFramePreamble(nClusterGroups, *where);
1858 for (
unsigned int i = 0; i < nClusterGroups; ++i) {
1861 clusterGroup.
fMinEntry = cgDesc.GetMinEntry();
1862 clusterGroup.
fEntrySpan = cgDesc.GetEntrySpan();
1863 clusterGroup.
fNClusters = cgDesc.GetNClusters();
1866 if (
auto res = SerializeClusterGroup(clusterGroup, *where)) {
1867 pos += res.Unwrap();
1872 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1873 pos += res.Unwrap();
1881 if (nAttributeSets > 0) {
1883 "back in the future (but your main data is)";
1885 pos += SerializeListFramePreamble(nAttributeSets, *where);
1887 if (
auto res = SerializeAttributeSet(attrSet, *where)) {
1888 pos += res.Unwrap();
1893 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame)) {
1894 pos += res.Unwrap();
1899 std::uint32_t
size = pos - base;
1900 if (
auto res = SerializeEnvelopePostscript(base,
size)) {
1901 size += res.Unwrap();
1912 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1914 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1922 pos += res.Unwrap();
1926 pos += SerializeString(attrDesc.
GetName(), *where);
1927 auto size = pos - frame;
1928 if (
auto res = SerializeFramePostscript(buffer ? frame :
nullptr,
size)) {
1937 for (std::size_t i = 0; i < featureFlags.size(); ++i) {
1938 if (!featureFlags[i])
1943 return R__FAIL(
"unsupported format feature: " + std::to_string(highestBitSet));
1951 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1953 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1955 std::uint64_t xxhash3{0};
1956 if (
auto res = DeserializeEnvelope(
bytes, fnBufSizeLeft(), kEnvelopeTypeHeader, xxhash3)) {
1957 bytes += res.Unwrap();
1963 std::vector<std::uint64_t> featureFlags;
1964 if (
auto res = DeserializeFeatureFlags(
bytes, fnBufSizeLeft(), featureFlags)) {
1965 bytes += res.Unwrap();
1974 std::string description;
1976 if (
auto res = DeserializeString(
bytes, fnBufSizeLeft(),
name)) {
1977 bytes += res.Unwrap();
1981 if (
auto res = DeserializeString(
bytes, fnBufSizeLeft(), description)) {
1982 bytes += res.Unwrap();
1986 if (
auto res = DeserializeString(
bytes, fnBufSizeLeft(),
writer)) {
1987 bytes += res.Unwrap();
1999 if (
auto res = DeserializeSchemaDescription(
bytes, fnBufSizeLeft(), descBuilder)) {
2009 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2011 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
2012 if (
auto res = DeserializeEnvelope(
bytes, fnBufSizeLeft(), kEnvelopeTypeFooter)) {
2013 bytes += res.Unwrap();
2018 std::vector<std::uint64_t> featureFlags;
2019 if (
auto res = DeserializeFeatureFlags(
bytes, fnBufSizeLeft(), featureFlags)) {
2020 bytes += res.Unwrap();
2028 std::uint64_t xxhash3{0};
2029 if (fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2030 return R__FAIL(
"footer too short");
2033 return R__FAIL(
"XxHash-3 mismatch between header and footer");
2035 std::uint64_t frameSize;
2037 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - frame); };
2039 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize)) {
2040 bytes += res.Unwrap();
2044 if (fnFrameSizeLeft() > 0) {
2046 if (
auto res = DeserializeSchemaDescription(
bytes, fnFrameSizeLeft(), descBuilder); !res) {
2050 bytes = frame + frameSize;
2053 std::uint32_t nClusterGroups;
2055 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nClusterGroups)) {
2056 bytes += res.Unwrap();
2060 for (std::uint32_t groupId = 0; groupId < nClusterGroups; ++groupId) {
2062 if (
auto res = DeserializeClusterGroup(
bytes, fnFrameSizeLeft(), clusterGroup)) {
2063 bytes += res.Unwrap();
2078 bytes = frame + frameSize;
2083 if (fnBufSizeLeft() > 8) {
2084 std::uint32_t nAttributeSets;
2086 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nAttributeSets)) {
2087 bytes += res.Unwrap();
2091 if (nAttributeSets > 0) {
2093 "back in the future (but your main data is)";
2095 for (std::uint32_t attrSetId = 0; attrSetId < nAttributeSets; ++attrSetId) {
2097 if (
auto res = DeserializeAttributeSet(
bytes, fnBufSizeLeft(), attrSetDescBld)) {
2099 bytes += res.Unwrap();
2104 bytes = frame + frameSize;
2113 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2115 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
2117 std::uint64_t frameSize;
2118 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize)) {
2119 bytes += res.Unwrap();
2123 if (fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2124 return R__FAIL(
"record frame too short");
2125 std::uint16_t vMajor, vMinor;
2128 std::uint32_t anchorLen;
2129 bytes += DeserializeUInt32(
bytes, anchorLen);
2131 if (
auto res = DeserializeLocator(
bytes, fnBufSizeLeft(), anchorLoc)) {
2132 bytes += res.Unwrap();
2137 if (
auto res = DeserializeString(
bytes, fnBufSizeLeft(),
name)) {
2138 bytes += res.Unwrap();
2153 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
2155 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
2157 if (
auto res = DeserializeEnvelope(
bytes, fnBufSizeLeft(), kEnvelopeTypePageList)) {
2158 bytes += res.Unwrap();
2163 std::uint64_t xxhash3{0};
2164 if (fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
2165 return R__FAIL(
"page list too short");
2168 return R__FAIL(
"XxHash-3 mismatch between header and page list");
2170 std::vector<RClusterDescriptorBuilder> clusterBuilders;
2176 std::uint64_t clusterSummaryFrameSize;
2177 auto clusterSummaryFrame =
bytes;
2178 auto fnClusterSummaryFrameSizeLeft = [&]() {
return clusterSummaryFrameSize - (
bytes - clusterSummaryFrame); };
2180 std::uint32_t nClusterSummaries;
2181 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), clusterSummaryFrameSize, nClusterSummaries)) {
2182 bytes += res.Unwrap();
2186 for (
auto clusterId = firstClusterId; clusterId < firstClusterId + nClusterSummaries; ++clusterId) {
2188 if (
auto res = DeserializeClusterSummary(
bytes, fnClusterSummaryFrameSizeLeft(), clusterSummary)) {
2189 bytes += res.Unwrap();
2196 clusterBuilders.emplace_back(std::move(builder));
2198 bytes = clusterSummaryFrame + clusterSummaryFrameSize;
2200 std::uint64_t topMostFrameSize;
2201 auto topMostFrame =
bytes;
2202 auto fnTopMostFrameSizeLeft = [&]() {
return topMostFrameSize - (
bytes - topMostFrame); };
2204 std::uint32_t nClusters;
2205 if (
auto res = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), topMostFrameSize, nClusters)) {
2206 bytes += res.Unwrap();
2211 if (nClusters != nClusterSummaries)
2212 return R__FAIL(
"mismatch between number of clusters and number of cluster summaries");
2214 for (std::uint32_t i = 0; i < nClusters; ++i) {
2215 std::uint64_t outerFrameSize;
2216 auto outerFrame =
bytes;
2217 auto fnOuterFrameSizeLeft = [&]() {
return outerFrameSize - (
bytes - outerFrame); };
2219 std::uint32_t nColumns;
2220 if (
auto res = DeserializeFrameHeader(
bytes, fnTopMostFrameSizeLeft(), outerFrameSize, nColumns)) {
2221 bytes += res.Unwrap();
2226 for (std::uint32_t j = 0; j < nColumns; ++j) {
2227 std::uint64_t innerFrameSize;
2228 auto innerFrame =
bytes;
2229 auto fnInnerFrameSizeLeft = [&]() {
return innerFrameSize - (
bytes - innerFrame); };
2231 std::uint32_t nPages;
2232 if (
auto res = DeserializeFrameHeader(
bytes, fnOuterFrameSizeLeft(), innerFrameSize, nPages)) {
2233 bytes += res.Unwrap();
2240 for (std::uint32_t k = 0; k < nPages; ++k) {
2241 if (fnInnerFrameSizeLeft() <
static_cast<int>(
sizeof(std::uint32_t)))
2242 return R__FAIL(
"inner frame too short");
2243 std::int32_t nElements;
2244 bool hasChecksum =
false;
2247 if (nElements < 0) {
2248 nElements = -nElements;
2251 if (
auto res = DeserializeLocator(
bytes, fnInnerFrameSizeLeft(), locator)) {
2252 bytes += res.Unwrap();
2256 pageRange.
GetPageInfos().push_back({
static_cast<std::uint32_t
>(nElements), locator, hasChecksum});
2259 if (fnInnerFrameSizeLeft() <
static_cast<int>(
sizeof(std::int64_t)))
2260 return R__FAIL(
"page list frame too short");
2261 std::int64_t columnOffset;
2262 bytes += DeserializeInt64(
bytes, columnOffset);
2263 if (columnOffset < 0) {
2265 return R__FAIL(
"unexpected non-empty page list");
2266 clusterBuilders[i].MarkSuppressedColumnRange(j);
2268 if (fnInnerFrameSizeLeft() <
static_cast<int>(
sizeof(std::uint32_t)))
2269 return R__FAIL(
"page list frame too short");
2270 std::uint32_t compressionSettings;
2271 bytes += DeserializeUInt32(
bytes, compressionSettings);
2272 clusterBuilders[i].CommitColumnRange(j, columnOffset, compressionSettings, pageRange);
2275 bytes = innerFrame + innerFrameSize;
2278 bytes = outerFrame + outerFrameSize;
2281 return clusterBuilders;
2290 if (!clusterBuildersRes)
2293 auto clusterBuilders = clusterBuildersRes.Unwrap();
2295 std::vector<ROOT::RClusterDescriptor> clusters;
2296 clusters.reserve(clusterBuilders.size());
2300 case EDescriptorDeserializeMode::kForReading:
2301 for (
auto &builder : clusterBuilders) {
2302 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2304 builder.AddExtendedColumnRanges(desc);
2305 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2308 case EDescriptorDeserializeMode::kForWriting:
2309 for (
auto &builder : clusterBuilders) {
2310 if (
auto res = builder.CommitSuppressedColumnRanges(desc); !res)
2312 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2315 case EDescriptorDeserializeMode::kRaw:
2316 for (
auto &builder : clusterBuilders)
2317 clusters.emplace_back(builder.MoveDescriptor().Unwrap());
2328 TList streamerInfos;
2329 for (
auto si : infos) {
2330 assert(si.first == si.second->GetNumber());
2331 streamerInfos.
Add(si.second);
2335 assert(buffer.
Length() > 0);
2348 TObjLink *lnk = infoList->FirstLink();
2352 infoMap[info->GetNumber()] = info->GetClass()->GetStreamerInfo(info->GetClassVersion());
2353 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.
RNTupleAttrSetDescriptorBuilder & AnchorLocator(const RNTupleLocator &loc)
RNTupleAttrSetDescriptorBuilder & SchemaVersion(std::uint16_t major, std::uint16_t minor)
RResult< ROOT::Experimental::RNTupleAttrSetDescriptor > MoveDescriptor()
Attempt to make an AttributeSet descriptor.
RNTupleAttrSetDescriptorBuilder & Name(std::string_view name)
RNTupleAttrSetDescriptorBuilder & AnchorLength(std::uint32_t length)
Metadata stored for every Attribute Set linked to an RNTuple.
std::uint16_t GetSchemaVersionMinor() const
const std::string & GetName() const
const RNTupleLocator & GetAnchorLocator() const
std::uint16_t GetSchemaVersionMajor() const
std::uint32_t GetAnchorLength() const
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)
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 > AddAttributeSet(Experimental::RNTupleAttrSetDescriptor &&attrSetDesc)
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
const RNTupleDescriptor & GetDescriptor() const
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)
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 > 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)
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
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
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)
ROOT::Experimental::RNTupleAttrSetDescriptorIterable GetAttrSetIterable() const
std::size_t GetNLogicalColumns() const
std::size_t GetNClusterGroups() const
const std::string & GetDescription() const
RNTupleLocator payload for the kTypeMulti locator (type 0x03).
RNTupleLocator payload that is common for object stores using 64bit location information.
Generic information about the physical location of data.
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