15#include <nlohmann/json.hpp>
37 nlohmann::json jsonAnchor;
52 return jsonAnchor.dump(2);
62 nlohmann::json jsonAnchor;
64 jsonAnchor = nlohmann::json::parse(
json);
65 }
catch (
const nlohmann::json::parse_error &
e) {
66 return R__FAIL(
"cannot parse S3 anchor JSON: " + std::string(
e.what()));
72 anchor.
fVersionAnchor = jsonAnchor.at(
"anchorVersion").get<std::uint32_t>();
73 }
catch (
const nlohmann::json::exception &
e) {
74 return R__FAIL(
"missing or invalid 'anchorVersion' in S3 anchor: " + std::string(
e.what()));
81 anchor.
fVersionEpoch = jsonAnchor.at(
"formatVersionEpoch").get<std::uint16_t>();
82 anchor.
fVersionMajor = jsonAnchor.at(
"formatVersionMajor").get<std::uint16_t>();
83 anchor.
fVersionMinor = jsonAnchor.at(
"formatVersionMinor").get<std::uint16_t>();
84 anchor.
fVersionPatch = jsonAnchor.at(
"formatVersionPatch").get<std::uint16_t>();
85 anchor.
fUrlTemplate = jsonAnchor.at(
"urlTemplate").get<std::string>();
86 anchor.
fHeaderObjId = jsonAnchor.at(
"headerObjId").get<std::uint64_t>();
87 anchor.
fHeaderOffset = jsonAnchor.at(
"headerOffset").get<std::uint64_t>();
88 anchor.
fNBytesHeader = jsonAnchor.at(
"nBytesHeader").get<std::uint64_t>();
89 anchor.
fLenHeader = jsonAnchor.at(
"lenHeader").get<std::uint64_t>();
90 anchor.
fFooterObjId = jsonAnchor.at(
"footerObjId").get<std::uint64_t>();
91 anchor.
fFooterOffset = jsonAnchor.at(
"footerOffset").get<std::uint64_t>();
92 anchor.
fNBytesFooter = jsonAnchor.at(
"nBytesFooter").get<std::uint64_t>();
93 anchor.
fLenFooter = jsonAnchor.at(
"lenFooter").get<std::uint64_t>();
94 }
catch (
const nlohmann::json::exception &
e) {
95 return R__FAIL(
"missing or invalid field in S3 anchor: " + std::string(
e.what()));
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
Entry point for an RNTuple stored in S3-compatible object storage.
std::uint16_t fVersionMinor
bool operator==(const RNTupleAnchorS3 &other) const
Field-by-field equality check across all 14 anchor members.
std::uint64_t fHeaderObjId
Object ID and byte offset of the compressed header within the S3 object.
std::string fUrlTemplate
Pattern for resolving object IDs to full S3 URLs.
std::uint32_t fVersionAnchor
Allows evolving the anchor JSON schema in future versions.
std::uint16_t fVersionPatch
std::uint16_t fVersionEpoch
Version of the RNTuple binary format supported by the writer.
std::uint64_t fNBytesHeader
Compressed and uncompressed sizes of the header envelope.
std::string ToJSON() const
Serialize the anchor to a JSON string suitable for storage at the base URL.
std::uint64_t fHeaderOffset
std::uint64_t fFooterOffset
std::uint64_t fNBytesFooter
Compressed and uncompressed sizes of the footer envelope.
static RResult< RNTupleAnchorS3 > CreateFromJSON(const std::string &json)
Deserialize the anchor from a JSON string. Returns an error on malformed or incompatible input.
std::uint64_t fFooterObjId
Object ID and byte offset of the compressed footer within the S3 object.
std::uint16_t fVersionMajor