From 45956a5a270c4956755e43ebd9142705f367a196 Mon Sep 17 00:00:00 2001 From: kimchy Date: Mon, 23 May 2011 04:56:57 +0300 Subject: [PATCH] optimize empty cached filters to return null --- .../AbstractConcurrentMapFilterCache.java | 2 +- .../support/AbstractWeightedFilterCache.java | 2 +- .../filter/support/FilterCacheHelper.java | 23 ------------------- 3 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/FilterCacheHelper.java diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java index 8dbcb42987a..6abb72ed43e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractConcurrentMapFilterCache.java @@ -171,7 +171,7 @@ public abstract class AbstractConcurrentMapFilterCache extends AbstractIndexComp if (prev != null) { docSet = prev; } - return docSet; + return docSet == DocSet.EMPTY_DOC_SET ? null : docSet; } public String toString() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractWeightedFilterCache.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractWeightedFilterCache.java index b6415261e70..f087ab99a2a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractWeightedFilterCache.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/AbstractWeightedFilterCache.java @@ -180,7 +180,7 @@ public abstract class AbstractWeightedFilterCache extends AbstractIndexComponent innerCache.putIfAbsent(cacheKey, cacheValue); } - return cacheValue.value(); + return cacheValue.value() == DocSet.EMPTY_DOC_SET ? null : cacheValue.value(); } public String toString() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/FilterCacheHelper.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/FilterCacheHelper.java deleted file mode 100644 index ea1ada36216..00000000000 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/filter/support/FilterCacheHelper.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to Elastic Search and Shay Banon under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. Elastic Search licenses this - * file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.index.cache.filter.support; - -public class FilterCacheHelper { -} \ No newline at end of file