Skip to content

Commit

Permalink
adapt cluster ranges to use new cluster summaries
Browse files Browse the repository at this point in the history
  • Loading branch information
Moelf committed Jan 19, 2024
1 parent d6ee392 commit d3f0f06
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/RNTuple/highlevel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ Base.IndexStyle(::RNTupleField) = IndexLinear()
The event number range a given cluster covers, in Julia's index
"""
function _rntuple_clusterrange(cs)
first_entry = cs.num_first_entry
n_entries = cs.num_entries
return first_entry+1:(first_entry+n_entries)
first_entry = cs.first_entry_number
n_entries = cs.number_of_entries
return first_entry+1:(first_entry+n_entries)
end

function _clusterranges(lbs::AbstractVector{<:RNTupleField})
ranges = map(_rntuple_clusterrange, first(lbs).rn.footer.cluster_summaries)
rn = first(lbs).rn
cluster_summaries = _read_page_list(rn, 1).cluster_summaries
ranges = map(_rntuple_clusterrange, cluster_summaries)
return ranges
end

Expand Down Expand Up @@ -110,9 +112,8 @@ function _read_page_list(rn, nth=1)
end

function _localindex_newcluster!(rf::RNTupleField, idx::Int, tid::Int)
(; header_checksum,
cluster_summaries,
nested_page_locations) = _read_page_list(rf.rn, 1)
page_list =_read_page_list(rf.rn, 1)
cluster_summaries, nested_page_locations = page_list.cluster_summaries, page_list.nested_page_locations

for (cluster_idx, cluster) in enumerate(cluster_summaries)
first_entry = cluster.first_entry_number
Expand Down Expand Up @@ -185,10 +186,11 @@ struct RNTuple{O, S}
end

function _length(rn::RNTuple)::Int
last = lastindex(rn.footer.cluster_group_records)
page_list = _read_page_list(rn, last)
last_cluster = page_list.cluster_summaries[end]
return last_cluster.first_entry_number + last_cluster.number_of_entries
last_record_idx = lastindex(rn.footer.cluster_group_records)
page_list = _read_page_list(rn, last_record_idx)
last_cs = page_list.cluster_summaries[end]
range = _rntuple_clusterrange(last_cs)
return last(range)
end

function Base.keys(rn::RNTuple)
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ LorentzVectors = "3f54b04b-17fc-5cd4-9758-90c048d965e3"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Expand Down

0 comments on commit d3f0f06

Please sign in to comment.