mirror of https://github.com/apache/lucene.git
fix bugs in DirectPF's lowFreq d-and-p-enum, set payload.bytes/offset/length in getPayload, also skip payload pointer correctly when scanning over deleted docs in nextDoc
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1364070 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
24092aab4c
commit
f55c8d1247
|
@ -1680,8 +1680,10 @@ public class DirectPostingsFormat extends PostingsFormat {
|
||||||
private int skipPositions;
|
private int skipPositions;
|
||||||
private int startOffset;
|
private int startOffset;
|
||||||
private int endOffset;
|
private int endOffset;
|
||||||
|
private int lastPayloadOffset;
|
||||||
private int payloadOffset;
|
private int payloadOffset;
|
||||||
private int payloadLength;
|
private int payloadLength;
|
||||||
|
private byte[] payloadBytes;
|
||||||
|
|
||||||
public LowFreqDocsAndPositionsEnum(Bits liveDocs, boolean hasOffsets, boolean hasPayloads) {
|
public LowFreqDocsAndPositionsEnum(Bits liveDocs, boolean hasOffsets, boolean hasPayloads) {
|
||||||
this.liveDocs = liveDocs;
|
this.liveDocs = liveDocs;
|
||||||
|
@ -1708,7 +1710,7 @@ public class DirectPostingsFormat extends PostingsFormat {
|
||||||
endOffset = -1;
|
endOffset = -1;
|
||||||
docID = -1;
|
docID = -1;
|
||||||
payloadLength = 0;
|
payloadLength = 0;
|
||||||
payload.bytes = payloadBytes;
|
this.payloadBytes = payloadBytes;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1741,9 +1743,19 @@ public class DirectPostingsFormat extends PostingsFormat {
|
||||||
skipPositions = freq;
|
skipPositions = freq;
|
||||||
return docID;
|
return docID;
|
||||||
}
|
}
|
||||||
|
if (hasPayloads) {
|
||||||
|
for(int i=0;i<freq;i++) {
|
||||||
|
upto++;
|
||||||
|
if (hasOffsets) {
|
||||||
|
upto += 2;
|
||||||
|
}
|
||||||
|
payloadOffset += postings[upto++];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
upto += posMult * freq;
|
upto += posMult * freq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return docID = NO_MORE_DOCS;
|
return docID = NO_MORE_DOCS;
|
||||||
}
|
}
|
||||||
|
@ -1769,7 +1781,7 @@ public class DirectPostingsFormat extends PostingsFormat {
|
||||||
}
|
}
|
||||||
if (hasPayloads) {
|
if (hasPayloads) {
|
||||||
payloadLength = postings[upto++];
|
payloadLength = postings[upto++];
|
||||||
payload.offset = payloadOffset;
|
lastPayloadOffset = payloadOffset;
|
||||||
payloadOffset += payloadLength;
|
payloadOffset += payloadLength;
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
|
@ -1802,6 +1814,8 @@ public class DirectPostingsFormat extends PostingsFormat {
|
||||||
@Override
|
@Override
|
||||||
public BytesRef getPayload() {
|
public BytesRef getPayload() {
|
||||||
if (payloadLength > 0) {
|
if (payloadLength > 0) {
|
||||||
|
payload.bytes = payloadBytes;
|
||||||
|
payload.offset = lastPayloadOffset;
|
||||||
payload.length = payloadLength;
|
payload.length = payloadLength;
|
||||||
payloadLength = 0;
|
payloadLength = 0;
|
||||||
return payload;
|
return payload;
|
||||||
|
|
Loading…
Reference in New Issue