perf(spanner-jdbc): cache JDBC metadata query strings - #14041
Conversation
Cache the SQL strings that are loaded from disk for the standard JDBC metadata queries.
There was a problem hiding this comment.
Code Review
This pull request introduces caching for SQL queries loaded from files in JdbcDatabaseMetaData using a ConcurrentHashMap to improve performance, and adds a corresponding unit test to verify the caching behavior. It also updates the file reading logic to use UTF-8 explicitly and adds a null check for the resource stream. The reviewer suggests managing all closeable resources (InputStream, InputStreamReader, and Scanner) within a try-with-resources block to prevent potential resource leaks and notes that BufferedReader is redundant.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces caching for SQL files read from resources in JdbcDatabaseMetaData using a ConcurrentHashMap to avoid redundant file I/O operations, and adds corresponding unit tests. The review feedback suggests optimizing the cache lookup by performing a fast get check before calling computeIfAbsent to prevent unnecessary lambda allocations on cache hits.
Cache the SQL strings that are loaded from disk for the standard JDBC metadata queries.