Skip to content

Conversation

@olavloite
Copy link
Collaborator

Add a cache for the statement parser that is used in the Connection API. This will reduce the number of times that a SQL string needs to be parsed by the JDBC driver and PGAdapter.

Add a cache for the statement parser that is used in the Connection API.
This will reduce the number of times that a SQL string needs to be
parsed by the JDBC driver and PGAdapter.
@olavloite olavloite requested a review from a team as a code owner January 19, 2024 17:10
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: spanner Issues related to the googleapis/java-spanner API. labels Jan 19, 2024
@olavloite olavloite requested review from ankiaga and manu2 January 19, 2024 17:11
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 20, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 20, 2024
@olavloite olavloite added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 25, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 25, 2024
// We do length*2 because Java uses 2 bytes for each char.
.weigher(
(Weigher<String, ParsedStatement>)
(key, value) -> 2 * key.length() + 2 * value.sqlWithoutComments.length())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we only considering value.sqlWithoutComments as there are other attributes also stored as value? Is it because those have constant small size?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, exactly. The other properties are all small, and all have fixed size. The statement (so the original SQL statement) is also not stored as part of the value in the cache, as that is the key that we are using.

@olavloite olavloite merged commit 340ba13 into main Jan 29, 2024
@olavloite olavloite deleted the statement-parser-cache branch January 29, 2024 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/java-spanner API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants