mirror of
https://github.com/apache/lucene.git
synced 2025-03-06 08:19:23 +00:00
Rename prefix to prefixLength, suffix to suffixLength. (#13629)
This commit is contained in:
parent
1ce1156de4
commit
cb8bc75750
@ -277,10 +277,10 @@ final class SegmentTermsEnum extends BaseTermsEnum {
|
||||
// System.out.println(" skip rewind!");
|
||||
// }
|
||||
}
|
||||
assert length == f.prefix;
|
||||
assert length == f.prefixLength;
|
||||
} else {
|
||||
f.nextEnt = -1;
|
||||
f.prefix = length;
|
||||
f.prefixLength = length;
|
||||
f.state.termBlockOrd = 0;
|
||||
f.fpOrig = f.fp = fp;
|
||||
f.lastSubFP = -1;
|
||||
@ -488,7 +488,7 @@ final class SegmentTermsEnum extends BaseTermsEnum {
|
||||
// toHex(targetLabel));
|
||||
// }
|
||||
|
||||
validIndexPrefix = currentFrame.prefix;
|
||||
validIndexPrefix = currentFrame.prefixLength;
|
||||
// validIndexPrefix = targetUpto;
|
||||
|
||||
currentFrame.scanToFloorFrame(target);
|
||||
@ -550,7 +550,7 @@ final class SegmentTermsEnum extends BaseTermsEnum {
|
||||
}
|
||||
|
||||
// validIndexPrefix = targetUpto;
|
||||
validIndexPrefix = currentFrame.prefix;
|
||||
validIndexPrefix = currentFrame.prefixLength;
|
||||
|
||||
currentFrame.scanToFloorFrame(target);
|
||||
|
||||
@ -772,7 +772,7 @@ final class SegmentTermsEnum extends BaseTermsEnum {
|
||||
// targetLabel);
|
||||
// }
|
||||
|
||||
validIndexPrefix = currentFrame.prefix;
|
||||
validIndexPrefix = currentFrame.prefixLength;
|
||||
// validIndexPrefix = targetUpto;
|
||||
|
||||
currentFrame.scanToFloorFrame(target);
|
||||
@ -830,7 +830,7 @@ final class SegmentTermsEnum extends BaseTermsEnum {
|
||||
}
|
||||
|
||||
// validIndexPrefix = targetUpto;
|
||||
validIndexPrefix = currentFrame.prefix;
|
||||
validIndexPrefix = currentFrame.prefixLength;
|
||||
|
||||
currentFrame.scanToFloorFrame(target);
|
||||
|
||||
@ -868,7 +868,7 @@ final class SegmentTermsEnum extends BaseTermsEnum {
|
||||
while (true) {
|
||||
SegmentTermsEnumFrame f = getFrame(ord);
|
||||
assert f != null;
|
||||
final BytesRef prefix = new BytesRef(term.get().bytes, 0, f.prefix);
|
||||
final BytesRef prefix = new BytesRef(term.get().bytes, 0, f.prefixLength);
|
||||
if (f.nextEnt == -1) {
|
||||
out.println(
|
||||
" frame "
|
||||
@ -879,7 +879,7 @@ final class SegmentTermsEnum extends BaseTermsEnum {
|
||||
+ f.fp
|
||||
+ (f.isFloor ? (" (fpOrig=" + f.fpOrig + ")") : "")
|
||||
+ " prefixLen="
|
||||
+ f.prefix
|
||||
+ f.prefixLength
|
||||
+ " prefix="
|
||||
+ prefix
|
||||
+ (f.nextEnt == -1 ? "" : (" (of " + f.entCount + ")"))
|
||||
@ -907,7 +907,7 @@ final class SegmentTermsEnum extends BaseTermsEnum {
|
||||
+ f.fp
|
||||
+ (f.isFloor ? (" (fpOrig=" + f.fpOrig + ")") : "")
|
||||
+ " prefixLen="
|
||||
+ f.prefix
|
||||
+ f.prefixLength
|
||||
+ " prefix="
|
||||
+ prefix
|
||||
+ " nextEnt="
|
||||
@ -932,12 +932,14 @@ final class SegmentTermsEnum extends BaseTermsEnum {
|
||||
}
|
||||
if (fr.index != null) {
|
||||
assert !isSeekFrame || f.arc != null : "isSeekFrame=" + isSeekFrame + " f.arc=" + f.arc;
|
||||
if (f.prefix > 0 && isSeekFrame && f.arc.label() != (term.byteAt(f.prefix - 1) & 0xFF)) {
|
||||
if (f.prefixLength > 0
|
||||
&& isSeekFrame
|
||||
&& f.arc.label() != (term.byteAt(f.prefixLength - 1) & 0xFF)) {
|
||||
out.println(
|
||||
" broken seek state: arc.label="
|
||||
+ (char) f.arc.label()
|
||||
+ " vs term byte="
|
||||
+ (char) (term.byteAt(f.prefix - 1) & 0xFF));
|
||||
+ (char) (term.byteAt(f.prefixLength - 1) & 0xFF));
|
||||
throw new RuntimeException("seek state is broken");
|
||||
}
|
||||
BytesRef output = Util.get(fr.index, prefix);
|
||||
@ -965,7 +967,7 @@ final class SegmentTermsEnum extends BaseTermsEnum {
|
||||
if (f == currentFrame) {
|
||||
break;
|
||||
}
|
||||
if (f.prefix == validIndexPrefix) {
|
||||
if (f.prefixLength == validIndexPrefix) {
|
||||
isSeekFrame = false;
|
||||
}
|
||||
ord++;
|
||||
@ -1046,7 +1048,7 @@ final class SegmentTermsEnum extends BaseTermsEnum {
|
||||
|
||||
// Note that the seek state (last seek) has been
|
||||
// invalidated beyond this depth
|
||||
validIndexPrefix = Math.min(validIndexPrefix, currentFrame.prefix);
|
||||
validIndexPrefix = Math.min(validIndexPrefix, currentFrame.prefixLength);
|
||||
// if (DEBUG) {
|
||||
// System.out.println(" reset validIndexPrefix=" + validIndexPrefix);
|
||||
// }
|
||||
|
@ -59,7 +59,7 @@ final class SegmentTermsEnumFrame {
|
||||
final ByteArrayDataInput floorDataReader = new ByteArrayDataInput();
|
||||
|
||||
// Length of prefix shared by all terms in this block
|
||||
int prefix;
|
||||
int prefixLength;
|
||||
|
||||
// Number of entries (term or sub-block) in this block
|
||||
int entCount;
|
||||
@ -318,11 +318,11 @@ final class SegmentTermsEnumFrame {
|
||||
assert nextEnt != -1 && nextEnt < entCount
|
||||
: "nextEnt=" + nextEnt + " entCount=" + entCount + " fp=" + fp;
|
||||
nextEnt++;
|
||||
suffix = suffixLengthsReader.readVInt();
|
||||
suffixLength = suffixLengthsReader.readVInt();
|
||||
startBytePos = suffixesReader.getPosition();
|
||||
ste.term.setLength(prefix + suffix);
|
||||
ste.term.setLength(prefixLength + suffixLength);
|
||||
ste.term.grow(ste.term.length());
|
||||
suffixesReader.readBytes(ste.term.bytes(), prefix, suffix);
|
||||
suffixesReader.readBytes(ste.term.bytes(), prefixLength, suffixLength);
|
||||
ste.termExists = true;
|
||||
}
|
||||
|
||||
@ -346,11 +346,11 @@ final class SegmentTermsEnumFrame {
|
||||
: "nextEnt=" + nextEnt + " entCount=" + entCount + " fp=" + fp;
|
||||
nextEnt++;
|
||||
final int code = suffixLengthsReader.readVInt();
|
||||
suffix = code >>> 1;
|
||||
suffixLength = code >>> 1;
|
||||
startBytePos = suffixesReader.getPosition();
|
||||
ste.term.setLength(prefix + suffix);
|
||||
ste.term.setLength(prefixLength + suffixLength);
|
||||
ste.term.grow(ste.term.length());
|
||||
suffixesReader.readBytes(ste.term.bytes(), prefix, suffix);
|
||||
suffixesReader.readBytes(ste.term.bytes(), prefixLength, suffixLength);
|
||||
if ((code & 1) == 0) {
|
||||
// A normal term
|
||||
ste.termExists = true;
|
||||
@ -375,7 +375,7 @@ final class SegmentTermsEnumFrame {
|
||||
// floor blocks we "typically" get
|
||||
public void scanToFloorFrame(BytesRef target) {
|
||||
|
||||
if (!isFloor || target.length <= prefix) {
|
||||
if (!isFloor || target.length <= prefixLength) {
|
||||
// if (DEBUG) {
|
||||
// System.out.println(" scanToFloorFrame skip: isFloor=" + isFloor + " target.length=" +
|
||||
// target.length + " vs prefix=" + prefix);
|
||||
@ -383,7 +383,7 @@ final class SegmentTermsEnumFrame {
|
||||
return;
|
||||
}
|
||||
|
||||
final int targetLabel = target.bytes[target.offset + prefix] & 0xFF;
|
||||
final int targetLabel = target.bytes[target.offset + prefixLength] & 0xFF;
|
||||
|
||||
// if (DEBUG) {
|
||||
// System.out.println(" scanToFloorFrame fpOrig=" + fpOrig + " targetLabel=" +
|
||||
@ -497,7 +497,7 @@ final class SegmentTermsEnumFrame {
|
||||
|
||||
// Used only by assert
|
||||
private boolean prefixMatches(BytesRef target) {
|
||||
for (int bytePos = 0; bytePos < prefix; bytePos++) {
|
||||
for (int bytePos = 0; bytePos < prefixLength; bytePos++) {
|
||||
if (target.bytes[target.offset + bytePos] != ste.term.byteAt(bytePos)) {
|
||||
return false;
|
||||
}
|
||||
@ -553,7 +553,7 @@ final class SegmentTermsEnumFrame {
|
||||
}
|
||||
|
||||
private int startBytePos;
|
||||
private int suffix;
|
||||
private int suffixLength;
|
||||
private long subCode;
|
||||
CompressionAlgorithm compressionAlg = CompressionAlgorithm.NO_COMPRESSION;
|
||||
|
||||
@ -584,7 +584,7 @@ final class SegmentTermsEnumFrame {
|
||||
do {
|
||||
nextEnt++;
|
||||
|
||||
suffix = suffixLengthsReader.readVInt();
|
||||
suffixLength = suffixLengthsReader.readVInt();
|
||||
|
||||
// if (DEBUG) {
|
||||
// BytesRef suffixBytesRef = new BytesRef();
|
||||
@ -596,16 +596,16 @@ final class SegmentTermsEnumFrame {
|
||||
// }
|
||||
|
||||
startBytePos = suffixesReader.getPosition();
|
||||
suffixesReader.skipBytes(suffix);
|
||||
suffixesReader.skipBytes(suffixLength);
|
||||
|
||||
// Loop over bytes in the suffix, comparing to the target
|
||||
final int cmp =
|
||||
Arrays.compareUnsigned(
|
||||
suffixBytes,
|
||||
startBytePos,
|
||||
startBytePos + suffix,
|
||||
startBytePos + suffixLength,
|
||||
target.bytes,
|
||||
target.offset + prefix,
|
||||
target.offset + prefixLength,
|
||||
target.offset + target.length);
|
||||
|
||||
if (cmp < 0) {
|
||||
@ -674,7 +674,7 @@ final class SegmentTermsEnumFrame {
|
||||
|
||||
assert prefixMatches(target);
|
||||
|
||||
suffix = suffixLengthsReader.readVInt();
|
||||
suffixLength = suffixLengthsReader.readVInt();
|
||||
// TODO early terminate when target length unequals suffix + prefix.
|
||||
// But we need to keep the same status with scanToTermLeaf.
|
||||
int start = nextEnt;
|
||||
@ -684,16 +684,16 @@ final class SegmentTermsEnumFrame {
|
||||
while (start <= end) {
|
||||
int mid = (start + end) >>> 1;
|
||||
nextEnt = mid + 1;
|
||||
startBytePos = mid * suffix;
|
||||
startBytePos = mid * suffixLength;
|
||||
|
||||
// Binary search bytes in the suffix, comparing to the target.
|
||||
cmp =
|
||||
Arrays.compareUnsigned(
|
||||
suffixBytes,
|
||||
startBytePos,
|
||||
startBytePos + suffix,
|
||||
startBytePos + suffixLength,
|
||||
target.bytes,
|
||||
target.offset + prefix,
|
||||
target.offset + prefixLength,
|
||||
target.offset + target.length);
|
||||
if (cmp < 0) {
|
||||
start = mid + 1;
|
||||
@ -701,7 +701,7 @@ final class SegmentTermsEnumFrame {
|
||||
end = mid - 1;
|
||||
} else {
|
||||
// Exact match!
|
||||
suffixesReader.setPosition(startBytePos + suffix);
|
||||
suffixesReader.setPosition(startBytePos + suffixLength);
|
||||
fillTerm();
|
||||
// if (DEBUG) System.out.println(" found!");
|
||||
return SeekStatus.FOUND;
|
||||
@ -724,14 +724,14 @@ final class SegmentTermsEnumFrame {
|
||||
// If binary search ended at the less term, and greater term exists.
|
||||
// We need to advance to the greater term.
|
||||
if (cmp < 0) {
|
||||
startBytePos += suffix;
|
||||
startBytePos += suffixLength;
|
||||
nextEnt++;
|
||||
}
|
||||
suffixesReader.setPosition(startBytePos + suffix);
|
||||
suffixesReader.setPosition(startBytePos + suffixLength);
|
||||
fillTerm();
|
||||
} else {
|
||||
seekStatus = SeekStatus.END;
|
||||
suffixesReader.setPosition(startBytePos + suffix);
|
||||
suffixesReader.setPosition(startBytePos + suffixLength);
|
||||
if (exactOnly) {
|
||||
fillTerm();
|
||||
}
|
||||
@ -769,7 +769,7 @@ final class SegmentTermsEnumFrame {
|
||||
nextEnt++;
|
||||
|
||||
final int code = suffixLengthsReader.readVInt();
|
||||
suffix = code >>> 1;
|
||||
suffixLength = code >>> 1;
|
||||
|
||||
// if (DEBUG) {
|
||||
// BytesRef suffixBytesRef = new BytesRef();
|
||||
@ -782,7 +782,7 @@ final class SegmentTermsEnumFrame {
|
||||
// }
|
||||
|
||||
startBytePos = suffixesReader.getPosition();
|
||||
suffixesReader.skipBytes(suffix);
|
||||
suffixesReader.skipBytes(suffixLength);
|
||||
ste.termExists = (code & 1) == 0;
|
||||
if (ste.termExists) {
|
||||
state.termBlockOrd++;
|
||||
@ -796,9 +796,9 @@ final class SegmentTermsEnumFrame {
|
||||
Arrays.compareUnsigned(
|
||||
suffixBytes,
|
||||
startBytePos,
|
||||
startBytePos + suffix,
|
||||
startBytePos + suffixLength,
|
||||
target.bytes,
|
||||
target.offset + prefix,
|
||||
target.offset + prefixLength,
|
||||
target.offset + target.length);
|
||||
|
||||
if (cmp < 0) {
|
||||
@ -819,7 +819,8 @@ final class SegmentTermsEnumFrame {
|
||||
// us to position to the next term after
|
||||
// the target, so we must recurse into the
|
||||
// sub-frame(s):
|
||||
ste.currentFrame = ste.pushFrame(null, ste.currentFrame.lastSubFP, prefix + suffix);
|
||||
ste.currentFrame =
|
||||
ste.pushFrame(null, ste.currentFrame.lastSubFP, prefixLength + suffixLength);
|
||||
ste.currentFrame.loadBlock();
|
||||
while (ste.currentFrame.next()) {
|
||||
ste.currentFrame = ste.pushFrame(null, ste.currentFrame.lastSubFP, ste.term.length());
|
||||
@ -864,9 +865,9 @@ final class SegmentTermsEnumFrame {
|
||||
}
|
||||
|
||||
private void fillTerm() {
|
||||
final int termLength = prefix + suffix;
|
||||
final int termLength = prefixLength + suffixLength;
|
||||
ste.term.setLength(termLength);
|
||||
ste.term.grow(termLength);
|
||||
System.arraycopy(suffixBytes, startBytePos, ste.term.bytes(), prefix, suffix);
|
||||
System.arraycopy(suffixBytes, startBytePos, ste.term.bytes(), prefixLength, suffixLength);
|
||||
}
|
||||
}
|
||||
|
@ -116,10 +116,10 @@ public class Stats {
|
||||
nonFloorBlockCount++;
|
||||
}
|
||||
|
||||
if (blockCountByPrefixLen.length <= frame.prefix) {
|
||||
blockCountByPrefixLen = ArrayUtil.grow(blockCountByPrefixLen, 1 + frame.prefix);
|
||||
if (blockCountByPrefixLen.length <= frame.prefixLength) {
|
||||
blockCountByPrefixLen = ArrayUtil.grow(blockCountByPrefixLen, 1 + frame.prefixLength);
|
||||
}
|
||||
blockCountByPrefixLen[frame.prefix]++;
|
||||
blockCountByPrefixLen[frame.prefixLength]++;
|
||||
startBlockCount++;
|
||||
totalBlockSuffixBytes += frame.totalSuffixBytes;
|
||||
totalUncompressedBlockSuffixBytes += frame.suffixesReader.length();
|
||||
|
Loading…
x
Reference in New Issue
Block a user