-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(bigtable): Add samples for deletes using streaming and batching #5335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(bigtable): Add samples for deletes using streaming and batching #5335
Conversation
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @bhshkh, 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!
Summary of Changes
Hello! Gemini here, providing a summary of this pull request. This PR, authored by bhshkh, introduces a new sample for Google Cloud Bigtable in Go. The primary goal, as indicated by the title and description (fixing b/417638724), is to demonstrate a pattern for deleting data in Bigtable by first streaming through rows to identify candidates for deletion and then applying those deletions efficiently in a batch operation. This involves adding both the sample code itself and a corresponding integration test to verify its functionality.
Highlights
- New Bigtable Sample: Adds a new Go sample demonstrating a specific Bigtable deletion pattern.
- Streaming Reads + Batch Deletes: The sample shows how to read rows using streaming (
tbl.ReadRows
) and collect mutations, then apply those mutations in a single bulk request (tbl.ApplyBulk
) for efficiency. - Integration Test Coverage: Includes a comprehensive integration test that sets up a temporary Bigtable table, populates it with test data, runs the sample function, and verifies that the intended cells were successfully deleted.
Changelog
Click here to see the changelog
- bigtable/deletes/delete_streaming_batching.go
- Added a new file containing the
streamingAndBatching
function. - Implements reading all rows from a specified table.
- For each row, creates a mutation to delete the cell in column
cell_plan:data_plan_01gb
. - Collects row keys and mutations into slices.
- Applies the collected mutations using
tbl.ApplyBulk
. - Includes error handling for client creation, reading rows, and applying bulk mutations.
- Added a new file containing the
- bigtable/deletes/delete_streaming_batching_test.go
- Added a new file containing the
TestStreamingAndBatching
integration test. - Sets up a temporary Bigtable table and column family for testing.
- Writes test data to the table, including the cell targeted for deletion.
- Calls the
streamingAndBatching
function with the test table. - Verifies the function's output message.
- Reads the test rows after the function runs to confirm the specific cell (
cell_plan:data_plan_01gb
) has been deleted.
- Added a new file containing the
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and 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 to provide feedback.
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.
Data flows like a stream,
Batching deletes, a coded dream.
Bigtable's might,
Making data light,
Cleaning up, a joyful gleam.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces new Go samples for deleting data from Bigtable using streaming reads and batched delete operations. The code is generally well-structured, and the accompanying test provides good coverage for the new functionality. I've identified a couple of areas for improvement, primarily related to package naming conventions and error reporting clarity, which I've detailed in the comments. Overall, this is a valuable addition to the samples.
Summary of Findings
- Package Naming Inconsistency: The Go package for the new sample (
writes
) does not match its directory (deletes/
). This should be aligned for better code organization and clarity (e.g.,package deletes
). This applies to both the sample file and its test file. - Incorrect Error Reporting for Bulk Operations: The error handling for
tbl.ApplyBulk
can inaccurately report errors. Specifically, it may return an error message indicating failures based on the total number of mutations rather than actual errors, and it might return an error even if all individual mutations succeeded.
Merge Readiness
The pull request introduces useful samples and is generally well-implemented. However, there are a couple of medium
severity issues related to package naming and error reporting that I recommend addressing before merging. Addressing these points will improve the clarity and correctness of the samples. I am not authorized to approve pull requests, so please ensure further review and approval as per your team's process after making any changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you so much!
Description
Fixes b/417638724
This sample will show up in https://cloud.google.com/bigtable/docs/delete-data#delete-stream-batch
Checklist
go test -v ./..
(see Testing)gofmt
(see Formatting)go vet
(see Formatting)