Skip to content

Commit 89079f9

Browse files
committed
解决版本未精准匹配时 !key 反选无效;优化性能
1 parent 143765a commit 89079f9

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/main/java/apijson/column/ColumnUtil.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ public static void init() {
111111

112112
for (Entry<Integer, Map<String, List<String>>> entry : allSet) {
113113
Map<String, Map<String, String>> keyColumnMap = VERSIONED_KEY_COLUMN_MAP.get(entry.getKey());
114-
Map<String, Map<String, String>> columnKeyMap = VERSIONED_COLUMN_KEY_MAP.get(entry.getKey());
114+
// 没必要,没特殊配置的就原样返回,没有安全隐患,还能减少性能浪费 Map<String, Map<String, String>> columnKeyMap = VERSIONED_COLUMN_KEY_MAP.get(entry.getKey());
115115
if (keyColumnMap == null) {
116116
keyColumnMap = new LinkedHashMap<>();
117117
VERSIONED_KEY_COLUMN_MAP.put(entry.getKey(), keyColumnMap);
118118
}
119-
if (columnKeyMap == null) {
120-
columnKeyMap = new LinkedHashMap<>();
121-
VERSIONED_COLUMN_KEY_MAP.put(entry.getKey(), columnKeyMap);
122-
}
119+
// if (columnKeyMap == null) {
120+
// columnKeyMap = new LinkedHashMap<>();
121+
// VERSIONED_COLUMN_KEY_MAP.put(entry.getKey(), columnKeyMap);
122+
// }
123123

124124
Map<String, List<String>> tableKeyColumnMap = entry == null ? null : entry.getValue();
125125
Set<Entry<String, List<String>>> tableKeyColumnSet = tableKeyColumnMap == null ? null : tableKeyColumnMap.entrySet();
@@ -133,22 +133,22 @@ public static void init() {
133133
if (list != null && list.isEmpty() == false) {
134134

135135
Map<String, String> kcm = keyColumnMap.get(tableKeyColumnEntry.getKey());
136-
Map<String, String> ckm = columnKeyMap.get(tableKeyColumnEntry.getKey());
136+
// Map<String, String> ckm = columnKeyMap.get(tableKeyColumnEntry.getKey());
137137
if (kcm == null) {
138138
kcm = new LinkedHashMap<>();
139139
keyColumnMap.put(tableKeyColumnEntry.getKey(), kcm);
140140
}
141-
if (ckm == null) {
142-
ckm = new LinkedHashMap<>();
143-
columnKeyMap.put(tableKeyColumnEntry.getKey(), ckm);
144-
}
141+
// if (ckm == null) {
142+
// ckm = new LinkedHashMap<>();
143+
// columnKeyMap.put(tableKeyColumnEntry.getKey(), ckm);
144+
// }
145145

146146
for (String column : list) {
147147
if (column == null) {
148148
continue;
149149
}
150150

151-
ckm.putIfAbsent(column, column);
151+
// ckm.putIfAbsent(column, column);
152152
//FIXME 对 Comment.toId (多版本) 居然不起作用
153153
// if (kcm.containsValue(column) == false) {
154154
kcm.putIfAbsent(column, column);
@@ -245,8 +245,7 @@ public static List<String> compatInputColumn(List<String> columns, String table,
245245
}
246246

247247
boolean isEmpty = exceptColumns == null || exceptColumns.isEmpty(); // exceptColumnMap == null || exceptColumnMap.isEmpty();
248-
Map<String, List<String>> map = isEmpty || VERSIONED_TABLE_COLUMN_MAP == null || VERSIONED_TABLE_COLUMN_MAP.isEmpty() ? null : VERSIONED_TABLE_COLUMN_MAP.get(version);
249-
List<String> allColumns = map == null || map.isEmpty() ? null : map.get(table);
248+
List<String> allColumns = isEmpty ? null : getClosestValue(VERSIONED_TABLE_COLUMN_MAP, version, table);
250249

251250
if (allColumns != null && allColumns.isEmpty() == false) {
252251

0 commit comments

Comments
 (0)