Refactor: Unify descending range search functions (Phase 4)#17
Merged
Conversation
Extract the duplicated schema building logic from three functions into a single `build_schema_from_store_meta()` helper: - infer_schema_from_zmetadata_json - infer_schema_with_meta - infer_schema_with_meta_async All three had identical logic for: 1. Building Dictionary-encoded coordinate fields (with CF time support) 2. Building regular array fields for data variables The helper centralizes this logic, making future schema changes easier to maintain consistently. Impact: -50 lines (57 additions, 107 deletions) Part of: #5
Consolidate the duplicated descending range search functions into unified helpers: - Add DescendingBoundType enum to parameterize FirstLeq vs FirstLt - Add compact_descending_bound() to unify compact_first_leq_descending and compact_first_lt_descending - Add find_descending_bound() to unify find_first_leq_descending and find_first_lt_descending - Add descending_partition_point() helper for explicit value arrays The original functions (find_first_leq_descending, find_first_lt_descending) are kept as thin wrappers for backward compatibility. Impact: +7 lines net, but significantly improved maintainability through consolidation of repeated match arms and comparison logic. Part of: #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 4 (final phase) of refactoring to eliminate duplicated code. This builds on Phase 1 (#13), Phase 2 (#15), and Phase 3 (#16).
Note: This PR includes all previous phase commits. After those PRs are merged, this PR will auto-update to show only Phase 4 changes.
Phase 4 Changes
Consolidate the duplicated descending range search functions in
filter.rs:DescendingBoundTypeenum to parameterizeFirstLeqvsFirstLtsearchescompact_descending_bound()- unifiescompact_first_leq_descendingandcompact_first_lt_descendingfind_descending_bound()- unifiesfind_first_leq_descendingandfind_first_lt_descendingdescending_partition_point()helper for explicit value arraysThe original wrapper functions are kept for backward compatibility.
Impact
Test plan
cargo test- All tests passcargo clippy- No warningscargo fmt- Properly formattedDepends on: #13 (Phase 1), #15 (Phase 2), #16 (Phase 3)
Part of #5