Repository navigation
fix: use int64 for the chunk index - #746
Conversation
While it's not a concern for one NAR to be chunked into more chunks than an int32 can handle, the performance and storage gain is simply not worth the special handling I had to do in order to support int32. Convert to int64 to keep the code simpler and the database essentially limitless in terms of number of chunks.
Summary of ChangesHello @kalbasit, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request standardizes the data types for chunk indexing and total chunk counts by migrating them from Highlights
Changelog
Activity
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 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 counter productive. 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Code Review
This pull request aims to simplify the codebase by changing the data type for chunk indices and total chunk counts from int32 to int64. The changes are applied across database migrations, schemas, and Go code for MySQL and PostgreSQL. This is a good simplification.
I've identified one critical issue that will cause a compilation failure and one minor style improvement. Additionally, it appears the database migration for chunk_index in SQLite was missed. While this may not cause a functional issue due to how SQLite and sqlc handle INTEGER types, it creates an inconsistency in the database schemas that should be rectified.
| // streamCompleteChunks streams all chunks for a NAR that has completed chunking. | ||
| // This is the fast path where all chunks are available immediately. | ||
| func (c *Cache) streamCompleteChunks(ctx context.Context, w io.Writer, narFileID int64, totalChunks int32) error { | ||
| func (c *Cache) streamCompleteChunks(ctx context.Context, w io.Writer, narFileID int64, totalChunks int64) error { |
There was a problem hiding this comment.
Hello @kalbasit,
Thanks for your feedback. While the change to the function signature on line 4186 itself might compile, the issue arises on line 4188 where totalChunks is used as the capacity argument for make.
The Go language specification requires the capacity argument for make to be of type int. When totalChunks is an int64 variable, the Go compiler will typically report a type mismatch error, such as cannot use totalChunks (type int64) as type int in argument to make.
It's possible your local environment or specific Go version might be more lenient in certain contexts, but to ensure strict adherence to the Go specification and avoid potential issues across different build environments, an explicit type conversion is necessary.
Please consider adding an explicit cast to int for totalChunks on line 4188:
chunkHashes := make([]string, 0, int(totalChunks))This ensures type correctness and portability.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #746 +/- ##
=======================================
Coverage 85.41% 85.41%
=======================================
Files 2 2
Lines 480 480
=======================================
Hits 410 410
Misses 65 65
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|

While it's not a concern for one NAR to be chunked into more chunks than
an int32 can handle, the performance and storage gain is simply not
worth the special handling I had to do in order to support int32.
Convert to int64 to keep the code simpler and the database essentially
limitless in terms of number of chunks.