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:41:25 GMT
Updated Branches:
  refs/heads/master c2ac7ec31 -> 0400bad87


Trying to reproduce a Facet error.

Conflicts:
	blur-core/src/test/java/org/apache/blur/thrift/BlurClusterTest.java


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

Branch: refs/heads/master
Commit: 58a63acaddbe8740470229c51cbb2e5d5921ee55
Parents: c2ac7ec
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:40:58 2013 -0500

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


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/58a63aca/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 59201d0..90431a5 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);
@@ -227,8 +233,38 @@ public class BlurClusterTest {
     blurQueryRow.setSelector(new Selector());
 
     BlurResults resultsRow = client.query("test", blurQueryRow);
-    assertEquals(100, resultsRow.getTotalResults());
     assertTrue(0 != resultsRow.getQuery().getStartTime());
+    // assertRowResults(resultsRow);
+    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 {
@@ -415,7 +451,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/58a63aca/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