incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/2] git commit: Trying to reproduce a Facet error.
Date Tue, 31 Dec 2013 03:39:02 GMT
Updated Branches:
  refs/heads/apache-blur-0.2 ddbab1655 -> 4f276ffa3


Trying to reproduce a Facet error.


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

Branch: refs/heads/apache-blur-0.2
Commit: b0bccbb34905c1138b017240dc2c75453425d8f4
Parents: ddbab16
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Dec 30 22:38:26 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Dec 30 22:38:26 2013 -0500

----------------------------------------------------------------------
 .../org/apache/blur/thrift/BlurClusterTest.java | 37 +++++++++++++++++---
 .../blur/lucene/search/FacetExecutor.java       | 13 +++++--
 2 files changed, 43 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b0bccbb3/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
----------------------------------------------------------------------
diff --git a/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java b/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
index 7176461..17e0828 100644
--- a/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
+++ b/blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java
@@ -33,6 +33,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.Random;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -52,6 +53,7 @@ import org.apache.blur.thrift.generated.BlurResult;
 import org.apache.blur.thrift.generated.BlurResults;
 import org.apache.blur.thrift.generated.ColumnDefinition;
 import org.apache.blur.thrift.generated.ErrorType;
+import org.apache.blur.thrift.generated.Facet;
 import org.apache.blur.thrift.generated.FetchResult;
 import org.apache.blur.thrift.generated.Query;
 import org.apache.blur.thrift.generated.RecordMutation;
@@ -117,6 +119,7 @@ public class BlurClusterTest {
     testLoadTable();
     testForEmptySchema();
     testQueryWithSelector();
+    testQueryWithFacets();
     testBatchFetch();
     testQueryCancel();
     testBackPressureViaQuery();
@@ -179,12 +182,15 @@ public class BlurClusterTest {
 
   public void testLoadTable() throws BlurException, TException, InterruptedException {
     Iface client = getClient();
-    int length = 100;
+    int length = 250;
+    int maxFacetValue = 100;
     List<RowMutation> mutations = new ArrayList<RowMutation>();
+    Random random = new Random(1);
     for (int i = 0; i < length; i++) {
       String rowId = UUID.randomUUID().toString();
       RecordMutation mutation = BlurThriftHelper.newRecordMutation("test", rowId,
-          BlurThriftHelper.newColumn("test", "value"));
+          BlurThriftHelper.newColumn("test", "value"),
+          BlurThriftHelper.newColumn("facet", Integer.toString(random.nextInt(maxFacetValue))));
       RowMutation rowMutation = BlurThriftHelper.newRowMutation("test", rowId, mutation);
       rowMutation.setWaitToBeVisible(true);
       mutations.add(rowMutation);
@@ -228,13 +234,36 @@ public class BlurClusterTest {
 
     BlurResults resultsRow = client.query("test", blurQueryRow);
     // assertRowResults(resultsRow);
-    assertEquals(100, resultsRow.getTotalResults());
+    assertEquals(250, resultsRow.getTotalResults());
 
     for (BlurResult blurResult : resultsRow.getResults()) {
       System.out.println(blurResult);
     }
 
+  }
+
+  private void testQueryWithFacets() throws BlurException, TException {
+    Iface client = getClient();
+    BlurQuery blurQueryRow = new BlurQuery();
+    Query queryRow = new Query();
+    // queryRow.setQuery("test.test:value");
+    queryRow.setQuery("*");
+    blurQueryRow.setQuery(queryRow);
+    blurQueryRow.setUseCacheIfPresent(false);
+    blurQueryRow.setCacheResult(false);
+    blurQueryRow.setSelector(new Selector());
+    for (int i = 0; i < 250; i++) {
+      blurQueryRow.addToFacets(new Facet("test.facet:" + i, Long.MAX_VALUE));
+    }
+
+    BlurResults resultsRow = client.query("test", blurQueryRow);
+    // assertRowResults(resultsRow);
+    assertEquals(250, resultsRow.getTotalResults());
+
+    System.out.println(resultsRow.getFacetCounts());
+
     System.out.println();
+
   }
 
   public void testBatchFetch() throws BlurException, TException {
@@ -421,7 +450,7 @@ public class BlurClusterTest {
     System.out.println("===========================");
 
     Iface client = getClient();
-    int length = 100;
+    int length = 250;
     BlurQuery blurQuery = new BlurQuery();
     blurQuery.setUseCacheIfPresent(false);
     Query query = new Query();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/b0bccbb3/blur-query/src/main/java/org/apache/blur/lucene/search/FacetExecutor.java
----------------------------------------------------------------------
diff --git a/blur-query/src/main/java/org/apache/blur/lucene/search/FacetExecutor.java b/blur-query/src/main/java/org/apache/blur/lucene/search/FacetExecutor.java
index 16cdba4..9544b3a 100644
--- a/blur-query/src/main/java/org/apache/blur/lucene/search/FacetExecutor.java
+++ b/blur-query/src/main/java/org/apache/blur/lucene/search/FacetExecutor.java
@@ -83,6 +83,11 @@ public class FacetExecutor {
     final Scorer[] _scorers;
     final AtomicReader _reader;
 
+    @Override
+    public String toString() {
+      return "Info scorers length [" + _scorers.length + "] reader[" + _reader + "]";
+    }
+
     Info(AtomicReaderContext context, Scorer[] scorers) {
       AtomicReader reader = context.reader();
       _bitSet = new OpenBitSet(reader.maxDoc());
@@ -97,7 +102,7 @@ public class FacetExecutor {
           Scorer scorer = _scorers[i];
           if (scorer != null) {
             scorer.score(col);
-            counts.addAndGet(i, col._hits);  
+            counts.addAndGet(i, col._hits);
           }
           col._hits = 0;
         }
@@ -109,7 +114,7 @@ public class FacetExecutor {
             Scorer scorer = _scorers[i];
             if (scorer != null) {
               scorer.score(col);
-              counts.addAndGet(i, col._hits);  
+              counts.addAndGet(i, col._hits);
             }
             counts.addAndGet(i, col._hits);
             col._hits = 0;
@@ -149,7 +154,9 @@ public class FacetExecutor {
       info = new Info(context, scorers);
       _infoMap.put(key, info);
     } else {
-      throw new IOException("Info about reader context [" + context + "] alread created.");
+      AtomicReader reader = context.reader();
+      throw new IOException("Info about reader context [" + context + "] alread created,
existing Info [" + info
+          + "] current reader [" + reader + "].");
     }
   }
 


Mime
View raw message