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 lazy reader support for reading annotations #622

Merged
merged 20 commits into from
Aug 23, 2023
Merged

Conversation

zslayton
Copy link
Contributor

Builds on outstanding PRs #609, #612, #613, #614, #616, #617, #619, and #620, #621.

Adds support for reading annotations in the LazyRawTextReader and LazyRawAnyReader.

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-any-reader August 12, 2023 00:01
@codecov
Copy link

codecov bot commented Aug 12, 2023

Codecov Report

Patch coverage: 75.14% and project coverage change: +0.14% 🎉

Comparison is base (ea1b61c) 81.11% compared to head (c3ce71c) 81.25%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #622      +/-   ##
==========================================
+ Coverage   81.11%   81.25%   +0.14%     
==========================================
  Files         123      123              
  Lines       22570    22715     +145     
  Branches    22570    22715     +145     
==========================================
+ Hits        18308    18458     +150     
+ Misses       2574     2554      -20     
- Partials     1688     1703      +15     
Files Changed Coverage Δ
src/lazy/decoder.rs 60.00% <ø> (ø)
src/lazy/encoding.rs 0.00% <ø> (ø)
src/lazy/raw_value_ref.rs 71.09% <0.00%> (ø)
src/lazy/text/encoded_value.rs 76.56% <0.00%> (+6.01%) ⬆️
src/lazy/text/raw/struct.rs 68.57% <0.00%> (ø)
src/lazy/binary/raw/value.rs 79.50% <33.33%> (-0.75%) ⬇️
src/lazy/any_encoding.rs 48.57% <65.78%> (+7.58%) ⬆️
src/lazy/text/raw/reader.rs 89.01% <66.66%> (-1.39%) ⬇️
src/lazy/text/value.rs 67.81% <76.92%> (+23.07%) ⬆️
src/lazy/text/buffer.rs 88.48% <100.00%> (+0.85%) ⬆️

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

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 -40 to +41
type AnnotationsIterator = Box<dyn Iterator<Item = IonResult<RawSymbolTokenRef<'data>>>>;
type AnnotationsIterator = RawAnyAnnotationsIterator<'data>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🗺️ The Box<dyn _> type was just a placeholder.

@@ -181,10 +182,10 @@ impl<'data> From<RawStreamItem<'data, BinaryEncoding>> for RawStreamItem<'data,
}

impl<'data> LazyRawValuePrivate<'data> for LazyRawAnyValue<'data> {
fn field_name(&self) -> Option<RawSymbolTokenRef<'data>> {
fn field_name(&self) -> IonResult<RawSymbolTokenRef<'data>> {
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 trait method signature had to be changed. The binary raw reader only ever encounters SymbolId field names. The text reader, however, can encounter string and symbol field names with invalid text. (For example: illegal escape sequences or invalid unicode.) Thus, we now return an IonResult instead of an Option.

Comment on lines -207 to -208
fn annotations(&self) -> <AnyEncoding as LazyDecoder<'data>>::AnnotationsIterator {
todo!()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🗺️ As with the other LazyRawAnyReader methods, we branch on which encoding we're reading and delegate the method call to the appropriate reader.

Comment on lines -182 to +188
pub(crate) fn field_name(&self) -> Option<SymbolId> {
pub(crate) fn field_id(&self) -> Option<SymbolId> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🗺️ I renamed this binary reader method from field_name to field_id to avoid be confused with the raw reader trait of the same name.

The binary reader can always return a symbol ID representing the field name if there is one. However, the raw reader trait needs to accommodate failure cases in the raw text reader and returns an IonResult<RawSymbolTokenRef> instead of an Option<SymbolId>.

Base automatically changed from lazy-any-reader to main August 23, 2023 19:50
@zslayton zslayton merged commit 01354e8 into main Aug 23, 2023
17 of 18 checks passed
@zslayton zslayton deleted the lazy-annotations branch August 23, 2023 20:13
@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