opencsv Source
Brought to you by:
aruckerjones,
sconway
Cai Yi wants to merge 2 commits from /u/cy2008/opencsv/ to master, 2024-09-02
1.Replace java.text.SimpleDateFormat to org.apache.commons.lang3.time.DateFormatUtils.format to reduce instance creation
2.Add ResultSetHelper ability to CSVParserWriter when using CSVWriterBuilder
3.Configurable null default in ResultSetHelperService
Hello Cai
The ResultSetHelperService the changes look good and I will merge that in a future date.
For the change in CSVWriterBuilder please create a test that will fail or error if your code is not there. This will provide good documentation as to why your change is necessary and prevent it from being removed if the code was ever refactored in the future.
Now for the SimpleDateFormat vs DateFormatUtils I wrote a test (attached at the end) and got some very interesting results. Depending on the order in which the test (and stress test portion) were run the SimpleDateFormat was at times way faster and other times way slower than DateFormatUtils!
Basically with the different orders I was seeing SimpleDateFormat take between 420-950 ms to run (your times may be different depending on the machine you run it on) and the DateFormatUtils was a more consistent 600-650ms. Because of the consistency (not the speed because it sometimes was not there) I will definitely merge that in as well.
Here was my test code - let me know if I did something wrong. The stress system is currently last instead of first because I wanted to check the times without the stress test.
Add ResultSetHelper ability to CSVParserWriter when using CSVWriterBuilder
When using CSVWriterBuilder.createCSVParserWriter to create ICSVWriter, property custom resultSetHelper in CSVWriterBuilder will be ignored, and new default ResultSetHelper created by AbstractCSVWriter.resultService will be used in ICSVWriter, then date format and number format are always default format, custom format will not work
Replacement of SimpleDateFormat
I am considered about memory usage when too many rows are writed, Mybe a property simpleDateFormat in ResultSetHelperService is a good idea raher than every creation when getColumnValue calls. I will test it later.
Last edit: Cai Yi 2022-08-15