LUCENE-5675: small cleanups

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5675@1595052 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-05-15 21:25:41 +00:00
parent ee1c309e6f
commit 1ea0ce4062
3 changed files with 22 additions and 17 deletions

View File

@ -291,9 +291,6 @@ public class BlockTreeTermsReader extends FieldsProducer {
}
}
final Outputs<BytesRef> fstOutputs = ByteSequenceOutputs.getSingleton();
final BytesRef NO_OUTPUT = fstOutputs.getNoOutput();
@Override
public long ramBytesUsed() {
long sizeInByes = ((postingsReader!=null) ? postingsReader.ramBytesUsed() : 0);

View File

@ -32,11 +32,14 @@ import org.apache.lucene.util.RamUsageEstimator;
import org.apache.lucene.util.StringHelper;
import org.apache.lucene.util.automaton.CompiledAutomaton;
import org.apache.lucene.util.automaton.RunAutomaton;
import org.apache.lucene.util.fst.ByteSequenceOutputs;
import org.apache.lucene.util.fst.FST;
import org.apache.lucene.util.fst.Outputs;
// NOTE: cannot seek!
final class IntersectTermsEnum extends TermsEnum {
final IndexInput in;
final static Outputs<BytesRef> fstOutputs = ByteSequenceOutputs.getSingleton();
private IntersectTermsEnumFrame[] stack;
@ -169,14 +172,14 @@ final class IntersectTermsEnum extends TermsEnum {
// passed to findTargetArc
arc = fr.index.findTargetArc(target, arc, getArc(1+idx), fstReader);
assert arc != null;
output = fr.parent.fstOutputs.add(output, arc.output);
output = fstOutputs.add(output, arc.output);
idx++;
}
f.arc = arc;
f.outputPrefix = output;
assert arc.isFinal();
f.load(fr.parent.fstOutputs.add(output, arc.nextFinalOutput));
f.load(fstOutputs.add(output, arc.nextFinalOutput));
return f;
}

View File

@ -32,12 +32,17 @@ import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.RamUsageEstimator;
import org.apache.lucene.util.fst.ByteSequenceOutputs;
import org.apache.lucene.util.fst.FST;
import org.apache.lucene.util.fst.Outputs;
import org.apache.lucene.util.fst.Util;
/** Iterates through terms in this field */
final class SegmentTermsEnum extends TermsEnum {
final static Outputs<BytesRef> fstOutputs = ByteSequenceOutputs.getSingleton();
final static BytesRef NO_OUTPUT = fstOutputs.getNoOutput();
// Lazy init:
IndexInput in;
@ -361,8 +366,8 @@ final class SegmentTermsEnum extends TermsEnum {
//System.out.println("FAIL: arc.label=" + (char) arc.label + " targetLabel=" + (char) (target.bytes[target.offset + targetUpto] & 0xFF));
//}
assert arc.label == (target.bytes[target.offset + targetUpto] & 0xFF): "arc.label=" + (char) arc.label + " targetLabel=" + (char) (target.bytes[target.offset + targetUpto] & 0xFF);
if (arc.output != fr.parent.NO_OUTPUT) {
output = fr.parent.fstOutputs.add(output, arc.output);
if (arc.output != NO_OUTPUT) {
output = fstOutputs.add(output, arc.output);
}
if (arc.isFinal()) {
lastFrame = stack[1+lastFrame.ord];
@ -452,7 +457,7 @@ final class SegmentTermsEnum extends TermsEnum {
//term.length = 0;
targetUpto = 0;
currentFrame = pushFrame(arc, fr.parent.fstOutputs.add(output, arc.nextFinalOutput), 0);
currentFrame = pushFrame(arc, fstOutputs.add(output, arc.nextFinalOutput), 0);
}
// if (DEBUG) {
@ -507,8 +512,8 @@ final class SegmentTermsEnum extends TermsEnum {
term.bytes[targetUpto] = (byte) targetLabel;
// Aggregate output as we go:
assert arc.output != null;
if (arc.output != fr.parent.NO_OUTPUT) {
output = fr.parent.fstOutputs.add(output, arc.output);
if (arc.output != NO_OUTPUT) {
output = fstOutputs.add(output, arc.output);
}
// if (DEBUG) {
@ -518,7 +523,7 @@ final class SegmentTermsEnum extends TermsEnum {
if (arc.isFinal()) {
//if (DEBUG) System.out.println(" arc is final!");
currentFrame = pushFrame(arc, fr.parent.fstOutputs.add(output, arc.nextFinalOutput), targetUpto);
currentFrame = pushFrame(arc, fstOutputs.add(output, arc.nextFinalOutput), targetUpto);
//if (DEBUG) System.out.println(" curFrame.ord=" + currentFrame.ord + " hasTerms=" + currentFrame.hasTerms);
}
}
@ -623,8 +628,8 @@ final class SegmentTermsEnum extends TermsEnum {
// seek; but, often the FST doesn't have any
// shared bytes (but this could change if we
// reverse vLong byte order)
if (arc.output != fr.parent.NO_OUTPUT) {
output = fr.parent.fstOutputs.add(output, arc.output);
if (arc.output != NO_OUTPUT) {
output = fstOutputs.add(output, arc.output);
}
if (arc.isFinal()) {
lastFrame = stack[1+lastFrame.ord];
@ -709,7 +714,7 @@ final class SegmentTermsEnum extends TermsEnum {
//term.length = 0;
targetUpto = 0;
currentFrame = pushFrame(arc, fr.parent.fstOutputs.add(output, arc.nextFinalOutput), 0);
currentFrame = pushFrame(arc, fstOutputs.add(output, arc.nextFinalOutput), 0);
}
//if (DEBUG) {
@ -764,8 +769,8 @@ final class SegmentTermsEnum extends TermsEnum {
arc = nextArc;
// Aggregate output as we go:
assert arc.output != null;
if (arc.output != fr.parent.NO_OUTPUT) {
output = fr.parent.fstOutputs.add(output, arc.output);
if (arc.output != NO_OUTPUT) {
output = fstOutputs.add(output, arc.output);
}
//if (DEBUG) {
@ -775,7 +780,7 @@ final class SegmentTermsEnum extends TermsEnum {
if (arc.isFinal()) {
//if (DEBUG) System.out.println(" arc is final!");
currentFrame = pushFrame(arc, fr.parent.fstOutputs.add(output, arc.nextFinalOutput), targetUpto);
currentFrame = pushFrame(arc, fstOutputs.add(output, arc.nextFinalOutput), targetUpto);
//if (DEBUG) System.out.println(" curFrame.ord=" + currentFrame.ord + " hasTerms=" + currentFrame.hasTerms);
}
}