perf(spanner): reduce autoboxing when reading data#12741
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors validation logic in AbstractStructReader and Struct by replacing Guava's checkState with manual exception throwing and utilizing ImmutableList and Type constants to reduce object allocation. It also introduces method overloads for validation that use column indices for error messages. Feedback highlights that changing the parameter type from Object to String in the protected checkNonNull method is a breaking change for subclasses and suggests maintaining backward compatibility by keeping the original signature as a deprecated overload.
...panner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractStructReader.java
Show resolved
Hide resolved
AbstractStructReader and Struct contained multiple method definitions and calls that would trigger unnecessary object creation and auto-boxing on the happy path. This change removes those, sometimes at the expense of some duplicate code. This however reduces the number of object creations for the happy flow, which is by far the most used code path.
7ffb87b to
d612ce4
Compare
rahul2393
approved these changes
Apr 10, 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.
AbstractStructReader and Struct contained multiple method definitions and calls that would trigger unnecessary object creation and auto-boxing on the happy path. This change removes those, sometimes at the expense of some duplicate code. This however reduces the number of object creations for the happy flow, which is by far the most used code path.