Skip to content

Apache Lucene open-source search software

LUCENE-5675: small cleanups

Michael McCandless1ea0ce40626e
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java
index 2fcb38c25c5..5d02490bf99 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/blocktree/BlockTreeTermsReader.java
@@ -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);
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/blocktree/IntersectTermsEnum.java b/lucene/core/src/java/org/apache/lucene/codecs/blocktree/IntersectTermsEnum.java
index d5e93456632..e910ed0db67 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/blocktree/IntersectTermsEnum.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/blocktree/IntersectTermsEnum.java
@@ -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;
}
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/blocktree/SegmentTermsEnum.java b/lucene/core/src/java/org/apache/lucene/codecs/blocktree/SegmentTermsEnum.java
index 839991f0754..5717ac70eaf 100644
--- a/lucene/core/src/java/org/apache/lucene/codecs/blocktree/SegmentTermsEnum.java
+++ b/lucene/core/src/java/org/apache/lucene/codecs/blocktree/SegmentTermsEnum.java
@@ -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);
}
}