Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for floats to the LazyRawTextReader #612

Merged
merged 9 commits into from
Aug 22, 2023
Merged

Adds support for floats to the LazyRawTextReader #612

merged 9 commits into from
Aug 22, 2023

Conversation

zslayton
Copy link
Contributor

@zslayton zslayton commented Jul 27, 2023

This PR builds on #609. Adds support for matching/reading float values in the LazyRawTextReader.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@zslayton zslayton changed the base branch from main to lazy-text-reader July 27, 2023 17:31
@codecov
Copy link

codecov bot commented Jul 27, 2023

Codecov Report

Patch coverage: 65.65% and project coverage change: -0.08% ⚠️

Comparison is base (31ec961) 81.72% compared to head (7b008b6) 81.64%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #612      +/-   ##
==========================================
- Coverage   81.72%   81.64%   -0.08%     
==========================================
  Files         118      118              
  Lines       20969    21147     +178     
  Branches    20969    21147     +178     
==========================================
+ Hits        17137    17266     +129     
- Misses       2193     2225      +32     
- Partials     1639     1656      +17     
Files Changed Coverage Δ
src/lazy/text/parse_result.rs 30.15% <0.00%> (-3.77%) ⬇️
src/lazy/text/value.rs 41.37% <0.00%> (-1.48%) ⬇️
src/lazy/text/raw/reader.rs 68.22% <61.29%> (-2.83%) ⬇️
src/lazy/text/matched.rs 59.01% <62.50%> (+2.25%) ⬆️
src/lazy/text/buffer.rs 85.25% <87.96%> (+0.57%) ⬆️
src/lazy/text/encoded_value.rs 73.52% <100.00%> (+0.26%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zslayton zslayton marked this pull request as ready for review July 27, 2023 17:52
Copy link
Contributor Author

@zslayton zslayton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗺️ PR tour

Comment on lines +197 to +199
|(matched_float, length)| {
EncodedTextValue::new(MatchedValue::Float(matched_float), self.offset(), length)
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗺️ When we match a float, record information about the match (offset, length, what kind of float) in case we eventually parse it.

Comment on lines +383 to +388
fn match_float(self) -> IonParseResult<'data, MatchedFloat> {
alt((
Self::match_float_special_value,
Self::match_float_numeric_value,
))(self)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗺️ This is the entry point for parsingfloats, which have two kinds of syntax: keyword special values (+inf, -inf, nan), and numeric values. Numeric values come in a big variety of shapes.

Comment on lines +115 to +126
/// A partially parsed Ion float.
#[derive(Copy, Clone, Debug, PartialEq)]
pub(crate) enum MatchedFloat {
/// `+inf`
PositiveInfinity,
/// `-inf`
NegativeInfinity,
/// `nan`
NotANumber,
/// Any numeric float value
Numeric,
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗺️ PR #609 introduced an EncodedValue struct that stores information like offset and length, but which also has a MatchedValue enum field. This is one of the variants of MatchedValue, and remembers the kind of float we encountered in case we read it later. The offset and length will be available in the parent data structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗺️ Changes in this file are reorganizing how various error types are converted into one another for easier bubbling up. No real logic changes.

@zslayton zslayton changed the title Lazy float Adds support for floats to the LazyRawTextReader Jul 27, 2023
@zslayton zslayton merged commit 789f2fb into main Aug 22, 2023
17 of 18 checks passed
@zslayton zslayton deleted the lazy-float branch August 22, 2023 00:12
@zslayton zslayton self-assigned this Aug 29, 2023
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.

2 participants