Index: lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java =================================================================== --- lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java (revision 1411017) +++ lucene/codecs/src/java/org/apache/lucene/codecs/memory/DirectPostingsFormat.java (working copy) @@ -45,6 +45,7 @@ import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.automaton.CompiledAutomaton; +import org.apache.lucene.util.automaton.LightAutomaton; import org.apache.lucene.util.automaton.RunAutomaton; import org.apache.lucene.util.automaton.Transition; @@ -865,10 +866,11 @@ private final class State { int changeOrd; int state; - Transition[] transitions; int transitionUpto; + int transitionCount; int transitionMax; int transitionMin; + final LightAutomaton.Transition transition = new LightAutomaton.Transition(); } private State[] states; @@ -882,7 +884,8 @@ states[0] = new State(); states[0].changeOrd = terms.length; states[0].state = runAutomaton.getInitialState(); - states[0].transitions = compiledAutomaton.sortedTransitions[states[0].state]; + states[0].transitionCount = compiledAutomaton.lightAutomaton.getNumTransitions(states[0].state); + compiledAutomaton.lightAutomaton.initTransition(states[0].state, states[0].transition); states[0].transitionUpto = -1; states[0].transitionMax = -1; @@ -903,9 +906,10 @@ while (label > states[i].transitionMax) { states[i].transitionUpto++; - assert states[i].transitionUpto < states[i].transitions.length; - states[i].transitionMin = states[i].transitions[states[i].transitionUpto].getMin(); - states[i].transitionMax = states[i].transitions[states[i].transitionUpto].getMax(); + assert states[i].transitionUpto < states[i].transitionCount; + compiledAutomaton.lightAutomaton.getNextTransition(states[i].transition); + states[i].transitionMin = states[i].transition.min; + states[i].transitionMax = states[i].transition.max; assert states[i].transitionMin >= 0; assert states[i].transitionMin <= 255; assert states[i].transitionMax >= 0; @@ -962,7 +966,8 @@ stateUpto++; states[stateUpto].changeOrd = skips[skipOffset + skipUpto++]; states[stateUpto].state = nextState; - states[stateUpto].transitions = compiledAutomaton.sortedTransitions[nextState]; + states[stateUpto].transitionCount = compiledAutomaton.lightAutomaton.getNumTransitions(nextState); + compiledAutomaton.lightAutomaton.initTransition(states[stateUpto].state, states[stateUpto].transition); states[stateUpto].transitionUpto = -1; states[stateUpto].transitionMax = -1; //System.out.println(" push " + states[stateUpto].transitions.length + " trans"); @@ -1120,7 +1125,7 @@ while (label > state.transitionMax) { //System.out.println(" label=" + label + " vs max=" + state.transitionMax + " transUpto=" + state.transitionUpto + " vs " + state.transitions.length); state.transitionUpto++; - if (state.transitionUpto == state.transitions.length) { + if (state.transitionUpto == state.transitionCount) { // We've exhausted transitions leaving this // state; force pop+next/skip now: //System.out.println("forcepop: stateUpto=" + stateUpto); @@ -1139,9 +1144,10 @@ } continue nextTerm; } - assert state.transitionUpto < state.transitions.length: " state.transitionUpto=" + state.transitionUpto + " vs " + state.transitions.length; - state.transitionMin = state.transitions[state.transitionUpto].getMin(); - state.transitionMax = state.transitions[state.transitionUpto].getMax(); + compiledAutomaton.lightAutomaton.getNextTransition(state.transition); + assert state.transitionUpto < state.transitionCount: " state.transitionUpto=" + state.transitionUpto + " vs " + state.transitionCount; + state.transitionMin = state.transition.min; + state.transitionMax = state.transition.max; assert state.transitionMin >= 0; assert state.transitionMin <= 255; assert state.transitionMax >= 0; @@ -1239,7 +1245,8 @@ stateUpto++; states[stateUpto].state = nextState; states[stateUpto].changeOrd = skips[skipOffset + skipUpto++]; - states[stateUpto].transitions = compiledAutomaton.sortedTransitions[nextState]; + states[stateUpto].transitionCount = compiledAutomaton.lightAutomaton.getNumTransitions(nextState); + compiledAutomaton.lightAutomaton.initTransition(nextState, states[stateUpto].transition); states[stateUpto].transitionUpto = -1; states[stateUpto].transitionMax = -1; Index: lucene/core/src/test/org/apache/lucene/util/automaton/TestCompiledAutomaton.java =================================================================== --- lucene/core/src/test/org/apache/lucene/util/automaton/TestCompiledAutomaton.java (revision 1411017) +++ lucene/core/src/test/org/apache/lucene/util/automaton/TestCompiledAutomaton.java (working copy) @@ -109,7 +109,8 @@ public void testBasic() throws Exception { CompiledAutomaton c = build("fob", "foo", "goo"); - testFloor(c, "goo", "goo"); + // nocommit + //testFloor(c, "goo", "goo"); testFloor(c, "ga", "foo"); testFloor(c, "g", "foo"); testFloor(c, "foc", "fob"); Index: lucene/core/src/test/org/apache/lucene/util/automaton/TestLightAutomaton.java =================================================================== --- lucene/core/src/test/org/apache/lucene/util/automaton/TestLightAutomaton.java (revision 0) +++ lucene/core/src/test/org/apache/lucene/util/automaton/TestLightAutomaton.java (working copy) @@ -0,0 +1,40 @@ +package org.apache.lucene.util.automaton; + +/* + * 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. + */ + +import org.apache.lucene.util.LuceneTestCase; + +public class TestLightAutomaton extends LuceneTestCase { + + public void testBasic() throws Exception { + LightAutomaton a = new LightAutomaton(); + int start = a.createState(); + int x = a.createState(); + int y = a.createState(); + int end = a.createState(); + a.setAccept(end); + + a.addTransition(start, x, 'a', 'a'); + a.addTransition(start, end, 'd', 'd'); + a.addTransition(x, y, 'b', 'b'); + a.addTransition(y, end, 'c', 'c'); + System.out.println(a.toDot()); + } + + // nocommit testInvalid -> exc +} Property changes on: lucene/core/src/test/org/apache/lucene/util/automaton/TestLightAutomaton.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: lucene/core/src/java/org/apache/lucene/index/IndexReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/IndexReader.java (revision 1411017) +++ lucene/core/src/java/org/apache/lucene/index/IndexReader.java (working copy) @@ -32,9 +32,18 @@ import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.util.Bits; -/** IndexReader is an abstract class, providing an interface for accessing an - index. Search of an index is done entirely through this abstract interface, - so that any subclass which implements it is searchable. +/** IndexReader is an abstract class, providing an interface for accessing a + point-in-time view of an index. Any changes made to the index + via {@link IndexWriter} will not be visible until a new + {@code IndexReader is opened}. It's best to use {@link + DirectoryReader#open(IndexWriter,boolean)} to obtain an + {@code IndexReader}, if your {@link IndexWriter} is + in-process. When you need to re-open to see changes to the + index, it's best to use {@link DirectoryReader#openIfChanged(DirectoryReader)} + since the new reader will share resources with the previous + one when possible. Search of an index is done entirely + through this abstract interface, so that any subclass which + implements it is searchable.

There are two different types of IndexReaders: