From 724611f2491bfa02b1878eb9410f5515f9152d12 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Tue, 18 Oct 2011 19:21:06 +0200 Subject: [PATCH] don't clear on both obtain and release for the search cache --- .../action/search/type/TransportSearchCache.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchCache.java index ab324463a95..d7fe85deaa8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/search/type/TransportSearchCache.java @@ -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 org.elasticsearch.search.query.QuerySearchResultProvider; 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 @@ public class TransportSearchCache { while ((shardFailures = cacheShardFailures.poll()) == null) { cacheShardFailures.offer(new LinkedTransferQueue()); } - shardFailures.clear(); return shardFailures; } @@ -67,7 +66,6 @@ public class TransportSearchCache { while ((dfsSearchResults = cacheDfsResults.poll()) == null) { cacheDfsResults.offer(new LinkedTransferQueue()); } - dfsSearchResults.clear(); return dfsSearchResults; } @@ -79,9 +77,8 @@ public class TransportSearchCache { public Map obtainQueryResults() { Map queryResults; while ((queryResults = cacheQueryResults.poll()) == null) { - cacheQueryResults.offer(new ConcurrentHashMap()); + cacheQueryResults.offer(ConcurrentCollections.newConcurrentMap()); } - queryResults.clear(); return queryResults; } @@ -93,9 +90,8 @@ public class TransportSearchCache { public Map obtainFetchResults() { Map fetchResults; while ((fetchResults = cacheFetchResults.poll()) == null) { - cacheFetchResults.offer(new ConcurrentHashMap()); + cacheFetchResults.offer(ConcurrentCollections.newConcurrentMap()); } - fetchResults.clear(); return fetchResults; } @@ -107,9 +103,8 @@ public class TransportSearchCache { public Map obtainQueryFetchResults() { Map fetchResults; while ((fetchResults = cacheQueryFetchResults.poll()) == null) { - cacheQueryFetchResults.offer(new ConcurrentHashMap()); + cacheQueryFetchResults.offer(ConcurrentCollections.newConcurrentMap()); } - fetchResults.clear(); return fetchResults; }