Skip to content

Refactor: Unify descending range search functions (Phase 4)#17

Merged
jayendra13 merged 2 commits into
mainfrom
refactor/phase4-filter-search
Feb 4, 2026
Merged

Refactor: Unify descending range search functions (Phase 4)#17
jayendra13 merged 2 commits into
mainfrom
refactor/phase4-filter-search

Conversation

@jayendra13
Copy link
Copy Markdown
Owner

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:

  • Add DescendingBoundType enum to parameterize FirstLeq vs FirstLt searches
  • Add compact_descending_bound() - unifies compact_first_leq_descending and compact_first_lt_descending
  • Add find_descending_bound() - unifies find_first_leq_descending and find_first_lt_descending
  • Add descending_partition_point() helper for explicit value arrays

The original wrapper functions are kept for backward compatibility.

Impact

  • Phase 4 net change: +7 lines (148 additions, 141 deletions)
  • Improved maintainability through consolidation
  • No functional changes - all tests pass

Test plan

  • cargo test - All tests pass
  • cargo clippy - No warnings
  • cargo fmt - Properly formatted

Depends on: #13 (Phase 1), #15 (Phase 2), #16 (Phase 3)

Part of #5

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
@jayendra13 jayendra13 merged commit ae34b59 into main Feb 4, 2026
1 of 3 checks passed
@jayendra13 jayendra13 deleted the refactor/phase4-filter-search branch February 4, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant