add PseudoMiniFile
This commit is contained in:
parent
d093936211
commit
af8606c44a
12 changed files with 1346 additions and 22 deletions
13
Makefile
13
Makefile
|
@ -3,20 +3,23 @@ CFLAGS = -Wall -Wextra -pedantic
|
|||
INC = -Ithird_party -Ithird_party/imgui
|
||||
ROOT = $(HOME)/root_build/debug
|
||||
ROOTFLAGS = -std=c++17 -m64 -I$(ROOT)/include
|
||||
ROOTLIBS = -L$(ROOT)/lib -lCore -lRIO -lROOTNTuple -Wl,-rpath,$(ROOT)/lib -pthread
|
||||
ROOTLIBS = -L$(ROOT)/lib -lCore -lRIO -lROOTNTuple -lxxhash -Wl,-rpath,$(ROOT)/lib -pthread
|
||||
LIBS = -lglfw
|
||||
MOLD = mold -run
|
||||
|
||||
all: build/imgui.o d
|
||||
all: build/imgui.o build/root_stuff.o noasan
|
||||
|
||||
build/imgui.o: src/imgui_inc.cpp third_party/imgui/imgui.h
|
||||
$(CXX) -O3 -fPIC -c -Ithird_party/imgui $< -o $@
|
||||
|
||||
build/root_stuff.o: src/PseudoMiniFile.cxx
|
||||
$(CXX) -fPIC -c $(ROOTFLAGS) $< -o $@
|
||||
|
||||
d:
|
||||
$(MOLD) $(CXX) -DDEBUG -g -O0 -DENABLE_ASAN $(CFLAGS) -fsanitize=undefined $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp build/imgui.o -lasan $(ROOTLIBS) $(LIBS)
|
||||
$(MOLD) $(CXX) -DDEBUG -g -O0 -DENABLE_ASAN $(CFLAGS) -fsanitize=undefined $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp build/imgui.o build/root_stuff.o -lasan $(ROOTLIBS) $(LIBS)
|
||||
|
||||
noasan:
|
||||
$(MOLD) $(CXX) -DDEBUG -g -O0 $(CFLAGS) -fsanitize=undefined $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOTLIBS) $(LIBS)
|
||||
$(MOLD) $(CXX) -DDEBUG -g -O0 $(CFLAGS) -fsanitize=undefined $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp build/imgui.o build/root_stuff.o $(ROOTLIBS) $(LIBS)
|
||||
|
||||
r:
|
||||
$(MOLD) $(CXX) -O2 $(CFLAGS) $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp build/imgui.o $(ROOTLIBS) $(LIBS)
|
||||
$(MOLD) $(CXX) -O2 $(CFLAGS) $(INC) $(ROOTFLAGS) -o rntviewer src/rntviewer.cpp build/imgui.o build/root_stuff.o $(ROOTLIBS) $(LIBS)
|
||||
|
|
|
@ -8,7 +8,7 @@ Size=1152,1414
|
|||
|
||||
[Window][main]
|
||||
Pos=0,0
|
||||
Size=1183,680
|
||||
Size=1777,680
|
||||
|
||||
[Window][Hex View]
|
||||
Pos=91,62
|
||||
|
|
1245
src/PseudoMiniFile.cxx
Normal file
1245
src/PseudoMiniFile.cxx
Normal file
File diff suppressed because it is too large
Load diff
41
src/PseudoMiniFile.hxx
Normal file
41
src/PseudoMiniFile.hxx
Normal file
|
@ -0,0 +1,41 @@
|
|||
#pragma once
|
||||
|
||||
#include <ROOT/RError.hxx>
|
||||
#include <ROOT/RNTuple.hxx>
|
||||
#include <ROOT/RRawFile.hxx>
|
||||
#include <string_view>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
struct RNTuple_FileInfo {
|
||||
std::uint64_t anchor_seek;
|
||||
std::uint64_t anchor_nbytes;
|
||||
std::uint64_t anchor_key_seek;
|
||||
std::uint64_t anchor_key_nbytes;
|
||||
std::uint64_t rblob_key_header_nbytes;
|
||||
std::uint64_t tfile_header_nbytes;
|
||||
};
|
||||
|
||||
class PseudoMiniFileReader final {
|
||||
public:
|
||||
explicit PseudoMiniFileReader(ROOT::Internal::RRawFile *rawFile);
|
||||
|
||||
// ROOT::Experimental::RResult<ROOT::Experimental::RNTuple>
|
||||
ROOT::Experimental::RResult<RNTuple_FileInfo>
|
||||
GetNTupleProper(std::string_view ntupleName);
|
||||
|
||||
void
|
||||
ReadBuffer(void *buffer, size_t nbytes, std::uint64_t offset);
|
||||
|
||||
// ROOT::Experimental::RNTuple
|
||||
// CreateAnchor(
|
||||
// std::uint16_t versionEpoch, std::uint16_t versionMajor, std::uint16_t versionMinor, std::uint16_t versionPatch,
|
||||
// std::uint64_t seekHeader, std::uint64_t nbytesHeader, std::uint64_t lenHeader, std::uint64_t seekFooter,
|
||||
// std::uint64_t nbytesFooter, std::uint64_t lenFooter, std::uint64_t maxKeySize);
|
||||
|
||||
ROOT::Internal::RRawFile *fRawFile;
|
||||
std::uint64_t fMaxBlobSize;
|
||||
};
|
|
@ -13,9 +13,10 @@ struct App_State {
|
|||
|
||||
Delta_Time_Accum delta_time_accum;
|
||||
|
||||
FILE *inspected_file;
|
||||
u8 *inspected_fmem;
|
||||
u64 inspected_file_size;
|
||||
FILE *inspected_file;
|
||||
u8 *inspected_fmem;
|
||||
u64 inspected_file_size;
|
||||
const char *inspected_fname;
|
||||
// @Platform: inotify file descriptor
|
||||
int inot;
|
||||
|
||||
|
|
|
@ -71,7 +71,6 @@ void run_main_loop(GLFWwindow *window, Arena *arena, App_State &app)
|
|||
u64 time_since_prev_frame_us = chr::duration_cast<chr::microseconds>(frame_start - last_saved_time).count();
|
||||
delta_time_ms = time_since_prev_frame_us * 0.001f;
|
||||
last_saved_time = frame_start;
|
||||
accum_dt_ms(app.delta_time_accum, delta_time_ms);
|
||||
|
||||
glfwPollEvents();
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ void os_open_and_map_file(const char *fname, App_State &app)
|
|||
if (!fmem)
|
||||
fprintf(stderr, "Failed to open file %s\n", fname);
|
||||
|
||||
app.inspected_fname = fname;
|
||||
app.inspected_file = file;
|
||||
app.inspected_file_size = fsize;
|
||||
app.inspected_fmem = reinterpret_cast<u8*>(fmem);
|
||||
|
|
|
@ -35,10 +35,16 @@ u32 mem_edit_bg_color_fn(const u8 *data, u64 off, const void *user_data)
|
|||
{
|
||||
const App_State *app = reinterpret_cast<const App_State *>(user_data);
|
||||
const RNTuple_Info &rinfo = app->rntinfo;
|
||||
u64 rblob_sz = rinfo.rblob_header_size;
|
||||
|
||||
#define COL(c) (ImColor((c)[0], (c)[1], (c)[2]))
|
||||
if (rinfo.header.start <= off && off <= rinfo.header.end()) return COL(app->vsettings.col_header);
|
||||
if (rinfo.footer.start <= off && off <= rinfo.footer.end()) return COL(app->vsettings.col_footer);
|
||||
if (off <= rinfo.root_file_header_size) return COL(app->vsettings.col_tfile);
|
||||
if (rinfo.rng_anchor_key.start <= off && off <= rinfo.rng_anchor_key.end()) return COL(app->vsettings.col_key);
|
||||
if (rinfo.rng_header.start - rblob_sz <= off && off <= rinfo.rng_header.start) return COL(app->vsettings.col_key);
|
||||
if (rinfo.rng_footer.start - rblob_sz <= off && off <= rinfo.rng_footer.start) return COL(app->vsettings.col_key);
|
||||
if (rinfo.rng_anchor.start <= off && off <= rinfo.rng_anchor.end()) return COL(app->vsettings.col_anchor);
|
||||
if (rinfo.rng_header.start <= off && off <= rinfo.rng_header.end()) return COL(app->vsettings.col_header);
|
||||
if (rinfo.rng_footer.start <= off && off <= rinfo.rng_footer.end()) return COL(app->vsettings.col_footer);
|
||||
#undef COL
|
||||
|
||||
return IM_COL32(0, 0, 0, 0);
|
||||
|
@ -61,8 +67,11 @@ Viewer_Settings make_viewer_settings()
|
|||
{
|
||||
Viewer_Settings settings {};
|
||||
#define COL(c, r, g, b) settings.c[0] = r/255.0, settings.c[1] = g/255.0, settings.c[2] = b/255.0
|
||||
COL(col_anchor, 150, 150, 0);
|
||||
COL(col_header, 150, 0, 50);
|
||||
COL(col_footer, 50, 0, 150);
|
||||
COL(col_key, 0, 100, 50);
|
||||
COL(col_tfile, 90, 90, 90);
|
||||
#undef COL
|
||||
return settings;
|
||||
}
|
||||
|
@ -70,7 +79,7 @@ Viewer_Settings make_viewer_settings()
|
|||
internal
|
||||
void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
|
||||
{
|
||||
(void)delta_time_ms;
|
||||
accum_dt_ms(app.delta_time_accum, delta_time_ms);
|
||||
|
||||
ImGui::SetNextWindowPos({ 0, 0 });
|
||||
ImGui::SetNextWindowSize({ (f32)app.win_data.width, (f32)app.win_data.height });
|
||||
|
@ -91,7 +100,7 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
|
|||
if (ImGui::Begin("main", nullptr, main_win_flags)) {
|
||||
|
||||
String8 ntpl_desc = rntuple_description(scratch.arena, app.rntinfo.anchor);
|
||||
ImGui::Text("Inspecting RNTuple '%s' (%s)", app.ntpl_name, ntpl_desc.c());
|
||||
ImGui::Text("RNTuple '%s' (%s) from file \"%s\"", app.ntpl_name, ntpl_desc.c(), app.inspected_fname);
|
||||
|
||||
// Draw stats
|
||||
{
|
||||
|
@ -122,8 +131,11 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
|
|||
mem_edit.DrawContents(app.inspected_fmem, app.inspected_file_size);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::ColorEdit3("Header", app.vsettings.col_header, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::ColorEdit3("Footer", app.vsettings.col_footer, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::ColorEdit3("TFile", app.vsettings.col_tfile, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::ColorEdit3("RNTuple Anchor", app.vsettings.col_anchor, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::ColorEdit3("RNTuple Header", app.vsettings.col_header, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::ColorEdit3("RNTuple Footer", app.vsettings.col_footer, ImGuiColorEditFlags_NoInputs);
|
||||
ImGui::ColorEdit3("TKey Header", app.vsettings.col_key, ImGuiColorEditFlags_NoInputs);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
struct Viewer_Settings {
|
||||
float col_anchor[3];
|
||||
float col_header[3];
|
||||
float col_footer[3];
|
||||
float col_key[3];
|
||||
float col_tfile[3];
|
||||
};
|
||||
|
||||
struct Edit_Bg_Color_Data {
|
||||
|
|
|
@ -26,13 +26,26 @@ RNTuple_Info get_rntuple_info(Arena *arena, const char *fname, const char *ntpl_
|
|||
const RNTuple *anchor = tfile->Get<RNTuple>(ntpl_name);
|
||||
if (anchor) {
|
||||
info.anchor = *anchor;
|
||||
info.header.start = anchor->GetSeekHeader();
|
||||
info.header.len = anchor->GetNBytesHeader();
|
||||
info.footer.start = anchor->GetSeekFooter();
|
||||
info.footer.len = anchor->GetNBytesFooter();
|
||||
info.rng_header.start = anchor->GetSeekHeader();
|
||||
info.rng_header.len = anchor->GetNBytesHeader();
|
||||
info.rng_footer.start = anchor->GetSeekFooter();
|
||||
info.rng_footer.len = anchor->GetNBytesFooter();
|
||||
} else {
|
||||
fprintf(stderr, "RNTuple '%s' not found in %s.\n", ntpl_name, fname);
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,10 @@ struct Byte_Range {
|
|||
struct RNTuple_Info {
|
||||
RNTuple anchor;
|
||||
|
||||
Byte_Range header;
|
||||
Byte_Range footer;
|
||||
u64 root_file_header_size;
|
||||
u64 rblob_header_size;
|
||||
Byte_Range rng_anchor;
|
||||
Byte_Range rng_anchor_key;
|
||||
Byte_Range rng_header;
|
||||
Byte_Range rng_footer;
|
||||
};
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#define GLFW_INCLUDE_NONE
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "PseudoMiniFile.hxx"
|
||||
|
||||
#include "types.h"
|
||||
#include "defer.hpp"
|
||||
#include "mem.h"
|
||||
|
|
Loading…
Reference in a new issue