Author: cbegin
Date: Sun Oct 4 03:31:48 2009
New Revision: 821458
URL: http://svn.apache.org/viewvc?rev=821458&view=rev
Log:
Used Set instead of Map for local key cache.
Modified:
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
Modified:
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java?rev=821458&r1=821457&r2=821458&view=diff
==============================================================================
---
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
(original)
+++
ibatis/java/ibatis-3/trunk/ibatis-3-core/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
Sun Oct 4 03:31:48 2009
@@ -131,7 +131,7 @@
final ResultMap discriminatedResultMap =
resolveDiscriminatedResultMap(rs, resultMap);
final CacheKey rowKey = createRowKey(discriminatedResultMap, rs);
final boolean knownValue = globalRowValueCache.containsKey(rowKey);
- Object rowValue = getRowValue(rs, discriminatedResultMap, rowKey,
globalRowValueCache);
+ Object rowValue = getRowValue(rs, discriminatedResultMap, rowKey);
if (!knownValue) {
resultContext.nextResultObject(rowValue);
resultHandler.handleResult(resultContext);
@@ -170,9 +170,9 @@
// GET VALUE FROM ROW
//
- private Object getRowValue(ResultSet rs, ResultMap resultMap, CacheKey
rowKey, Map cache) throws SQLException {
- if (cache.containsKey(rowKey)) {
- final Object resultObject = cache.get(rowKey);
+ private Object getRowValue(ResultSet rs, ResultMap resultMap, CacheKey
rowKey) throws SQLException {
+ if (globalRowValueCache.containsKey(rowKey)) {
+ final Object resultObject = globalRowValueCache.get(rowKey);
final MetaObject metaObject = MetaObject.forObject(resultObject);
applyNestedResultMappings(rs, resultMap, metaObject);
return resultObject;
@@ -191,7 +191,7 @@
resultObject = foundValues ? resultObject : null;
}
if (rowKey != NULL_ROW_KEY) {
- cache.put(rowKey, resultObject);
+ globalRowValueCache.put(rowKey, resultObject);
}
return resultObject;
}
@@ -431,11 +431,14 @@
try {
final ResultMap nestedResultMap = getNestedResultMap(rs,
nestedResultMapId);
final Object collectionProperty =
instantiateCollectionPropertyIfAppropriate(resultMapping, metaObject);
+
final CacheKey parentRowKey = createRowKey(resultMap, rs);
final CacheKey rowKey = createRowKey(nestedResultMap, rs);
- final Map localRowValueCache = getRowValueCache(parentRowKey);
- final boolean knownValue = localRowValueCache .containsKey(rowKey);
- Object rowValue = getRowValue(rs, nestedResultMap, rowKey,
localRowValueCache);
+ final Set localRowValueCache = getRowValueCache(parentRowKey);
+ final boolean knownValue = localRowValueCache .contains(rowKey);
+ localRowValueCache.add(rowKey);
+ Object rowValue = getRowValue(rs, nestedResultMap, rowKey);
+
if (rowValue != null && rowValue != NO_VALUE) {
if (collectionProperty != null && collectionProperty instanceof
Collection) {
if (!knownValue) {
@@ -455,10 +458,10 @@
return foundValues;
}
- private Map getRowValueCache(CacheKey rowKey) {
- Map cache = (Map) localRowValueCaches.get(rowKey);
+ private Set getRowValueCache(CacheKey rowKey) {
+ Set cache = (Set) localRowValueCaches.get(rowKey);
if (cache == null) {
- cache = new HashMap();
+ cache = new HashSet();
localRowValueCaches.put(rowKey,cache);
}
return cache;