You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replaced linear List#indexOf with a precomputed Map-based index lookup
This reduces the time complexity from O(n) to O(1), improving performance
for field lookups in wide CSV files. This change preserves existing
behavior and error messages
Resolves: #4930
Signed-off-by: Choi Wang Gyu <dhkdrb897@gmail.com>
Copy file name to clipboardExpand all lines: spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSet.java
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -24,8 +24,10 @@
24
24
importjava.text.SimpleDateFormat;
25
25
importjava.util.Arrays;
26
26
importjava.util.Date;
27
+
importjava.util.HashMap;
27
28
importjava.util.List;
28
29
importjava.util.Locale;
30
+
importjava.util.Map;
29
31
importjava.util.Properties;
30
32
31
33
importorg.springframework.lang.Nullable;
@@ -40,6 +42,7 @@
40
42
* @author Rob Harrop
41
43
* @author Dave Syer
42
44
* @author Mahmoud Ben Hassine
45
+
* @author Choi Wang Gyu
43
46
*/
44
47
publicclassDefaultFieldSetimplementsFieldSet {
45
48
@@ -60,6 +63,8 @@ public class DefaultFieldSet implements FieldSet {
60
63
61
64
privateList<String> names;
62
65
66
+
privateMap<String, Integer> nameIndexMap;
67
+
63
68
/**
64
69
* The {@link NumberFormat} to use for parsing numbers. If unset the {@link Locale#US}
65
70
* will be used ('.' as decimal place).
@@ -137,6 +142,10 @@ public DefaultFieldSet(String[] tokens, String[] names, @Nullable DateFormat dat
0 commit comments