mirror of https://github.com/apache/lucene.git
LUCENE-5960: move CHANGES entry under 5.0
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1625998 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f74d55d5b3
commit
0bf7d74eac
|
@ -186,6 +186,11 @@ Tests
|
||||||
* LUCENE-5957: Add option for tests to not randomize codec
|
* LUCENE-5957: Add option for tests to not randomize codec
|
||||||
(Ryan Ernst)
|
(Ryan Ernst)
|
||||||
|
|
||||||
|
Optimizations
|
||||||
|
|
||||||
|
* LUCENE-5960: Use a more efficient bitset, not a Set<Integer>, to
|
||||||
|
track visited states. (Markus Heiden via Mike McCandless)
|
||||||
|
|
||||||
Build
|
Build
|
||||||
|
|
||||||
* LUCENE-5909: Smoke tester now has better command line parsing and
|
* LUCENE-5909: Smoke tester now has better command line parsing and
|
||||||
|
@ -327,9 +332,6 @@ Optimizations
|
||||||
Always use MethodHandles to create AttributeImpl classes.
|
Always use MethodHandles to create AttributeImpl classes.
|
||||||
(Uwe Schindler)
|
(Uwe Schindler)
|
||||||
|
|
||||||
* LUCENE-5960: Use a more efficient bitset, not a Set<Integer>, to
|
|
||||||
track visited states. (Markus Heiden via Mike McCandless)
|
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
|
|
||||||
* LUCENE-5796: Fixes the Scorer.getChildren() method for two combinations
|
* LUCENE-5796: Fixes the Scorer.getChildren() method for two combinations
|
||||||
|
|
|
@ -67,18 +67,34 @@ public class Automaton {
|
||||||
* leaving transitions are stored, or -1 if this state
|
* leaving transitions are stored, or -1 if this state
|
||||||
* has not added any transitions yet, followed by number
|
* has not added any transitions yet, followed by number
|
||||||
* of transitions. */
|
* of transitions. */
|
||||||
private int[] states = new int[4];
|
private int[] states;
|
||||||
|
|
||||||
|
private final BitSet isAccept;
|
||||||
|
|
||||||
/** Holds toState, min, max for each transition. */
|
/** Holds toState, min, max for each transition. */
|
||||||
private int[] transitions = new int[6];
|
private int[] transitions;
|
||||||
|
|
||||||
private final BitSet isAccept = new BitSet(4);
|
|
||||||
|
|
||||||
/** True if no state has two transitions leaving with the same label. */
|
/** True if no state has two transitions leaving with the same label. */
|
||||||
private boolean deterministic = true;
|
private boolean deterministic = true;
|
||||||
|
|
||||||
/** Sole constructor; creates an automaton with no states. */
|
/** Sole constructor; creates an automaton with no states. */
|
||||||
public Automaton() {
|
public Automaton() {
|
||||||
|
this(2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor which creates an automaton with enough space for the given
|
||||||
|
* number of states and transitions.
|
||||||
|
*
|
||||||
|
* @param numStates
|
||||||
|
* Number of states.
|
||||||
|
* @param numTransitions
|
||||||
|
* Number of transitions.
|
||||||
|
*/
|
||||||
|
public Automaton(int numStates, int numTransitions) {
|
||||||
|
states = new int[numStates * 2];
|
||||||
|
isAccept = new BitSet(numStates);
|
||||||
|
transitions = new int[numTransitions * 3];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a new state. */
|
/** Create a new state. */
|
||||||
|
@ -620,12 +636,28 @@ public class Automaton {
|
||||||
* it's too restrictive to have to add all transitions
|
* it's too restrictive to have to add all transitions
|
||||||
* leaving each state at once. */
|
* leaving each state at once. */
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private int[] transitions = new int[4];
|
private int nextState = 0;
|
||||||
private int nextTransition;
|
private final BitSet isAccept;
|
||||||
private final Automaton a = new Automaton();
|
private int[] transitions;
|
||||||
|
private int nextTransition = 0;
|
||||||
|
|
||||||
/** Sole constructor. */
|
/** Default constructor, pre-allocating for 16 states and transitions. */
|
||||||
public Builder() {
|
public Builder() {
|
||||||
|
this(16, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor which creates a builder with enough space for the given
|
||||||
|
* number of states and transitions.
|
||||||
|
*
|
||||||
|
* @param numStates
|
||||||
|
* Number of states.
|
||||||
|
* @param numTransitions
|
||||||
|
* Number of transitions.
|
||||||
|
*/
|
||||||
|
public Builder(int numStates, int numTransitions) {
|
||||||
|
isAccept = new BitSet(numStates);
|
||||||
|
transitions = new int[numTransitions * 4];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add a new transition with min = max = label. */
|
/** Add a new transition with min = max = label. */
|
||||||
|
@ -712,43 +744,53 @@ public class Automaton {
|
||||||
/** Compiles all added states and transitions into a new {@code Automaton}
|
/** Compiles all added states and transitions into a new {@code Automaton}
|
||||||
* and returns it. */
|
* and returns it. */
|
||||||
public Automaton finish() {
|
public Automaton finish() {
|
||||||
//System.out.println("LA.Builder.finish: count=" + (nextTransition/4));
|
// Create automaton with the correct size.
|
||||||
// TODO: we could make this more efficient,
|
int numStates = nextState;
|
||||||
// e.g. somehow xfer the int[] to the automaton, or
|
int numTransitions = nextTransition / 4;
|
||||||
// alloc exactly the right size from the automaton
|
Automaton a = new Automaton(numStates, numTransitions);
|
||||||
//System.out.println("finish pending");
|
|
||||||
sorter.sort(0, nextTransition/4);
|
// Create all states.
|
||||||
int upto = 0;
|
for (int state = 0; state < numStates; state++) {
|
||||||
while (upto < nextTransition) {
|
a.createState();
|
||||||
|
a.setAccept(state, isAccept(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create all transitions
|
||||||
|
sorter.sort(0, numTransitions);
|
||||||
|
for (int upto = 0; upto < nextTransition; upto += 4) {
|
||||||
a.addTransition(transitions[upto],
|
a.addTransition(transitions[upto],
|
||||||
transitions[upto+1],
|
transitions[upto+1],
|
||||||
transitions[upto+2],
|
transitions[upto+2],
|
||||||
transitions[upto+3]);
|
transitions[upto+3]);
|
||||||
upto += 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a.finishState();
|
a.finishState();
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a new state. */
|
/** Create a new state. */
|
||||||
public int createState() {
|
public int createState() {
|
||||||
return a.createState();
|
return nextState++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set or clear this state as an accept state. */
|
/** Set or clear this state as an accept state. */
|
||||||
public void setAccept(int state, boolean accept) {
|
public void setAccept(int state, boolean accept) {
|
||||||
a.setAccept(state, accept);
|
if (state >= getNumStates()) {
|
||||||
|
throw new IllegalArgumentException("state=" + state + " is out of bounds (numStates=" + getNumStates() + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isAccept.set(state, accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if this state is an accept state. */
|
/** Returns true if this state is an accept state. */
|
||||||
public boolean isAccept(int state) {
|
public boolean isAccept(int state) {
|
||||||
return a.isAccept(state);
|
return this.isAccept.get(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** How many states this automaton has. */
|
/** How many states this automaton has. */
|
||||||
public int getNumStates() {
|
public int getNumStates() {
|
||||||
return a.getNumStates();
|
return nextState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copies over all states/transitions from other. */
|
/** Copies over all states/transitions from other. */
|
||||||
|
|
Loading…
Reference in New Issue