reorganize some hover info in Sec_Page
This commit is contained in:
parent
526fbd42b3
commit
ab7877db7d
4 changed files with 65 additions and 16 deletions
|
@ -62,6 +62,34 @@ ROOT::Experimental::RNTupleDescriptor create_descriptor(Arena *arena, RMicroFile
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal
|
||||||
|
String8 build_fully_qualified_field_name(Arena *arena, const ROOT::Experimental::RNTupleDescriptor &desc,
|
||||||
|
const ROOT::Experimental::RFieldDescriptor *field_desc)
|
||||||
|
{
|
||||||
|
String8_Node *sn = push_str8_node(arena, nullptr, "%s", field_desc->GetFieldName().c_str());
|
||||||
|
ROOT::Experimental::DescriptorId_t field_id = field_desc->GetParentId();
|
||||||
|
u64 size = sn->str.size;
|
||||||
|
while (field_id != ROOT::Experimental::kInvalidDescriptorId) {
|
||||||
|
field_desc = &desc.GetFieldDescriptor(field_id);
|
||||||
|
if (field_desc->GetFieldName().empty())
|
||||||
|
break;
|
||||||
|
sn = push_str8_node(arena, sn, "%s", field_desc->GetFieldName().c_str());
|
||||||
|
field_id = field_desc->GetParentId();
|
||||||
|
size += sn->str.size + 1;
|
||||||
|
}
|
||||||
|
String8 str;
|
||||||
|
str.str = arena_push_array_nozero<u8>(arena, size + 1);
|
||||||
|
str.str[size] = 0;
|
||||||
|
str.size = 0;
|
||||||
|
for (String8_Node *snode = sn; snode; snode = snode->prev) {
|
||||||
|
memcpy(str.str + str.size, snode->str.str, snode->str.size);
|
||||||
|
str.size += snode->str.size;
|
||||||
|
if (str.size < size)
|
||||||
|
str.str[str.size++] = '.';
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
internal
|
internal
|
||||||
void gather_ntuple_metadata(Arena *arena, RMicroFileReader &reader, const RNTuple_File_Info &info, RNTuple_Data &rndata)
|
void gather_ntuple_metadata(Arena *arena, RMicroFileReader &reader, const RNTuple_File_Info &info, RNTuple_Data &rndata)
|
||||||
{
|
{
|
||||||
|
@ -112,6 +140,8 @@ void gather_ntuple_metadata(Arena *arena, RMicroFileReader &reader, const RNTupl
|
||||||
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);
|
const auto &col_descriptor = descriptor.GetColumnDescriptor(col_range.fPhysicalColumnId);
|
||||||
elem_type_name = RColumnElementBase::GetTypeName(col_descriptor.GetType()); // @ForeignAlloc
|
elem_type_name = RColumnElementBase::GetTypeName(col_descriptor.GetType()); // @ForeignAlloc
|
||||||
|
const auto &field_desc = descriptor.GetFieldDescriptor(col_descriptor.GetFieldId());
|
||||||
|
const String8 owner_field_name = build_fully_qualified_field_name(arena, descriptor, &field_desc);
|
||||||
|
|
||||||
// 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);
|
||||||
|
@ -126,6 +156,7 @@ void gather_ntuple_metadata(Arena *arena, RMicroFileReader &reader, const RNTupl
|
||||||
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());
|
pinfo->elem_type_name = push_str8f(arena, "%s", elem_type_name.c_str());
|
||||||
|
pinfo->owner_field_name = owner_field_name;
|
||||||
pinfo->bits_per_elem = col_descriptor.GetBitsOnStorage();
|
pinfo->bits_per_elem = col_descriptor.GetBitsOnStorage();
|
||||||
|
|
||||||
Cluster_Info &cluster = clusters[pinfo->cluster_id];
|
Cluster_Info &cluster = clusters[pinfo->cluster_id];
|
||||||
|
@ -686,6 +717,9 @@ struct Try_Sec_Hover_Fn {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
b8 field(const char *desc_fmt, Display_Fn<T> display_val = hover_display_val_be<T>) const
|
b8 field(const char *desc_fmt, Display_Fn<T> display_val = hover_display_val_be<T>) const
|
||||||
{
|
{
|
||||||
|
if constexpr (std::is_same_v<T, String8>) {
|
||||||
|
return field_str8(desc_fmt, display_val);
|
||||||
|
} else {
|
||||||
u64 field_len = sizeof(T);
|
u64 field_len = sizeof(T);
|
||||||
if (roff < cur_field_off + field_len) {
|
if (roff < cur_field_off + field_len) {
|
||||||
info.rng = { start + cur_field_off, field_len };
|
info.rng = { start + cur_field_off, field_len };
|
||||||
|
@ -697,9 +731,9 @@ struct Try_Sec_Hover_Fn {
|
||||||
cur_field_off += field_len;
|
cur_field_off += field_len;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
b8 field_str8(const char *desc_fmt, Display_Fn<String8> display_val) const
|
||||||
b8 field<String8>(const char *desc_fmt, Display_Fn<String8> display_val) const
|
|
||||||
{
|
{
|
||||||
u8 str_size = data[start + cur_field_off];
|
u8 str_size = data[start + cur_field_off];
|
||||||
if (roff < cur_field_off + 1 + str_size) {
|
if (roff < cur_field_off + 1 + str_size) {
|
||||||
|
@ -748,7 +782,11 @@ struct Try_Sec_Hover_Fn {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// discard the description (it's fine since it's allocated in the scratch arena)
|
// discard the description (it's fine since it's allocated in the scratch arena)
|
||||||
info.desc->first_child = nullptr;
|
if (info.desc->first_child == info.desc->last_child) {
|
||||||
|
info.desc->first_child = info.desc->last_child = nullptr;
|
||||||
|
} else {
|
||||||
|
info.desc->last_child = info.desc->last_child->prev;
|
||||||
|
}
|
||||||
cur_field_off += range_len;
|
cur_field_off += range_len;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -811,8 +849,12 @@ Sec_Hover_Info get_section_hover_info(Arena *arena, Section section, u64 off, co
|
||||||
String8 sec_name = section_names[section.id];
|
String8 sec_name = section_names[section.id];
|
||||||
if (section.id == Sec_Page && section.info) {
|
if (section.id == Sec_Page && section.info) {
|
||||||
Page_Info_Node *pinfo = (Page_Info_Node *)section.info;
|
Page_Info_Node *pinfo = (Page_Info_Node *)section.info;
|
||||||
info.desc = push_str8_node(arena, nullptr, "%s [%s, n.elems: %d (%u b)]",
|
info.desc = push_str8_node(arena, nullptr, "%s [%s]",
|
||||||
sec_name.c(), pinfo->elem_type_name.c(), abs(pinfo->n_elems), pinfo->bits_per_elem);
|
sec_name.c(), pinfo->elem_type_name.c());
|
||||||
|
push_str8_node_child(arena, info.desc, "Field: %s", pinfo->owner_field_name.c());
|
||||||
|
push_str8_node_child(arena, info.desc, "N. Elems: %d", abs(pinfo->n_elems));
|
||||||
|
push_str8_node_child(arena, info.desc, "Bits per elem: %u", pinfo->bits_per_elem);
|
||||||
|
push_str8_node_child(arena, info.desc, "-----------");
|
||||||
} else {
|
} else {
|
||||||
info.desc = push_str8_node(arena, nullptr, "%s", sec_name.c());
|
info.desc = push_str8_node(arena, nullptr, "%s", sec_name.c());
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ struct Page_Info_Node {
|
||||||
|
|
||||||
u8 bits_per_elem;
|
u8 bits_per_elem;
|
||||||
String8 elem_type_name;
|
String8 elem_type_name;
|
||||||
|
String8 owner_field_name;
|
||||||
|
|
||||||
inline u64 checksum_size() const {
|
inline u64 checksum_size() const {
|
||||||
return (n_elems < 0) * 8;
|
return (n_elems < 0) * 8;
|
||||||
|
|
|
@ -48,8 +48,13 @@ String8_Node *push_str8_node(Arena *arena, String8_Node *prev, const char *fmt,
|
||||||
snode->str = push_str8fv(arena, fmt, args);
|
snode->str = push_str8fv(arena, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (prev)
|
if (prev) {
|
||||||
prev->next = snode;
|
prev->next = snode;
|
||||||
|
snode->head = prev->head;
|
||||||
|
} else {
|
||||||
|
snode->head = snode;
|
||||||
|
}
|
||||||
|
snode->prev = prev;
|
||||||
|
|
||||||
return snode;
|
return snode;
|
||||||
}
|
}
|
||||||
|
@ -66,6 +71,7 @@ String8_Node *push_str8_node_child(Arena *arena, String8_Node *parent, const cha
|
||||||
snode->str = push_str8fv(arena, fmt, args);
|
snode->str = push_str8fv(arena, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
snode->prev = parent->last_child;
|
||||||
if (parent->first_child) {
|
if (parent->first_child) {
|
||||||
parent->last_child->next = snode;
|
parent->last_child->next = snode;
|
||||||
parent->last_child = snode;
|
parent->last_child = snode;
|
||||||
|
|
|
@ -12,7 +12,7 @@ struct String8 {
|
||||||
#define str8(s) String8 { (u8*)(s), sizeof(s) - 1 }
|
#define str8(s) String8 { (u8*)(s), sizeof(s) - 1 }
|
||||||
|
|
||||||
struct String8_Node {
|
struct String8_Node {
|
||||||
String8_Node *next;
|
String8_Node *next, *prev, *head;
|
||||||
String8_Node *first_child, *last_child;
|
String8_Node *first_child, *last_child;
|
||||||
String8 str;
|
String8 str;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue