Skip to content

Conversation

@rjrudin
Copy link
Contributor

@rjrudin rjrudin commented Dec 30, 2025

Started making tests under "com.marklogic.client.datamovement" as well so that protected methods can be unit-tested.

Copilot AI review requested due to automatic review settings December 30, 2025 22:02
@rjrudin rjrudin requested a review from stevebio as a code owner December 30, 2025 22:02
@github-actions
Copy link

github-actions bot commented Dec 30, 2025

Copyright Validation Results
Total: 12 | Passed: 10 | Failed: 0 | Skipped: 2 | at: 2025-12-30 22:04:51 UTC | commit: a285cd5

⏭️ Skipped (Excluded) Files

  • .copyrightconfig
  • CODEOWNERS

✅ Valid Files

  • marklogic-client-api/src/main/java/com/marklogic/client/datamovement/DocumentWriteSetFilter.java
  • marklogic-client-api/src/main/java/com/marklogic/client/datamovement/WriteBatcher.java
  • marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/BatchWriteSet.java
  • marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/BatchWriter.java
  • marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/WriteBatcherImpl.java
  • marklogic-client-api/src/main/java/com/marklogic/client/impl/okhttp/RetryIOExceptionInterceptor.java
  • marklogic-client-api/src/test/java/com/marklogic/client/datamovement/WriteNakedPropertiesTest.java
  • marklogic-client-api/src/test/java/com/marklogic/client/datamovement/filter/RemoveAllDocumentsFilterTest.java
  • marklogic-client-api/src/test/java/com/marklogic/client/datamovement/filter/WriteBatcherTemplate.java
  • marklogic-client-api/src/test/java/com/marklogic/client/test/AbstractClientTest.java

✅ All files have valid copyright headers!

@rjrudin rjrudin force-pushed the feature/26420-just-filter branch from eef2d02 to c947055 Compare December 30, 2025 22:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new DocumentWriteSetFilter interface that allows users to filter or modify document batches before they are written to MarkLogic. The filter can inspect batch context (batch number, database client, temporal collection) and return a modified or new DocumentWriteSet, or return null/empty to skip the write entirely.

Key changes:

  • Added DocumentWriteSetFilter interface with a Context that provides batch information
  • Integrated filter support into WriteBatcher and BatchWriter to apply filters before writing
  • Reorganized test structure to enable testing of protected methods

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
DocumentWriteSetFilter.java New interface defining the filter contract and context
WriteBatcher.java Added withDocumentWriteSetFilter() method to configure filters
WriteBatcherImpl.java Stores filter and passes it to BatchWriter instances
BatchWriter.java Applies filter before writing and handles empty results
BatchWriteSet.java Implements DocumentWriteSetFilter.Context interface
RemoveAllDocumentsFilterTest.java Test verifying filter behavior when all documents are removed
WriteBatcherTemplate.java Helper class for reducing boilerplate in tests
WriteNakedPropertiesTest.java Moved to different package for access to protected methods
IncrementalWriteTest.java Removed (functionality moved to WriteBatcherTemplate)
AbstractClientTest.java Added client cleanup to prevent resource leaks
RetryIOExceptionInterceptor.java Extended exception handling to include MarkLogicIOException

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

documentWriteSet = filter.apply(batchWriteSet);
if (documentWriteSet == null || documentWriteSet.isEmpty()) {
logger.debug("Filter returned empty write set for batch {}, skipping write", batchWriteSet.getBatchNumber());
closeAllHandles();
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

When the filter returns an empty DocumentWriteSet, closeAllHandles() is called on the original batchWriteSet.getDocumentWriteSet() handles, but these handles are not necessarily the same as those in the filtered documentWriteSet. If the filter created a new DocumentWriteSet, the original handles from batchWriteSet won't be closed. Consider closing handles from both the original and filtered sets, or ensure handles are properly managed when filters return new DocumentWriteSets.

Copilot uses AI. Check for mistakes.
private final ServerTransform transform;
private final String temporalCollection;

// Can be overridden after creation
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The comment 'Can be overridden after creation' is misleading as this is a private field, not an overridable method. Consider revising to 'Can be replaced after creation via updateWithFilteredDocumentWriteSet()' to more accurately describe the intended usage pattern.

Suggested change
// Can be overridden after creation
// Can be replaced after creation via updateWithFilteredDocumentWriteSet()

Copilot uses AI. Check for mistakes.
import java.util.function.Consumer;

// Experimenting with a template that gets rid of some annoying DMSDK boilerplate.
record WriteBatcherTemplate(DatabaseClient databaseClient) {
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The WriteBatcherTemplate record has package-private visibility but is used across different test packages (e.g., RemoveAllDocumentsFilterTest). Consider making it public or moving it to a more accessible location to support its intended cross-package usage.

Suggested change
record WriteBatcherTemplate(DatabaseClient databaseClient) {
public record WriteBatcherTemplate(DatabaseClient databaseClient) {

Copilot uses AI. Check for mistakes.
Started making tests under "com.marklogic.client.datamovement" as well so that protected methods can be unit-tested.
@rjrudin rjrudin force-pushed the feature/26420-just-filter branch from c947055 to a285cd5 Compare December 30, 2025 22:04
@rjrudin rjrudin merged commit 1c8dd85 into develop Dec 31, 2025
3 checks passed
@rjrudin rjrudin deleted the feature/26420-just-filter branch December 31, 2025 00:07
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.

3 participants