incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [21/47] git commit: SuperQuery bug fix.
Date Mon, 03 Sep 2012 00:32:19 GMT
SuperQuery bug fix.


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

Branch: refs/heads/master
Commit: 5244512d20daf8ba362b1d9a19a421b79f41490f
Parents: 4d530d9
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun Aug 26 10:17:19 2012 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun Aug 26 10:17:19 2012 -0400

----------------------------------------------------------------------
 .../blur/lucene/search/SuperQuery.java             |   34 +++++++++-----
 .../blur/manager/IndexManagerTest.java             |   34 +++++++++++++--
 2 files changed, 52 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5244512d/src/blur-core/src/main/java/com/nearinfinity/blur/lucene/search/SuperQuery.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/com/nearinfinity/blur/lucene/search/SuperQuery.java
b/src/blur-core/src/main/java/com/nearinfinity/blur/lucene/search/SuperQuery.java
index f3529aa..506329d 100644
--- a/src/blur-core/src/main/java/com/nearinfinity/blur/lucene/search/SuperQuery.java
+++ b/src/blur-core/src/main/java/com/nearinfinity/blur/lucene/search/SuperQuery.java
@@ -125,9 +125,14 @@ public class SuperQuery extends AbstractWrapperQuery {
 
   @SuppressWarnings("unused")
   public static class SuperScorer extends Scorer {
+    
+    private static final Logger LOG = LoggerFactory.getLogger(SuperScorer.class);
 
-    private final static Logger LOG = LoggerFactory.getLogger(SuperScorer.class);
+    private static final String DOC_ID = "docId";
+    private static final String NEXT_DOC = "nextDoc";
+    private static final String ADVANCE = "advance";
     private static final double SUPER_POWER_CONSTANT = 2;
+    private static final boolean debug = false;
     private Scorer scorer;
     private OpenBitSet bitSet;
     private int nextPrimeDoc;
@@ -168,29 +173,35 @@ public class SuperQuery extends AbstractWrapperQuery {
 
     @Override
     public int docID() {
-      return primeDoc;
+      return print(DOC_ID, primeDoc);
     }
 
     @Override
     public int advance(int target) throws IOException {
       if (target == NO_MORE_DOCS) {
-        return scorer.advance(NO_MORE_DOCS);
+        return print(ADVANCE, primeDoc = scorer.advance(NO_MORE_DOCS));
       }
       int doc = scorer.docID();
       int odoc = doc;
       if (isScorerExhausted(doc)) {
-        return primeDoc = doc;
+        return print(ADVANCE, primeDoc = doc);
       }
       if (target > doc || doc == -1) {
         doc = scorer.advance(target);
         if (isScorerExhausted(doc)) {
-          return primeDoc = doc;
+          return print(ADVANCE, primeDoc = doc);
         }
       } else if (isScorerExhausted(doc)) {
-        return primeDoc == -1 ? primeDoc = doc : primeDoc;
+        return print(ADVANCE, primeDoc == -1 ? primeDoc = doc : primeDoc);
+      }
+      return print(ADVANCE, gatherAllHitsSuperDoc(doc));
+    }
+
+    private int print(String message, int i) {
+      if (debug) {
+        System.out.println(message + " [" + i + "] " + originalQueryStr);
       }
-      int gatherAllHitsSuperDoc = gatherAllHitsSuperDoc(doc);
-      return gatherAllHitsSuperDoc;
+      return i;
     }
 
     @Override
@@ -203,14 +214,13 @@ public class SuperQuery extends AbstractWrapperQuery {
       if (doc == -1) {
         doc = scorer.nextDoc();
         if (isScorerExhausted(doc)) {
-          return primeDoc = doc;
+          return print(NEXT_DOC, primeDoc = doc);
         }
       } else if (isScorerExhausted(doc)) {
-        return primeDoc == -1 ? primeDoc = doc : primeDoc;
+        return print(NEXT_DOC, primeDoc == -1 ? primeDoc = doc : primeDoc);
       }
 
-      int gatherAllHitsSuperDoc = gatherAllHitsSuperDoc(doc);
-      return gatherAllHitsSuperDoc;
+      return print(NEXT_DOC, gatherAllHitsSuperDoc(doc));
     }
 
     private int gatherAllHitsSuperDoc(int doc) throws IOException {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/5244512d/src/blur-core/src/test/java/com/nearinfinity/blur/manager/IndexManagerTest.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/test/java/com/nearinfinity/blur/manager/IndexManagerTest.java
b/src/blur-core/src/test/java/com/nearinfinity/blur/manager/IndexManagerTest.java
index 2a22b0f..2ac502d 100644
--- a/src/blur-core/src/test/java/com/nearinfinity/blur/manager/IndexManagerTest.java
+++ b/src/blur-core/src/test/java/com/nearinfinity/blur/manager/IndexManagerTest.java
@@ -115,11 +115,13 @@ public class IndexManagerTest {
     RowMutation mutation1 = newRowMutation(TABLE, "row-1",
         newRecordMutation(FAMILY, "record-1", newColumn("testcol1", "value1"), newColumn("testcol2",
"value2"), newColumn("testcol3", "value3")));
     RowMutation mutation2 = newRowMutation(TABLE, "row-2",
-        newRecordMutation(FAMILY, "record-2", newColumn("testcol1", "value4"), newColumn("testcol2",
"value5"), newColumn("testcol3", "value6")));
+        newRecordMutation(FAMILY, "record-2", newColumn("testcol1", "value4"), newColumn("testcol2",
"value5"), newColumn("testcol3", "value6")),
+        newRecordMutation(FAMILY, "record-2B", newColumn("testcol2", "value234123"), newColumn("testcol3",
"value234123")));
     RowMutation mutation3 = newRowMutation(TABLE, "row-3",
         newRecordMutation(FAMILY, "record-3", newColumn("testcol1", "value7"), newColumn("testcol2",
"value8"), newColumn("testcol3", "value9")));
     RowMutation mutation4 = newRowMutation(TABLE, "row-4",
-        newRecordMutation(FAMILY, "record-4", newColumn("testcol1", "value1"), newColumn("testcol2",
"value5"), newColumn("testcol3", "value9")));
+        newRecordMutation(FAMILY, "record-4", newColumn("testcol1", "value1"), newColumn("testcol2",
"value5"), newColumn("testcol3", "value9")),
+        newRecordMutation(FAMILY, "record-4B", newColumn("testcol2", "value234123"), newColumn("testcol3",
"value234123")));
     RowMutation mutation5 = newRowMutation(
         TABLE,
         "row-5",
@@ -133,7 +135,32 @@ public class IndexManagerTest {
     indexManager.mutate(mutation4);
     indexManager.mutate(mutation5);
   }
-  
+
+  @Test
+  public void testQueryWithJoin() throws Exception {
+    BlurQuery blurQuery = new BlurQuery();
+    blurQuery.simpleQuery = new SimpleQuery();
+    blurQuery.simpleQuery.queryStr = "+(+test-family.testcol1:value1 nojoin) +(+test-family.testcol3:value234123)";
+//    blurQuery.simpleQuery.queryStr = "+(+test-family.testcol1:value1 nojoin)";
+//    blurQuery.simpleQuery.queryStr = "+(+test-family.testcol3:value234123)";
+    blurQuery.simpleQuery.superQueryOn = true;
+    blurQuery.simpleQuery.type = ScoreType.SUPER;
+    blurQuery.fetch = 10;
+    blurQuery.minimumNumberOfResults = Long.MAX_VALUE;
+    blurQuery.maxQueryTime = Long.MAX_VALUE;
+    blurQuery.uuid = 1;
+
+    BlurResultIterable iterable = indexManager.query(TABLE, blurQuery, null);
+    assertEquals(iterable.getTotalResults(), 1);
+    for (BlurResult result : iterable) {
+      Selector selector = new Selector().setLocationId(result.getLocationId());
+      FetchResult fetchResult = new FetchResult();
+      indexManager.fetchRow(TABLE, selector, fetchResult);
+      assertNotNull(fetchResult.rowResult);
+      assertNull(fetchResult.recordResult);
+    }
+  }
+
   @Test
   public void testQueryWithFacetsWithWildCard() throws Exception {
     BlurQuery blurQuery = new BlurQuery();
@@ -448,7 +475,6 @@ public class IndexManagerTest {
     assertTrue(indexManager.currentQueries(TABLE).isEmpty());
   }
 
-  
   @Test
   public void testTerms() throws Exception {
     List<String> terms = indexManager.terms(TABLE, FAMILY, "testcol1", "", (short)
100);


Mime
View raw message