Skip to content

MLE-28075: Configure incremental write options via Flux API - #700

Open
prgs-rsingh wants to merge 1 commit into
developfrom
feature/mle-28075-iw-api
Open

prgs-rsingh wants to merge 1 commit into
developfrom
feature/mle-28075-iw-api

Conversation

@prgs-rsingh

@prgs-rsingh prgs-rsingh commented Oct 27, 2026 •

Copy link
Copy Markdown

Summary

MLE-28075 - Configure incremental write options via Flux API

Incremental write could be configured from the CLI (--incremental-write* options) but not from the Flux API. This PR adds IncrementalWriteOptions, which hangs off WriteDocumentsOptions:

Flux.importGenericFiles()
    .from("path/to/files")
    .to(options -> options
        .incrementalWrite(iw -> iw
            .enable()
            .schemaAndView("example", "incrementalWrite")
            .hashName("myHash")
            .timestampName("myTimestamp")
            .jsonExclusions("/lastModified")
            .xmlExclusions("/root/lastModified")
            .disableJsonCanonicalization()
            .logSkipped(500)))
    .execute();

Changes

  • New API interface IncrementalWriteOptions (@since 2.2.0), with one method per existing CLI option:

    CLI option API method
    --incremental-write enable()
    --incremental-write-schema + --incremental-write-view schemaAndView(schema, view)
    --incremental-write-hash-name hashName(name)
    --incremental-write-timestamp-name timestampName(name)
    --incremental-write-disable-json-canonicalization disableJsonCanonicalization()
    --incremental-write-json-exclusion jsonExclusions(String...)
    --incremental-write-xml-exclusion xmlExclusions(String...)
    --log-skipped logSkipped(int)
  • WriteDocumentsOptions#incrementalWrite(Consumer<IncrementalWriteOptions>): the API entry point. As in the CLI, incremental write is only turned on by enable(); the other options have no effect without it.

  • IncrementalWriteParams now implements IncrementalWriteOptions. Its picocli annotations and makeOptions() are unchanged, so existing CLI behavior is unaffected.

  • WriteDocumentParams implements incrementalWrite(...) by delegating to the existing IncrementalWriteParams. TDE generation reads the hash name from the same object, so a custom hashName set through the API carries over to includeIncrementalWriteColumns().

  • copy command: DocumentCopier.CopyWriteDocumentsOptions extends WriteDocumentsOptions, so CopyCommand.CopyWriteDocumentsParams now implements incrementalWrite(...). To keep the copy API and CLI consistent, IncrementalWriteParams is also added as a mixin. copy therefore now accepts the same unprefixed --incremental-write* / --log-skipped options as the import commands, as it already does with the splitter, embedder and classifier mixins. (See follow-up comment for confirmation on this.)

  • Docs: noted in docs/import/incremental-write.md that copy supports incremental write. The doc covers CLI options only, like the other feature pages.

Notes

Testing

  • New IncrementalWriteOptionsTest: covers all options, defaults, and incremental write staying off unless requested.
  • CopyOptionsTest: new cases cover the copy CLI options, the copy API, and incremental write staying off unless requested.
  • GenericFilesImporterTest#incrementalWrite: integration test that imports the same files twice and verifies the hash and timestamp metadata are written and that unchanged documents are skipped on the second run (timestamp unchanged; logs Skipped count: 4). To support it, the test-app content database now has an incrementalWriteHash metadata field with an unsignedLong range index.
  • Ran locally: IncrementalWriteOptionsTest, CopyOptionsTest, ImportFilesOptionsTest, SplitterOptionsTest (26 passing), plus GenericFilesImporterTest (8 passing) against a freshly deployed test-app on MarkLogic 12. :flux-cli:javadoc builds cleanly.

@prgs-rsingh

Copy link
Copy Markdown
Author

Adding incrementalWrite(...) to WriteDocumentsOptions also adds it to the copy API (DocumentCopier.CopyWriteDocumentsOptions), but the copy CLI has never had --incremental-write* options. For consistency I've added incremental write to the copy CLI too, reusing the same unprefixed option names the import commands use, as the splitter, embedder and classifier options already do on copy. Is that OK, or should copy support it through the API only, or not at all?

Comment thread docs/import/incremental-write.md Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new test uses an apiHash lookup without provisioning the required metadata field and range index, causing it to fail on a fresh test-app deployment before reaching the skipped-document assertions.

1 open issue
What changed in this PR

This PR exposes incremental-write configuration through the Flux Java API, reusing the existing CLI parameters, and adds incremental-write support to copy.

Changes:

  • Adds IncrementalWriteOptions and enables configuration through WriteDocumentsOptions.
  • Connects import and copy options to the shared incremental-write implementation.
  • Adds option-mapping tests, an integration test, and API usage documentation.
File Description
flux-cli/​src/​test/​java/​com/​marklogic/​flux/​impl/​copy/​CopyOptionsTest.java Tests copy CLI and API options and default behavior.
flux-cli/​src/​test/​java/​com/​marklogic/​flux/​api/​IncrementalWriteOptionsTest.java Tests API option mappings, defaults, and opt-in behavior.
flux-cli/​src/​test/​java/​com/​marklogic/​flux/​api/​GenericFilesImporterTest.java Adds repeat-import verification of hashes, timestamps, and skipping.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​importdata/​WriteDocumentParams.java Enables incremental writing through import API options.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​importdata/​IncrementalWriteParams.java Implements the new API using existing CLI parameters.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​copy/​CopyCommand.java Wires incremental-write options into copy CLI and API configuration.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​api/​WriteDocumentsOptions.java Adds the incremental-write configuration entry point.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​api/​IncrementalWriteOptions.java Defines the public incremental-write configuration interface.
docs/​import/​incremental-write.md Documents API usage, CLI mappings, and copy support.

Review effort: Balanced

@prgs-rsingh
prgs-rsingh requested review from rjrudin and a balanced review from Copilot October 28, 2026 12:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the incremental-write API and copy-command changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@prgs-rsingh
prgs-rsingh marked this pull request as ready for review November 2, 2026 12:07
- Add IncrementalWriteOptions#enable() to mirror --incremental-write;
  incrementalWrite(...) no longer enables incremental write on its own.
- Remove the API-specific section from incremental-write.md, as other
  feature docs only document CLI options.
- Add an incrementalWriteHash metadata field and range index to the
  test-app so the incremental write integration test can run.

MLE-28075: Configure incremental write options via Flux API

Adds IncrementalWriteOptions to the Flux API, exposed via
WriteDocumentsOptions#incrementalWrite(Consumer<IncrementalWriteOptions>).
Calling it enables incremental write; the consumer can customize the
schema/view, hash and timestamp key names, JSON/XML exclusions, JSON
canonicalization, and the skipped-documents log interval.

Because DocumentCopier.CopyWriteDocumentsOptions extends
WriteDocumentsOptions, the copy command now also supports incremental
write via both the API and the CLI (--incremental-write* options).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the incremental-write API and copy-command changes.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

No deployments
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