Refactor: Extract helper functions to reduce sync/async duplication (Phase 1)#13
Merged
Merged
Conversation
Phase 1 of refactoring to eliminate duplicated code between sync and async Zarr reading paths. Extracted helpers: - apply_cf_time_conversion(): CF time conversion logic (cf_time.rs) - create_empty_result_stream(): Empty result stream for unmatched filters - build_projected_schema(): Schema building with coordinate filtering - coord_values_to_refs(): CoordValues to CoordValuesRef conversion - calculate_effective_sizes(): Filter-based size calculation - extract_filtered_coords(): Coordinate value extraction with ranges - calculate_query_coord_sizes(): Mixed-dimensionality size calculation - create_result_batch(): Final batch creation with empty projection handling - apply_limit_to_arrays(): Limit application to result arrays Impact: Net reduction of ~2 lines with significantly improved maintainability. The sync and async paths now share common logic through these helpers. Part of: #5
This was referenced Feb 4, 2026
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 1 of refactoring to eliminate duplicated code between sync and async Zarr reading paths.
apply_cf_time_conversion()helper tocf_time.rsfor CF time conversion logiczarr_reader.rsto consolidate repeated patterns:create_empty_result_stream()- Empty result stream for unmatched filtersbuild_projected_schema()- Schema building with coordinate filteringcoord_values_to_refs()- CoordValues to CoordValuesRef conversioncalculate_effective_sizes()- Filter-based size calculationextract_filtered_coords()- Coordinate value extraction with rangescalculate_query_coord_sizes()- Mixed-dimensionality size calculationcreate_result_batch()- Final batch creation with empty projection handlingapply_limit_to_arrays()- Limit application to result arraysImpact
Test plan
cargo test- All tests passcargo clippy- No warningscargo fmt- Properly formattedPart of #5