mirror of https://github.com/apache/lucene.git
Avoid object construction when linear searching arcs (#12692)
This commit is contained in:
parent
6fde1db228
commit
343a9e7100
|
@ -746,7 +746,7 @@ public final class FST<T> implements Accountable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Arc<T> readFirstRealTargetArc(long nodeAddress, Arc<T> arc, final BytesReader in)
|
private void readFirstArcInfo(long nodeAddress, Arc<T> arc, final BytesReader in)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
in.setPosition(nodeAddress);
|
in.setPosition(nodeAddress);
|
||||||
// System.out.println(" flags=" + arc.flags);
|
// System.out.println(" flags=" + arc.flags);
|
||||||
|
@ -770,7 +770,11 @@ public final class FST<T> implements Accountable {
|
||||||
arc.nextArc = nodeAddress;
|
arc.nextArc = nodeAddress;
|
||||||
arc.bytesPerArc = 0;
|
arc.bytesPerArc = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Arc<T> readFirstRealTargetArc(long nodeAddress, Arc<T> arc, final BytesReader in)
|
||||||
|
throws IOException {
|
||||||
|
readFirstArcInfo(nodeAddress, arc, in);
|
||||||
return readNextRealArc(arc, in);
|
return readNextRealArc(arc, in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1081,22 +1085,30 @@ public final class FST<T> implements Accountable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Linear scan
|
// Linear scan
|
||||||
readFirstRealTargetArc(follow.target(), arc, in);
|
readFirstArcInfo(follow.target(), arc, in);
|
||||||
|
in.setPosition(arc.nextArc());
|
||||||
while (true) {
|
while (true) {
|
||||||
// System.out.println(" non-bs cycle");
|
assert arc.bytesPerArc() == 0;
|
||||||
// TODO: we should fix this code to not have to create
|
flags = arc.flags = in.readByte();
|
||||||
// object for the output of every arc we scan... only
|
long pos = in.getPosition();
|
||||||
// for the matching arc, if found
|
int label = readLabel(in);
|
||||||
if (arc.label() == labelToMatch) {
|
if (label == labelToMatch) {
|
||||||
// System.out.println(" found!");
|
in.setPosition(pos);
|
||||||
return arc;
|
return readArc(arc, in);
|
||||||
} else if (arc.label() > labelToMatch) {
|
} else if (label > labelToMatch) {
|
||||||
return null;
|
return null;
|
||||||
} else if (arc.isLast()) {
|
} else if (arc.isLast()) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
readNextRealArc(arc, in);
|
if (flag(flags, BIT_ARC_HAS_OUTPUT)) {
|
||||||
|
outputs.skipOutput(in);
|
||||||
|
}
|
||||||
|
if (flag(flags, BIT_ARC_HAS_FINAL_OUTPUT)) {
|
||||||
|
outputs.skipFinalOutput(in);
|
||||||
|
}
|
||||||
|
if (flag(flags, BIT_STOP_NODE) == false && flag(flags, BIT_TARGET_NEXT) == false) {
|
||||||
|
readUnpackedNodeTarget(in);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1116,7 +1128,7 @@ public final class FST<T> implements Accountable {
|
||||||
outputs.skipFinalOutput(in);
|
outputs.skipFinalOutput(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!flag(flags, BIT_STOP_NODE) && !flag(flags, BIT_TARGET_NEXT)) {
|
if (flag(flags, BIT_STOP_NODE) == false && flag(flags, BIT_TARGET_NEXT) == false) {
|
||||||
readUnpackedNodeTarget(in);
|
readUnpackedNodeTarget(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue