rntviewer/src/rntuple.cpp

52 lines
1.7 KiB
C++
Raw Normal View History

2024-07-11 12:00:43 +00:00
internal
String8 rntuple_description(Arena *arena, const RNTuple &anchor)
{
String8 desc = push_str8f(arena, "version %u.%u.%u.%u",
anchor.GetVersionEpoch(),
anchor.GetVersionMajor(),
anchor.GetVersionMinor(),
anchor.GetVersionPatch());
return desc;
}
internal
2024-07-11 14:49:18 +00:00
RNTuple_Info get_rntuple_info(const char *fname, const char *ntpl_name)
2024-07-11 12:00:43 +00:00
{
2024-07-11 12:27:19 +00:00
RNTuple_Info info = {};
2024-07-11 12:00:43 +00:00
// Open the TFile
TFile *tfile = TFile::Open(fname, "READ");
if (!tfile) {
fprintf(stderr, "Failed to open TFile.\n");
return info;
}
defer { delete tfile; };
// Get the RNTuple information
const RNTuple *anchor = tfile->Get<RNTuple>(ntpl_name);
if (anchor) {
2024-07-11 12:27:19 +00:00
info.anchor = *anchor;
2024-07-11 14:29:44 +00:00
info.rng_header.start = anchor->GetSeekHeader();
info.rng_header.len = anchor->GetNBytesHeader();
info.rng_footer.start = anchor->GetSeekFooter();
info.rng_footer.len = anchor->GetNBytesFooter();
2024-07-11 12:00:43 +00:00
} else {
fprintf(stderr, "RNTuple '%s' not found in %s.\n", ntpl_name, fname);
}
2024-07-11 14:29:44 +00:00
// TODO: proper error handling
auto raw_file = ROOT::Internal::RRawFile::Create(fname);
if (raw_file) {
PseudoMiniFileReader file_reader { raw_file.get() };
auto file_info = file_reader.GetNTupleProper(ntpl_name).Unwrap();
info.rng_anchor.start = file_info.anchor_seek;
info.rng_anchor.len = file_info.anchor_nbytes;
info.rng_anchor_key.start = file_info.anchor_key_seek;
info.rng_anchor_key.len = file_info.anchor_key_nbytes;
info.rblob_header_size = file_info.rblob_key_header_nbytes;
info.root_file_header_size = file_info.tfile_header_nbytes;
}
2024-07-11 12:00:43 +00:00
return info;
}