add type and n.elems info to hover page

This commit is contained in:
silverweed 2024-08-14 13:41:14 +02:00
parent c10ebca4d6
commit 2c2cdae805
3 changed files with 26 additions and 1 deletions

View file

@ -99,11 +99,18 @@ void gather_ntuple_metadata(Arena *arena, RMicroFileReader &reader, const RNTupl
Cluster_Info *clusters = arena_push_array<Cluster_Info>(arena, descriptor.GetNActiveClusters()); Cluster_Info *clusters = arena_push_array<Cluster_Info>(arena, descriptor.GetNActiveClusters());
// @ForeignAlloc: currently using directly the RColumnElementBase API which forces foreign allocations.
// If we don't want to have this we could create our own function to retrieve a column type name.
std::string elem_type_name;
// gather clusters and pages metadata // gather clusters and pages metadata
for (const RClusterDescriptor &cluster_desc : descriptor.GetClusterIterable()) { for (const RClusterDescriptor &cluster_desc : descriptor.GetClusterIterable()) {
++n_clusters; ++n_clusters;
for (const RClusterDescriptor::RColumnRange &col_range : cluster_desc.GetColumnRangeIterable()) { for (const RClusterDescriptor::RColumnRange &col_range : cluster_desc.GetColumnRangeIterable()) {
const auto &col_descriptor = descriptor.GetColumnDescriptor(col_range.fPhysicalColumnId);
elem_type_name = RColumnElementBase::GetTypeName(col_descriptor.GetType()); // @ForeignAlloc
// insert page infos sorted by byte range // insert page infos sorted by byte range
const auto &page_range = cluster_desc.GetPageRange(col_range.fPhysicalColumnId); const auto &page_range = cluster_desc.GetPageRange(col_range.fPhysicalColumnId);
for (const auto &page_info : page_range.fPageInfos) { for (const auto &page_info : page_range.fPageInfos) {
@ -116,6 +123,7 @@ void gather_ntuple_metadata(Arena *arena, RMicroFileReader &reader, const RNTupl
// If in the future we get RNTuples with more than 4B clusters we can just change the type to u64. // If in the future we get RNTuples with more than 4B clusters we can just change the type to u64.
assert(cluster_desc.GetId() <= UINT_MAX); assert(cluster_desc.GetId() <= UINT_MAX);
pinfo->cluster_id = cluster_desc.GetId(); pinfo->cluster_id = cluster_desc.GetId();
pinfo->elem_type_name = push_str8f(arena, "%s", elem_type_name.c_str());
Cluster_Info &cluster = clusters[pinfo->cluster_id]; Cluster_Info &cluster = clusters[pinfo->cluster_id];
if (!cluster.first_page || pinfo->range.start < cluster.first_page->range.start) { if (!cluster.first_page || pinfo->range.start < cluster.first_page->range.start) {
@ -474,6 +482,7 @@ Section find_section(App_State &app, u64 off, i64 hilite_cluster = -1)
sec.pre_size = pre_size; sec.pre_size = pre_size;
sec.post_size = app.last_pinfo->checksum_size(); sec.post_size = app.last_pinfo->checksum_size();
sec.highlighted = hilite_cluster >= 0 && app.last_pinfo->cluster_id == (u64)hilite_cluster; sec.highlighted = hilite_cluster >= 0 && app.last_pinfo->cluster_id == (u64)hilite_cluster;
sec.info = app.last_pinfo;
return sec; return sec;
} }
@ -488,6 +497,7 @@ Section find_section(App_State &app, u64 off, i64 hilite_cluster = -1)
sec.pre_size = pre_size; sec.pre_size = pre_size;
sec.post_size = app.last_pinfo->checksum_size(); sec.post_size = app.last_pinfo->checksum_size();
sec.highlighted = hilite_cluster >= 0 && app.last_pinfo->cluster_id == (u64)hilite_cluster; sec.highlighted = hilite_cluster >= 0 && app.last_pinfo->cluster_id == (u64)hilite_cluster;
sec.info = app.last_pinfo;
return sec; return sec;
} }
} }
@ -561,6 +571,7 @@ Section find_section(App_State &app, u64 off, i64 hilite_cluster = -1)
sec.pre_size = pre_size; sec.pre_size = pre_size;
sec.post_size = pinfo->checksum_size(); sec.post_size = pinfo->checksum_size();
sec.highlighted = hilite_cluster >= 0 && pinfo->cluster_id == (u64)hilite_cluster; sec.highlighted = hilite_cluster >= 0 && pinfo->cluster_id == (u64)hilite_cluster;
sec.info = pinfo;
return sec; return sec;
} }
} }
@ -788,7 +799,14 @@ Sec_Hover_Info get_section_hover_info(Arena *arena, Section section, u64 off, co
// printf("off: 0x%lX, sec start - pre_size: (0x%lX - %lu) = 0x%lX\n", off, section.range.start, section.pre_size, section.range.start - section.pre_size); // printf("off: 0x%lX, sec start - pre_size: (0x%lX - %lu) = 0x%lX\n", off, section.range.start, section.pre_size, section.range.start - section.pre_size);
assert(off >= section.range.start - section.pre_size); assert(off >= section.range.start - section.pre_size);
info.desc = push_str8_node(arena, nullptr, section_names[section.id].c()); // Hover info header
String8 sec_name = section_names[section.id];
if (section.id == Sec_Page && section.info) {
Page_Info_Node *pinfo = (Page_Info_Node *)section.info;
info.desc = push_str8_node(arena, nullptr, "%s [%s, n.elems: %d]", sec_name.c(), pinfo->elem_type_name.c(), abs(pinfo->n_elems));
} else {
info.desc = push_str8_node(arena, nullptr, "%s", sec_name.c());
}
u64 start = section.range.start - section.pre_size; u64 start = section.range.start - section.pre_size;
u64 roff = off - start; // offset relative to `section` u64 roff = off - start; // offset relative to `section`

View file

@ -18,6 +18,8 @@ struct Page_Info_Node {
u32 cluster_id; u32 cluster_id;
b8 is_first_in_cluster; b8 is_first_in_cluster;
String8 elem_type_name;
inline u64 checksum_size() const { inline u64 checksum_size() const {
return (n_elems < 0) * 8; return (n_elems < 0) * 8;
} }
@ -120,6 +122,10 @@ struct Section {
u64 pre_size; // usually the TKey header, excluded from `range` u64 pre_size; // usually the TKey header, excluded from `range`
u64 post_size; // usually the checksum, included in `range` u64 post_size; // usually the checksum, included in `range`
b8 highlighted; b8 highlighted;
// Optional pointer to the specific information for the section.
// e.g. if the section is a Page this points to the relative Page_Info_Node
const void *info;
}; };
internal const String8 section_names[Sec_COUNT] = { internal const String8 section_names[Sec_COUNT] = {

View file

@ -1,3 +1,4 @@
#include <ROOT/RNTupleSerialize.hxx> #include <ROOT/RNTupleSerialize.hxx>
#include <ROOT/RNTupleDescriptor.hxx> #include <ROOT/RNTupleDescriptor.hxx>
#include <ROOT/RNTupleZip.hxx> #include <ROOT/RNTupleZip.hxx>
#include <ROOT/RColumnElement.hxx>