dataconnect(chore): Add QueryId value type and use it instead of passing around raw byte arrays#8207
dataconnect(chore): Add QueryId value type and use it instead of passing around raw byte arrays#8207dconeybe wants to merge 1 commit into
Conversation
…ing around raw byte arrays
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
📝 PRs merging into main branchOur main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a dedicated QueryId value class to represent stable, SHA-512-based identifiers for Data Connect queries, replacing the previous use of raw ImmutableByteArray. The changes include refactoring DataConnectGrpcRPCs to compute these IDs on a non-blocking dispatcher and updating the SQLite cache database to utilize the new type. Additionally, new utilities for verbatim Struct serialization and comprehensive unit tests have been added. Review feedback suggests optimizing performance by calculating the query ID only when caching is active and ensuring deterministic serialization by sorting protobuf map keys.
This PR introduces the type-safe internal value class
QueryIdfor Data Connect to represent stable identifiers for query cache entries, replacing rawImmutableByteArrayinstances in caching APIs. It also shifts the CPU-intensive query ID calculation to a background worker thread to improve overall responsiveness, and establishes comprehensive testing tools to verify the hash algorithm remains consistent over time.Highlights
QueryId: Replaced genericImmutableByteArrayhashes with a dedicatedQueryIdvalue class to represent stable query identifiers, improving type safety across the database caching layer and simplifying logging statements.nonBlockingCoroutineDispatcher) via a new internal@WorkerThreadfunctioncalculateQueryId.QueryIdUnitTestTestCases.dat.gz) to protect the persistent cache key generation algorithm against accidental changes.Structobjects to enable the generation and testing of frozen static hash samples.Changelog
QueryIdtype instead of rawImmutableByteArray.calculateQueryIdexecution to a background task running onnonBlockingCoroutineDispatcher.QueryIdinternal inline value class wrappingImmutableByteArray.@WorkerThreadutility functioncalculateQueryIdto compute the SHA-512 query identifier based on query variables and operation name.QueryIdtype.queryIddirectly instead of manually formatting it as a hex string.serializeStructVerbatimanddeserializeStructVerbatimutility functions to consistently serialize and deserialize complexStructobjects for static test cases.QueryIdsamples.