lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [05/26] lucene-solr:jira/solr-12730: SOLR-12875: AIOOBE fix when unique()/uniqueBlock() is used with DVHASH method in json.facet
Date Mon, 05 Nov 2018 18:56:23 GMT
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/5aa8ad5b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/5aa8ad5b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/5aa8ad5b

Branch: refs/heads/jira/solr-12730
Commit: 5aa8ad5b14ab7f6f8f3191cba39285c3a0bf9112
Parents: ac19250
Author: Mikhail Khludnev <mkhl@apache.org>
Authored: Tue Oct 30 10:54:36 2018 +0300
Committer: Mikhail Khludnev <mkhl@apache.org>
Committed: Tue Oct 30 10:56:34 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/5aa8ad5b/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e5d19f5..f0b8e92 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -228,6 +228,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/5aa8ad5b/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/5aa8ad5b/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/5aa8ad5b/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}" +
+            "    ]}" +
+            "}"
+    );
   }
 
 


Mime
View raw message