Davis-Zhang-Onehouse opened a new pull request, #20807:
URL: https://github.com/apache/hudi/pull/20807

   ### Describe the issue this Pull Request addresses
   
   issue: #20806
   Part of #20683, RFC-118 (#20684).
   Stacked on #20805: review only the last commit. Until the PRs below it 
merge, this PR also shows their commits.
   
   The Java APIs inside the unstructured ingestion code should be easy to read 
and call: no long positional parameter lists, no arguments a caller must pass 
that the callee can derive itself (the transformers a mode requires, the table 
schema a layout is computed from, a `JavaSparkContext` next to the 
`SparkSession`), names that say what an accessor or constant returns, and 
schema-contract checks small enough to read one at a time.
   
   This commit gives those APIs explicit shapes: builders and small holder 
objects for the parts a round or iterator owns, derived arguments computed 
where they are used, and named checks in the schema contract. It does not 
change configuration, prep logic versions or the table format.
   
   ### Summary and Changelog
   
   Unstructured ingestion code with simpler Java APIs and clearer ownership of 
the resources each round uses; behaviour is unchanged.
   
   - Schema contract: `UnstructuredSchemaContract.checkChainPlan(mode, chain, 
...)` derives the required transformer from the mode and uses 
`UnstructuredSchemaGuard` as the closing entry, so `UnstructuredDataSource` 
passes neither. The chain checks are named steps (`requiredIndex`, 
`checkAddOnly`, `checkPartitionColumns`, `checkTargetSchema`, 
`withErrorColumn`) with a `ChainPlanner` that holds the arguments every chain 
entry shares. The error messages are the same.
   - Builders and parameter objects: `PreprocessingIterator.builder(blobRows, 
config, instant)` with optional `bytesSource`, `registry`, `tokenizer`, 
`counters`, `sideOutputs`, `destination` and `prefetchMaxBytes` (default 
`EmbeddingTableConfig#prepPrefetchMaxBytes()`); `ComputeRound.Resources` groups 
the stored-input source, the compute counters and the storage level of a 
compute round; `Chunk.Builder#build` passes the builder to a private `Chunk` 
constructor; `PrepSideOutput(FileMeta, sourcePath, modality, chunkId, stage, 
error)` takes the file identity as one object.
   - Ownership of derived arguments: `PrepRound` computes the output layout 
itself from the config and the output schema it is given, with no table-schema 
argument; `EmbeddingTableTransformer` reads the default parallelism and 
registers counters through the `SparkSession`'s `SparkContext`.
   - Names: `EmbeddingTableConfig.embeddingMode()` and `modelSpecs()`; 
`PREPROCESSOR_NAME` on `ImageInputPreprocessor`, `VideoFramePreprocessor` and 
`JcodecVideoFramePreprocessor`.
   - Small cleanups: `EmbeddingClientFactory` keys its Bedrock client map with 
an `EnumMap`; `TransientRetry` computes backoff in floating point; 
`MicroBatchEmbeddingIterator` guards a warning with `isWarnEnabled()`; `\d` and 
`\w` in the `BlobInlineCeiling` master patterns and the embedding column-name 
check (same matches); an unused helper in `EmbeddingTableConfig` is dropped; 
comments record the intended exception handling in `PreprocessingIterator` and 
`SourceReadException`.
   - Tests: the existing unstructured tests follow the final APIs; 
`TestUnstructuredSourceTransformers` adds cases for the composed transformer 
chain (a subclass of the required transformer runs once in first position, 
stable ids for the required transformer and the closing guard, refusal of an 
explicit guard, of colliding ids and of another mode's transformer); 
`LogCapture` records the throwables of captured events. 126 test files.
   
   Existing files touched: none. Outside the 
`org.apache.hudi.utilities.unstructured` packages the diff changes only RFC-118 
source files and tests: `sources/UnstructuredDataSource`, 
`sources/blob/BlobInlineCeiling`, 
`sources/unstructured/UnstructuredSchemaContract`, the `sources`, 
`sources/blob` and `sources/unstructured` unstructured tests, and the 
`com.sun.imageio.plugins.leakspy` test helper.
   
   No code was copied from other projects.
   
   ### Impact
   
   No change to configuration keys, defaults, prep logic versions, table format 
or error messages. Java APIs inside the unstructured packages change shape (the 
builder, parameter objects and names above), which affects only code that calls 
these classes directly. Existing Hudi behaviour outside the unstructured 
ingestion path is unchanged.
   
   ### Risk Level
   
   low: the changes are refactorings of Java APIs within the unstructured 
ingestion code, with the schema-contract checks keeping their order and 
messages; the existing unstructured test suites are updated to the final APIs.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to