gf2121 commented on code in PR #15151:
URL: https://github.com/apache/lucene/pull/15151#discussion_r2328621857


##########
lucene/core/src/test/org/apache/lucene/search/TestSynonymQuery.java:
##########
@@ -386,8 +396,18 @@ public int getDocIdUpTo(int level) {
         }
 
         @Override
-        public List<Impact> getImpacts(int level) {
-          return Arrays.asList(impacts[level]);
+        public FreqAndNormBuffer getImpacts(int level) {
+          FreqAndNormBuffer buffer = new FreqAndNormBuffer();
+          int size = impacts[level].length;
+          buffer.growNoCopy(size);
+          buffer.size = size;
+          int i = 0;
+          for (Impact impact : impacts[level]) {
+            buffer.freqs[i] = impact.freq;
+            buffer.norms[i] = impact.norm;
+            i++;
+          }

Review Comment:
   ```suggestion
             Arrays.stream(impacts[level]).forEach(impact -> 
buffer.add(impact.freq, impact.norm));
   ```



##########
lucene/core/src/test/org/apache/lucene/search/TestPhraseQuery.java:
##########
@@ -953,8 +962,18 @@ public int getDocIdUpTo(int level) {
         }
 
         @Override
-        public List<Impact> getImpacts(int level) {
-          return Arrays.asList(impacts[level]);
+        public FreqAndNormBuffer getImpacts(int level) {
+          FreqAndNormBuffer buffer = new FreqAndNormBuffer();
+          int size = impacts[level].length;
+          buffer.growNoCopy(size);
+          buffer.size = size;
+          int i = 0;
+          for (Impact impact : impacts[level]) {
+            buffer.freqs[i] = impact.freq;
+            buffer.norms[i] = impact.norm;
+            i++;
+          }

Review Comment:
   ```suggestion
             Arrays.stream(impacts[level]).forEach(impact -> 
buffer.add(impact.freq, impact.norm));
   ```



##########
lucene/core/src/java/org/apache/lucene/search/SloppyPhraseMatcher.java:
##########
@@ -128,14 +126,23 @@ public SloppyPhraseMatcher(
           public Impacts getImpacts() throws IOException {
             return new Impacts() {
 
+              private final FreqAndNormBuffer impactBuffer = new 
FreqAndNormBuffer();
+
+              {
+                impactBuffer.growNoCopy(1);
+                impactBuffer.freqs[0] = Integer.MAX_VALUE;
+                impactBuffer.norms[0] = 1L;
+                impactBuffer.size = 1;

Review Comment:
   ```suggestion
                   impactBuffer.add(Integer.MAX_VALUE, 1)
   ```



-- 
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]

Reply via email to