incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [3/6] git commit: Some updates to the ReadInterceptor class, removing the mutate filter.
Date Wed, 08 Jan 2014 03:24:12 GMT
Some updates to the ReadInterceptor class, removing the mutate filter.


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

Branch: refs/heads/apache-blur-0.2
Commit: 3e0933990517b8c9e66dd7cab3f0a257f1737189
Parents: ff40894
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Jan 7 21:34:43 2014 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Jan 7 21:36:46 2014 -0500

----------------------------------------------------------------------
 .../org/apache/blur/manager/IndexManager.java   | 48 +++++++++++---------
 .../apache/blur/manager/ReadInterceptor.java    |  4 --
 .../results/BlurResultIterableSearcher.java     |  2 +-
 .../manager/writer/BlurIndexSimpleWriter.java   |  2 +-
 .../org/apache/blur/server/TableContext.java    |  5 --
 .../IndexManagerTestReadInterceptor.java        |  8 ----
 .../blur/lucene/search/IterablePaging.java      |  7 +--
 .../lucene/search/TestingPagingCollector.java   |  2 +-
 8 files changed, 32 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3e093399/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
index c72a227..15ca93c 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/IndexManager.java
@@ -106,6 +106,7 @@ import org.apache.lucene.index.StoredFieldVisitor;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.queries.BooleanFilter;
 import org.apache.lucene.queryparser.classic.ParseException;
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.BooleanQuery;
@@ -232,7 +233,7 @@ public class IndexManager {
         @Override
         public FetchResult call() throws Exception {
           FetchResult fetchResult = new FetchResult();
-          fetchRow(table, selector, fetchResult, false);
+          fetchRow(table, selector, fetchResult);
           return fetchResult;
         }
       }));
@@ -252,19 +253,10 @@ public class IndexManager {
   }
 
   public void fetchRow(String table, Selector selector, FetchResult fetchResult) throws BlurException
{
-    fetchRow(table, selector, fetchResult, false);
-  }
-
-  public void fetchRow(String table, Selector selector, FetchResult fetchResult, boolean
mutation) throws BlurException {
     validSelector(selector);
     TableContext tableContext = getTableContext(table);
     ReadInterceptor interceptor = tableContext.getReadInterceptor();
-    Filter filter;
-    if (mutation) {
-      filter = interceptor.getFilterForMutation();
-    } else {
-      filter = interceptor.getFilter();
-    }
+    Filter filter = interceptor.getFilter();
     BlurIndex index = null;
     String shard = null;
     Tracer trace = Trace.trace("manager fetch", Trace.param("table", table));
@@ -476,27 +468,41 @@ public class IndexManager {
       TableContext context = getTableContext(table);
       FieldManager fieldManager = context.getFieldManager();
       org.apache.blur.thrift.generated.Query simpleQuery = blurQuery.query;
-      Filter preFilter = QueryParserUtil.parseFilter(table, simpleQuery.recordFilter, false,
fieldManager,
+      ReadInterceptor interceptor = context.getReadInterceptor();
+      Filter readFilter = interceptor.getFilter();
+      Filter recordFilterForSearch = QueryParserUtil.parseFilter(table, simpleQuery.recordFilter,
false, fieldManager,
           _filterCache, context);
-      Filter postFilter = QueryParserUtil.parseFilter(table, simpleQuery.rowFilter, true,
fieldManager, _filterCache,
-          context);
-      Query userQuery = QueryParserUtil.parseQuery(simpleQuery.query, simpleQuery.rowQuery,
fieldManager, postFilter,
-          preFilter, getScoreType(simpleQuery.scoreType), context);
+      Filter rowFilterForSearch = QueryParserUtil.parseFilter(table, simpleQuery.rowFilter,
true, fieldManager,
+          _filterCache, context);
+      Filter docFilter;
+      if (recordFilterForSearch == null && readFilter != null) {
+        docFilter = readFilter;
+      } else if (recordFilterForSearch != null && readFilter == null) {
+        docFilter = recordFilterForSearch;
+      } else if (recordFilterForSearch != null && readFilter != null) {
+        BooleanFilter booleanFilter = new BooleanFilter();
+        booleanFilter.add(recordFilterForSearch, Occur.MUST);
+        booleanFilter.add(readFilter, Occur.MUST);
+        docFilter = booleanFilter;
+      } else {
+        docFilter = null;
+      }
+      Query userQuery = QueryParserUtil.parseQuery(simpleQuery.query, simpleQuery.rowQuery,
fieldManager,
+          rowFilterForSearch, docFilter, getScoreType(simpleQuery.scoreType), context);
 
       Query facetedQuery;
       FacetExecutor executor = null;
       if (blurQuery.facets != null) {
         long[] facetMinimums = getFacetMinimums(blurQuery.facets);
         executor = new FacetExecutor(blurQuery.facets.size(), facetMinimums, facetedCounts);
-        facetedQuery = new FacetQuery(userQuery, getFacetQueries(blurQuery, fieldManager,
context, postFilter,
-            preFilter), executor);
+        facetedQuery = new FacetQuery(userQuery, getFacetQueries(blurQuery, fieldManager,
context, rowFilterForSearch,
+            recordFilterForSearch), executor);
       } else {
         facetedQuery = userQuery;
       }
 
-      ReadInterceptor interceptor = context.getReadInterceptor();
-      call = new SimpleQueryParallelCall(running, table, status, facetedQuery, interceptor.getFilter(),
-          blurQuery.selector, _queriesInternalMeter, shardServerContext, runSlow, _fetchCount,
_maxHeapPerRowFetch,
+      call = new SimpleQueryParallelCall(running, table, status, facetedQuery, readFilter,
blurQuery.selector,
+          _queriesInternalMeter, shardServerContext, runSlow, _fetchCount, _maxHeapPerRowFetch,
           context.getSimilarity(), context);
       trace.done();
       MergerBlurResultIterable merger = new MergerBlurResultIterable(blurQuery);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3e093399/blur-core/src/main/java/org/apache/blur/manager/ReadInterceptor.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/ReadInterceptor.java b/blur-core/src/main/java/org/apache/blur/manager/ReadInterceptor.java
index fdd5244..7dc457e 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/ReadInterceptor.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/ReadInterceptor.java
@@ -27,8 +27,4 @@ public abstract class ReadInterceptor {
 
   public abstract Filter getFilter();
 
-  public Filter getFilterForMutation() {
-    return null;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3e093399/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
index 1129b92..7e5b371 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/results/BlurResultIterableSearcher.java
@@ -80,7 +80,7 @@ public class BlurResultIterableSearcher implements BlurResultIterable {
 
   private void performSearch() throws BlurException {
     IterablePaging iterablePaging = new IterablePaging(_running, _searcher, _query, _fetchCount,
_totalHitsRef,
-        _progressRef, _runSlow, _filter);
+        _progressRef, _runSlow);
     _iterator = new IteratorConverter<ScoreDoc, BlurResult, BlurException>(iterablePaging.iterator(),
         new Converter<ScoreDoc, BlurResult, BlurException>() {
           @Override

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3e093399/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
b/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
index 13d8d50..5c00ea9 100644
--- a/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
+++ b/blur-core/src/main/java/org/apache/blur/manager/writer/BlurIndexSimpleWriter.java
@@ -202,7 +202,7 @@ public class BlurIndexSimpleWriter extends BlurIndex {
   public synchronized void optimize(final int numberOfSegmentsPerShard) throws IOException
{
     final String table = _tableContext.getTable();
     final String shard = _shardContext.getShard();
-    if (_optimizeThread != null || _optimizeThread.isAlive()) {
+    if (_optimizeThread == null || _optimizeThread.isAlive()) {
       LOG.info("Already running an optimize on table [{0}] shard [{1}]", table, shard);
       return;
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3e093399/blur-core/src/main/java/org/apache/blur/server/TableContext.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/server/TableContext.java b/blur-core/src/main/java/org/apache/blur/server/TableContext.java
index 4db9058..12dd316 100644
--- a/blur-core/src/main/java/org/apache/blur/server/TableContext.java
+++ b/blur-core/src/main/java/org/apache/blur/server/TableContext.java
@@ -79,11 +79,6 @@ public class TableContext {
 
   private static final ReadInterceptor DEFAULT_INTERCEPTOR = new ReadInterceptor(null) {
     @Override
-    public Filter getFilterForMutation() {
-      return null;
-    }
-
-    @Override
     public Filter getFilter() {
       return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3e093399/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTestReadInterceptor.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTestReadInterceptor.java
b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTestReadInterceptor.java
index f0968af..7b3c23c 100644
--- a/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTestReadInterceptor.java
+++ b/blur-core/src/test/java/org/apache/blur/manager/IndexManagerTestReadInterceptor.java
@@ -28,14 +28,6 @@ public class IndexManagerTestReadInterceptor extends ReadInterceptor {
   }
 
   @Override
-  public Filter getFilterForMutation() {
-    if (interceptor == null) {
-      return null;
-    }
-    return interceptor.getFilterForMutation();
-  }
-
-  @Override
   public Filter getFilter() {
     if (interceptor == null) {
       return null;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3e093399/blur-query/src/main/java/org/apache/blur/lucene/search/IterablePaging.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/search/IterablePaging.java b/blur-query/src/main/java/org/apache/blur/lucene/search/IterablePaging.java
index 80b9ed8..8df4a99 100644
--- a/blur-query/src/main/java/org/apache/blur/lucene/search/IterablePaging.java
+++ b/blur-query/src/main/java/org/apache/blur/lucene/search/IterablePaging.java
@@ -29,7 +29,6 @@ import org.apache.blur.thrift.generated.ErrorType;
 import org.apache.blur.utils.BlurIterable;
 import org.apache.blur.utils.BlurIterator;
 import org.apache.lucene.search.Collector;
-import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
@@ -46,7 +45,6 @@ public class IterablePaging implements BlurIterable<ScoreDoc, BlurException>
{
   private final AtomicBoolean _running;
   private final int _numHitsToCollect;
   private final boolean _runSlow;
-  private final Filter _filter;
 
   private TotalHitsRef _totalHitsRef;
   private ProgressRef _progressRef;
@@ -54,9 +52,8 @@ public class IterablePaging implements BlurIterable<ScoreDoc, BlurException>
{
   private int gather = -1;
 
   public IterablePaging(AtomicBoolean running, IndexSearcher searcher, Query query, int numHitsToCollect,
-      TotalHitsRef totalHitsRef, ProgressRef progressRef, boolean runSlow, Filter filter)
throws BlurException {
+      TotalHitsRef totalHitsRef, ProgressRef progressRef, boolean runSlow) throws BlurException
{
     _running = running;
-    _filter = filter;
     try {
       _query = searcher.rewrite(query);
     } catch (IOException e) {
@@ -192,7 +189,7 @@ public class IterablePaging implements BlurIterable<ScoreDoc, BlurException>
{
         if (_runSlow) {
           col = new SlowCollector(col);
         }
-        _searcher.search(_query, _filter, col);
+        _searcher.search(_query, col);
         _totalHitsRef.totalHits.set(collector.getTotalHits());
         TopDocs topDocs = collector.topDocs();
         scoreDocs = topDocs.scoreDocs;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3e093399/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
----------------------------------------------------------------------
diff --git a/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
b/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
index 7c00f9d..48884af 100644
--- a/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
+++ b/blur-query/src/test/java/org/apache/blur/lucene/search/TestingPagingCollector.java
@@ -59,7 +59,7 @@ public class TestingPagingCollector {
     ProgressRef progressRef = new ProgressRef();
 
     TermQuery query = new TermQuery(new Term("f1", "value"));
-    IterablePaging paging = new IterablePaging(new AtomicBoolean(true), searcher, query,
100, null, null, false, null);
+    IterablePaging paging = new IterablePaging(new AtomicBoolean(true), searcher, query,
100, null, null, false);
     IterablePaging itPaging = paging.skipTo(90).gather(20).totalHits(totalHitsRef).progress(progressRef);
     BlurIterator<ScoreDoc, BlurException> iterator = itPaging.iterator();
     while (iterator.hasNext()) {


Mime
View raw message