mirror of
https://github.com/apache/lucene.git
synced 2025-02-08 19:15:06 +00:00
Copy collected acc(maxFreqs) into empty acc, rather than merge them. (#12846)
This commit is contained in:
parent
701619d35a
commit
4b1180372e
@ -93,6 +93,18 @@ public final class CompetitiveImpactAccumulator {
|
|||||||
assert assertConsistent();
|
assert assertConsistent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Replace the content of this {@code acc} with the provided {@code acc}. */
|
||||||
|
public void copy(CompetitiveImpactAccumulator acc) {
|
||||||
|
int[] maxFreqs = this.maxFreqs;
|
||||||
|
int[] otherMaxFreqs = acc.maxFreqs;
|
||||||
|
|
||||||
|
System.arraycopy(otherMaxFreqs, 0, maxFreqs, 0, maxFreqs.length);
|
||||||
|
otherFreqNormPairs.clear();
|
||||||
|
otherFreqNormPairs.addAll(acc.otherFreqNormPairs);
|
||||||
|
|
||||||
|
assert assertConsistent();
|
||||||
|
}
|
||||||
|
|
||||||
/** Get the set of competitive freq and norm pairs, ordered by increasing freq and norm. */
|
/** Get the set of competitive freq and norm pairs, ordered by increasing freq and norm. */
|
||||||
public Collection<Impact> getCompetitiveFreqNormPairs() {
|
public Collection<Impact> getCompetitiveFreqNormPairs() {
|
||||||
List<Impact> impacts = new ArrayList<>();
|
List<Impact> impacts = new ArrayList<>();
|
||||||
|
@ -166,7 +166,7 @@ public final class Lucene99SkipWriter extends MultiLevelSkipListWriter {
|
|||||||
this.curPayPointer = payFP;
|
this.curPayPointer = payFP;
|
||||||
this.curPosBufferUpto = posBufferUpto;
|
this.curPosBufferUpto = posBufferUpto;
|
||||||
this.curPayloadByteUpto = payloadByteUpto;
|
this.curPayloadByteUpto = payloadByteUpto;
|
||||||
this.curCompetitiveFreqNorms[0].addAll(competitiveFreqNorms);
|
this.curCompetitiveFreqNorms[0].copy(competitiveFreqNorms);
|
||||||
bufferSkip(numDocs);
|
bufferSkip(numDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,71 @@ public class TestCompetitiveFreqNormAccumulator extends LuceneTestCase {
|
|||||||
assertEquals(List.copyOf(expected), List.copyOf(acc.getCompetitiveFreqNormPairs()));
|
assertEquals(List.copyOf(expected), List.copyOf(acc.getCompetitiveFreqNormPairs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCopy() {
|
||||||
|
CompetitiveImpactAccumulator acc = new CompetitiveImpactAccumulator();
|
||||||
|
CompetitiveImpactAccumulator copiedAcc = new CompetitiveImpactAccumulator();
|
||||||
|
CompetitiveImpactAccumulator mergedAcc = new CompetitiveImpactAccumulator();
|
||||||
|
|
||||||
|
acc.add(3, 5);
|
||||||
|
copiedAcc.copy(acc);
|
||||||
|
assertEquals(
|
||||||
|
List.copyOf(copiedAcc.getCompetitiveFreqNormPairs()),
|
||||||
|
List.copyOf(acc.getCompetitiveFreqNormPairs()));
|
||||||
|
|
||||||
|
mergedAcc.addAll(acc);
|
||||||
|
assertEquals(
|
||||||
|
List.copyOf(copiedAcc.getCompetitiveFreqNormPairs()),
|
||||||
|
List.copyOf(mergedAcc.getCompetitiveFreqNormPairs()));
|
||||||
|
|
||||||
|
acc.add(10, 10000);
|
||||||
|
copiedAcc.copy(acc);
|
||||||
|
assertEquals(
|
||||||
|
List.copyOf(copiedAcc.getCompetitiveFreqNormPairs()),
|
||||||
|
List.copyOf(acc.getCompetitiveFreqNormPairs()));
|
||||||
|
|
||||||
|
mergedAcc.clear();
|
||||||
|
mergedAcc.addAll(acc);
|
||||||
|
assertEquals(
|
||||||
|
List.copyOf(copiedAcc.getCompetitiveFreqNormPairs()),
|
||||||
|
List.copyOf(mergedAcc.getCompetitiveFreqNormPairs()));
|
||||||
|
|
||||||
|
acc.add(5, 200);
|
||||||
|
copiedAcc.copy(acc);
|
||||||
|
assertEquals(
|
||||||
|
List.copyOf(copiedAcc.getCompetitiveFreqNormPairs()),
|
||||||
|
List.copyOf(acc.getCompetitiveFreqNormPairs()));
|
||||||
|
|
||||||
|
mergedAcc.clear();
|
||||||
|
mergedAcc.addAll(acc);
|
||||||
|
assertEquals(
|
||||||
|
List.copyOf(copiedAcc.getCompetitiveFreqNormPairs()),
|
||||||
|
List.copyOf(mergedAcc.getCompetitiveFreqNormPairs()));
|
||||||
|
|
||||||
|
acc.add(20, -100);
|
||||||
|
copiedAcc.copy(acc);
|
||||||
|
assertEquals(
|
||||||
|
List.copyOf(copiedAcc.getCompetitiveFreqNormPairs()),
|
||||||
|
List.copyOf(acc.getCompetitiveFreqNormPairs()));
|
||||||
|
|
||||||
|
mergedAcc.clear();
|
||||||
|
mergedAcc.addAll(acc);
|
||||||
|
assertEquals(
|
||||||
|
List.copyOf(copiedAcc.getCompetitiveFreqNormPairs()),
|
||||||
|
List.copyOf(mergedAcc.getCompetitiveFreqNormPairs()));
|
||||||
|
|
||||||
|
acc.add(30, -3);
|
||||||
|
copiedAcc.copy(acc);
|
||||||
|
assertEquals(
|
||||||
|
List.copyOf(copiedAcc.getCompetitiveFreqNormPairs()),
|
||||||
|
List.copyOf(acc.getCompetitiveFreqNormPairs()));
|
||||||
|
|
||||||
|
mergedAcc.clear();
|
||||||
|
mergedAcc.addAll(acc);
|
||||||
|
assertEquals(
|
||||||
|
List.copyOf(copiedAcc.getCompetitiveFreqNormPairs()),
|
||||||
|
List.copyOf(mergedAcc.getCompetitiveFreqNormPairs()));
|
||||||
|
}
|
||||||
|
|
||||||
public void testOmitFreqs() {
|
public void testOmitFreqs() {
|
||||||
CompetitiveImpactAccumulator acc = new CompetitiveImpactAccumulator();
|
CompetitiveImpactAccumulator acc = new CompetitiveImpactAccumulator();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user