You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2012/01/20 02:54:32 UTC

svn commit: r1233715 - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/contrib/analyzers/ lucene/contrib/analyzers/common/ lucene/contrib/analyzers/kuromoji/ lucene/contrib/grouping/src/java/org/apache/lucene/search/grouping/ solr/ solr/core/

Author: yonik
Date: Fri Jan 20 01:54:32 2012
New Revision: 1233715

URL: http://svn.apache.org/viewvc?rev=1233715&view=rev
Log:
LUCENE-3711: fix small SentielIntSet expanding bug

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/lucene/CHANGES.txt
    lucene/dev/branches/branch_3x/lucene/contrib/analyzers/   (props changed)
    lucene/dev/branches/branch_3x/lucene/contrib/analyzers/common/   (props changed)
    lucene/dev/branches/branch_3x/lucene/contrib/analyzers/kuromoji/   (props changed)
    lucene/dev/branches/branch_3x/lucene/contrib/grouping/src/java/org/apache/lucene/search/grouping/SentinelIntSet.java
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/core/   (props changed)

Modified: lucene/dev/branches/branch_3x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/CHANGES.txt?rev=1233715&r1=1233714&r2=1233715&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/lucene/CHANGES.txt Fri Jan 20 01:54:32 2012
@@ -140,6 +140,12 @@ Bug fixes
 * LUCENE-3605: don't sleep in a retry loop when trying to locate the
   segments_N file (Robert Muir, Mike McCandless)
 
+* LUCENE-3711: SentinelIntSet with a small initial size can go into
+  an infinite loop when expanded.  This can affect grouping using
+  TermAllGroupsCollector or TermAllGroupHeadsCollector if instantiated with a
+  non default small size. (Martijn van Groningen, yonik)
+
+
 Optimizations
 
 * LUCENE-3653: Improve concurrency in VirtualMethod and AttributeSource by

Modified: lucene/dev/branches/branch_3x/lucene/contrib/grouping/src/java/org/apache/lucene/search/grouping/SentinelIntSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/contrib/grouping/src/java/org/apache/lucene/search/grouping/SentinelIntSet.java?rev=1233715&r1=1233714&r2=1233715&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/contrib/grouping/src/java/org/apache/lucene/search/grouping/SentinelIntSet.java (original)
+++ lucene/dev/branches/branch_3x/lucene/contrib/grouping/src/java/org/apache/lucene/search/grouping/SentinelIntSet.java Fri Jan 20 01:54:32 2012
@@ -1,4 +1,6 @@
-/**
+package org.apache.lucene.search.grouping;
+
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -15,17 +17,24 @@
  * limitations under the License.
  */
 
-package org.apache.lucene.search.grouping;
-
 import java.util.Arrays;
 
-/** A native int set where one value is reserved to mean "EMPTY" */
-class SentinelIntSet {
+/**
+ * A native int set where one value is reserved to mean "EMPTY"
+ *
+ * @lucene.internal
+ */
+public class SentinelIntSet {
   public int[] keys;
   public int count;
   public final int emptyVal;
   public int rehashCount;   // the count at which a rehash should be done
 
+  /**
+   *
+   * @param size  The minimum number of elements this set should be able to hold without re-hashing (i.e. the slots are guaranteed not to change)
+   * @param emptyVal The integer value to use for EMPTY
+   */
   public SentinelIntSet(int size, int emptyVal) {
     this.emptyVal = emptyVal;
     int tsize = Math.max(org.apache.lucene.util.BitUtil.nextHighestPowerOfTwo(size), 1);
@@ -87,13 +96,13 @@ class SentinelIntSet {
   public int put(int key) {
     int s = find(key);
     if (s < 0) {
+      count++;
       if (count >= rehashCount) {
         rehash();
         s = getSlot(key);
       } else {
         s = -s-1;
       }
-      count++;
       keys[s] = key;
     }
     return s;