Skip to content

Conversation

@karenyrx
Copy link
Contributor

@karenyrx karenyrx commented Nov 9, 2025

Description

A series of gRPC bulk API fixes/optimizations:

  1. Fix update operation to use doc field instead of object field (still fallsback to object for backward compatibility)
  2. Fix the default value of fetchSource to null to match REST
  3. Add pipeline support for upsert
  4. Optimize document bytes copying to pass bytes reference

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…llsback to object for bwc)

bytes optimize

Set the default value of source to null to match REST

Support allowExplicitIndex setting

Signed-off-by: Karen Xu <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2025

❌ Gradle check result for f3818ca: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Karen Xu <[email protected]>
Signed-off-by: Karen Xu <[email protected]>
@github-actions
Copy link
Contributor

❕ Gradle check result for 34bbaf4: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

❌ Patch coverage is 81.35593% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.19%. Comparing base (022d594) to head (3b80f63).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
...est/document/bulk/BulkRequestParserProtoUtils.java 81.03% 6 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #19937      +/-   ##
============================================
- Coverage     73.27%   73.19%   -0.09%     
+ Complexity    71563    71546      -17     
============================================
  Files          5785     5785              
  Lines        326822   326853      +31     
  Branches      47294    47299       +5     
============================================
- Hits         239484   239237     -247     
- Misses        68111    68372     +261     
- Partials      19227    19244      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@karenyrx karenyrx marked this pull request as ready for review November 10, 2025 21:50
@karenyrx karenyrx requested a review from a team as a code owner November 10, 2025 21:50
Signed-off-by: Karen Xu <[email protected]>
@github-actions
Copy link
Contributor

❌ Gradle check result for 6d897b8: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Contributor

❌ Gradle check result for 6d897b8: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

index = createOperation.hasXIndex() ? createOperation.getXIndex() : index;
// Check explicit index (matches REST BulkRequestParser line 218-221)
if (createOperation.hasXIndex()) {
if (!allowExplicitIndex && defaultIndex != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does allowExplicitIndex have a use case in the context of gRPC? For REST one use case could be forcing users to provide the target index in the URI which is more easily filtered on than parsing a request body. For gRPC though this information will always be in the request body and allowExplicitIndex will only control which index fields you are allowed to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, let me remove it to decouple from this PR for now
I'm not sure of the original intent of allowExplicitIndex - is it just for security concerns or could it also help to reduce the sizes of request payloads? Erring on the side of caution, had added support for it in the gRPC APIs to maintain parity but I can create a separate issue to track it later: #19962

@github-actions
Copy link
Contributor

❌ Gradle check result for 2a16f30: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Contributor

❕ Gradle check result for 2a16f30: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@github-actions
Copy link
Contributor

✅ Gradle check result for 3b80f63: SUCCESS


if (buffer.hasArray()) {
// Fast path: ByteBuffer is backed by an array
byte[] array = buffer.array();
Copy link
Contributor

@varunbharadwaj varunbharadwaj Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test to cover this path to confirm buffer.array() works fine on a read-only byte buffer?
Update: it might actually fail with ReadOnlyBufferException (ref)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity any idea what cases we will not have an array backed buffer? And similarly when the array will have an offset?

// Fallback: ByteBuffer is not array-backed (rare case)
// Must copy in this case
byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes);
Copy link
Contributor

@varunbharadwaj varunbharadwaj Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we instead use ByteString.toByteArray()?

Copy link
Contributor

@msfroh msfroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall. I really appreciate the use of zero-copy for the byte arrays.

I'll hold off on merging until you've had a chance to respond to @varunbharadwaj's comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants