-
Notifications
You must be signed in to change notification settings - Fork 35
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
Conversation
Codecov ReportPatch coverage:
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
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗺️ PR tour
type AnnotationsIterator = Box<dyn Iterator<Item = IonResult<RawSymbolTokenRef<'data>>>>; | ||
type AnnotationsIterator = RawAnyAnnotationsIterator<'data>; |
There was a problem hiding this comment.
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>> { |
There was a problem hiding this comment.
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
.
fn annotations(&self) -> <AnyEncoding as LazyDecoder<'data>>::AnnotationsIterator { | ||
todo!() |
There was a problem hiding this comment.
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.
pub(crate) fn field_name(&self) -> Option<SymbolId> { | ||
pub(crate) fn field_id(&self) -> Option<SymbolId> { |
There was a problem hiding this comment.
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>
.
Builds on outstanding PRs #609, #612, #613, #614, #616, #617, #619, and #620, #621.
Adds support for reading annotations in the
LazyRawTextReader
andLazyRawAnyReader
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.