Methods Summary |
---|
public final void | close()
super.close();
if (proxStream != null) proxStream.close();
|
public byte[] | getPayload(byte[] data, int offset)
if (!needToLoadPayload) {
throw new IOException("Payload cannot be loaded more than once for the same term position.");
}
// read payloads lazily
byte[] retArray;
int retOffset;
if (data == null || data.length - offset < payloadLength) {
// the array is too small to store the payload data,
// so we allocate a new one
retArray = new byte[payloadLength];
retOffset = 0;
} else {
retArray = data;
retOffset = offset;
}
proxStream.readBytes(retArray, retOffset, payloadLength);
needToLoadPayload = false;
return retArray;
|
public int | getPayloadLength()
return payloadLength;
|
public boolean | isPayloadAvailable()
return needToLoadPayload && payloadLength > 0;
|
private void | lazySkip()
if (proxStream == null) {
// clone lazily
proxStream = (IndexInput)parent.proxStream.clone();
}
// we might have to skip the current payload
// if it was not read yet
skipPayload();
if (lazySkipPointer != 0) {
proxStream.seek(lazySkipPointer);
lazySkipPointer = 0;
}
if (lazySkipProxCount != 0) {
skipPositions(lazySkipProxCount);
lazySkipProxCount = 0;
}
|
public final boolean | next()
// we remember to skip the remaining positions of the current
// document lazily
lazySkipProxCount += proxCount;
if (super.next()) { // run super
proxCount = freq; // note frequency
position = 0; // reset position
return true;
}
return false;
|
public final int | nextPosition()
// perform lazy skips if neccessary
lazySkip();
proxCount--;
return position += readDeltaPosition();
|
public final int | read(int[] docs, int[] freqs)
throw new UnsupportedOperationException("TermPositions does not support processing multiple documents in one call. Use TermDocs instead.");
|
private final int | readDeltaPosition()
int delta = proxStream.readVInt();
if (currentFieldStoresPayloads) {
// if the current field stores payloads then
// the position delta is shifted one bit to the left.
// if the LSB is set, then we have to read the current
// payload length
if ((delta & 1) != 0) {
payloadLength = proxStream.readVInt();
}
delta >>>= 1;
needToLoadPayload = true;
} else {
payloadLength = 0;
needToLoadPayload = false;
}
return delta;
|
final void | seek(org.apache.lucene.index.TermInfo ti, org.apache.lucene.index.Term term)
super.seek(ti, term);
if (ti != null)
lazySkipPointer = ti.proxPointer;
lazySkipProxCount = 0;
proxCount = 0;
payloadLength = 0;
needToLoadPayload = false;
|
private void | skipPayload()
if (needToLoadPayload && payloadLength > 0) {
proxStream.seek(proxStream.getFilePointer() + payloadLength);
}
needToLoadPayload = false;
|
private void | skipPositions(int n)
for (int f = n; f > 0; f--) { // skip unread positions
readDeltaPosition();
skipPayload();
}
|
protected void | skipProx(long proxPointer, int payloadLength)Called by super.skipTo().
// we save the pointer, we might have to skip there lazily
lazySkipPointer = proxPointer;
lazySkipProxCount = 0;
proxCount = 0;
this.payloadLength = payloadLength;
needToLoadPayload = false;
|
protected final void | skippingDoc()
// we remember to skip a document lazily
lazySkipProxCount += freq;
|