Skip to content

Introduce new createOrReplaceAndReturn/bulkCreateOrReplaceAndReturn APIs with WriteAndReturnOptions in Collection#309

Open
suddendust wants to merge 5 commits into
mainfrom
WriteAndReturnOptions
Open

Introduce new createOrReplaceAndReturn/bulkCreateOrReplaceAndReturn APIs with WriteAndReturnOptions in Collection#309
suddendust wants to merge 5 commits into
mainfrom
WriteAndReturnOptions

Conversation

@suddendust
Copy link
Copy Markdown
Contributor

Description

This PR introduces two new methods in Collection.java:

  1. Collection#createOrReplaceAndReturn(final Key key, final Document document, final WriteAndReturnOptions options)
  2. Collection#ulkCreateOrReplaceAndReturn(Map<Key, Document> documents, WriteAndReturnOptions options)

The idea behind these methods is to return the before/after docs to the client in a single-shot rather the client requesting before/after docs by itself (which requires more round-trips to the DB). We do something similar with UpdateOptions.

Testing

N/A: This PR just adds these methods to the contract, so not testing is needed yet.

Checklist:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

Documentation

The user can also control if we wants the operation to be atomic using atomic parameters in WriteAndReturnOptions. If set to true, then the before/after view are returned atomically, ensuring no intertwining of concurrent requests.

@suddendust suddendust changed the title Introduce new methods in Collection.java Introduce new createOrReplaceAndReturn/bulkCreateOrReplaceAndReturn APIs with WriteAndReturnOptions in Collection May 26, 2026
@suddendust suddendust changed the title Introduce new createOrReplaceAndReturn/bulkCreateOrReplaceAndReturn APIs with WriteAndReturnOptions in Collection Introduce new createOrReplaceAndReturn/bulkCreateOrReplaceAndReturn APIs with WriteAndReturnOptions in Collection May 26, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.45%. Comparing base (f25bebd) to head (38591dd).

Files with missing lines Patch % Lines
...mentstore/model/options/WriteAndReturnOptions.java 0.00% 6 Missing ⚠️
...g/hypertrace/core/documentstore/ReturnOptions.java 0.00% 5 Missing ⚠️
...trace/core/documentstore/WriteAndReturnResult.java 0.00% 4 Missing ⚠️
.../org/hypertrace/core/documentstore/Collection.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #309      +/-   ##
============================================
- Coverage     81.63%   81.45%   -0.19%     
  Complexity     1549     1549              
============================================
  Files           242      245       +3     
  Lines          7450     7467      +17     
  Branches        720      720              
============================================
  Hits           6082     6082              
- Misses          916      933      +17     
  Partials        452      452              
Flag Coverage Δ
integration 81.45% <0.00%> (-0.19%) ⬇️
unit 55.85% <0.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@github-actions
Copy link
Copy Markdown

ghost commented May 26, 2026

Test Results

  124 files  ±0    124 suites  ±0   42s ⏱️ +5s
  838 tests ±0    837 ✅ ±0  1 💤 ±0  0 ❌ ±0 
1 174 runs  ±0  1 173 ✅ ±0  1 💤 ±0  0 ❌ ±0 

Results for commit 38591dd. ± Comparison against base commit f25bebd.

♻️ This comment has been updated with latest results.

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.

1 participant