hansva opened a new issue, #9437: URL: https://github.com/apache/hop/issues/9437
### Apache Hop version? 2.20.0 ### Java version? 21 ### Operating system Other ### What happened? The vCard output and input transforms (since 2.19.0) have three bugs and two performance problems in the same code. **Bugs** 1. **Only the last card is kept.** vCard output opens, writes and closes the file for every row. With "Append" off, which is the default, every row overwrites the file, so a pipeline that writes 1,000 contacts to one file ends with one card in it. 2. **Placeholder text in the file name.** With "Include date in filename" or "Include time in filename" on, the file is named `contacts_<yyyMMdd>_<HHmmss>.vcf`: the transform uses the preview form of the name. `VCardFileSettingsTest` asserts this. The date pattern also has three letters y. 3. **Mapping a field to Categories fails.** `VCardMapper` calls `card.getCategories().getValues()` when writing and when reading. A card without categories returns null there, so vCard output fails on the first row, and vCard input fails on any card without categories. **Performance** 4. **vCard output, per row:** the file name is built with a new `SimpleDateFormat`, the parent folder is checked, the file is opened and closed, the character set is looked up, and a result file entry is created. This is 74% of the transform's CPU when writing 500,000 cards. 5. **vCard input, per row and per mapping:** the wanted e-mail and telephone type sets are parsed again from the mapping's text. This is 15% of the transform's CPU. ### Proposed changes **vCard output** - Keep the current file open and write every card to it. Close it when the transform finishes, in `dispose()`. - With "Append" off, a file is created or emptied the first time the run writes to it; later cards in the same run are added to it. With "Append" on, the first write also adds to what is there. - File name from a field: when the name changes, close the current file and open the next one. Remember the names this run has written, so that a name that comes back is appended to and not emptied. One open file at a time keeps the number of open files bounded when every contact has its own file. - Build the file name once per run, with the real date and time of the start of the run, and the pattern `yyyyMMdd`. Fix the test that asserts the placeholders. - Resolve the character set, the output field index and the parent folder once per file, and add each file to the result once. - "Do not create file at start" is stored and shown, but nothing reads it. Make it work as in Text file output (when off, an empty file is created even without rows), or remove the option. **vCard input and the shared mapper** - Treat a card without categories as an empty list when reading, and create the categories property when writing. - Parse the type tokens of each mapping once, when the transform starts, and reuse them for every card. ### Behavior that changes - A pipeline that wrote many rows to one file with "Append" off now gets all cards in the file, not only the last one. - A file name with date or time now carries the date and time, not the text `<yyyMMdd>`. Everything else stays: one card per row, the vCard version, the encoding, the output field, passing the input fields on, and the saved format of both transforms. ### Issue Priority Priority: 2 ### Issue Component Component: Transforms -- 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]
