You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mk...@apache.org on 2018/10/30 09:57:25 UTC

lucene-solr:branch_7x: SOLR-12875: AIOOBE fix when unique()/uniqueBlock() is used with DVHASH method in json.facet

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 46fd0873f -> 788dd4fd3


SOLR-12875: AIOOBE fix when unique()/uniqueBlock() is used with DVHASH method in json.facet


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/788dd4fd
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/788dd4fd
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/788dd4fd

Branch: refs/heads/branch_7x
Commit: 788dd4fd324baaff669dda237cdef14cc63428fe
Parents: 46fd087
Author: Mikhail Khludnev <mk...@apache.org>
Authored: Tue Oct 30 10:54:36 2018 +0300
Committer: Mikhail Khludnev <mk...@apache.org>
Committed: Tue Oct 30 12:26:35 2018 +0300

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  3 +
 .../solr/search/facet/UniqueBlockAgg.java       |  8 ++-
 .../apache/solr/search/facet/UniqueSlotAcc.java |  3 +
 .../solr/search/facet/TestJsonFacets.java       | 65 ++++++++++++++++++++
 4 files changed, 78 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/788dd4fd/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9417419..fa3f49f 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -146,6 +146,9 @@ Bug Fixes
 
 * SOLR-7557: Fix parsing of child documents using queryAndStreamResponse (Marvin Bredal Lillehaug/Stian Østerhaug via janhoy)
 
+* SOLR-12875: fix ArrayIndexOutOfBoundsException when unique(field) or uniqueBlock(_root_) is 
+used with DVHASH method in json.facet. (Tim Underwood via Mikhail Khludnev)
+
 Improvements
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/788dd4fd/solr/core/src/java/org/apache/solr/search/facet/UniqueBlockAgg.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/facet/UniqueBlockAgg.java b/solr/core/src/java/org/apache/solr/search/facet/UniqueBlockAgg.java
index c2bfec7..42ddbb5 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/UniqueBlockAgg.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/UniqueBlockAgg.java
@@ -53,7 +53,13 @@ public class UniqueBlockAgg extends UniqueAgg {
       Arrays.fill(counts, 0);
       Arrays.fill(lastSeenValuesPerSlot, Integer.MIN_VALUE);
     }
-    
+
+    @Override
+    public void resize(Resizer resizer) {
+      lastSeenValuesPerSlot = resizer.resize(lastSeenValuesPerSlot, Integer.MIN_VALUE);
+      super.resize(resizer);
+    }
+
     @Override
     public Object getValue(int slot) throws IOException {
       return counts[slot];

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/788dd4fd/solr/core/src/java/org/apache/solr/search/facet/UniqueSlotAcc.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/facet/UniqueSlotAcc.java b/solr/core/src/java/org/apache/solr/search/facet/UniqueSlotAcc.java
index 17575fb..5e85fd1 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/UniqueSlotAcc.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/UniqueSlotAcc.java
@@ -148,5 +148,8 @@ abstract class UniqueSlotAcc extends SlotAcc {
   @Override
   public void resize(Resizer resizer) {
     arr = resizer.resize(arr, null);
+    if (counts != null) {
+      counts = resizer.resize(counts, 0);
+    }
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/788dd4fd/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java
index 0035b16..01d29b7 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java
@@ -2410,7 +2410,72 @@ public class TestJsonFacets extends SolrTestCaseHS {
             ", books2:{ buckets:[ {val:q,count:1} ] }" +
             "}"
     );
+  }
+
+  /**
+   * An explicit test for unique*(_root_) across all methods
+   */
+  public void testUniquesForMethod() throws Exception {
+    final Client client = Client.localClient();
+
+    final SolrParams p = params("rows","0");
+
+    client.deleteByQuery("*:*", null);
+
+    SolrInputDocument parent;
+    parent = sdoc("id", "1", "type_s","book", "book_s","A", "v_t","q");
+    client.add(parent, null);
+
+    parent = sdoc("id", "2", "type_s","book", "book_s","B", "v_t","q w");
+    parent.addChildDocument( sdoc("id","2.1", "type_s","page", "page_s","a", "v_t","x y z")  );
+    parent.addChildDocument( sdoc("id","2.2", "type_s","page", "page_s","b", "v_t","x y  ") );
+    parent.addChildDocument( sdoc("id","2.3", "type_s","page", "page_s","c", "v_t","  y z" )  );
+    client.add(parent, null);
 
+    parent = sdoc("id", "3", "type_s","book", "book_s","C", "v_t","q w e");
+    parent.addChildDocument( sdoc("id","3.1", "type_s","page", "page_s","d", "v_t","x    ")  );
+    parent.addChildDocument( sdoc("id","3.2", "type_s","page", "page_s","e", "v_t","  y  ")  );
+    parent.addChildDocument( sdoc("id","3.3", "type_s","page", "page_s","f", "v_t","    z")  );
+    client.add(parent, null);
+
+    parent = sdoc("id", "4", "type_s","book", "book_s","D", "v_t","e");
+    client.add(parent, null);
+
+    client.commit();
+
+    client.testJQ(params(p, "q", "type_s:page"
+        , "json.facet", "{" +
+            "  types: {" +
+            "    type:terms," +
+            "    field:type_s," +
+            "    limit:-1," +
+            "    facet: {" +
+            "           in_books: \"unique(_root_)\" }"+
+            "  }," +
+            "  pages: {" +
+            "    type:terms," +
+            "    field:page_s," +
+            "    limit:-1," +
+            "    facet: {" +
+            "           in_books: \"uniqueBlock(_root_)\" }"+
+            "  }" +
+            "}" )
+
+        , "response=={numFound:6,start:0,docs:[]}"
+        , "facets=={ count:6," +
+            "types:{" +
+            "    buckets:[ {val:page, count:6, in_books:2} ]}" +
+            "pages:{" +
+            "    buckets:[ " +
+            "     {val:a, count:1, in_books:1}," +
+            "     {val:b, count:1, in_books:1}," +
+            "     {val:c, count:1, in_books:1}," +
+            "     {val:d, count:1, in_books:1}," +
+            "     {val:e, count:1, in_books:1}," +
+            "     {val:f, count:1, in_books:1}" +
+            "    ]}" +
+            "}"
+    );
   }