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 += SerializeFieldV1(
f, onDiskParentId, *where);
100 std::uint32_t bufSize,
105 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
107 std::uint32_t frameSize;
108 auto fnFrameSizeLeft = [&]() {
return frameSize -
static_cast<std::uint32_t
>(
bytes - base); };
109 auto result = RNTupleSerializer::DeserializeFrameHeader(
bytes, bufSize, frameSize);
114 std::uint32_t fieldVersion;
115 std::uint32_t typeVersion;
116 std::uint32_t parentId;
118 ENTupleStructure structure{ENTupleStructure::kLeaf};
120 if (fnFrameSizeLeft() < 3 *
sizeof(std::uint32_t) +
121 RNTupleSerializer::SerializeFieldStructure(structure,
nullptr) +
122 sizeof(std::uint16_t))
124 return R__FAIL(
"field record frame too short");
126 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, fieldVersion);
127 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, typeVersion);
128 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, parentId);
129 auto res16 = RNTupleSerializer::DeserializeFieldStructure(
bytes, structure);
132 bytes += res16.Unwrap();
133 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, flags);
136 if (flags & RNTupleSerializer::kFlagRepetitiveField) {
137 if (fnFrameSizeLeft() <
sizeof(std::uint64_t))
138 return R__FAIL(
"field record frame too short");
139 std::uint64_t nRepetitions;
140 bytes += RNTupleSerializer::DeserializeUInt64(
bytes, nRepetitions);
144 std::string fieldName;
145 std::string typeName;
146 std::string aliasName;
147 std::string description;
148 result = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), fieldName).Unwrap();
152 result = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), typeName).Unwrap();
156 result = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), aliasName).Unwrap();
160 result = RNTupleSerializer::DeserializeString(
bytes, fnFrameSizeLeft(), description).Unwrap();
170 std::span<const ROOT::Experimental::DescriptorId_t> fieldList,
176 auto base =
reinterpret_cast<unsigned char *
>(buffer);
178 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
180 for (
auto parentId : fieldList) {
182 if (
c.IsAliasColumn())
186 pos += RNTupleSerializer::SerializeRecordFramePreamble(*where);
188 auto type =
c.GetModel().GetType();
189 pos += RNTupleSerializer::SerializeColumnType(
type, *where);
190 pos += RNTupleSerializer::SerializeUInt16(RColumnElementBase::GetBitsOnStorage(
type), *where);
191 pos += RNTupleSerializer::SerializeUInt32(context.
GetOnDiskFieldId(
c.GetFieldId()), *where);
192 std::uint32_t flags = 0;
194 if (
c.GetModel().GetIsSorted())
195 flags |= RNTupleSerializer::kFlagSortAscColumn;
198 flags |= RNTupleSerializer::kFlagNonNegativeColumn;
199 const std::uint64_t firstElementIdx =
c.GetFirstElementIndex();
200 if (firstElementIdx > 0)
201 flags |= RNTupleSerializer::kFlagDeferredColumn;
202 pos += RNTupleSerializer::SerializeUInt32(flags, *where);
203 if (flags & RNTupleSerializer::kFlagDeferredColumn)
204 pos += RNTupleSerializer::SerializeUInt64(firstElementIdx, *where);
206 pos += RNTupleSerializer::SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
215 std::uint32_t bufSize,
220 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
222 std::uint32_t frameSize;
223 auto fnFrameSizeLeft = [&]() {
return frameSize -
static_cast<std::uint32_t
>(
bytes - base); };
224 auto result = RNTupleSerializer::DeserializeFrameHeader(
bytes, bufSize, frameSize);
231 std::uint16_t bitsOnStorage;
232 std::uint32_t fieldId;
234 std::uint64_t firstElementIdx = 0;
235 if (fnFrameSizeLeft() < RNTupleSerializer::SerializeColumnType(
type,
nullptr) +
236 sizeof(std::uint16_t) + 2 *
sizeof(std::uint32_t))
238 return R__FAIL(
"column record frame too short");
240 auto res16 = RNTupleSerializer::DeserializeColumnType(
bytes,
type);
243 bytes += res16.Unwrap();
244 bytes += RNTupleSerializer::DeserializeUInt16(
bytes, bitsOnStorage);
245 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, fieldId);
246 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, flags);
247 if (flags & RNTupleSerializer::kFlagDeferredColumn) {
248 if (fnFrameSizeLeft() <
sizeof(std::uint64_t))
249 return R__FAIL(
"column record frame too short");
250 bytes += RNTupleSerializer::DeserializeUInt64(
bytes, firstElementIdx);
254 return R__FAIL(
"column element size mismatch");
256 const bool isSorted = (flags & (RNTupleSerializer::kFlagSortAscColumn | RNTupleSerializer::kFlagSortDesColumn));
257 columnDesc.
FieldId(fieldId).
Model({
type, isSorted}).FirstElementIndex(firstElementIdx);
264 const auto &uri = locator.
GetPosition<std::string>();
265 if (uri.length() >= (1 << 16))
268 memcpy(buffer, uri.data(), uri.length());
272void DeserializeLocatorPayloadURI(
const unsigned char *buffer, std::uint32_t payloadSize,
276 auto &uri = locator.
fPosition.emplace<std::string>();
277 uri.resize(payloadSize);
278 memcpy(uri.data(), buffer, payloadSize);
286 RNTupleSerializer::SerializeUInt64(
data.fLocation, buffer +
sizeof(std::uint32_t));
288 return sizeof(std::uint32_t) +
sizeof(std::uint64_t);
295 RNTupleSerializer::DeserializeUInt64(buffer +
sizeof(std::uint32_t),
data.fLocation);
299 std::span<const ROOT::Experimental::DescriptorId_t> fieldList,
303 auto base =
reinterpret_cast<unsigned char *
>(buffer);
305 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
307 for (
auto parentId : fieldList) {
309 if (!
c.IsAliasColumn())
313 pos += RNTupleSerializer::SerializeRecordFramePreamble(*where);
315 pos += RNTupleSerializer::SerializeUInt32(context.
GetOnDiskColumnId(
c.GetPhysicalId()), *where);
316 pos += RNTupleSerializer::SerializeUInt32(context.
GetOnDiskFieldId(
c.GetFieldId()), *where);
318 pos += RNTupleSerializer::SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
326 std::uint32_t &physicalColumnId, std::uint32_t &fieldId)
328 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
330 std::uint32_t frameSize;
331 auto fnFrameSizeLeft = [&]() {
return frameSize -
static_cast<std::uint32_t
>(
bytes - base); };
332 auto result = RNTupleSerializer::DeserializeFrameHeader(
bytes, bufSize, frameSize);
337 if (fnFrameSizeLeft() < 2 *
sizeof(std::uint32_t)) {
338 return R__FAIL(
"alias column record frame too short");
341 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, physicalColumnId);
342 bytes += RNTupleSerializer::DeserializeUInt32(
bytes, fieldId);
351 const unsigned char *
data, std::uint32_t
length, std::uint32_t &crc32,
void *buffer)
353 if (buffer !=
nullptr) {
354 crc32 = R__crc32(0,
nullptr, 0);
362 const unsigned char *
data, std::uint32_t
length, std::uint32_t &crc32)
364 auto checksumReal = R__crc32(0,
nullptr, 0);
365 checksumReal = R__crc32(checksumReal,
data,
length);
367 if (crc32 != checksumReal)
368 return R__FAIL(
"CRC32 checksum mismatch");
374 const unsigned char *
data, std::uint32_t
length)
383 if (buffer !=
nullptr) {
384 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
385 bytes[0] = (val & 0x00FF);
386 bytes[1] = (val & 0xFF00) >> 8;
393 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
394 val = std::int16_t(
bytes[0]) + (std::int16_t(
bytes[1]) << 8);
400 return SerializeInt16(val, buffer);
405 return DeserializeInt16(buffer, *
reinterpret_cast<std::int16_t *
>(&val));
410 if (buffer !=
nullptr) {
411 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
412 bytes[0] = (val & 0x000000FF);
413 bytes[1] = (val & 0x0000FF00) >> 8;
414 bytes[2] = (val & 0x00FF0000) >> 16;
415 bytes[3] = (val & 0xFF000000) >> 24;
422 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
423 val = std::int32_t(
bytes[0]) + (std::int32_t(
bytes[1]) << 8) +
424 (std::int32_t(
bytes[2]) << 16) + (std::int32_t(
bytes[3]) << 24);
430 return SerializeInt32(val, buffer);
435 return DeserializeInt32(buffer, *
reinterpret_cast<std::int32_t *
>(&val));
440 if (buffer !=
nullptr) {
441 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
442 bytes[0] = (val & 0x00000000000000FF);
443 bytes[1] = (val & 0x000000000000FF00) >> 8;
444 bytes[2] = (val & 0x0000000000FF0000) >> 16;
445 bytes[3] = (val & 0x00000000FF000000) >> 24;
446 bytes[4] = (val & 0x000000FF00000000) >> 32;
447 bytes[5] = (val & 0x0000FF0000000000) >> 40;
448 bytes[6] = (val & 0x00FF000000000000) >> 48;
449 bytes[7] = (val & 0xFF00000000000000) >> 56;
456 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
457 val = std::int64_t(
bytes[0]) + (std::int64_t(
bytes[1]) << 8) +
458 (std::int64_t(
bytes[2]) << 16) + (std::int64_t(
bytes[3]) << 24) +
459 (std::int64_t(
bytes[4]) << 32) + (std::int64_t(
bytes[5]) << 40) +
460 (std::int64_t(
bytes[6]) << 48) + (std::int64_t(
bytes[7]) << 56);
466 return SerializeInt64(val, buffer);
471 return DeserializeInt64(buffer, *
reinterpret_cast<std::int64_t *
>(&val));
477 auto pos =
reinterpret_cast<unsigned char *
>(buffer);
478 pos += SerializeUInt32(val.length(), pos);
479 memcpy(pos, val.data(), val.length());
481 return sizeof(std::uint32_t) + val.length();
485 const void *buffer, std::uint32_t bufSize, std::string &val)
487 if (bufSize <
sizeof(std::uint32_t))
488 return R__FAIL(
"string buffer too short");
489 bufSize -=
sizeof(std::uint32_t);
491 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
496 return R__FAIL(
"string buffer too short");
500 return sizeof(std::uint32_t) +
length;
545 std::uint16_t onDiskType;
546 auto result = DeserializeUInt16(buffer, onDiskType);
547 switch (onDiskType) {
575 default:
return R__FAIL(
"unexpected on-disk column type");
587 return SerializeUInt16(0x00, buffer);
589 return SerializeUInt16(0x01, buffer);
591 return SerializeUInt16(0x02, buffer);
593 return SerializeUInt16(0x03, buffer);
595 return SerializeUInt16(0x04, buffer);
606 std::uint16_t onDiskValue;
607 auto result = DeserializeUInt16(buffer, onDiskValue);
608 switch (onDiskValue) {
625 return R__FAIL(
"unexpected on-disk field structure value");
635 auto base =
reinterpret_cast<unsigned char *
>(buffer);
637 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
639 pos += SerializeUInt16(kEnvelopeCurrentVersion, *where);
640 pos += SerializeUInt16(kEnvelopeMinVersion, *where);
646 const unsigned char *envelope, std::uint32_t
size, std::uint32_t &crc32,
void *buffer)
648 return SerializeCRC32(envelope,
size, crc32, buffer);
652 const unsigned char *envelope, std::uint32_t
size,
void *buffer)
655 return SerializeEnvelopePostscript(envelope,
size, crc32, buffer);
661 const void *buffer, std::uint32_t bufSize, std::uint32_t &crc32)
663 if (bufSize < (2 *
sizeof(std::uint16_t) +
sizeof(std::uint32_t)))
664 return R__FAIL(
"invalid envelope, too short");
666 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
669 std::uint16_t protocolVersionAtWrite;
670 std::uint16_t protocolVersionMinRequired;
671 bytes += DeserializeUInt16(
bytes, protocolVersionAtWrite);
673 if (protocolVersionAtWrite < 1)
674 return R__FAIL(
"The RNTuple format is too old (version 0)");
676 bytes += DeserializeUInt16(
bytes, protocolVersionMinRequired);
677 if (protocolVersionMinRequired > kEnvelopeCurrentVersion) {
678 return R__FAIL(std::string(
"The RNTuple format is too new (version ") +
679 std::to_string(protocolVersionMinRequired) +
")");
683 auto result = VerifyCRC32(base, bufSize - 4, crc32);
687 return sizeof(protocolVersionAtWrite) +
sizeof(protocolVersionMinRequired);
692 const void *buffer, std::uint32_t bufSize)
702 return SerializeInt32(1, buffer);
707 std::uint32_t
nitems,
void *buffer)
712 auto base =
reinterpret_cast<unsigned char *
>(buffer);
714 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
718 pos += SerializeUInt32(
nitems, *where);
723 void *frame, std::int32_t
size)
727 if (
size <
static_cast<std::int32_t
>(
sizeof(std::int32_t)))
731 DeserializeInt32(frame, marker);
732 if ((marker < 0) && (
size <
static_cast<std::int32_t
>(2 *
sizeof(std::int32_t))))
735 SerializeInt32(marker *
size, frame);
741 const void *buffer, std::uint32_t bufSize, std::uint32_t &frameSize, std::uint32_t &
nitems)
743 if (bufSize <
sizeof(std::int32_t))
744 return R__FAIL(
"frame too short");
746 std::int32_t *ssize =
reinterpret_cast<std::int32_t *
>(&frameSize);
747 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
752 if (frameSize <
sizeof(std::int32_t))
753 return R__FAIL(
"corrupt record frame size");
756 if (bufSize < 2 *
sizeof(std::int32_t))
757 return R__FAIL(
"frame too short");
761 if (frameSize < 2 *
sizeof(std::int32_t))
762 return R__FAIL(
"corrupt list frame size");
765 if (bufSize < frameSize)
766 return R__FAIL(
"frame too short");
768 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
772 const void *buffer, std::uint32_t bufSize, std::uint32_t &frameSize)
779 const std::vector<std::int64_t> &flags,
void *buffer)
782 return SerializeInt64(0, buffer);
785 auto bytes =
reinterpret_cast<unsigned char *
>(buffer);
787 for (
unsigned i = 0; i < flags.size(); ++i) {
792 if (i == (flags.size() - 1))
793 SerializeInt64(flags[i],
bytes);
795 bytes += SerializeInt64(flags[i] | 0x8000000000000000,
bytes);
798 return (flags.size() *
sizeof(std::int64_t));
802 const void *buffer, std::uint32_t bufSize, std::vector<std::int64_t> &flags)
804 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
809 if (bufSize <
sizeof(std::int64_t))
810 return R__FAIL(
"feature flag buffer too short");
812 bufSize -=
sizeof(std::int64_t);
813 flags.emplace_back(
f & ~0x8000000000000000);
816 return (flags.size() *
sizeof(std::int64_t));
825 std::uint32_t
size = 0;
831 buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
835 auto payloadp = buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
sizeof(std::int32_t) :
nullptr;
836 switch (locator.
fType) {
841 std::int32_t head =
sizeof(std::int32_t) +
size;
843 head |=
static_cast<int>(locator.
fType & 0x7F) << 24;
850 const void *buffer, std::uint32_t bufSize,
RNTupleLocator &locator)
852 if (bufSize <
sizeof(std::int32_t))
853 return R__FAIL(
"too short locator");
855 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
859 bufSize -=
sizeof(std::int32_t);
862 const int type = head >> 24;
863 const std::uint32_t payloadSize = (
static_cast<std::uint32_t
>(head) & 0x0000FFFF) -
sizeof(std::int32_t);
864 if (bufSize < payloadSize)
865 return R__FAIL(
"too short locator");
867 locator.
fReserved =
static_cast<std::uint32_t
>(head >> 16) & 0xFF;
871 default:
return R__FAIL(
"unsupported locator type: " + std::to_string(
type));
873 bytes += payloadSize;
875 if (bufSize <
sizeof(std::uint64_t))
876 return R__FAIL(
"too short locator");
883 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
891 buffer ?
reinterpret_cast<unsigned char *
>(buffer) +
size :
nullptr);
896 const void *buffer, std::uint32_t bufSize,
REnvelopeLink &envelopeLink)
898 if (bufSize <
sizeof(std::int32_t))
899 return R__FAIL(
"too short envelope link");
901 auto bytes =
reinterpret_cast<const unsigned char *
>(buffer);
903 bufSize -=
sizeof(std::uint32_t);
908 return bytes -
reinterpret_cast<const unsigned char *
>(buffer);
915 auto base =
reinterpret_cast<unsigned char *
>(buffer);
917 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
920 pos += SerializeRecordFramePreamble(*where);
921 pos += SerializeUInt64(clusterSummary.
fFirstEntry, *where);
923 pos += SerializeInt64(-
static_cast<int64_t
>(clusterSummary.
fNEntries), *where);
926 pos += SerializeInt64(
static_cast<int64_t
>(clusterSummary.
fNEntries), *where);
928 auto size = pos - frame;
929 pos += SerializeFramePostscript(frame,
size);
935 const void *buffer, std::uint32_t bufSize,
RClusterSummary &clusterSummary)
937 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
939 std::uint32_t frameSize;
940 auto result = DeserializeFrameHeader(
bytes, bufSize, frameSize);
945 auto fnBufSizeLeft = [&]() {
return frameSize -
static_cast<std::uint32_t
>(
bytes - base); };
946 if (fnBufSizeLeft() < 2 *
sizeof(std::uint64_t))
947 return R__FAIL(
"too short cluster summary");
950 std::int64_t nEntries;
954 if (fnBufSizeLeft() <
sizeof(std::uint32_t))
955 return R__FAIL(
"too short cluster summary");
957 std::uint32_t columnGroupID;
958 bytes += DeserializeUInt32(
bytes, columnGroupID);
972 auto base =
reinterpret_cast<unsigned char *
>(buffer);
974 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
977 pos += SerializeRecordFramePreamble(*where);
978 pos += SerializeUInt32(clusterGroup.
fNClusters, *where);
980 auto size = pos - frame;
981 pos += SerializeFramePostscript(frame,
size);
987 const void *buffer, std::uint32_t bufSize,
RClusterGroup &clusterGroup)
989 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
992 std::uint32_t frameSize;
993 auto result = DeserializeFrameHeader(
bytes, bufSize, frameSize);
998 auto fnFrameSizeLeft = [&]() {
return frameSize -
static_cast<std::uint32_t
>(
bytes - base); };
999 if (fnFrameSizeLeft() <
sizeof(std::uint32_t))
1000 return R__FAIL(
"too short cluster group");
1011 bool forHeaderExtension)
1014 auto depthFirstTraversal = [&](std::span<DescriptorId_t> fieldTrees,
auto doForEachField) {
1015 std::deque<DescriptorId_t> idQueue{fieldTrees.begin(), fieldTrees.end()};
1016 while (!idQueue.empty()) {
1017 auto fieldId = idQueue.front();
1018 idQueue.pop_front();
1020 if (fieldId != fieldZeroId)
1021 doForEachField(fieldId);
1024 idQueue.insert(idQueue.begin() + i++,
f.GetId());
1029 if (!forHeaderExtension)
1030 R__ASSERT(GetHeaderExtensionOffset() == -1U);
1032 std::vector<DescriptorId_t> fieldTrees;
1033 if (!forHeaderExtension) {
1034 fieldTrees.emplace_back(fieldZeroId);
1036 fieldTrees = xHeader->GetTopLevelFields(desc);
1038 depthFirstTraversal(fieldTrees, [&](
DescriptorId_t fieldId) { MapFieldId(fieldId); });
1041 if (!
c.IsAliasColumn())
1042 MapColumnId(
c.GetLogicalId());
1046 if (
c.IsAliasColumn())
1047 MapColumnId(
c.GetLogicalId());
1051 if (!forHeaderExtension)
1052 BeginHeaderExtension();
1058 bool forHeaderExtension)
1060 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1062 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
1064 std::size_t nFields = 0, nColumns = 0, nAliasColumns = 0, fieldListOffset = 0;
1065 if (forHeaderExtension) {
1069 nFields = xHeader->GetNFields();
1070 nColumns = xHeader->GetNPhysicalColumns();
1071 nAliasColumns = xHeader->GetNLogicalColumns() - xHeader->GetNPhysicalColumns();
1080 R__ASSERT(onDiskFields.size() >= fieldListOffset);
1081 std::span<const DescriptorId_t> fieldList{onDiskFields.data() + fieldListOffset,
1082 onDiskFields.size() - fieldListOffset};
1085 pos += SerializeListFramePreamble(nFields, *where);
1086 pos += SerializeFieldList(desc, fieldList, fieldListOffset, context, *where);
1087 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1090 pos += SerializeListFramePreamble(nColumns, *where);
1091 pos += SerializeColumnListV1(desc, fieldList, context, *where);
1092 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1095 pos += SerializeListFramePreamble(nAliasColumns, *where);
1096 pos += SerializeAliasColumnList(desc, fieldList, context, *where);
1097 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1101 pos += SerializeListFramePreamble(0, *where);
1102 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1103 return static_cast<std::uint32_t
>(pos - base);
1110 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1112 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1115 std::uint32_t frameSize;
1117 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - frame); };
1119 std::uint32_t nFields;
1120 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nFields);
1126 for (
unsigned i = 0; i < nFields; ++i) {
1127 std::uint32_t fieldId = fieldIdRangeBegin + i;
1129 result = DeserializeFieldV1(
bytes, fnFrameSizeLeft(), fieldBuilder);
1134 fieldBuilder.
ParentId(kZeroFieldId);
1138 auto parentId = fieldDesc.Inspect().GetParentId();
1139 descBuilder.
AddField(fieldDesc.Unwrap());
1140 auto resVoid = descBuilder.
AddFieldLink(parentId, fieldId);
1144 bytes = frame + frameSize;
1146 std::uint32_t nColumns;
1148 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nColumns);
1153 std::unordered_map<DescriptorId_t, std::uint32_t> maxIndexes;
1154 for (
unsigned i = 0; i < nColumns; ++i) {
1155 std::uint32_t columnId = columnIdRangeBegin + i;
1157 result = DeserializeColumnV1(
bytes, fnFrameSizeLeft(), columnBuilder);
1162 std::uint32_t idx = 0;
1163 const auto fieldId = columnBuilder.
GetFieldId();
1164 auto maxIdx = maxIndexes.find(fieldId);
1165 if (maxIdx != maxIndexes.end())
1166 idx = maxIdx->second + 1;
1167 maxIndexes[fieldId] = idx;
1172 auto resVoid = descBuilder.
AddColumn(columnDesc.Unwrap());
1176 bytes = frame + frameSize;
1178 std::uint32_t nAliasColumns;
1180 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nAliasColumns);
1184 const std::uint32_t aliasColumnIdRangeBegin = columnIdRangeBegin + nColumns;
1185 for (
unsigned i = 0; i < nAliasColumns; ++i) {
1186 std::uint32_t physicalId;
1187 std::uint32_t fieldId;
1188 result = DeserializeAliasColumn(
bytes, fnFrameSizeLeft(), physicalId, fieldId);
1197 std::uint32_t idx = 0;
1198 auto maxIdx = maxIndexes.find(fieldId);
1199 if (maxIdx != maxIndexes.end())
1200 idx = maxIdx->second + 1;
1201 maxIndexes[fieldId] = idx;
1204 if (!aliasColumnDesc)
1206 auto resVoid = descBuilder.
AddColumn(aliasColumnDesc.Unwrap());
1210 bytes = frame + frameSize;
1212 std::uint32_t nTypeInfo;
1214 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nTypeInfo);
1219 bytes = frame + frameSize;
1221 return bytes - base;
1230 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1232 void **where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void **
>(&pos);
1234 pos += SerializeEnvelopePreamble(*where);
1236 pos += SerializeFeatureFlags(std::vector<std::int64_t>(), *where);
1237 pos += SerializeUInt32(kReleaseCandidateTag, *where);
1238 pos += SerializeString(desc.
GetName(), *where);
1240 pos += SerializeString(std::string(
"ROOT v") +
ROOT_RELEASE, *where);
1243 pos += SerializeSchemaDescription(*where, desc, context);
1245 std::uint32_t
size = pos - base;
1246 std::uint32_t crc32 = 0;
1247 size += SerializeEnvelopePostscript(base,
size, crc32, *where);
1257 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1259 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
1261 pos += SerializeEnvelopePreamble(*where);
1262 auto topMostFrame = pos;
1263 pos += SerializeListFramePreamble(physClusterIDs.size(), *where);
1265 for (
auto clusterId : physClusterIDs) {
1268 std::set<DescriptorId_t> onDiskColumnIds;
1269 for (
auto column : clusterDesc.GetColumnIds())
1272 auto outerFrame = pos;
1273 pos += SerializeListFramePreamble(onDiskColumnIds.size(), *where);
1274 for (
auto onDiskId : onDiskColumnIds) {
1276 const auto &columnRange = clusterDesc.GetColumnRange(memId);
1277 const auto &pageRange = clusterDesc.GetPageRange(memId);
1279 auto innerFrame = pos;
1280 pos += SerializeListFramePreamble(pageRange.fPageInfos.size(), *where);
1282 for (
const auto &pi : pageRange.fPageInfos) {
1283 pos += SerializeUInt32(pi.fNElements, *where);
1284 pos += SerializeLocator(pi.fLocator, *where);
1286 pos += SerializeUInt64(columnRange.fFirstElementIndex, *where);
1287 pos += SerializeUInt32(columnRange.fCompressionSettings, *where);
1289 pos += SerializeFramePostscript(buffer ? innerFrame :
nullptr, pos - innerFrame);
1291 pos += SerializeFramePostscript(buffer ? outerFrame :
nullptr, pos - outerFrame);
1294 pos += SerializeFramePostscript(buffer ? topMostFrame :
nullptr, pos - topMostFrame);
1295 std::uint32_t
size = pos - base;
1296 size += SerializeEnvelopePostscript(base,
size, *where);
1305 auto base =
reinterpret_cast<unsigned char *
>(buffer);
1307 void** where = (buffer ==
nullptr) ? &buffer :
reinterpret_cast<void**
>(&pos);
1309 pos += SerializeEnvelopePreamble(*where);
1312 pos += SerializeFeatureFlags(std::vector<std::int64_t>(), *where);
1317 pos += SerializeRecordFramePreamble(*where);
1318 pos += SerializeSchemaDescription(*where, desc, context,
true);
1319 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1323 pos += SerializeListFramePreamble(0, *where);
1324 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1328 unsigned int nClusters = 0;
1330 nClusters += cgDesc.GetNClusters();
1332 pos += SerializeListFramePreamble(nClusters, *where);
1333 for (
unsigned int i = 0; i < nClusterGroups; ++i) {
1336 const auto &clusterIds = cgDesc.GetClusterIds();
1337 for (
unsigned int j = 0; j < nClustersInGroup; ++j) {
1339 RClusterSummary summary{clusterDesc.GetFirstEntryIndex(), clusterDesc.GetNEntries(), -1};
1340 pos += SerializeClusterSummary(summary, *where);
1343 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1347 pos += SerializeListFramePreamble(nClusterGroups, *where);
1348 for (
unsigned int i = 0; i < nClusterGroups; ++i) {
1351 clusterGroup.
fNClusters = cgDesc.GetNClusters();
1354 pos += SerializeClusterGroup(clusterGroup, *where);
1356 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1360 pos += SerializeListFramePreamble(0, *where);
1361 pos += SerializeFramePostscript(buffer ? frame :
nullptr, pos - frame);
1363 std::uint32_t
size = pos - base;
1364 size += SerializeEnvelopePostscript(base,
size, *where);
1371 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1373 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1376 std::uint32_t crc32{0};
1377 result = DeserializeEnvelope(
bytes, fnBufSizeLeft(), crc32);
1383 std::vector<std::int64_t> featureFlags;
1384 result = DeserializeFeatureFlags(
bytes, fnBufSizeLeft(), featureFlags);
1388 for (
auto f: featureFlags) {
1393 std::uint32_t rcTag;
1394 if (fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint32_t)))
1395 return R__FAIL(
"header too short");
1402 std::string description;
1408 result = DeserializeString(
bytes, fnBufSizeLeft(), description);
1421 result = DeserializeSchemaDescription(
bytes, fnBufSizeLeft(), descBuilder);
1432 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1434 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1437 result = DeserializeEnvelope(
bytes, fnBufSizeLeft());
1442 std::vector<std::int64_t> featureFlags;
1443 result = DeserializeFeatureFlags(
bytes, fnBufSizeLeft(), featureFlags);
1447 for (
auto f: featureFlags) {
1452 std::uint32_t crc32{0};
1453 if (fnBufSizeLeft() <
static_cast<int>(
sizeof(std::uint32_t)))
1454 return R__FAIL(
"footer too short");
1457 return R__FAIL(
"CRC32 mismatch between header and footer");
1459 std::uint32_t frameSize;
1461 auto fnFrameSizeLeft = [&]() {
return frameSize - (
bytes - frame); };
1463 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize);
1467 if (fnFrameSizeLeft() > 0) {
1469 result = DeserializeSchemaDescription(
bytes, fnFrameSizeLeft(), descBuilder);
1473 bytes = frame + frameSize;
1475 std::uint32_t nColumnGroups;
1477 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nColumnGroups);
1480 if (nColumnGroups > 0)
1481 return R__FAIL(
"sharded clusters are still unsupported");
1482 bytes = frame + frameSize;
1484 std::uint32_t nClusterSummaries;
1486 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nClusterSummaries);
1490 for (std::uint32_t clusterId = 0; clusterId < nClusterSummaries; ++clusterId) {
1492 result = DeserializeClusterSummary(
bytes, fnFrameSizeLeft(), clusterSummary);
1497 return R__FAIL(
"sharded clusters are still unsupported");
1500 bytes = frame + frameSize;
1502 std::uint32_t nClusterGroups;
1504 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nClusterGroups);
1508 std::uint64_t clusterId = 0;
1509 for (std::uint32_t groupId = 0; groupId < nClusterGroups; ++groupId) {
1511 result = DeserializeClusterGroup(
bytes, fnFrameSizeLeft(), clusterGroup);
1521 for (std::uint64_t i = 0; i < clusterGroup.
fNClusters; ++i)
1522 clusterGroupBuilder.
AddCluster(clusterId + i);
1526 bytes = frame + frameSize;
1528 std::uint32_t nMDBlocks;
1530 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), frameSize, nMDBlocks);
1535 bytes = frame + frameSize;
1542 const void *buffer, std::uint32_t bufSize, std::vector<RClusterDescriptorBuilder> &clusters)
1544 auto base =
reinterpret_cast<const unsigned char *
>(buffer);
1546 auto fnBufSizeLeft = [&]() {
return bufSize - (
bytes - base); };
1549 result = DeserializeEnvelope(
bytes, fnBufSizeLeft());
1554 std::uint32_t topMostFrameSize;
1555 auto topMostFrame =
bytes;
1556 auto fnTopMostFrameSizeLeft = [&]() {
return topMostFrameSize - (
bytes - topMostFrame); };
1558 std::uint32_t nClusters;
1559 result = DeserializeFrameHeader(
bytes, fnBufSizeLeft(), topMostFrameSize, nClusters);
1564 if (nClusters != clusters.size())
1565 return R__FAIL(
"mismatch of page list and cluster summaries");
1567 for (std::uint32_t i = 0; i < nClusters; ++i) {
1568 std::uint32_t outerFrameSize;
1569 auto outerFrame =
bytes;
1570 auto fnOuterFrameSizeLeft = [&]() {
return outerFrameSize - (
bytes - outerFrame); };
1572 std::uint32_t nColumns;
1573 result = DeserializeFrameHeader(
bytes, fnTopMostFrameSizeLeft(), outerFrameSize, nColumns);
1578 for (std::uint32_t j = 0; j < nColumns; ++j) {
1579 std::uint32_t innerFrameSize;
1580 auto innerFrame =
bytes;
1581 auto fnInnerFrameSizeLeft = [&]() {
return innerFrameSize - (
bytes - innerFrame); };
1583 std::uint32_t nPages;
1584 result = DeserializeFrameHeader(
bytes, fnOuterFrameSizeLeft(), innerFrameSize, nPages);
1591 for (std::uint32_t k = 0; k < nPages; ++k) {
1592 if (fnInnerFrameSizeLeft() <
static_cast<int>(
sizeof(std::uint32_t)))
1593 return R__FAIL(
"inner frame too short");
1594 std::uint32_t nElements;
1596 bytes += DeserializeUInt32(
bytes, nElements);
1597 result = DeserializeLocator(
bytes, fnInnerFrameSizeLeft(), locator);
1600 pageRange.
fPageInfos.push_back({nElements, locator});
1604 if (fnInnerFrameSizeLeft() <
static_cast<int>(
sizeof(std::uint32_t) +
sizeof(std::uint64_t)))
1605 return R__FAIL(
"page list frame too short");
1606 std::uint64_t columnOffset;
1607 bytes += DeserializeUInt64(
bytes, columnOffset);
1608 std::uint32_t compressionSettings;
1609 bytes += DeserializeUInt32(
bytes, compressionSettings);
1611 clusters[i].CommitColumnRange(j, columnOffset, compressionSettings, pageRange);
1612 bytes = innerFrame + innerFrameSize;
1615 bytes = outerFrame + outerFrameSize;
#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 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 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
A column element encapsulates the translation between basic C++ types and their column representation...
virtual std::size_t GetBitsOnStorage() const
The available trivial, native content types of a column.
The serialization context is used for the piecewise serialization of a descriptor.
void SetHeaderCRC32(std::uint32_t crc32)
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,...
void SetHeaderSize(std::uint32_t size)
DescriptorId_t GetOnDiskFieldId(DescriptorId_t memId) const
std::uint32_t GetHeaderCRC32() const
DescriptorId_t GetMemColumnId(DescriptorId_t onDiskId) const
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 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 RResult< std::uint32_t > DeserializeString(const void *buffer, std::uint32_t bufSize, std::string &val)
static std::uint32_t SerializeFeatureFlags(const std::vector< std::int64_t > &flags, void *buffer)
static std::uint32_t SerializePageListV1(void *buffer, const RNTupleDescriptor &desc, std::span< DescriptorId_t > physClusterIDs, const RContext &context)
static std::uint32_t SerializeListFramePreamble(std::uint32_t nitems, void *buffer)
static RResult< std::uint32_t > DeserializeLocator(const void *buffer, std::uint32_t bufSize, RNTupleLocator &locator)
static std::uint32_t SerializeCRC32(const unsigned char *data, std::uint32_t length, std::uint32_t &crc32, void *buffer)
Writes a CRC32 checksum of the byte range given by data and length.
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 > DeserializePageListV1(const void *buffer, std::uint32_t bufSize, std::vector< RClusterDescriptorBuilder > &clusters)
static std::uint32_t SerializeString(const std::string &val, void *buffer)
static RResult< std::uint32_t > DeserializeEnvelope(const void *buffer, std::uint32_t bufSize)
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 DeserializeInt16(const void *buffer, std::int16_t &val)
static std::uint32_t SerializeClusterSummary(const RClusterSummary &clusterSummary, void *buffer)
static RContext SerializeHeaderV1(void *buffer, const RNTupleDescriptor &desc)
static RResult< void > DeserializeFooterV1(const void *buffer, std::uint32_t bufSize, RNTupleDescriptorBuilder &descBuilder)
static std::uint32_t SerializeInt16(std::int16_t val, void *buffer)
static RResult< std::uint32_t > DeserializeSchemaDescription(const void *buffer, std::uint32_t bufSize, RNTupleDescriptorBuilder &descBuilder)
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 std::uint32_t SerializeLocator(const RNTupleLocator &locator, void *buffer)
static std::uint32_t SerializeInt32(std::int32_t val, void *buffer)
static std::uint32_t SerializeEnvelopePreamble(void *buffer)
Currently all enevelopes have the same version number (1).
static RResult< std::uint16_t > DeserializeColumnType(const void *buffer, ROOT::Experimental::EColumnType &type)
static RResult< std::uint32_t > DeserializeClusterGroup(const void *buffer, std::uint32_t bufSize, RClusterGroup &clusterGroup)
static std::uint32_t DeserializeUInt64(const void *buffer, std::uint64_t &val)
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::uint32_t > DeserializeEnvelopeLink(const void *buffer, std::uint32_t bufSize, REnvelopeLink &envelopeLink)
static std::uint32_t SerializeEnvelopePostscript(const unsigned char *envelope, std::uint32_t size, void *buffer)
static RResult< std::uint16_t > DeserializeFieldStructure(const void *buffer, ROOT::Experimental::ENTupleStructure &structure)
static std::uint32_t SerializeEnvelopeLink(const REnvelopeLink &envelopeLink, void *buffer)
static std::uint32_t SerializeRecordFramePreamble(void *buffer)
static std::uint32_t SerializeUInt16(std::uint16_t val, void *buffer)
static RResult< std::uint32_t > DeserializeFrameHeader(const void *buffer, std::uint32_t bufSize, std::uint32_t &frameSize, std::uint32_t &nitems)
static RResult< std::uint32_t > DeserializeFeatureFlags(const void *buffer, std::uint32_t bufSize, std::vector< std::int64_t > &flags)
static std::uint32_t SerializeClusterGroup(const RClusterGroup &clusterGroup, void *buffer)
static std::uint32_t SerializeFramePostscript(void *frame, std::int32_t size)
static std::uint32_t SerializeFooterV1(void *buffer, const RNTupleDescriptor &desc, const RContext &context)
static std::uint32_t SerializeInt64(std::int64_t val, void *buffer)
static RResult< void > VerifyCRC32(const unsigned char *data, std::uint32_t length, std::uint32_t &crc32)
Expects a CRC32 checksum in the 4 bytes following data + length and verifies it.
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 std::uint32_t SerializeUInt32(std::uint32_t val, void *buffer)
static RResult< void > DeserializeHeaderV1(const void *buffer, std::uint32_t bufSize, RNTupleDescriptorBuilder &descBuilder)
static RResult< std::uint32_t > DeserializeClusterSummary(const void *buffer, std::uint32_t bufSize, RClusterSummary &clusterSummary)
A helper class for piece-wise construction of an RClusterGroupDescriptor.
RClusterGroupDescriptorBuilder & ClusterGroupId(DescriptorId_t clusterGroupId)
void AddCluster(DescriptorId_t clusterId)
RClusterGroupDescriptorBuilder & PageListLength(std::uint32_t pageListLength)
RClusterGroupDescriptorBuilder & PageListLocator(const RNTupleLocator &pageListLocator)
std::uint64_t GetNClusters() const
A helper class for piece-wise construction of an RColumnDescriptor.
RColumnDescriptorBuilder & Model(const RColumnModel &model)
RResult< RColumnDescriptor > MakeDescriptor() const
Attempt to make a column descriptor.
RColumnDescriptorBuilder & FieldId(DescriptorId_t fieldId)
DescriptorId_t GetFieldId() const
RColumnDescriptorBuilder & Index(std::uint32_t index)
RColumnDescriptorBuilder & LogicalColumnId(DescriptorId_t logicalColumnId)
RColumnDescriptorBuilder & PhysicalColumnId(DescriptorId_t physicalColumnId)
RColumnModel GetModel() const
Base class for all ROOT issued exceptions.
A helper class for piece-wise construction of an RFieldDescriptor.
RFieldDescriptorBuilder & FieldName(const std::string &fieldName)
RFieldDescriptorBuilder & NRepetitions(std::uint64_t nRepetitions)
DescriptorId_t GetParentId() const
RFieldDescriptorBuilder & Structure(const ENTupleStructure &structure)
RResult< RFieldDescriptor > MakeDescriptor() const
Attempt to make a field descriptor.
RFieldDescriptorBuilder & TypeName(const std::string &typeName)
RFieldDescriptorBuilder & TypeVersion(std::uint32_t typeVersion)
RFieldDescriptorBuilder & ParentId(DescriptorId_t id)
RFieldDescriptorBuilder & FieldDescription(const std::string &fieldDescription)
RFieldDescriptorBuilder & FieldVersion(std::uint32_t fieldVersion)
RFieldDescriptorBuilder & TypeAlias(const std::string &typeAlias)
RFieldDescriptorBuilder & FieldId(DescriptorId_t fieldId)
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
A helper class for piece-wise construction of an RNTupleDescriptor.
std::uint32_t GetHeaderCRC32() const
void AddToOnDiskFooterSize(std::uint64_t size)
The real footer size also include the page list envelopes.
RResult< void > AddClusterSummary(DescriptorId_t clusterId, std::uint64_t firstEntry, std::uint64_t nEntries)
void AddColumn(DescriptorId_t logicalId, DescriptorId_t physicalId, DescriptorId_t fieldId, const RColumnModel &model, std::uint32_t index, std::uint64_t firstElementIdx=0U)
RResult< void > AddFieldLink(DescriptorId_t fieldId, DescriptorId_t linkId)
void SetHeaderCRC32(std::uint32_t crc32)
void SetNTuple(const std::string_view name, const std::string_view description)
const RNTupleDescriptor & GetDescriptor() const
void AddClusterGroup(RClusterGroupDescriptorBuilder &&clusterGroup)
void BeginHeaderExtension()
Mark the beginning of the header extension; any fields and columns added after a call to this functio...
void AddField(const RFieldDescriptor &fieldDesc)
The on-storage meta-data of an ntuple.
std::size_t GetNLogicalColumns() const
RClusterGroupDescriptorIterable GetClusterGroupIterable() const
std::string GetDescription() const
std::string GetName() 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
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,...
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"
std::uint32_t fUnzippedSize
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