mkhludnev commented on code in PR #16805:
URL: https://github.com/apache/lucene/pull/16805#discussion_r4242543580
##########
lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsWithScoreCollectorManager.java:
##########
@@ -313,64 +304,100 @@ static final class Scores {
// same per-document scores in a different order may round to a different
float.
final double[][] blocks;
final double unset;
+ final ReadWriteLock locks[];
private Scores(long valueCount, double unset) {
long blockSize = valueCount + arraySize - 1;
blocks = new double[(int) ((blockSize) / arraySize)][];
+ locks = createLocks(blocks.length);
this.unset = unset;
}
public void setScore(int globalOrdinal, double score) {
int block = globalOrdinal / arraySize;
int offset = globalOrdinal % arraySize;
- double[] scores = blocks[block];
- if (scores == null) {
- blocks[block] = scores = new double[arraySize];
- if (unset != 0d) {
- Arrays.fill(scores, unset);
+ locks[block].writeLock().lock();
+ try {
+ double[] scores = blocks[block];
+ if (scores == null) {
+ blocks[block] = scores = new double[arraySize];
+ if (unset != 0d) {
+ Arrays.fill(scores, unset);
+ }
}
+ scores[offset] = score;
+ } finally {
+ locks[block].writeLock().unlock();
}
- scores[offset] = score;
}
public double getScore(int globalOrdinal) {
+ if (locks == null) {
+ return unset;
+ }
int block = globalOrdinal / arraySize;
int offset = globalOrdinal % arraySize;
- double[] scores = blocks[block];
- double score;
- if (scores != null) {
- score = scores[offset];
- } else {
- score = unset;
+ locks[block].readLock().lock();
+ try {
+ double[] scores = blocks[block];
+ if (scores != null) {
+ return scores[offset];
+ } else {
+ return unset;
+ }
+ } finally {
+ locks[block].readLock().unlock();
}
- return score;
}
}
static final class Occurrences {
final int[][] blocks;
+ final ReadWriteLock locks[];
private Occurrences(long valueCount) {
long blockSize = valueCount + arraySize - 1;
blocks = new int[(int) (blockSize / arraySize)][];
+ locks = createLocks(blocks.length);
}
public void increment(int globalOrdinal) {
int block = globalOrdinal / arraySize;
- int offset = globalOrdinal % arraySize;
- int[] occurrences = blocks[block];
- if (occurrences == null) {
- blocks[block] = occurrences = new int[arraySize];
+ locks[block].writeLock().lock();
Review Comment:
sadly, only Solr level ones https://github.com/mkhludnev/aijoin-benchmark I
think rebuild it for lucene snapshot is too hard.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]