bruno-roustant commented on a change in pull request #163: URL: https://github.com/apache/lucene/pull/163#discussion_r650761025
########## File path: lucene/core/src/java/org/apache/lucene/util/automaton/StateSet.java ########## @@ -0,0 +1,106 @@ +/* + * 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. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.lucene.util.automaton; + +import java.util.Arrays; +import org.apache.lucene.util.hppc.BitMixer; +import org.apache.lucene.util.hppc.IntIntHashMap; + +/** A thin wrapper of {@link IntIntHashMap} */ Review comment: Should we say something about the keys and values? key = state num, value = ref count ########## File path: lucene/core/src/test/org/apache/lucene/util/automaton/TestIntSet.java ########## @@ -31,14 +31,13 @@ public void testFreezeEqualityLargeSet() { } private void testFreezeEquality(int size) { - SortedIntSet sortedSet = new SortedIntSet(0); + StateSet sortedSet = new StateSet(0); Review comment: Can we rename sortedSet? (confusing) ########## File path: lucene/core/src/java/org/apache/lucene/util/automaton/Operations.java ########## @@ -693,7 +694,7 @@ public static Automaton determinize(Automaton a, int maxDeterminizedStates) { final PointTransitionSet points = new PointTransitionSet(); // like SortedMap<Integer,Integer> Review comment: The comment should be replaced. ########## File path: lucene/core/src/java/org/apache/lucene/util/automaton/StateSet.java ########## @@ -0,0 +1,106 @@ +/* + * 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. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.lucene.util.automaton; + +import java.util.Arrays; +import org.apache.lucene.util.hppc.BitMixer; +import org.apache.lucene.util.hppc.IntIntHashMap; + +/** A thin wrapper of {@link IntIntHashMap} */ +final class StateSet extends IntSet { + + private final IntIntHashMap inner; + private long hashCode; + private boolean hashUpdated = true; + private boolean arrayUpdated = true; + private int[] arrayCache = new int[0]; + + StateSet(int capacity) { + inner = new IntIntHashMap(capacity); + } + + // Adds this state to the set Review comment: Should be javadoc. Increments the ref count of a state? ########## File path: lucene/core/src/java/org/apache/lucene/util/automaton/StateSet.java ########## @@ -0,0 +1,106 @@ +/* + * 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. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.lucene.util.automaton; + +import java.util.Arrays; +import org.apache.lucene.util.hppc.BitMixer; +import org.apache.lucene.util.hppc.IntIntHashMap; + +/** A thin wrapper of {@link IntIntHashMap} */ +final class StateSet extends IntSet { + + private final IntIntHashMap inner; + private long hashCode; + private boolean hashUpdated = true; + private boolean arrayUpdated = true; + private int[] arrayCache = new int[0]; + + StateSet(int capacity) { + inner = new IntIntHashMap(capacity); + } + + // Adds this state to the set + void incr(int num) { + if (inner.addTo(num, 1) == 1) { + keyChanged(); + } + } + + // Removes this state from the set, if count decrs to 0 Review comment: Better with javadoc. -- 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 --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org