29#include <unordered_map>
42 auto base =
reinterpret_cast<unsigned char *
>(buffer);
44 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
46 pos += RNTupleSerializer::SerializeRecordFramePreamble(*where);
48 pos += RNTupleSerializer::SerializeUInt32(fieldDesc.
GetFieldVersion(), *where);
49 pos += RNTupleSerializer::SerializeUInt32(fieldDesc.
GetTypeVersion(), *where);
50 pos += RNTupleSerializer::SerializeUInt32(onDiskParentId, *where);
51 pos += RNTupleSerializer::SerializeFieldStructure(fieldDesc.
GetStructure(), *where);
53 pos += RNTupleSerializer::SerializeUInt16(RNTupleSerializer::kFlagRepetitiveField, *where);
54 pos += RNTupleSerializer::SerializeUInt64(fieldDesc.
GetNRepetitions(), *where);
56 pos += RNTupleSerializer::SerializeUInt16(0, *where);
58 pos += RNTupleSerializer::SerializeString(fieldDesc.
GetFieldName(), *where);
59 pos += RNTupleSerializer::SerializeString(fieldDesc.
GetTypeName(), *where);
60 pos += RNTupleSerializer::SerializeString(fieldDesc.
GetTypeAlias(), *where);
63 auto size = pos - base;
64 RNTupleSerializer::SerializeFramePostscript(base,
size);
77 std::span<const ROOT::Experimental::DescriptorId_t> fieldList,
78 std::size_t firstOnDiskId,
81 auto base =
reinterpret_cast<unsigned char *
>(buffer);
83 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
87 for (
auto fieldId : fieldList) {
90 (
f.GetParentId() == fieldZeroId) ? onDiskFieldId : context.
GetOnDiskFieldId(
f.GetParentId());
91 pos += SerializeField(
f, onDiskParentId, *where);
103 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
105 std::uint64_t frameSize;
106 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
107 auto result = RNTupleSerializer::DeserializeFrameHeader(
bytes, bufSize, frameSize);
112 std::uint32_t fieldVersion;
113 std::uint32_t typeVersion;
114 std::uint32_t parentId;
116 ENTupleStructure structure{ENTupleStructure::kLeaf};
118 if (fnFrameSizeLeft() < 3 *
sizeof(std::uint32_t) +
119 RNTupleSerializer::SerializeFieldStructure(structure,
nullptr) +
120 sizeof(std::uint16_t))
122 return R__FAIL(
"field record frame too short");
124 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, fieldVersion);
125 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, typeVersion);
126 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, parentId);
127 auto res16 = RNTupleSerializer::DeserializeFieldStructure(
bytes, structure);
130 bytes += res16.Unwrap();
131 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
134 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
135 if (fnFrameSizeLeft() <
sizeof(std::uint64_t))
136 return R__FAIL(
"field record frame too short");
137 std::uint64_t nRepetitions;
138 bytes += RNTupleSerializer::DeserializeUInt64(
bytes, nRepetitions);
142 std::string fieldName;
143 std::string typeName;
144 std::string aliasName;
145 std::string description;
146 result = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), fieldName).Unwrap();
150 result = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), typeName).Unwrap();
154 result = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), aliasName).Unwrap();
158 result = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), description).Unwrap();
168 std::span<const ROOT::Experimental::DescriptorId_t> fieldList,
174 auto base =
reinterpret_cast<unsigned char *
>(buffer);
176 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
178 for (
auto parentId : fieldList) {
180 if (
c.IsAliasColumn())
184 pos += RNTupleSerializer::SerializeRecordFramePreamble(*where);
186 auto type =
c.GetModel().GetType();
187 pos += RNTupleSerializer::SerializeColumnType(
type, *where);
188 pos += RNTupleSerializer::SerializeUInt16(RColumnElementBase::GetBitsOnStorage(
type), *where);
189 pos += RNTupleSerializer::SerializeUInt32(context.
GetOnDiskFieldId(
c.GetFieldId()), *where);
190 std::uint32_t flags = 0;
192 if (
c.GetModel().GetIsSorted())
193 flags |= RNTupleSerializer::kFlagSortAscColumn;
196 flags |= RNTupleSerializer::kFlagNonNegativeColumn;
197 const std::uint64_t firstElementIdx =
c.GetFirstElementIndex();
198 if (firstElementIdx > 0)
199 flags |= RNTupleSerializer::kFlagDeferredColumn;
200 pos += RNTupleSerializer::SerializeUInt32(flags, *where);
201 if (flags & RNTupleSerializer::kFlagDeferredColumn)
202 pos += RNTupleSerializer::SerializeUInt64(firstElementIdx, *where);
204 pos += RNTupleSerializer::SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
216 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
218 std::uint64_t frameSize;
219 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
220 auto result = RNTupleSerializer::DeserializeFrameHeader(
bytes, bufSize, frameSize);
227 std::uint16_t bitsOnStorage;
228 std::uint32_t fieldId;
230 std::uint64_t firstElementIdx = 0;
231 if (fnFrameSizeLeft() < RNTupleSerializer::SerializeColumnType(
type,
nullptr) +
232 sizeof(std::uint16_t) + 2 *
sizeof(std::uint32_t))
234 return R__FAIL(
"column record frame too short");
236 auto res16 = RNTupleSerializer::DeserializeColumnType(
bytes,
type);
239 bytes += res16.Unwrap();
240 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, bitsOnStorage);
241 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, fieldId);
242 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, flags);
243 if (flags & RNTupleSerializer::kFlagDeferredColumn) {
244 if (fnFrameSizeLeft() <
sizeof(std::uint64_t))
245 return R__FAIL(
"column record frame too short");
246 bytes += RNTupleSerializer::DeserializeUInt64(
bytes, firstElementIdx);
250 return R__FAIL(
"column element size mismatch");
252 const bool isSorted = (flags & (RNTupleSerializer::kFlagSortAscColumn | RNTupleSerializer::kFlagSortDesColumn));
253 columnDesc.
FieldId(fieldId).
Model({
type, isSorted}).FirstElementIndex(firstElementIdx);
260 const auto &uri = locator.
GetPosition<std::string>();
261 if (uri.length() >= (1 << 16))
264 memcpy(buffer, uri.data(), uri.length());
268void DeserializeLocatorPayloadURI(
const unsigned char *buffer, std::uint32_t payloadSize,
272 auto &uri = locator.
fPosition.emplace<std::string>();
273 uri.resize(payloadSize);
274 memcpy(uri.data(), buffer, payloadSize);
282 RNTupleSerializer::SerializeUInt64(
data.fLocation, buffer +
sizeof(std::uint32_t));
284 return sizeof(std::uint32_t) +
sizeof(std::uint64_t);
291 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint32_t),
data.fLocation);
295 std::span<const ROOT::Experimental::DescriptorId_t> fieldList,
299 auto base =
reinterpret_cast<unsigned char *
>(buffer);
301 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
303 for (
auto parentId : fieldList) {
305 if (!
c.IsAliasColumn())
309 pos += RNTupleSerializer::SerializeRecordFramePreamble(*where);
311 pos += RNTupleSerializer::SerializeUInt32(context.
GetOnDiskColumnId(
c.GetPhysicalId()), *where);
312 pos += RNTupleSerializer::SerializeUInt32(context.
GetOnDiskFieldId(
c.GetFieldId()), *where);
314 pos += RNTupleSerializer::SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
322 std::uint32_t &physicalColumnId, std::uint32_t &fieldId)
324 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
326 std::uint64_t frameSize;
327 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
328 auto result = RNTupleSerializer::DeserializeFrameHeader(
bytes, bufSize, frameSize);
333 if (fnFrameSizeLeft() < 2 *
sizeof(std::uint32_t)) {
334 return R__FAIL(
"alias column record frame too short");
337 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, physicalColumnId);
338 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, fieldId);
347 std::uint64_t &xxhash3,
void *buffer)
349 if (buffer !=
nullptr) {
358 std::uint64_t &xxhash3)
360 auto checksumReal = XXH3_64bits(
data,
length);
362 if (xxhash3 != checksumReal)
363 return R__FAIL(
"XxHash-3 checksum mismatch");
370 std::uint64_t xxhash3;
377 if (buffer !=
nullptr) {
378 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
379 bytes[0] = (val & 0x00FF);
380 bytes[1] = (val & 0xFF00) >> 8;
387 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
388 val = std::int16_t(
bytes[0]) + (std::int16_t(
bytes[1]) << 8);
394 return SerializeInt16(val, buffer);
399 return DeserializeInt16(buffer, *
reinterpret_cast<std::int16_t *
>(&val));
404 if (buffer !=
nullptr) {
405 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
406 bytes[0] = (val & 0x000000FF);
407 bytes[1] = (val & 0x0000FF00) >> 8;
408 bytes[2] = (val & 0x00FF0000) >> 16;
409 bytes[3] = (val & 0xFF000000) >> 24;
416 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
417 val = std::int32_t(
bytes[0]) + (std::int32_t(
bytes[1]) << 8) +
418 (std::int32_t(
bytes[2]) << 16) + (std::int32_t(
bytes[3]) << 24);
424 return SerializeInt32(val, buffer);
429 return DeserializeInt32(buffer, *
reinterpret_cast<std::int32_t *
>(&val));
434 if (buffer !=
nullptr) {
435 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
436 bytes[0] = (val & 0x00000000000000FF);
437 bytes[1] = (val & 0x000000000000FF00) >> 8;
438 bytes[2] = (val & 0x0000000000FF0000) >> 16;
439 bytes[3] = (val & 0x00000000FF000000) >> 24;
440 bytes[4] = (val & 0x000000FF00000000) >> 32;
441 bytes[5] = (val & 0x0000FF0000000000) >> 40;
442 bytes[6] = (val & 0x00FF000000000000) >> 48;
443 bytes[7] = (val & 0xFF00000000000000) >> 56;
450 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
451 val = std::int64_t(
bytes[0]) + (std::int64_t(
bytes[1]) << 8) +
452 (std::int64_t(
bytes[2]) << 16) + (std::int64_t(
bytes[3]) << 24) +
453 (std::int64_t(
bytes[4]) << 32) + (std::int64_t(
bytes[5]) << 40) +
454 (std::int64_t(
bytes[6]) << 48) + (std::int64_t(
bytes[7]) << 56);
460 return SerializeInt64(val, buffer);
465 return DeserializeInt64(buffer, *
reinterpret_cast<std::int64_t *
>(&val));
471 auto pos =
reinterpret_cast<unsigned char *
>(buffer);
472 pos += SerializeUInt32(val.length(), pos);
473 memcpy(pos, val.data(), val.length());
475 return sizeof(std::uint32_t) + val.length();
479 std::uint64_t bufSize,
482 if (bufSize <
sizeof(std::uint32_t))
483 return R__FAIL(
"string buffer too short");
484 bufSize -=
sizeof(std::uint32_t);
486 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
491 return R__FAIL(
"string buffer too short");
495 return sizeof(std::uint32_t) +
length;
540 std::uint16_t onDiskType;
541 auto result = DeserializeUInt16(buffer, onDiskType);
542 switch (onDiskType) {
570 default:
return R__FAIL(
"unexpected on-disk column type");
582 return SerializeUInt16(0x00, buffer);
584 return SerializeUInt16(0x01, buffer);
586 return SerializeUInt16(0x02, buffer);
588 return SerializeUInt16(0x03, buffer);
590 return SerializeUInt16(0x04, buffer);
601 std::uint16_t onDiskValue;
602 auto result = DeserializeUInt16(buffer, onDiskValue);
603 switch (onDiskValue) {
620 return R__FAIL(
"unexpected on-disk field structure value");
628 auto base =
reinterpret_cast<unsigned char *
>(buffer);
630 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
632 pos += SerializeUInt64(envelopeType, *where);
639 std::uint64_t &xxhash3)
641 if (
size <
sizeof(std::uint64_t))
643 if (
size >=
static_cast<uint64_t
>(1) << 48)
646 std::uint64_t typeAndSize;
647 DeserializeUInt64(envelope, typeAndSize);
648 typeAndSize |= (
size + 8) << 16;
649 SerializeUInt64(typeAndSize, envelope);
651 return SerializeXxHash3(envelope,
size, xxhash3, envelope ? (envelope +
size) :
nullptr);
657 std::uint64_t xxhash3;
658 return SerializeEnvelopePostscript(envelope,
size, xxhash3);
663 std::uint16_t expectedType, std::uint64_t &xxhash3)
665 const std::uint64_t minEnvelopeSize =
sizeof(std::uint64_t) +
sizeof(std::uint64_t);
666 if (bufSize < minEnvelopeSize)
667 return R__FAIL(
"invalid envelope buffer, too short");
669 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
672 std::uint64_t typeAndSize;
673 bytes += DeserializeUInt64(
bytes, typeAndSize);
675 std::uint16_t envelopeType = typeAndSize & 0xFFFF;
676 if (envelopeType != expectedType) {
677 return R__FAIL(
"envelope type mismatch: expected " + std::to_string(expectedType) +
", found " +
678 std::to_string(envelopeType));
681 std::uint64_t envelopeSize = typeAndSize >> 16;
682 if (bufSize < envelopeSize)
683 return R__FAIL(
"envelope buffer size too small");
684 if (envelopeSize < minEnvelopeSize)
685 return R__FAIL(
"invalid envelope, too short");
687 auto result = VerifyXxHash3(base, envelopeSize - 8, xxhash3);
691 return sizeof(typeAndSize);
695 std::uint64_t bufSize,
696 std::uint16_t expectedType)
698 std::uint64_t xxhash3;
699 return R__FORWARD_RESULT(DeserializeEnvelope(buffer, bufSize, expectedType, xxhash3));
706 return SerializeInt64(1, buffer);
711 std::uint32_t
nitems,
void *buffer)
713 auto base =
reinterpret_cast<unsigned char *
>(buffer);
715 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
718 pos += SerializeInt64(-1, *where);
719 pos += SerializeUInt32(
nitems, *where);
725 auto preambleSize =
sizeof(std::int64_t);
726 if (
size < preambleSize)
730 DeserializeInt64(frame, marker);
731 if ((marker < 0) && (
size < (
sizeof(std::uint32_t) + preambleSize)))
733 SerializeInt64(marker *
static_cast<int64_t
>(
size), frame);
740 std::uint64_t &frameSize, std::uint32_t &
nitems)
742 std::uint64_t minSize =
sizeof(std::int64_t);
743 if (bufSize < minSize)
744 return R__FAIL(
"frame too short");
746 std::int64_t *ssize =
reinterpret_cast<std::int64_t *
>(&frameSize);
747 DeserializeInt64(buffer, *ssize);
749 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
757 minSize +=
sizeof(std::uint32_t);
758 if (bufSize < minSize)
759 return R__FAIL(
"frame too short");
764 if (frameSize < minSize)
765 return R__FAIL(
"corrupt frame size");
766 if (bufSize < frameSize)
767 return R__FAIL(
"frame too short");
769 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
774 std::uint64_t &frameSize)
785 return SerializeUInt64(0, buffer);
788 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
790 for (
unsigned i = 0; i < flags.size(); ++i) {
791 if (flags[i] & 0x8000000000000000)
795 if (i == (flags.size() - 1))
796 SerializeUInt64(flags[i],
bytes);
798 bytes += SerializeUInt64(flags[i] | 0x8000000000000000,
bytes);
801 return (flags.size() *
sizeof(std::int64_t));
806 std::vector<std::uint64_t> &flags)
808 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
813 if (bufSize <
sizeof(std::uint64_t))
814 return R__FAIL(
"feature flag buffer too short");
816 bufSize -=
sizeof(std::uint64_t);
817 flags.emplace_back(
f & ~0x8000000000000000);
818 }
while (
f & 0x8000000000000000);
820 return (flags.size() *
sizeof(std::uint64_t));
829 std::uint32_t
size = 0;
835 buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
839 auto payloadp = buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
sizeof(std::int32_t) :
nullptr;
840 switch (locator.
fType) {
845 std::int32_t head =
sizeof(std::int32_t) +
size;
847 head |=
static_cast<int>(locator.
fType & 0x7F) << 24;
854 std::uint64_t bufSize,
857 if (bufSize <
sizeof(std::int32_t))
858 return R__FAIL(
"too short locator");
860 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
864 bufSize -=
sizeof(std::int32_t);
867 const int type = head >> 24;
868 const std::uint32_t payloadSize = (
static_cast<std::uint32_t
>(head) & 0x0000FFFF) -
sizeof(std::int32_t);
869 if (bufSize < payloadSize)
870 return R__FAIL(
"too short locator");
872 locator.
fReserved =
static_cast<std::uint32_t
>(head >> 16) & 0xFF;
876 default:
return R__FAIL(
"unsupported locator type: " + std::to_string(
type));
878 bytes += payloadSize;
880 if (bufSize <
sizeof(std::uint64_t))
881 return R__FAIL(
"too short locator");
888 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
894 auto size = SerializeUInt64(envelopeLink.
fLength, buffer);
896 buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
904 if (bufSize <
sizeof(std::int64_t))
905 return R__FAIL(
"too short envelope link");
907 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
909 bufSize -=
sizeof(std::uint64_t);
914 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
921 auto base =
reinterpret_cast<unsigned char *
>(buffer);
923 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
926 pos += SerializeRecordFramePreamble(*where);
927 pos += SerializeUInt64(clusterSummary.
fFirstEntry, *where);
929 pos += SerializeInt64(-
static_cast<int64_t
>(clusterSummary.
fNEntries), *where);
932 pos += SerializeInt64(
static_cast<int64_t
>(clusterSummary.
fNEntries), *where);
934 auto size = pos - frame;
935 pos += SerializeFramePostscript(frame,
size);
943 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
945 std::uint64_t frameSize;
946 auto result = DeserializeFrameHeader(
bytes, bufSize, frameSize);
951 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
952 if (fnFrameSizeLeft() < 2 *
sizeof(std::uint64_t))
953 return R__FAIL(
"too short cluster summary");
956 std::int64_t nEntries;
960 if (fnFrameSizeLeft() <
sizeof(std::uint32_t))
961 return R__FAIL(
"too short cluster summary");
963 std::uint32_t columnGroupID;
964 bytes += DeserializeUInt32(
bytes, columnGroupID);
978 auto base =
reinterpret_cast<unsigned char *
>(buffer);
980 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
983 pos += SerializeRecordFramePreamble(*where);
984 pos += SerializeUInt64(clusterGroup.
fMinEntry, *where);
985 pos += SerializeUInt64(clusterGroup.
fEntrySpan, *where);
986 pos += SerializeUInt32(clusterGroup.
fNClusters, *where);
988 auto size = pos - frame;
989 pos += SerializeFramePostscript(frame,
size);
997 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1000 std::uint64_t frameSize;
1001 auto result = DeserializeFrameHeader(
bytes, bufSize, frameSize);
1006 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - base); };
1007 if (fnFrameSizeLeft() <
sizeof(std::uint32_t) + 2 *
sizeof(std::uint64_t))
1008 return R__FAIL(
"too short cluster group");
1021 bool forHeaderExtension)
1024 auto depthFirstTraversal = [&](std::span<DescriptorId_t> fieldTrees,
auto doForEachField) {
1025 std::deque<DescriptorId_t> idQueue{fieldTrees.begin(), fieldTrees.end()};
1026 while (!idQueue.empty()) {
1027 auto fieldId = idQueue.front();
1028 idQueue.pop_front();
1030 if (fieldId != fieldZeroId)
1031 doForEachField(fieldId);
1034 idQueue.insert(idQueue.begin() + i++,
f.GetId());
1039 if (!forHeaderExtension)
1040 R__ASSERT(GetHeaderExtensionOffset() == -1U);
1042 std::vector<DescriptorId_t> fieldTrees;
1043 if (!forHeaderExtension) {
1044 fieldTrees.emplace_back(fieldZeroId);
1046 fieldTrees = xHeader->GetTopLevelFields(desc);
1048 depthFirstTraversal(fieldTrees, [&](
DescriptorId_t fieldId) { MapFieldId(fieldId); });
1051 if (!
c.IsAliasColumn())
1052 MapColumnId(
c.GetLogicalId());
1056 if (
c.IsAliasColumn())
1057 MapColumnId(
c.GetLogicalId());
1061 if (!forHeaderExtension)
1062 BeginHeaderExtension();
1068 bool forHeaderExtension)
1070 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1072 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
1074 std::size_t nFields = 0, nColumns = 0, nAliasColumns = 0, fieldListOffset = 0;
1075 if (forHeaderExtension) {
1079 nFields = xHeader->GetNFields();
1080 nColumns = xHeader->GetNPhysicalColumns();
1081 nAliasColumns = xHeader->GetNLogicalColumns() - xHeader->GetNPhysicalColumns();
1090 R__ASSERT(onDiskFields.size() >= fieldListOffset);
1091 std::span<const DescriptorId_t> fieldList{onDiskFields.data() + fieldListOffset,
1092 onDiskFields.size() - fieldListOffset};
1095 pos += SerializeListFramePreamble(nFields, *where);
1096 pos += SerializeFieldList(desc, fieldList, fieldListOffset, context, *where);
1097 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1100 pos += SerializeListFramePreamble(nColumns, *where);
1101 pos += SerializeColumnList(desc, fieldList, context, *where);
1102 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1105 pos += SerializeListFramePreamble(nAliasColumns, *where);
1106 pos += SerializeAliasColumnList(desc, fieldList, context, *where);
1107 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1111 pos += SerializeListFramePreamble(0, *where);
1112 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1113 return static_cast<std::uint32_t
>(pos - base);
1120 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1122 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1125 std::uint64_t frameSize;
1127 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - frame); };
1129 std::uint32_t nFields;
1130 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nFields);
1136 for (
unsigned i = 0; i < nFields; ++i) {
1137 std::uint32_t fieldId = fieldIdRangeBegin + i;
1139 result = DeserializeField(
bytes, fnFrameSizeLeft(), fieldBuilder);
1144 fieldBuilder.
ParentId(kZeroFieldId);
1148 auto parentId = fieldDesc.Inspect().GetParentId();
1149 descBuilder.
AddField(fieldDesc.Unwrap());
1150 auto resVoid = descBuilder.
AddFieldLink(parentId, fieldId);
1154 bytes = frame + frameSize;
1156 std::uint32_t nColumns;
1158 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nColumns);
1163 std::unordered_map<DescriptorId_t, std::uint32_t> maxIndexes;
1164 for (
unsigned i = 0; i < nColumns; ++i) {
1165 std::uint32_t columnId = columnIdRangeBegin + i;
1167 result = DeserializeColumn(
bytes, fnFrameSizeLeft(), columnBuilder);
1172 std::uint32_t idx = 0;
1173 const auto fieldId = columnBuilder.
GetFieldId();
1174 auto maxIdx = maxIndexes.find(fieldId);
1175 if (maxIdx != maxIndexes.end())
1176 idx = maxIdx->second + 1;
1177 maxIndexes[fieldId] = idx;
1182 auto resVoid = descBuilder.
AddColumn(columnDesc.Unwrap());
1186 bytes = frame + frameSize;
1188 std::uint32_t nAliasColumns;
1190 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nAliasColumns);
1194 const std::uint32_t aliasColumnIdRangeBegin = columnIdRangeBegin + nColumns;
1195 for (
unsigned i = 0; i < nAliasColumns; ++i) {
1196 std::uint32_t physicalId;
1197 std::uint32_t fieldId;
1198 result = DeserializeAliasColumn(
bytes, fnFrameSizeLeft(), physicalId, fieldId);
1207 std::uint32_t idx = 0;
1208 auto maxIdx = maxIndexes.find(fieldId);
1209 if (maxIdx != maxIndexes.end())
1210 idx = maxIdx->second + 1;
1211 maxIndexes[fieldId] = idx;
1214 if (!aliasColumnDesc)
1216 auto resVoid = descBuilder.
AddColumn(aliasColumnDesc.Unwrap());
1220 bytes = frame + frameSize;
1222 std::uint32_t nTypeInfo;
1224 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nTypeInfo);
1229 bytes = frame + frameSize;
1231 return bytes - base;
1240 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1242 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1244 pos += SerializeEnvelopePreamble(kEnvelopeTypeHeader, *where);
1247 pos += SerializeString(desc.
GetName(), *where);
1249 pos += SerializeString(std::string(
"ROOT v") +
ROOT_RELEASE, *where);
1252 pos += SerializeSchemaDescription(*where, desc, context);
1254 std::uint64_t
size = pos - base;
1255 std::uint64_t xxhash3 = 0;
1256 size += SerializeEnvelopePostscript(base,
size, xxhash3);
1265 std::span<DescriptorId_t> physClusterIDs,
1268 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1270 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
1272 pos += SerializeEnvelopePreamble(kEnvelopeTypePageList, *where);
1277 const auto nClusters = physClusterIDs.size();
1278 auto clusterSummaryFrame = pos;
1279 pos += SerializeListFramePreamble(nClusters, *where);
1280 for (
auto clusterId : physClusterIDs) {
1282 RClusterSummary summary{clusterDesc.GetFirstEntryIndex(), clusterDesc.GetNEntries(), -1};
1283 pos += SerializeClusterSummary(summary, *where);
1285 pos += SerializeFramePostscript(buffer ? clusterSummaryFrame :
nullptr, pos - clusterSummaryFrame);
1288 auto topMostFrame = pos;
1289 pos += SerializeListFramePreamble(nClusters, *where);
1291 for (
auto clusterId : physClusterIDs) {
1294 std::set<DescriptorId_t> onDiskColumnIds;
1295 for (
auto column : clusterDesc.GetColumnIds())
1298 auto outerFrame = pos;
1299 pos += SerializeListFramePreamble(onDiskColumnIds.size(), *where);
1300 for (
auto onDiskId : onDiskColumnIds) {
1302 const auto &columnRange = clusterDesc.GetColumnRange(memId);
1303 const auto &pageRange = clusterDesc.GetPageRange(memId);
1305 auto innerFrame = pos;
1306 pos += SerializeListFramePreamble(pageRange.fPageInfos.size(), *where);
1308 for (
const auto &pi : pageRange.fPageInfos) {
1309 pos += SerializeUInt32(pi.fNElements, *where);
1310 pos += SerializeLocator(pi.fLocator, *where);
1312 pos += SerializeUInt64(columnRange.fFirstElementIndex, *where);
1313 pos += SerializeUInt32(columnRange.fCompressionSettings, *where);
1315 pos += SerializeFramePostscript(buffer ? innerFrame :
nullptr, pos - innerFrame);
1317 pos += SerializeFramePostscript(buffer ? outerFrame :
nullptr, pos - outerFrame);
1320 pos += SerializeFramePostscript(buffer ? topMostFrame :
nullptr, pos - topMostFrame);
1321 std::uint64_t
size = pos - base;
1322 size += SerializeEnvelopePostscript(base,
size);
1331 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1333 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
1335 pos += SerializeEnvelopePreamble(kEnvelopeTypeFooter, *where);
1338 pos += SerializeFeatureFlags(std::vector<std::uint64_t>(), *where);
1343 pos += SerializeRecordFramePreamble(*where);
1344 pos += SerializeSchemaDescription(*where, desc, context,
true);
1345 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1349 pos += SerializeListFramePreamble(0, *where);
1350 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1355 pos += SerializeListFramePreamble(nClusterGroups, *where);
1356 for (
unsigned int i = 0; i < nClusterGroups; ++i) {
1359 clusterGroup.
fMinEntry = cgDesc.GetMinEntry();
1360 clusterGroup.
fEntrySpan = cgDesc.GetEntrySpan();
1361 clusterGroup.
fNClusters = cgDesc.GetNClusters();
1364 pos += SerializeClusterGroup(clusterGroup, *where);
1366 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1370 pos += SerializeListFramePreamble(0, *where);
1371 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1373 std::uint32_t
size = pos - base;
1374 size += SerializeEnvelopePostscript(base,
size);
1382 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1384 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1387 std::uint64_t xxhash3{0};
1388 result = DeserializeEnvelope(
bytes, fnBufSizeLeft(), kEnvelopeTypeHeader, xxhash3);
1394 std::vector<std::uint64_t> featureFlags;
1395 result = DeserializeFeatureFlags(
bytes, fnBufSizeLeft(), featureFlags);
1399 for (std::size_t i = 0; i < featureFlags.size(); ++i) {
1400 if (!featureFlags[i])
1402 unsigned int bit = 0;
1403 while (!(featureFlags[i] & (
static_cast<uint64_t
>(1) << bit)))
1405 return R__FAIL(
"unsupported format feature: " + std::to_string(i * 64 + bit));
1409 std::string description;
1415 result = DeserializeString(
bytes, fnBufSizeLeft(), description);
1428 result = DeserializeSchemaDescription(
bytes, fnBufSizeLeft(), descBuilder);
1439 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1441 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1444 result = DeserializeEnvelope(
bytes, fnBufSizeLeft(), kEnvelopeTypeFooter);
1449 std::vector<std::uint64_t> featureFlags;
1450 result = DeserializeFeatureFlags(
bytes, fnBufSizeLeft(), featureFlags);
1454 for (
auto f: featureFlags) {
1459 std::uint64_t xxhash3{0};
1460 if (fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
1461 return R__FAIL(
"footer too short");
1464 return R__FAIL(
"XxHash-3 mismatch between header and footer");
1466 std::uint64_t frameSize;
1468 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - frame); };
1470 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize);
1474 if (fnFrameSizeLeft() > 0) {
1476 result = DeserializeSchemaDescription(
bytes, fnFrameSizeLeft(), descBuilder);
1480 bytes = frame + frameSize;
1482 std::uint32_t nColumnGroups;
1484 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nColumnGroups);
1487 if (nColumnGroups > 0)
1488 return R__FAIL(
"sharded clusters are still unsupported");
1489 bytes = frame + frameSize;
1491 std::uint32_t nClusterGroups;
1493 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nClusterGroups);
1497 for (std::uint32_t groupId = 0; groupId < nClusterGroups; ++groupId) {
1499 result = DeserializeClusterGroup(
bytes, fnFrameSizeLeft(), clusterGroup);
1514 bytes = frame + frameSize;
1516 std::uint32_t nMDBlocks;
1518 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nMDBlocks);
1523 bytes = frame + frameSize;
1533 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1535 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1538 result = DeserializeEnvelope(
bytes, fnBufSizeLeft(), kEnvelopeTypePageList);
1543 std::uint64_t xxhash3{0};
1544 if (fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint64_t)))
1545 return R__FAIL(
"page list too short");
1548 return R__FAIL(
"XxHash-3 mismatch between header and page list");
1550 std::vector<RClusterDescriptorBuilder> clusterBuilders;
1556 std::uint64_t clusterSummaryFrameSize;
1557 auto clusterSummaryFrame =
bytes;
1558 auto fnClusterSummaryFrameSizeLeft = [&]() {
return clusterSummaryFrameSize - (
bytes - clusterSummaryFrame); };
1560 std::uint32_t nClusterSummaries;
1561 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), clusterSummaryFrameSize, nClusterSummaries);
1565 for (
auto clusterId = firstClusterId; clusterId < firstClusterId + nClusterSummaries; ++clusterId) {
1567 result = DeserializeClusterSummary(
bytes, fnClusterSummaryFrameSizeLeft(), clusterSummary);
1572 return R__FAIL(
"sharded clusters are still unsupported");
1576 clusterBuilders.emplace_back(std::move(builder));
1578 bytes = clusterSummaryFrame + clusterSummaryFrameSize;
1580 std::uint64_t topMostFrameSize;
1581 auto topMostFrame =
bytes;
1582 auto fnTopMostFrameSizeLeft = [&]() {
return topMostFrameSize - (
bytes - topMostFrame); };
1584 std::uint32_t nClusters;
1585 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), topMostFrameSize, nClusters);
1590 if (nClusters != nClusterSummaries)
1591 return R__FAIL(
"mismatch between number of clusters and number of cluster summaries");
1593 std::vector<RClusterDescriptor> clusters;
1594 for (std::uint32_t i = 0; i < nClusters; ++i) {
1595 std::uint64_t outerFrameSize;
1596 auto outerFrame =
bytes;
1597 auto fnOuterFrameSizeLeft = [&]() {
return outerFrameSize - (
bytes - outerFrame); };
1599 std::uint32_t nColumns;
1600 result = DeserializeFrameHeader(
bytes, fnTopMostFrameSizeLeft(), outerFrameSize, nColumns);
1605 for (std::uint32_t j = 0; j < nColumns; ++j) {
1606 std::uint64_t innerFrameSize;
1607 auto innerFrame =
bytes;
1608 auto fnInnerFrameSizeLeft = [&]() {
return innerFrameSize - (
bytes - innerFrame); };
1610 std::uint32_t nPages;
1611 result = DeserializeFrameHeader(
bytes, fnOuterFrameSizeLeft(), innerFrameSize, nPages);
1618 for (std::uint32_t k = 0; k < nPages; ++k) {
1619 if (fnInnerFrameSizeLeft() <
static_cast<int>(
sizeof(std::uint32_t)))
1620 return R__FAIL(
"inner frame too short");
1621 std::int32_t nElements;
1624 if (nElements < 0) {
1626 nElements = -nElements;
1628 result = DeserializeLocator(
bytes, fnInnerFrameSizeLeft(), locator);
1631 pageRange.
fPageInfos.push_back({
static_cast<std::uint32_t
>(nElements), locator});
1635 if (fnInnerFrameSizeLeft() <
static_cast<int>(
sizeof(std::uint32_t) +
sizeof(std::uint64_t)))
1636 return R__FAIL(
"page list frame too short");
1637 std::uint64_t columnOffset;
1638 bytes += DeserializeUInt64(
bytes, columnOffset);
1639 std::uint32_t compressionSettings;
1640 bytes += DeserializeUInt32(
bytes, compressionSettings);
1642 clusterBuilders[i].CommitColumnRange(j, columnOffset, compressionSettings, pageRange);
1643 bytes = innerFrame + innerFrameSize;
1646 bytes = outerFrame + outerFrameSize;
1648 clusterBuilders[i].AddDeferredColumnRanges(desc);
1649 clusters.emplace_back(clusterBuilders[i].MoveDescriptor().Unwrap());
#define R__FORWARD_ERROR(res)
Short-hand to return an RResult<T> in an error state (i.e. after checking)
#define R__FORWARD_RESULT(res)
Short-hand to return an RResult<T> value from a subroutine to the calling stack frame.
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
#define R__LOG_WARNING(...)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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 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 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 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 & ClusterId(DescriptorId_t clusterId)
RClusterDescriptorBuilder & NEntries(std::uint64_t nEntries)
RClusterDescriptorBuilder & FirstEntryIndex(std::uint64_t firstEntryIndex)
A helper class for piece-wise construction of an RClusterGroupDescriptor.
RClusterGroupDescriptorBuilder & PageListLocator(const RNTupleLocator &pageListLocator)
RClusterGroupDescriptorBuilder & MinEntry(std::uint64_t minEntry)
RClusterGroupDescriptorBuilder & ClusterGroupId(DescriptorId_t clusterGroupId)
RClusterGroupDescriptorBuilder & EntrySpan(std::uint64_t entrySpan)
RClusterGroupDescriptorBuilder & NClusters(std::uint32_t nClusters)
RClusterGroupDescriptorBuilder & PageListLength(std::uint64_t pageListLength)
RResult< RClusterGroupDescriptor > MoveDescriptor()
A helper class for piece-wise construction of an RColumnDescriptor.
RColumnDescriptorBuilder & PhysicalColumnId(DescriptorId_t physicalColumnId)
RColumnDescriptorBuilder & Model(const RColumnModel &model)
RColumnDescriptorBuilder & FieldId(DescriptorId_t fieldId)
RColumnDescriptorBuilder & Index(std::uint32_t index)
RResult< RColumnDescriptor > MakeDescriptor() const
Attempt to make a column descriptor.
DescriptorId_t GetFieldId() const
RColumnDescriptorBuilder & LogicalColumnId(DescriptorId_t logicalColumnId)
A column element encapsulates the translation between basic C++ types and their column representation...
std::size_t GetBitsOnStorage() const
A helper class for piece-wise construction of an RFieldDescriptor.
DescriptorId_t GetParentId() const
RFieldDescriptorBuilder & TypeVersion(std::uint32_t typeVersion)
RFieldDescriptorBuilder & NRepetitions(std::uint64_t nRepetitions)
RFieldDescriptorBuilder & FieldVersion(std::uint32_t fieldVersion)
RFieldDescriptorBuilder & Structure(const ENTupleStructure &structure)
RFieldDescriptorBuilder & TypeName(const std::string &typeName)
RResult< RFieldDescriptor > MakeDescriptor() const
Attempt to make a field descriptor.
RFieldDescriptorBuilder & FieldName(const std::string &fieldName)
RFieldDescriptorBuilder & ParentId(DescriptorId_t id)
RFieldDescriptorBuilder & TypeAlias(const std::string &typeAlias)
RFieldDescriptorBuilder & FieldId(DescriptorId_t fieldId)
RFieldDescriptorBuilder & FieldDescription(const std::string &fieldDescription)
A helper class for piece-wise construction of an RNTupleDescriptor.
void BeginHeaderExtension()
Mark the beginning of the header extension; any fields and columns added after a call to this functio...
RResult< void > AddFieldLink(DescriptorId_t fieldId, DescriptorId_t linkId)
void AddToOnDiskFooterSize(std::uint64_t size)
The real footer size also include the page list envelopes.
void SetNTuple(const std::string_view name, const std::string_view description)
RResult< void > AddClusterGroup(RClusterGroupDescriptor &&clusterGroup)
const RNTupleDescriptor & GetDescriptor() const
void AddField(const RFieldDescriptor &fieldDesc)
void AddColumn(DescriptorId_t logicalId, DescriptorId_t physicalId, DescriptorId_t fieldId, const RColumnModel &model, std::uint32_t index, std::uint64_t firstElementIdx=0U)
void SetOnDiskHeaderXxHash3(std::uint64_t xxhash3)
The serialization context is used for the piecewise serialization of a descriptor.
DescriptorId_t GetOnDiskColumnId(DescriptorId_t memId) const
const std::vector< DescriptorId_t > & GetOnDiskFieldList() const
Return a vector containing the in-memory field ID for each on-disk counterpart, in order,...
DescriptorId_t GetOnDiskFieldId(DescriptorId_t memId) const
DescriptorId_t GetMemColumnId(DescriptorId_t onDiskId) const
std::uint64_t GetHeaderXxHash3() const
void SetHeaderXxHash3(std::uint64_t xxhash3)
std::size_t GetHeaderExtensionOffset() const
Return the offset of the first element in fOnDisk2MemFieldIDs that is part of the schema extension.
DescriptorId_t GetMemClusterGroupId(DescriptorId_t onDiskId) const
DescriptorId_t GetMemClusterId(DescriptorId_t onDiskId) const
void SetHeaderSize(std::uint64_t size)
void MapSchema(const RNTupleDescriptor &desc, bool forHeaderExtension)
Map in-memory field and column IDs to their on-disk counterparts.
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::uint32_t > DeserializeClusterSummary(const void *buffer, std::uint64_t bufSize, RClusterSummary &clusterSummary)
static std::uint32_t SerializeListFramePreamble(std::uint32_t nitems, void *buffer)
static RResult< std::uint32_t > DeserializeClusterGroup(const void *buffer, std::uint64_t bufSize, RClusterGroup &clusterGroup)
static std::uint32_t SerializeEnvelopePostscript(unsigned char *envelope, std::uint64_t size)
static RContext SerializeHeader(void *buffer, const RNTupleDescriptor &desc)
static std::uint32_t SerializeFeatureFlags(const std::vector< std::uint64_t > &flags, void *buffer)
static std::uint16_t SerializeColumnType(ROOT::Experimental::EColumnType type, void *buffer)
static std::uint32_t DeserializeUInt16(const void *buffer, std::uint16_t &val)
static RResult< void > DeserializeHeader(const void *buffer, std::uint64_t bufSize, RNTupleDescriptorBuilder &descBuilder)
static RResult< void > DeserializeFooter(const void *buffer, std::uint64_t bufSize, RNTupleDescriptorBuilder &descBuilder)
static std::uint32_t SerializeString(const std::string &val, void *buffer)
static RResult< std::uint32_t > DeserializeFrameHeader(const void *buffer, std::uint64_t bufSize, std::uint64_t &frameSize, std::uint32_t &nitems)
static std::uint32_t SerializePageList(void *buffer, const RNTupleDescriptor &desc, std::span< DescriptorId_t > physClusterIDs, const RContext &context)
static std::uint32_t DeserializeUInt32(const void *buffer, std::uint32_t &val)
static std::uint32_t SerializeUInt64(std::uint64_t val, void *buffer)
static std::uint32_t SerializeEnvelopePreamble(std::uint16_t envelopeType, void *buffer)
static std::uint32_t DeserializeInt16(const void *buffer, std::int16_t &val)
static std::uint32_t SerializeClusterSummary(const RClusterSummary &clusterSummary, void *buffer)
static std::uint32_t SerializeFramePostscript(void *frame, std::uint64_t size)
static std::uint32_t SerializeInt16(std::int16_t val, void *buffer)
static RResult< void > DeserializePageList(const void *buffer, std::uint64_t bufSize, DescriptorId_t clusterGroupId, RNTupleDescriptor &desc)
static 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 > DeserializeSchemaDescription(const void *buffer, std::uint64_t bufSize, RNTupleDescriptorBuilder &descBuilder)
static std::uint32_t SerializeLocator(const RNTupleLocator &locator, void *buffer)
static std::uint32_t SerializeInt32(std::int32_t val, void *buffer)
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::uint16_t > DeserializeColumnType(const void *buffer, ROOT::Experimental::EColumnType &type)
static std::uint32_t DeserializeUInt64(const void *buffer, std::uint64_t &val)
static RResult< std::uint32_t > DeserializeFeatureFlags(const void *buffer, std::uint64_t bufSize, std::vector< std::uint64_t > &flags)
static std::uint32_t DeserializeInt32(const void *buffer, std::int32_t &val)
static std::uint32_t DeserializeInt64(const void *buffer, std::int64_t &val)
static RResult< std::uint16_t > DeserializeFieldStructure(const void *buffer, ROOT::Experimental::ENTupleStructure &structure)
static std::uint32_t SerializeEnvelopeLink(const REnvelopeLink &envelopeLink, void *buffer)
static RResult< std::uint32_t > DeserializeString(const void *buffer, std::uint64_t bufSize, std::string &val)
static std::uint32_t SerializeRecordFramePreamble(void *buffer)
static std::uint32_t SerializeUInt16(std::uint16_t val, void *buffer)
static std::uint32_t SerializeClusterGroup(const RClusterGroup &clusterGroup, void *buffer)
static RResult< std::uint32_t > DeserializeEnvelopeLink(const void *buffer, std::uint64_t bufSize, REnvelopeLink &envelopeLink)
static std::uint32_t SerializeFooter(void *buffer, const RNTupleDescriptor &desc, const RContext &context)
static std::uint32_t SerializeInt64(std::int64_t val, void *buffer)
static std::uint16_t SerializeFieldStructure(ROOT::Experimental::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 > DeserializeEnvelope(const void *buffer, std::uint64_t bufSize, std::uint16_t expectedType)
static std::uint32_t SerializeUInt32(std::uint32_t val, void *buffer)
static RResult< std::uint32_t > DeserializeLocator(const void *buffer, std::uint64_t bufSize, RNTupleLocator &locator)
std::uint32_t GetNClusters() const
RColumnModel GetModel() const
Base class for all ROOT issued exceptions.
Meta-data stored for every field of an ntuple.
std::string GetTypeAlias() const
std::uint32_t GetTypeVersion() const
std::string GetFieldName() const
std::uint32_t GetFieldVersion() const
std::string GetFieldDescription() const
std::string GetTypeName() const
std::uint64_t GetNRepetitions() const
ENTupleStructure GetStructure() const
The on-storage meta-data of an ntuple.
std::size_t GetNLogicalColumns() const
std::string GetDescription() const
std::string GetName() const
std::uint64_t GetOnDiskHeaderXxHash3() const
DescriptorId_t GetFieldZeroId() const
Returns the logical parent of all top-level NTuple data fields.
const RClusterDescriptor & GetClusterDescriptor(DescriptorId_t clusterId) const
RFieldDescriptorIterable GetFieldIterable(const RFieldDescriptor &fieldDesc) const
std::size_t GetNFields() const
RResult< void > AddClusterGroupDetails(DescriptorId_t clusterGroupId, std::vector< RClusterDescriptor > &clusterDescs)
Methods to load and drop cluster group details (cluster IDs and page locations)
const RColumnDescriptor & GetColumnDescriptor(DescriptorId_t columnId) const
std::size_t GetNClusterGroups() const
const RFieldDescriptor & GetFieldDescriptor(DescriptorId_t fieldId) const
const RClusterGroupDescriptor & GetClusterGroupDescriptor(DescriptorId_t clusterGroupId) const
RColumnDescriptorIterable GetColumnIterable() const
std::size_t GetNPhysicalColumns() const
const RHeaderExtension * GetHeaderExtension() const
Return header extension information; if the descriptor does not have a header extension,...
std::vector< std::uint64_t > GetFeatureFlags() const
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
RLogChannel & NTupleLog()
Log channel for RNTuple diagnostics.
ENTupleStructure
The fields in the ntuple model tree can carry different structural information about the type system.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
REnvelopeLink fPageListEnvelopeLink
std::uint64_t fFirstEntry
std::int32_t fColumnGroupID
-1 for "all columns"
RNTupleLocator payload that is common for object stores using 64bit location information.
Generic information about the physical location of data.
ELocatorType
Values for the Type field in non-disk locators.
std::uint8_t fReserved
Reserved for use by concrete storage backends.
ELocatorType fType
For non-disk locators, the value for the Type field.
std::uint32_t fBytesOnStorage
std::variant< std::uint64_t, std::string, RNTupleLocatorObject64 > fPosition
Simple on-disk locators consisting of a 64-bit offset use variant type uint64_t; extended locators ha...
const T & GetPosition() const