dnhatn commented on a change in pull request #1263: LUCENE-9228: Sort dv updates by terms by applying URL: https://github.com/apache/lucene-solr/pull/1263#discussion_r380946428
########## File path: lucene/core/src/java/org/apache/lucene/index/FieldUpdatesBuffer.java ########## @@ -195,10 +197,34 @@ private int append(Term term) { return numUpdates++; } + void finish() { + assert termsIteratorProvider == null; + if (isSortedTerms()) { + // sort by ascending by term, then sort descending by docsUpTo + termsIteratorProvider = termValues.iteratorProvider(BytesRef::compareTo, + (i1, i2) -> Integer.compare( + docsUpTo[getArrayIndex(docsUpTo.length, i2)], + docsUpTo[getArrayIndex(docsUpTo.length, i1)])); + bytesUsed.addAndGet(termValues.size() * Integer.BYTES); // sorted indices of the iterators + } else { + termsIteratorProvider = termValues.iteratorProvider(null, null); + } + } + BufferedUpdateIterator iterator() { + assert termsIteratorProvider != null : "finish is not called yet"; Review comment: ++. Added at https://github.com/apache/lucene-solr/blob/ed0f59f2f4419caae4e2a8aa6cf6c63f92df73c0/lucene/core/src/java/org/apache/lucene/index/FieldUpdatesBuffer.java#L120. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org