| Index: lucene/src/test/org/apache/lucene/util/automaton/fst/TestFSTs.java |
| =================================================================== |
| --- lucene/src/test/org/apache/lucene/util/automaton/fst/TestFSTs.java (revision 1104452) |
| +++ lucene/src/test/org/apache/lucene/util/automaton/fst/TestFSTs.java (working copy) |
| @@ -540,7 +540,7 @@ |
| Object output = run(fst, term, null); |
| |
| assertNotNull("term " + inputToString(inputMode, term) + " is not accepted", output); |
| - assertEquals(output, pair.output); |
| + assertEquals(pair.output, output); |
| |
| // verify enum's next |
| IntsRefFSTEnum.InputOutput<T> t = fstEnum.next(); |
| Index: lucene/src/java/org/apache/lucene/index/codecs/VariableGapTermsIndexWriter.java |
| =================================================================== |
| --- lucene/src/java/org/apache/lucene/index/codecs/VariableGapTermsIndexWriter.java (revision 1104452) |
| +++ lucene/src/java/org/apache/lucene/index/codecs/VariableGapTermsIndexWriter.java (working copy) |
| @@ -200,6 +200,7 @@ |
| private class FSTFieldWriter extends FieldWriter { |
| private final Builder<Long> fstBuilder; |
| private final PositiveIntOutputs fstOutputs; |
| + private final long startTermsFilePointer; |
| |
| final FieldInfo fieldInfo; |
| int numIndexTerms; |
| @@ -220,6 +221,7 @@ |
| |
| // Always put empty string in |
| fstBuilder.add(new BytesRef(), fstOutputs.get(termsFilePointer)); |
| + startTermsFilePointer = termsFilePointer; |
| } |
| |
| @Override |
| @@ -239,6 +241,11 @@ |
| |
| @Override |
| public void add(BytesRef text, TermStats stats, long termsFilePointer) throws IOException { |
| + if (text.length == 0) { |
| + // We already added empty string in ctor |
| + assert termsFilePointer == startTermsFilePointer; |
| + return; |
| + } |
| final int lengthSave = text.length; |
| text.length = indexedTermPrefixLength(lastTerm, text); |
| try { |
| Index: lucene/src/java/org/apache/lucene/util/automaton/fst/FST.java |
| =================================================================== |
| --- lucene/src/java/org/apache/lucene/util/automaton/fst/FST.java (revision 1104452) |
| +++ lucene/src/java/org/apache/lucene/util/automaton/fst/FST.java (working copy) |
| @@ -232,9 +232,7 @@ |
| |
| void setEmptyOutput(T v) throws IOException { |
| if (emptyOutput != null) { |
| - if (!emptyOutput.equals(v)) { |
| - emptyOutput = outputs.merge(emptyOutput, v); |
| - } |
| + emptyOutput = outputs.merge(emptyOutput, v); |
| } else { |
| emptyOutput = v; |
| } |