gsmiller commented on code in PR #15803: URL: https://github.com/apache/lucene/pull/15803#discussion_r2907483426
########## lucene/CHANGES.txt: ########## @@ -550,6 +548,10 @@ API Changes instance instead of a Bits instance to identify document IDs to filter. (Shubham Chaudhary, Adrien Grand) +* GITHUB#15803: Add ReaderUtil#partitionByLeaf to partition sorted global Review Comment: Did you mean to put this under 10.3? I assume we'd want to target 10.5 with this? ########## lucene/core/src/test/org/apache/lucene/index/TestReaderUtil.java: ########## @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.lucene.index; + +import java.io.IOException; +import java.util.List; +import org.apache.lucene.document.Document; +import org.apache.lucene.store.Directory; +import org.apache.lucene.tests.util.LuceneTestCase; + +public class TestReaderUtil extends LuceneTestCase { Review Comment: Thank you for adding tests! ########## lucene/core/src/java/org/apache/lucene/index/ReaderUtil.java: ########## @@ -89,4 +89,49 @@ public static int subIndex(int n, List<LeafReaderContext> leaves) { } return hi; } + + /** + * Partitions sorted global doc IDs by leaf. + * + * @param sortedDocIds global doc IDs, must be sorted ascending + * @param leaves the index reader's leaves + * @return array indexed by leaf ord, containing global doc IDs for that leaf (empty if no hits) + */ + public static int[][] partitionByLeaf(int[] sortedDocIds, List<LeafReaderContext> leaves) { Review Comment: It might be helpful to add an `assert` check in here to validate that `soredDocIds` are actually sorted for debugging/testing with assertions turned on. -- 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]
