LUCENE-10264: Clone index input when creating a PointTree in SimpleTextBKDReader (#478)

Fixes a race condition introduced in LUCENE-9820.
This commit is contained in:
Ignacio Vera 2021-11-29 09:20:20 +01:00 committed by GitHub
parent 63c89f678d
commit 634c22c527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -77,7 +77,7 @@ final class SimpleTextBKDReader extends PointValues {
@Override
public PointTree getPointTree() {
return new SimpleTextPointTree(1, 1, minPackedValue, maxPackedValue);
return new SimpleTextPointTree(in.clone(), 1, 1, minPackedValue, maxPackedValue);
}
private class SimpleTextPointTree implements PointTree {
@ -94,8 +94,11 @@ final class SimpleTextBKDReader extends PointValues {
// holds the splitDim for each level:
private final int[] splitDims;
private final IndexInput in;
private SimpleTextPointTree(
int nodeID, int level, byte[] minPackedValue, byte[] maxPackedValue) {
IndexInput in, int nodeID, int level, byte[] minPackedValue, byte[] maxPackedValue) {
this.in = in;
this.scratchDocIDs = new int[config.maxPointsInLeafNode];
this.scratchPackedValue = new byte[config.packedBytesLength];
this.nodeID = nodeID;
@ -121,7 +124,7 @@ final class SimpleTextBKDReader extends PointValues {
@Override
public PointTree clone() {
SimpleTextPointTree index =
new SimpleTextPointTree(nodeID, level, minPackedValue, maxPackedValue);
new SimpleTextPointTree(in.clone(), nodeID, level, minPackedValue, maxPackedValue);
if (isLeafNode() == false) {
// copy node data
index.splitDims[level] = splitDims[level];