Repository navigation
refactor: decouple read/write responsibilities and introduce ColumnBinding - #1128
bengbengbalabalabeng wants to merge 18 commits into
Conversation
…and column binding - Separate Converter into WriteConverter (write-specific) and ReadConverter (read-specific) - Introduce ColumnBinding to support column-scoped converters in dynamic/no-bean scenarios - Introduce hierarchical CellDataConverterRegistry supporting local-first delegation - Implement LIFO precedence for custom converters - Eliminate the issue where CSV types strongly depend on CellDataType in writing
|
Thanks! All the issues mentioned are fixed. |
There was a problem hiding this comment.
The global-converter docs from #1091 no longer match how this PR looks up write converters. They say a global write converter has to return null from supportExcelTypeKey() for XLSX/XLS (the GlobalStringWriteConverter variant) and CellDataTypeEnum.STRING for CSV.
Do you plan to update the docs in this PR, or in a separate one?
The relevant documentation has been updated. |
|
@nkuprins , thank you very much for your review and valuable feedback! Since these changes touch the core converter architecture and write execution flow, I'd suggest gathering additional reviews/approvals just to err on the side of caution. @GOODBOY008 @delei, please take a look when you have a chance. Thanks! |
Mikkey-f
left a comment
There was a problem hiding this comment.
Header cells are pulled through custom converters
ConverterUtils.convertToStringMap is only used for header rows (AnalysisEventListener#invokeHead and DefaultAnalysisEventProcessor#buildHead), but it now resolves through the registry:
readSheetHolder.converterRegistry().findReadConverter(String.class, cellData.getType(), key)findReadConverter gives custom and column-bound converters precedence (selectConverter), so the header path starts applying them:
- a global
ReadConverter<String>rewrites every header cell — this is issue #1098, still open; - a
ColumnBindingconverter rewrites the header cell in its bound column. That one is new in this PR: the header path now passes the column index, even though binding is meant for data cells.
I verified on ea56a7c6 with a small probe (header NAME, one data row, model @ExcelProperty("NAME")):
global converter: invokeHeadMap -> {0=MOCK}; @ExcelProperty field -> null
column-bound (0): invokeHeadMap -> {0=MOCK}; @ExcelProperty field -> null
Resolving the header lookup against built-in read converters only (DefaultConverterLoader.loadDefaultReadConverter() or a registry findDefaultReadConverter) makes both pass. CustomConverterTest, CustomConverterRoundTripTest, CellDataConverterRegistryTest, DefaultConverterLoaderTest and ReadConverterIsolationTest stay green; only two ConverterUtilsTest mock stubs need updating for AnalysisContext#currentReadHolder.
This matches your earlier ruling on #1098 that converters apply to data cells, not header parsing. Our #1212 fixes the header path on the old architecture — I'm happy to rework it against the registry after this merges if you'd rather keep this PR scoped. Which do you prefer?
|
Hi @Mikkey-f , Since the related follow-up issues are already covered in #1098 and #1212, I suggest continuing those discussions in their respective threads. The current scope of this PR is already fairly complete. To keep it manageable and avoid high review and merge overhead from an overly large PR, I would prefer not to introduce further changes here. |
|
Thanks for the reply — understood, let's keep #1128 scoped as it is. I'll continue the header-path discussion in #1098 and #1212. Once this merges, I'll rework #1212 against the new |
|
Hi, @bengbengbalabalabeng & @nkuprins I noticed that this PR is related to older PRs and there might even be conflicts arising from it. In order to coordinate the various improvements made by different contributors, please first review and evaluate #1069 . If the current PR better aligns with the final expectations, please consider reaching a consensus with other contributors(e.g., @Mikkey-f ). I'm willing to coordinate together. IMO,I suggest merging the old PR first instead of closing it, and then trying to resolve any potential conflicts in the current PR. This can also implement the proposal in #1104 . |
Purpose of the pull request
Related: #1104
What's changed?
For more examples, please refer to: #1104
Checklist