Index: lucene/src/java/org/apache/lucene/util/fst/Builder.java =================================================================== --- lucene/src/java/org/apache/lucene/util/fst/Builder.java (revision 1143420) +++ lucene/src/java/org/apache/lucene/util/fst/Builder.java (working copy) @@ -108,10 +108,9 @@ return dedupHash == null ? 0 : fst.nodeCount; } - private CompiledNode compileNode(UnCompiledNode n) throws IOException { - + private CompiledNode compileNode(UnCompiledNode n, int tailLength) throws IOException { final int address; - if (dedupHash != null) { + if (dedupHash != null && tailLength < 10) { if (n.numArcs == 0) { address = fst.addNode(n); } else { @@ -186,7 +185,7 @@ } else { if (minSuffixCount2 != 0) { - compileAllTargets(node); + compileAllTargets(node, lastInput.length-idx); } final T nextFinalOutput = node.output; @@ -202,7 +201,7 @@ // compile any targets that were previously // undecided: parent.replaceLast(lastInput.ints[lastInput.offset + idx-1], - compileNode(node), + compileNode(node, 1+lastInput.length-idx), nextFinalOutput, isFinal); } else { @@ -393,22 +392,23 @@ // empty string got pruned return null; } else { - fst.finish(compileNode(frontier[0]).address); + // nocommit + fst.finish(compileNode(frontier[0], 0).address); //System.out.println("compile addr = " + fst.getStartNode()); return fst; } } else { if (minSuffixCount2 != 0) { - compileAllTargets(frontier[0]); + compileAllTargets(frontier[0], 1); } //System.out.println("NOW: " + frontier[0].numArcs); - fst.finish(compileNode(frontier[0]).address); + fst.finish(compileNode(frontier[0], 0).address); } return fst; } - private void compileAllTargets(UnCompiledNode node) throws IOException { + private void compileAllTargets(UnCompiledNode node, int tailLength) throws IOException { for(int arcIdx=0;arcIdx arc = node.arcs[arcIdx]; if (!arc.target.isCompiled()) { @@ -418,7 +418,7 @@ //System.out.println("seg=" + segment + " FORCE final arc=" + (char) arc.label); arc.isFinal = n.isFinal = true; } - arc.target = compileNode(n); + arc.target = compileNode(n, tailLength-1); } } }