From 6accff3cbdf26a94372bffc0935675df6912ce03 Mon Sep 17 00:00:00 2001 From: silverweed Date: Thu, 8 Aug 2024 16:25:09 +0200 Subject: [PATCH] jumping to cluster now also sets latest page gone to --- src/render.cpp | 6 ++++-- src/rntuple.cpp | 12 ++++++++++-- src/rntuple.h | 5 +++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/render.cpp b/src/render.cpp index 0b32b56..da32525 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -210,11 +210,13 @@ void viewer_jump_to_cluster(App_State &app, u64 cluster_idx) { assert(app.rndata.n_clusters > 0); cluster_idx = (cluster_idx + app.rndata.n_clusters) % app.rndata.n_clusters; - - Page_Info_Node *page = app.rndata.clusters[cluster_idx].first_page; + + Cluster_Info &cluster = app.rndata.clusters[cluster_idx]; + Page_Info_Node *page = cluster.first_page; assert(page); app.viewer.highlighted_cluster = cluster_idx; + app.viewer.latest_page_gone_to = cluster.first_page_idx; viewer_jump_to(app, page->range.start); } diff --git a/src/rntuple.cpp b/src/rntuple.cpp index 3fa127f..5df3546 100644 --- a/src/rntuple.cpp +++ b/src/rntuple.cpp @@ -96,7 +96,7 @@ void gather_ntuple_metadata(Arena *arena, RMicroFileReader &reader, const RNTupl chr::time_point start_t = chr::high_resolution_clock::now(); - Cluster_Info_Node *clusters = arena_push_array(arena, descriptor.GetNActiveClusters()); + Cluster_Info *clusters = arena_push_array(arena, descriptor.GetNActiveClusters()); // gather clusters and pages metadata for (const RClusterDescriptor &cluster_desc : descriptor.GetClusterIterable()) { @@ -116,8 +116,10 @@ void gather_ntuple_metadata(Arena *arena, RMicroFileReader &reader, const RNTupl assert(cluster_desc.GetId() <= UINT_MAX); pinfo->cluster_id = cluster_desc.GetId(); - Cluster_Info_Node &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) + cluster.first_page->is_first_in_cluster = false; cluster.first_page = pinfo; pinfo->is_first_in_cluster = true; } @@ -230,6 +232,12 @@ void gather_ntuple_metadata(Arena *arena, RMicroFileReader &reader, const RNTupl } chunks_tail->range.len += pinfo->range.len; + // while we're at it, set the first_page_idx information on the page's parent cluster + // Note that the first page won't update its cluster's `first_page_idx` (since we loop + // from idx = 1) but that's fine because that idx is by definition 0. + if (pinfo->is_first_in_cluster) + clusters[pinfo->cluster_id].first_page_idx = idx; + if (idx++ % GROUP_SIZE != 0) continue; diff --git a/src/rntuple.h b/src/rntuple.h index 167898e..3d00998 100644 --- a/src/rntuple.h +++ b/src/rntuple.h @@ -36,8 +36,9 @@ struct Page_Info_Chunk { u32 first_group; }; -struct Cluster_Info_Node { +struct Cluster_Info { Page_Info_Node *first_page; + u64 first_page_idx; // index in the pages linked list }; struct Cluster_Group_Info { @@ -83,7 +84,7 @@ struct RNTuple_Data { u64 n_cluster_groups; u64 tot_page_list_size; - Cluster_Info_Node *clusters; + Cluster_Info *clusters; u64 n_clusters; Page_Info_Group *page_groups;