mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved get statdata performance.
This commit is contained in:
@@ -628,7 +628,7 @@ public class JdbcSqlStatValue {
|
||||
}
|
||||
|
||||
public Map<String, Object> getData() throws JMException {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Map<String, Object> map = new HashMap<String, Object>(48);
|
||||
|
||||
// 0 - 4
|
||||
map.put("ID", id);
|
||||
|
||||
@@ -61,13 +61,20 @@ public class MapComparator<K extends Object, V extends Object> implements Compar
|
||||
if (key instanceof String) {
|
||||
String keyStr = (String) key;
|
||||
|
||||
if (keyStr.matches(".+\\[[0-9]+\\]")) {
|
||||
Object value = map.get(keyStr.substring(0, keyStr.indexOf('[')));
|
||||
int bracketIndex = keyStr.indexOf('[');
|
||||
if (bracketIndex > 0) {
|
||||
Object value = map.get(keyStr.substring(0, bracketIndex));
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Integer index = StringUtils.subStringToInteger(keyStr, "[", "]");
|
||||
int p2 = keyStr.indexOf(']', bracketIndex);
|
||||
if (p2 == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String indexText = keyStr.substring(bracketIndex + 1, p2);
|
||||
int index = Integer.parseInt(indexText);
|
||||
if (value.getClass().isArray() && Array.getLength(value) >= index) {
|
||||
return Array.get(value, index);
|
||||
}
|
||||
@@ -92,6 +99,10 @@ public class MapComparator<K extends Object, V extends Object> implements Compar
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (v1 instanceof Long) {
|
||||
return (int) (((Long) v1).longValue() - ((Number) v2).longValue());
|
||||
}
|
||||
|
||||
if (v1 instanceof Number) {
|
||||
return compare((Number) v1, (Number) v2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user