-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add sample for making a batch request #7725
Conversation
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
|
||
// The directory prefix. All objects in the bucket with this prefix will have their metadata | ||
// updated | ||
// String objectName = "your-object-name"; |
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.
Is this supposed to be directoryPrefix
?
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.
Good catch, thanks!
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.
Other than the comment, LGTM!
|
||
// Add all blobs with the given prefix to the batch request | ||
for (Blob blob : blobs.iterateAll()) { | ||
batchRequest.update(blob.toBuilder().setMetadata(newMetadata).build()); |
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.
Is there a max number of updates you can put into a batch? If someones has lots of objects I could imagine this possibly resulting in an error.
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.
According to the docs, "You should not include more than 100 calls in a single batch request. If you need to make more calls than that, use multiple batch requests. The total batch request payload must be less than 10MB."
Should i put a note about that in the comments?
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.
I would recommend limiting the batch operation to 100 calls per batch operation / submit combination.
Might be overkill though?
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.
@frankyn Like, in this sample? Or do you mean update the actual batch code?
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.
This is more of a question; do you know if the Batch client will handle batch requests correctly if there are more than 100 requests?
Otherwise LGTM.
@frankyn this good to merge? |
|
||
// Add all blobs with the given prefix to the batch request | ||
for (Blob blob : blobs.iterateAll()) { | ||
batchRequest.update(blob.toBuilder().setMetadata(newMetadata).build()); |
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.
This is more of a question; do you know if the Batch client will handle batch requests correctly if there are more than 100 requests?
Otherwise LGTM.
Thanks for your work, Jesse! |
Adds a sample for making a batch request, internal bug 121151093