dataconnect(chore): add last_update_sequence_number to cache db#8226
Conversation
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. |
|
/gemini review |
📝 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. |
There was a problem hiding this comment.
Code Review
This pull request introduces sequence numbers (SqliteSequenceNumber) to track updates for queries and entities in the SQLite cache database, migrating the schema from version 1.0.0 to 1.1.0. It also adds a lexicographical comparison utility for byte arrays to support comparing ImmutableByteArray instances on older Android API levels. The review feedback highlights opportunities to simplify string concatenations by removing redundant empty strings in DataConnectCacheDatabaseMigrator.kt.
This pull request introduces a new
last_update_sequence_numbercolumn to the Data Connect SQLite cache database for queries and entities. This sequence number tracks the order of cache updates and will be used by subsequent work to avoid publishing duplicate query results from cache in realtime query subscriptions.Highlights
DataConnectCacheDatabaseto generate monotonically increasing sequence numbers using a sequence helper table, assign them to queries and entities during update transactions, and report the maximum sequence number across a query and all of its referenced entities upon retrieval.1.1.0and structured the schema migrator to perform incremental multi-step migrations, starting with database creation at1.0.0and applying the migration to1.1.0which adds thelast_update_sequence_numbercolumns.ImmutableByteArrayto theComparableinterface, supported by a backport of signed lexicographical byte array comparison (contentCompareTo) to ensure compatibility with Android versions below API level 33.Changelog
last_update_sequence_numbertracking logic, including theSqliteSequenceNumberinline value class, sequence number generation helper, and maximum last update sequence number computation during query rehydration.1.1.0, introduced an incremental migration runner loop, and implemented step migration from1.0.0to1.1.0to alterqueriesandentitiestables.contentCompareTo) for Android devices running on API levels below 33.ImmutableByteArrayto theComparable<ImmutableByteArray>interface, utilizing the newcontentCompareTologic to achieve a stable cross-process sort order.1.0.0to1.1.0migrations, and that proper exceptions are thrown when the database version or application ID is unrecognized.ImmutableByteArray, covering identical arrays, prefixes, and different array lengths.Arb) outside of standard property-based tests.