[User]Reader wraps SystemReader, not RawReader #567
Merged
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.
The
UserReader
(alias:Reader
) is implemented as a(RawReader, SymbolTable)
pair. If/when theRawReader
encounters a symbol table, theReader
consumes it and adds its symbols to theSymbolTable
.The
SystemReader
is a very similar; it is also a(RawReader, SymbolTable)
pair. However, when theRawReader
encounters a symbol table, theSystemReader
cannot consume it. Instead, it needs to process only the value over which theRawReader
is currently positioned. This requires some complex state tracking, but it allows theSystemReader
to expose/return system-level values while also processing them.This PR modifies the
UserReader
to be a thin wrapper around theSystemReader
. Whenever theSystemReader
reports one or more system-level values, theUserReader
skips over them until it finds the next user-level value or exhausts the input stream. This change is in commit 727417f.When the
SystemReader
was originally written, implementations of theRawReader
were not required to have idempotentread_*
operations; they tended to consume the value when it was read, meaning applications had to materialize/store the value if they wished to refer to it multiple times. Given this constraint, when theSystemReader
encountered part of a symbol table, it had to materialize it so it could be processed once by theSystemReader
and (potentially) a second time by the user.This constraint no longer exists; all
RawReader
implementations now allow a user to callread_*
any number of times, always returning the same value. This PR also removes the machinery that was needed to store a materialized copy of system values; it does this in commit e6c3b87.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.