incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [7/7] git commit: Cleaned up some older code, no longer need to pass the IndexReader around for cleanup.
Date Sun, 31 Mar 2013 15:10:59 GMT
Cleaned up some older code, no longer need to pass the IndexReader around for cleanup.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/349e8aab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/349e8aab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/349e8aab

Branch: refs/heads/0.1.5
Commit: 349e8aab6827c1cf503a122dfeac458f62900cf6
Parents: c0a0953
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun Mar 31 11:10:09 2013 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun Mar 31 11:10:09 2013 -0400

----------------------------------------------------------------------
 .../java/org/apache/blur/manager/IndexManager.java |    9 +++---
 .../results/BlurResultIterableSearcher.java        |   21 ++++----------
 2 files changed, 11 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/349e8aab/src/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java b/src/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
index 6517534..23ac2c8 100644
--- a/src/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
+++ b/src/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
@@ -968,17 +968,18 @@ public class IndexManager {
     @Override
     public BlurResultIterable call(Entry<String, BlurIndex> entry) throws Exception
{
       _status.attachThread();
+      BlurIndex index = entry.getValue();
+      IndexSearcherClosable searcher = index.getIndexReader();
       try {
-        BlurIndex index = entry.getValue();
-        IndexSearcherClosable searcher = index.getIndexReader();
         String shard = entry.getKey();
         // @TODO need to add escapable rewriter
         // IndexReader escapeReader = EscapeRewrite.wrap(reader, _running);
         // IndexSearcher searcher = new IndexSearcher(escapeReader);
         searcher.setSimilarity(_indexServer.getSimilarity(_table));
         Query rewrite = searcher.rewrite((Query) _query.clone());
-        return new BlurResultIterableSearcher(_running, rewrite, _table, shard, searcher,
_selector,
-            searcher.getIndexReader());
+        
+        //BlurResultIterableSearcher will close searcher.
+        return new BlurResultIterableSearcher(_running, rewrite, _table, shard, searcher,
_selector);
       } finally {
         _queriesInternalMeter.mark();
         _status.deattachThread();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/349e8aab/src/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
b/src/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
index 0a0786d..8f245ac 100644
--- a/src/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
+++ b/src/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
@@ -22,28 +22,23 @@ import java.util.Map;
 import java.util.TreeMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.apache.blur.log.Log;
-import org.apache.blur.log.LogFactory;
 import org.apache.blur.lucene.search.IterablePaging;
 import org.apache.blur.lucene.search.IterablePaging.ProgressRef;
 import org.apache.blur.lucene.search.IterablePaging.TotalHitsRef;
 import org.apache.blur.manager.IndexManager;
+import org.apache.blur.server.IndexSearcherClosable;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.BlurResult;
 import org.apache.blur.thrift.generated.FetchResult;
 import org.apache.blur.thrift.generated.Selector;
 import org.apache.blur.utils.Converter;
 import org.apache.blur.utils.IteratorConverter;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 
 
 public class BlurResultIterableSearcher implements BlurResultIterable {
 
-  private static final Log LOG = LogFactory.getLog(BlurResultIterableSearcher.class);
-
   private Map<String, Long> _shardInfo = new TreeMap<String, Long>();
   private String _shard;
   private long _skipTo;
@@ -53,13 +48,12 @@ public class BlurResultIterableSearcher implements BlurResultIterable
{
   private IteratorConverter<ScoreDoc, BlurResult> _iterator;
   private Selector _selector;
   private Query _query;
-  private IndexSearcher _searcher;
+  private IndexSearcherClosable _searcher;
   private TotalHitsRef _totalHitsRef = new TotalHitsRef();
   private ProgressRef _progressRef = new ProgressRef();
   private AtomicBoolean _running;
-  private IndexReader _reader;
 
-  public BlurResultIterableSearcher(AtomicBoolean running, Query query, String table, String
shard, IndexSearcher searcher, Selector selector, IndexReader reader)
+  public BlurResultIterableSearcher(AtomicBoolean running, Query query, String table, String
shard, IndexSearcherClosable searcher, Selector selector)
       throws IOException {
     _running = running;
     _table = table;
@@ -67,7 +61,6 @@ public class BlurResultIterableSearcher implements BlurResultIterable {
     _shard = shard;
     _searcher = searcher;
     _selector = selector;
-    _reader = reader;
     performSearch();
   }
 
@@ -125,11 +118,9 @@ public class BlurResultIterableSearcher implements BlurResultIterable
{
 
   @Override
   public void close() throws IOException {
-    if (_reader != null) {
-      int refCount = _reader.getRefCount();
-      _reader.decRef();
-      LOG.debug("Decrementing reader old ref [{0}] new ref count [{1}]", refCount, _reader.getRefCount());
-      _reader = null;
+    if (_searcher != null) {
+      _searcher.close();
+      _searcher = null;
     }
   }
 }


Mime
View raw message