remove tfile_data.rntuples

This commit is contained in:
silverweed 2025-01-24 11:20:12 +01:00
parent 47c993dd01
commit fb5f728dfa
6 changed files with 17 additions and 38 deletions

View file

@ -147,15 +147,15 @@ void init_viewer(Arena *arena, App_State &app, u16 n_cols)
Temp scratch = scratch_begin(&arena, 1);
defer { scratch_end(scratch); };
const ROOT::RNTuple &anchor = *(const ROOT::RNTuple *)app.tfile_data.sections[Sec_RNTuple_Anchor].head->info;
String8 ntpl_desc = rntuple_description(scratch.arena, anchor);
if (rntuple_is_old_version(anchor)) {
const RNTuple_Anchor_Info *anchor = (const RNTuple_Anchor_Info *)app.tfile_data.sections[Sec_RNTuple_Anchor].head->info;
String8 ntpl_desc = rntuple_description(scratch.arena, anchor->anchor);
if (rntuple_is_old_version(anchor->anchor)) {
viewer.col_title[0] = 1.f;
viewer.title = push_str8f(arena, "\"%s\" (%s) from file \"%s\" ** old version, some data missing! **",
app.ntpl_name.c(), ntpl_desc.c(), app.inspected_file.name.c());
anchor->name.c(), ntpl_desc.c(), app.inspected_file.name.c());
} else {
viewer.col_title[0] = viewer.col_title[1] = viewer.col_title[2] = 1.f;
viewer.title = push_str8f(arena, "\"%s\" (%s) from file \"%s\"", app.ntpl_name.c(), ntpl_desc.c(), app.inspected_file.name.c());
viewer.title = push_str8f(arena, "\"%s\" (%s) from file \"%s\"", anchor->name.c(), ntpl_desc.c(), app.inspected_file.name.c());
}
} else {
viewer.col_title[0] = viewer.col_title[1] = viewer.col_title[2] = 1.f;
@ -334,8 +334,6 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
Temp scratch = scratch_begin(&arena, 1);
defer { scratch_end(scratch); };
printf("-----------------------\n");
const auto main_win_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDecoration;
if (ImGui::Begin("main", nullptr, main_win_flags)) {

View file

@ -217,7 +217,7 @@ String8_Node *render_range_to_string(Arena *arena, App_State &app, u64 len, u64
defer { scratch_end(scratch); };
// Header
String8 ntpl_desc = rntuple_description(scratch.arena, *(const ROOT::RNTuple *)app.tfile_data.sections[Sec_RNTuple_Anchor].head->info); // FIXME :multiple_anchors:
String8 ntpl_desc = rntuple_description(scratch.arena, ((const RNTuple_Anchor_Info *)app.tfile_data.sections[Sec_RNTuple_Anchor].head->info)->anchor); // FIXME :multiple_anchors:
String8_Node *result = push_str8_node(arena, nullptr, "RNTuple '%s' (%s) from file \"%s\"\n",
app.ntpl_name.c(), ntpl_desc.c(), app.inspected_file.name.c());
String8_Node *result_tail = result;

View file

@ -208,7 +208,7 @@ RNTuple_Data get_rntuple_data(Arena *arena, const Inspected_File &file, const TF
for (Section *sec_anchor = tfile_data.sections[Sec_RNTuple_Anchor].head; sec_anchor; sec_anchor = sec_anchor->next, ++anchor_idx) {
RNTupleDescriptor &desc = descriptors[anchor_idx];
new (&desc) RNTupleDescriptor();
desc = create_descriptor(arena, *(const ROOT::RNTuple *)sec_anchor->info, reader);
desc = create_descriptor(arena, ((const RNTuple_Anchor_Info *)sec_anchor->info)->anchor, reader);
n_tot_cluster_groups += desc.GetNClusterGroups();
n_tot_clusters += desc.GetNActiveClusters();
}
@ -225,7 +225,7 @@ RNTuple_Data get_rntuple_data(Arena *arena, const Inspected_File &file, const TF
/// Load all RNTuple data ///
anchor_idx = 0;
for (Section *sec_anchor = tfile_data.sections[Sec_RNTuple_Anchor].head; sec_anchor; sec_anchor = sec_anchor->next, ++anchor_idx) {
const ROOT::RNTuple &anchor = *(const ROOT::RNTuple *)sec_anchor->info;
const ROOT::RNTuple &anchor = ((const RNTuple_Anchor_Info *)sec_anchor->info)->anchor;
if (!anchor.GetNBytesHeader())
continue;
@ -578,14 +578,6 @@ Section find_section(App_State &app, u64 off, i64 hilite_cluster = -1)
// fast case: `off` is in the same obj as previous `off`.
for (i32 i = 0; i < 2; ++i) {
const Section &other_sec = *app.last_other_root_obj;
if (i == 1)
printf("checking if 0x%lX is in the next root obj, i.e. 0x%lX - 0x%lX - %s\n",
off, other_sec.range.start - other_sec.pre_size, other_sec.range.end(),
(other_sec.range.start - other_sec.pre_size <= off && off < other_sec.range.end()) ? "yes" : "no");
// else
// printf("checking if 0x%lX is in the first root obj, i.e. 0x%lX - 0x%lX - %s\n",
// off, other_sec.range.start - other_sec.pre_size, other_sec.range.end(),
// (other_sec.range.start - other_sec.pre_size < off && off < other_sec.range.end()) ? "yes" : "no");
if (other_sec.range.start - other_sec.pre_size <= off && off < other_sec.range.end()) {
return other_sec;
}
@ -598,12 +590,9 @@ Section find_section(App_State &app, u64 off, i64 hilite_cluster = -1)
}
// Slow linear lookup, ideally only done once per render when last_other_root_obj is invalid.
printf("page fault\n");
for (Section *other_sec = app.tfile_data.sections[Sec_Other].head; other_sec; other_sec = other_sec->next) {
if (other_sec->range.start - other_sec->pre_size <= off && off < other_sec->range.end()) {
app.last_other_root_obj = other_sec;
printf("off 0x%lX: last root obj set to 0x%lX - 0x%lX\n",
off, other_sec->range.start - other_sec->pre_size, other_sec->range.end());
return *other_sec;
}
}

View file

@ -88,7 +88,7 @@ struct Section {
// Optional pointer to the specific information for the section.
// Here are the actual types:
// - Sec_RNTuple_Anchor => ROOT::RNTuple
// - Sec_RNTuple_Anchor => RNTuple_Anchor_Info
// - Sec_Page => Page_Info_Node (aliased from RNTuple_Data::pages)
// - Sec_Other => String8 (the class name of the object)
const void *info;
@ -119,9 +119,9 @@ struct Byte_Range_Node {
};
struct RNTuple_Anchor_Info {
RNTuple_Anchor_Info *next;
String8 name;
u64 offset_in_file;
ROOT::RNTuple anchor;
};
struct Sections {
@ -131,7 +131,6 @@ struct Sections {
};
struct TKeys_Data {
RNTuple_Anchor_Info *rntuples;
Byte_Range_Node *rblob_keys;
};

View file

@ -166,8 +166,10 @@ int main(int argc, char **argv)
walk_tkeys_flags |= WTK_COLLECT_OTHER_ROOT_OBJS;
b8 success = get_tfile_data(arena, app.inspected_file, walk_tkeys_flags, app.ntpl_name, app.tfile_data);
if (args.only_print_rntuple_names) {
for (RNTuple_Anchor_Info *info = app.tfile_data.tkeys_data.rntuples; info; info = info->next)
for (Section *sec = app.tfile_data.sections[Sec_RNTuple_Anchor].head; sec; sec = sec->next) {
const RNTuple_Anchor_Info *info = (const RNTuple_Anchor_Info *)sec->info;
printf("%s at 0x%" PRIX64 "\n", info->name.c(), info->offset_in_file);
}
return 0;
}

View file

@ -200,8 +200,6 @@ b8 walk_tkeys(Arena *arena, const u8 *data, u64 data_len, u32 flags, TFile_Data
cur = pre + tfile_obj_nbytes;
RNTuple_Anchor_Info *rntuple_info_tail = nullptr;
Sections *sections = tfile_data.sections;
u32 n_keys = 0;
@ -279,32 +277,25 @@ b8 walk_tkeys(Arena *arena, const u8 *data, u64 data_len, u32 flags, TFile_Data
if (name_len) {
rntuple_info->name = str8_from_buf(arena, data + name_off + 1, name_len);
}
if (rntuple_info_tail)
rntuple_info_tail->next = rntuple_info;
else
tkeys_data.rntuples = rntuple_info;
rntuple_info_tail = rntuple_info;
u64 anchor_seek = cur + keylen;
RNTuple_Anchor_On_Disk anchor;
memcpy(&anchor, data + anchor_seek, sizeof(anchor));
ROOT::RNTuple *rntuple = arena_push<ROOT::RNTuple>(arena);
new (rntuple) ROOT::RNTuple();
*rntuple = ROOT::Experimental::Internal::CreateAnchor(
rntuple_info->anchor = ROOT::Experimental::Internal::CreateAnchor(
bswap(anchor.epoch_be), bswap(anchor.major_be), bswap(anchor.minor_be), bswap(anchor.patch_be),
bswap(anchor.seek_header_be), bswap(anchor.nbytes_header_be), bswap(anchor.len_header_be),
bswap(anchor.seek_footer_be), bswap(anchor.nbytes_footer_be), bswap(anchor.len_footer_be),
bswap(anchor.max_key_size_be));
Section *sec_anchor = push_section(arena, tfile_data, Sec_RNTuple_Anchor);
sec_anchor->info = rntuple;
sec_anchor->info = rntuple_info;
sec_anchor->id = Sec_RNTuple_Anchor;
sec_anchor->range.start = anchor_seek;
sec_anchor->range.len = n_bytes - keylen;
sec_anchor->pre_size = keylen;
sec_anchor->post_size = 8;
sec_anchor->from_old_version_rntuple = rntuple_is_old_version(*rntuple);
sec_anchor->from_old_version_rntuple = rntuple_is_old_version(rntuple_info->anchor);
} else if (key_has_class_name("RBlob")) {
if (!sections[Sec_Page].head) {
@ -403,7 +394,7 @@ void map_rntuple_rblobs(Arena *arena, TFile_Data &tfile_data)
u64 best_anchor_diff = (u64)-1;
b8 *found_sec = found[sec_id == Sec_RNTuple_Footer];
for (Section *sec_anchor = tfile_data.sections[Sec_RNTuple_Anchor].head; sec_anchor; sec_anchor = sec_anchor->next, ++i) {
const ROOT::RNTuple &anchor = *(const ROOT::RNTuple *)sec_anchor->info;
const ROOT::RNTuple &anchor = ((const RNTuple_Anchor_Info *)sec_anchor->info)->anchor;
if (!found_sec[i]) {
u64 seek = sec_id == Sec_RNTuple_Header ? anchor.GetSeekHeader() : anchor.GetSeekFooter();
i64 diff = seek - tkey->rng.start;