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>
(cherry picked from commit 480a343)
Copy file name to clipboardExpand all lines: spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/DefaultFieldSet.java
+13-5Lines changed: 13 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2006-2024 the original author or authors.
2
+
* Copyright 2006-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -25,9 +25,10 @@
25
25
importjava.util.Arrays;
26
26
importjava.util.Date;
27
27
importjava.util.List;
28
+
importjava.util.HashMap;
28
29
importjava.util.Locale;
29
30
importjava.util.Properties;
30
-
31
+
importjava.util.Map;
31
32
importorg.springframework.lang.Nullable;
32
33
importorg.springframework.util.Assert;
33
34
importorg.springframework.util.StringUtils;
@@ -40,6 +41,7 @@
40
41
* @author Rob Harrop
41
42
* @author Dave Syer
42
43
* @author Mahmoud Ben Hassine
44
+
* @author Choi Wang Gyu
43
45
*/
44
46
publicclassDefaultFieldSetimplementsFieldSet {
45
47
@@ -60,6 +62,8 @@ public class DefaultFieldSet implements FieldSet {
60
62
61
63
privateList<String> names;
62
64
65
+
privateMap<String, Integer> nameIndexMap;
66
+
63
67
/**
64
68
* The {@link NumberFormat} to use for parsing numbers. If unset the {@link Locale#US}
65
69
* will be used ('.' as decimal place).
@@ -137,6 +141,10 @@ public DefaultFieldSet(String[] tokens, String[] names, @Nullable DateFormat dat
0 commit comments