atris commented on a change in pull request #8148: URL: https://github.com/apache/pinot/pull/8148#discussion_r806530206
########## File path: pinot-core/src/test/java/org/apache/pinot/core/operator/dociditerators/NotDocIdIteratorTest.java ########## @@ -0,0 +1,103 @@ +/** + * 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.pinot.core.operator.dociditerators; + +import org.apache.pinot.core.common.BlockDocIdIterator; +import org.apache.pinot.segment.spi.Constants; +import org.roaringbitmap.buffer.MutableRoaringBitmap; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + + +public class NotDocIdIteratorTest { + @Test + public void testNotDocIdIterator() { + // OR result: [0, 1, 2, 4, 5, 6, 8, 10, 13, 15, 16, 17, 18, 19, 20] + int[] docIds1 = new int[]{1, 4, 6, 10, 15, 17, 18, 20}; + int[] docIds2 = new int[]{0, 1, 5, 8, 15, 18}; + int[] docIds3 = new int[]{1, 2, 6, 13, 16, 19}; + int[] docIds4 = new int[]{0, 1, 2, 3, 4, 5}; + + MutableRoaringBitmap bitmap1 = new MutableRoaringBitmap(); + bitmap1.add(docIds1); + MutableRoaringBitmap bitmap2 = new MutableRoaringBitmap(); + bitmap2.add(docIds2); + MutableRoaringBitmap bitmap3 = new MutableRoaringBitmap(); + bitmap3.add(docIds3); + MutableRoaringBitmap bitmap4 = new MutableRoaringBitmap(); + bitmap4.add(docIds4); + OrDocIdIterator orDocIdIterator = new OrDocIdIterator(new BlockDocIdIterator[]{ + new RangelessBitmapDocIdIterator(bitmap1), new RangelessBitmapDocIdIterator( + bitmap2), new RangelessBitmapDocIdIterator(bitmap3) + }); + NotDocIdIterator notDocIdIterator = new NotDocIdIterator(new RangelessBitmapDocIdIterator(bitmap1), 25); + + assertEquals(notDocIdIterator.advance(1), 2); + assertEquals(notDocIdIterator.next(), 3); + assertEquals(notDocIdIterator.next(), 5); + assertEquals(notDocIdIterator.advance(7), 8); Review comment: The comment above advance() BlockDocIdIterator is a bit confusing. It says: Returns the first matching document whose id is greater than or equal to the given target document id I interpreted it as being ok if we return the first id greater than the target document id, which is what this test demonstrates. If that is not the case, should we reword the API spec to be explicit? Fixed this issue, thanks for sharing the proposed solution! ########## File path: pinot-core/src/test/java/org/apache/pinot/core/operator/dociditerators/NotDocIdIteratorTest.java ########## @@ -0,0 +1,103 @@ +/** + * 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.pinot.core.operator.dociditerators; + +import org.apache.pinot.core.common.BlockDocIdIterator; +import org.apache.pinot.segment.spi.Constants; +import org.roaringbitmap.buffer.MutableRoaringBitmap; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + + +public class NotDocIdIteratorTest { + @Test + public void testNotDocIdIterator() { + // OR result: [0, 1, 2, 4, 5, 6, 8, 10, 13, 15, 16, 17, 18, 19, 20] + int[] docIds1 = new int[]{1, 4, 6, 10, 15, 17, 18, 20}; + int[] docIds2 = new int[]{0, 1, 5, 8, 15, 18}; + int[] docIds3 = new int[]{1, 2, 6, 13, 16, 19}; + int[] docIds4 = new int[]{0, 1, 2, 3, 4, 5}; + + MutableRoaringBitmap bitmap1 = new MutableRoaringBitmap(); + bitmap1.add(docIds1); + MutableRoaringBitmap bitmap2 = new MutableRoaringBitmap(); + bitmap2.add(docIds2); + MutableRoaringBitmap bitmap3 = new MutableRoaringBitmap(); + bitmap3.add(docIds3); + MutableRoaringBitmap bitmap4 = new MutableRoaringBitmap(); + bitmap4.add(docIds4); + OrDocIdIterator orDocIdIterator = new OrDocIdIterator(new BlockDocIdIterator[]{ Review comment: We use it to test NotDocIdIterator later in the test -- 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]
