mikemccand commented on a change in pull request #1184: LUCENE-9142 Refactor IntSet operations for determinize URL: https://github.com/apache/lucene-solr/pull/1184#discussion_r369110759
########## File path: lucene/core/src/java/org/apache/lucene/util/automaton/SortedIntSet.java ########## @@ -16,59 +16,70 @@ */ package org.apache.lucene.util.automaton; +import java.util.Arrays; import java.util.TreeMap; import java.util.Map; import org.apache.lucene.util.ArrayUtil; +import org.apache.lucene.util.SuppressForbidden; // Just holds a set of int[] states, plus a corresponding -// int[] count per state. Used by -// BasicOperations.determinize -final class SortedIntSet { - int[] values; +// int[] count per state. Used by Operations.determinize() +final class SortedIntSet extends IntSet { int[] counts; int upto; - private int hashCode; + + // Tracks if the hashCode computation is out of date and also if the array is out of sync with the map + boolean stale = true; + + int hashCode; // If we hold more than this many states, we switch from // O(N^2) linear ops to O(N log(N)) TreeMap - private final static int TREE_MAP_CUTOVER = 30; + private final static int TREE_MAP_CUTOVER = 32; private final Map<Integer,Integer> map = new TreeMap<>(); Review comment: Would be nice to use a native map from HPPC instead -- does HPPC have a sorted map? Hmm, but this is core, and we don't have any dependencies in Lucene's core :) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org