Permalink
Browse files

don't clear on both obtain and release for the search cache

  • Loading branch information...
kimchy committed Oct 18, 2011
1 parent 4ffbdbe commit 724611f2491bfa02b1878eb9410f5515f9152d12
@@ -20,6 +20,7 @@
package org.elasticsearch.action.search.type;
import org.elasticsearch.action.search.ShardSearchFailure;
+import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
import org.elasticsearch.common.util.concurrent.jsr166y.LinkedTransferQueue;
import org.elasticsearch.search.SearchShardTarget;
import org.elasticsearch.search.dfs.DfsSearchResult;
@@ -30,7 +31,6 @@
import java.util.Collection;
import java.util.Map;
import java.util.Queue;
-import java.util.concurrent.ConcurrentHashMap;
/**
* @author kimchy (shay.banon)
@@ -53,7 +53,6 @@
while ((shardFailures = cacheShardFailures.poll()) == null) {
cacheShardFailures.offer(new LinkedTransferQueue<ShardSearchFailure>());
}
- shardFailures.clear();
return shardFailures;
}
@@ -67,7 +66,6 @@ public void releaseShardFailures(Collection<ShardSearchFailure> shardFailures) {
while ((dfsSearchResults = cacheDfsResults.poll()) == null) {
cacheDfsResults.offer(new LinkedTransferQueue<DfsSearchResult>());
}
- dfsSearchResults.clear();
return dfsSearchResults;
}
@@ -79,9 +77,8 @@ public void releaseDfsResults(Collection<DfsSearchResult> dfsResults) {
public Map<SearchShardTarget, QuerySearchResultProvider> obtainQueryResults() {
Map<SearchShardTarget, QuerySearchResultProvider> queryResults;
while ((queryResults = cacheQueryResults.poll()) == null) {
- cacheQueryResults.offer(new ConcurrentHashMap<SearchShardTarget, QuerySearchResultProvider>());
+ cacheQueryResults.offer(ConcurrentCollections.<SearchShardTarget, QuerySearchResultProvider>newConcurrentMap());
}
- queryResults.clear();
return queryResults;
}
@@ -93,9 +90,8 @@ public void releaseQueryResults(Map<SearchShardTarget, QuerySearchResultProvider
public Map<SearchShardTarget, FetchSearchResult> obtainFetchResults() {
Map<SearchShardTarget, FetchSearchResult> fetchResults;
while ((fetchResults = cacheFetchResults.poll()) == null) {
- cacheFetchResults.offer(new ConcurrentHashMap<SearchShardTarget, FetchSearchResult>());
+ cacheFetchResults.offer(ConcurrentCollections.<SearchShardTarget, FetchSearchResult>newConcurrentMap());
}
- fetchResults.clear();
return fetchResults;
}
@@ -107,9 +103,8 @@ public void releaseFetchResults(Map<SearchShardTarget, FetchSearchResult> fetchR
public Map<SearchShardTarget, QueryFetchSearchResult> obtainQueryFetchResults() {
Map<SearchShardTarget, QueryFetchSearchResult> fetchResults;
while ((fetchResults = cacheQueryFetchResults.poll()) == null) {
- cacheQueryFetchResults.offer(new ConcurrentHashMap<SearchShardTarget, QueryFetchSearchResult>());
+ cacheQueryFetchResults.offer(ConcurrentCollections.<SearchShardTarget, QueryFetchSearchResult>newConcurrentMap());
}
- fetchResults.clear();
return fetchResults;
}

0 comments on commit 724611f

Please sign in to comment.