mirror of https://github.com/apache/lucene.git
LUCENE-8709: Set pointWriter to null when size of the HeapPointWriter is 0
This commit is contained in:
parent
748d483e67
commit
beda852fc2
|
@ -41,7 +41,7 @@ public final class HeapPointReader implements PointReader {
|
|||
this.pointValue = new HeapPointValue(block, packedBytesLength);
|
||||
} else {
|
||||
//no values
|
||||
this.pointValue = new HeapPointValue(block, 0);
|
||||
this.pointValue = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public final class HeapPointWriter implements PointWriter {
|
|||
private int nextWrite;
|
||||
private boolean closed;
|
||||
|
||||
private HeapPointReader.HeapPointValue offlinePointValue;
|
||||
private HeapPointReader.HeapPointValue pointValue;
|
||||
|
||||
|
||||
public HeapPointWriter(int size, int packedBytesLength) {
|
||||
|
@ -42,18 +42,18 @@ public final class HeapPointWriter implements PointWriter {
|
|||
this.packedBytesLength = packedBytesLength;
|
||||
this.scratch = new byte[packedBytesLength];
|
||||
if (size > 0) {
|
||||
offlinePointValue = new HeapPointReader.HeapPointValue(block, packedBytesLength);
|
||||
pointValue = new HeapPointReader.HeapPointValue(block, packedBytesLength);
|
||||
} else {
|
||||
//no values
|
||||
offlinePointValue = new HeapPointReader.HeapPointValue(block, 0);
|
||||
pointValue = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns a reference, in <code>result</code>, to the byte[] slice holding this value */
|
||||
public PointValue getPackedValueSlice(int index) {
|
||||
assert index < nextWrite : "nextWrite=" + (nextWrite) + " vs index=" + index;
|
||||
offlinePointValue.setValue(index * packedBytesLength, docIDs[index]);
|
||||
return offlinePointValue;
|
||||
pointValue.setValue(index * packedBytesLength, docIDs[index]);
|
||||
return pointValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue