Repository navigation
MLE-28075: Configure incremental write options via Flux API - #700
prgs-rsingh wants to merge 1 commit into
Conversation
|
Adding |
There was a problem hiding this comment.
🟡 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
IncrementalWriteOptionsand enables configuration throughWriteDocumentsOptions. - 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
- 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).
696454e to
be8b71c
Compare

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 addsIncrementalWriteOptions, which hangs offWriteDocumentsOptions:Changes
New API interface
IncrementalWriteOptions(@since 2.2.0), with one method per existing CLI option:--incremental-writeenable()--incremental-write-schema+--incremental-write-viewschemaAndView(schema, view)--incremental-write-hash-namehashName(name)--incremental-write-timestamp-nametimestampName(name)--incremental-write-disable-json-canonicalizationdisableJsonCanonicalization()--incremental-write-json-exclusionjsonExclusions(String...)--incremental-write-xml-exclusionxmlExclusions(String...)--log-skippedlogSkipped(int)WriteDocumentsOptions#incrementalWrite(Consumer<IncrementalWriteOptions>): the API entry point. As in the CLI, incremental write is only turned on byenable(); the other options have no effect without it.IncrementalWriteParamsnow implementsIncrementalWriteOptions. Its picocli annotations andmakeOptions()are unchanged, so existing CLI behavior is unaffected.WriteDocumentParamsimplementsincrementalWrite(...)by delegating to the existingIncrementalWriteParams. TDE generation reads the hash name from the same object, so a customhashNameset through the API carries over toincludeIncrementalWriteColumns().copycommand:DocumentCopier.CopyWriteDocumentsOptionsextendsWriteDocumentsOptions, soCopyCommand.CopyWriteDocumentsParamsnow implementsincrementalWrite(...). To keep the copy API and CLI consistent,IncrementalWriteParamsis also added as a mixin.copytherefore now accepts the same unprefixed--incremental-write*/--log-skippedoptions 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.mdthatcopysupports incremental write. The doc covers CLI options only, like the other feature pages.Notes
--incremental-write-source-uri-name(PDP-2114 Added --incremental-write-source-uri-name #677) is not included here. It depends on the unreleased connector change in PDP-2114 Incremental write source URI support marklogic-spark-connector#697. The matchingsourceUriName(...)API method can be added once both are merged.logSkipped(0)behaves the same as--log-skipped 0. The option is omitted so the connector's default of 0, which disables logging, applies.Testing
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; logsSkipped count: 4). To support it, the test-app content database now has anincrementalWriteHashmetadata field with anunsignedLongrange index.IncrementalWriteOptionsTest,CopyOptionsTest,ImportFilesOptionsTest,SplitterOptionsTest(26 passing), plusGenericFilesImporterTest(8 passing) against a freshly deployed test-app on MarkLogic 12.:flux-cli:javadocbuilds cleanly.