separate root_iface type from RNTuple_Info

This commit is contained in:
silverweed 2024-07-12 10:25:58 +02:00
parent db4d0c64f6
commit edd376b4ba
6 changed files with 35 additions and 15 deletions

View file

@ -7,6 +7,7 @@ ROOTLIBS = -L$(ROOT)/lib -lCore -lRIO -lROOTNTuple -lxxhash -Wl,-rpath,$(ROOT)/l
LIBS = -lglfw
MOLD = mold -run
ROOT_IFACE = build/libroot_iface.so
ROOT_IFACE_DBG = build/libroot_iface_d.so
.PHONY: all clean
all: build/imgui.o $(ROOT_IFACE) noasan
@ -20,14 +21,17 @@ build/imgui.o: src/imgui_inc.cpp third_party/imgui/imgui.h
# $(ROOT_IFACE): src/root/RMicroFileReader.cxx
# $(CXX) -O3 -fPIC -c $(ROOTFLAGS) $< -o $@
$(ROOT_IFACE): src/root/RMicroFileReader.cxx
$(ROOT_IFACE): src/root/RMicroFileReader.cxx src/root/RMicroFileReader.hxx
$(CXX) -O3 -fPIC -shared $(ROOTFLAGS) $< -o $@ $(ROOTLIBS)
d: $(ROOT_IFACE) build/imgui.o
$(MOLD) $(CXX) -DDEBUG -g -O0 -DENABLE_ASAN $(CFLAGS) -fsanitize=undefined $(INC) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE) -lasan $(LIBS)
$(ROOT_IFACE_DBG): src/root/RMicroFileReader.cxx src/root/RMicroFileReader.hxx
$(CXX) -g -O0 -fPIC -shared $(ROOTFLAGS) $< -o $@ $(ROOTLIBS)
d: $(ROOT_IFACE_DBG) build/imgui.o
$(MOLD) $(CXX) -DDEBUG -g -O0 -DENABLE_ASAN $(CFLAGS) $(INC) -o rntviewer src/rntviewer.cpp build/imgui.o -lasan $(ROOT_IFACE_DBG) $(LIBS)
noasan: $(ROOT_IFACE) build/imgui.o
$(MOLD) $(CXX) -DDEBUG -g -O0 $(CFLAGS) -fsanitize=undefined $(INC) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE) $(LIBS)
noasan: $(ROOT_IFACE_DBG) build/imgui.o
$(MOLD) $(CXX) -DDEBUG -g -O0 $(CFLAGS) -fsanitize=undefined $(INC) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE_DBG) $(LIBS)
r: $(ROOT_IFACE) build/imgui.o
$(MOLD) $(CXX) -O2 $(CFLAGS) $(INC) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOT_IFACE) $(LIBS)

View file

@ -101,7 +101,7 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
const auto main_win_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDecoration;
if (ImGui::Begin("main", nullptr, main_win_flags)) {
String8 ntpl_desc = rntuple_description(scratch.arena, app.rntinfo.anchor);
String8 ntpl_desc = rntuple_description(scratch.arena, app.rntinfo);
ImGui::Text("RNTuple '%s' (%s) from file \"%s\"", app.ntpl_name, ntpl_desc.c(), app.inspected_fname);
// Draw stats

View file

@ -1,11 +1,11 @@
internal
String8 rntuple_description(Arena *arena, const RNTuple_Anchor &anchor)
String8 rntuple_description(Arena *arena, const RNTuple_Info &ntuple)
{
String8 desc = push_str8f(arena, "version %u.%u.%u.%u",
anchor.fVersionEpoch,
anchor.fVersionMajor,
anchor.fVersionMinor,
anchor.fVersionPatch);
ntuple.version.epoch,
ntuple.version.major,
ntuple.version.minor,
ntuple.version.patch);
return desc;
}
@ -15,9 +15,13 @@ RNTuple_Info get_rntuple_info(const char *fname, const char *ntpl_name)
RNTuple_Info info = {};
// TODO: proper error handling
RMicroFileReader file_reader { fname };
RNTuple_File_Info file_info = file_reader.GetNTupleProper(ntpl_name);
root::RMicroFileReader file_reader { fname };
root::RNTuple_File_Info file_info = file_reader.GetNTupleProper(ntpl_name);
if (!file_info.failed) {
info.version.epoch = file_info.anchor.fVersionEpoch;
info.version.major = file_info.anchor.fVersionMajor;
info.version.minor = file_info.anchor.fVersionMinor;
info.version.patch = file_info.anchor.fVersionPatch;
info.rng_header.start = file_info.anchor.fSeekHeader;
info.rng_header.len = file_info.anchor.fNBytesHeader;
info.rng_footer.start = file_info.anchor.fSeekFooter;

View file

@ -6,8 +6,10 @@ struct Byte_Range {
};
struct RNTuple_Info {
RNTuple_Anchor anchor;
struct {
u16 epoch, major, minor, patch;
} version;
u64 root_file_header_size;
u64 rblob_header_size;
Byte_Range rng_anchor;

View file

@ -1064,6 +1064,12 @@ static size_t ComputeNumChunks(size_t nbytes, size_t maxChunkSize)
return nChunks;
}
// =========================================================================================
// PUBLIC INTERFACE
// =========================================================================================
using namespace root;
struct RMicroFileReader::Impl {
std::unique_ptr<ROOT::Internal::RRawFile> fRawFile;
std::uint64_t fMaxBlobSize;

View file

@ -2,6 +2,8 @@
#include <cstdint>
namespace root {
struct RNTuple_Anchor {
/// Version of the RNTuple binary format that the writer supports (see specification).
/// Changing the epoch indicates backward-incompatible changes
@ -61,3 +63,5 @@ public:
struct Impl;
Impl *impl;
};
}