incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [6/6] git commit: Adding some tracing code to the segment searching.
Date Wed, 08 Jan 2014 03:24:15 GMT
Adding some tracing code to the segment searching.


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

Branch: refs/heads/apache-blur-0.2
Commit: 293023adc6629f63d48f4c651fbf00dce9b26dd3
Parents: ef3f28f
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Jan 7 22:23:51 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Jan 7 22:23:51 2014 -0500

----------------------------------------------------------------------
 .../blur/server/IndexSearcherClosable.java      | 38 +++++++++++++++
 .../blur/server/IndexSearcherClosableNRT.java   | 49 --------------------
 2 files changed, 38 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/293023ad/blur-core/src/main/java/org/apache/blur/server/IndexSearcherClosable.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/server/IndexSearcherClosable.java b/blur-core/src/main/java/org/apache/blur/server/IndexSearcherClosable.java
index 331a9ff..673d47f 100644
--- a/blur-core/src/main/java/org/apache/blur/server/IndexSearcherClosable.java
+++ b/blur-core/src/main/java/org/apache/blur/server/IndexSearcherClosable.java
@@ -18,10 +18,18 @@ package org.apache.blur.server;
  */
 import java.io.Closeable;
 import java.io.IOException;
+import java.util.List;
 import java.util.concurrent.ExecutorService;
 
+import org.apache.blur.trace.Trace;
+import org.apache.blur.trace.Tracer;
+import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.search.CollectionTerminatedException;
+import org.apache.lucene.search.Collector;
 import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Scorer;
+import org.apache.lucene.search.Weight;
 import org.apache.lucene.store.Directory;
 
 public abstract class IndexSearcherClosable extends IndexSearcher implements Closeable {
@@ -35,4 +43,34 @@ public abstract class IndexSearcherClosable extends IndexSearcher implements
Clo
   @Override
   public abstract void close() throws IOException;
 
+  protected void search(List<AtomicReaderContext> leaves, Weight weight, Collector
collector) throws IOException {
+
+    // TODO: should we make this
+    // threaded...? the Collector could be sync'd?
+    // always use single thread:
+    for (AtomicReaderContext ctx : leaves) { // search each subreader
+      Tracer trace = Trace.trace("search - internal", Trace.param("AtomicReader", ctx.reader()));
+      try {
+        try {
+          collector.setNextReader(ctx);
+        } catch (CollectionTerminatedException e) {
+          // there is no doc of interest in this reader context
+          // continue with the following leaf
+          continue;
+        }
+        Scorer scorer = weight.scorer(ctx, !collector.acceptsDocsOutOfOrder(), true, ctx.reader().getLiveDocs());
+        if (scorer != null) {
+          try {
+            scorer.score(collector);
+          } catch (CollectionTerminatedException e) {
+            // collection was terminated prematurely
+            // continue with the following leaf
+          }
+        }
+      } finally {
+        trace.done();
+      }
+    }
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/293023ad/blur-core/src/main/java/org/apache/blur/server/IndexSearcherClosableNRT.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/server/IndexSearcherClosableNRT.java
b/blur-core/src/main/java/org/apache/blur/server/IndexSearcherClosableNRT.java
deleted file mode 100644
index ddd28ab..0000000
--- a/blur-core/src/main/java/org/apache/blur/server/IndexSearcherClosableNRT.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.apache.blur.server;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * 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.
- */
-import java.io.IOException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.NRTManager;
-import org.apache.lucene.store.Directory;
-
-public class IndexSearcherClosableNRT extends IndexSearcherClosable {
-
-  private final AtomicReference<NRTManager> _nrtManagerRef;
-  private final Directory _directory;
-
-  public IndexSearcherClosableNRT(IndexReader r, ExecutorService executor, AtomicReference<NRTManager>
nrtManagerRef,
-      Directory directory) {
-    super(r, executor);
-    _nrtManagerRef = nrtManagerRef;
-    _directory = directory;
-  }
-  
-  @Override
-  public Directory getDirectory() {
-    return _directory;
-  }
-
-  @Override
-  public void close() throws IOException {
-    _nrtManagerRef.get().release(this);
-  }
-
-}


Mime
View raw message