xiangfu0 commented on code in PR #19303: URL: https://github.com/apache/pinot/pull/19303#discussion_r3886135236
########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/vector/BaseDocIdBitmapFilterQuery.java: ########## @@ -0,0 +1,124 @@ +/** + * 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.segment.local.segment.index.readers.vector; + +import java.io.IOException; +import org.apache.lucene.index.LeafReaderContext; +import org.apache.lucene.search.ConstantScoreWeight; +import org.apache.lucene.search.DocIdSetIterator; +import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.QueryVisitor; +import org.apache.lucene.search.ScoreMode; +import org.apache.lucene.search.Scorer; +import org.apache.lucene.search.Weight; +import org.roaringbitmap.buffer.ImmutableRoaringBitmap; + + +/// Base class for Lucene [Query] implementations that accept only documents whose PINOT doc id is present +/// in a [ImmutableRoaringBitmap]. Used to implement pre-filter ANN search by restricting HNSW graph +/// traversal to the filtered document set. +/// +/// Because Lucene uses its own internal doc ids (which differ from Pinot doc ids), subclasses supply the +/// per-leaf iterator that maps Lucene doc ids to Pinot doc ids before testing membership in the bitmap +/// (via a doc-id translator, doc values, etc.). This class owns the constant-score weight/scorer +/// scaffolding, identity-based equality, and cache opt-out, so filter-correctness fixes apply to every +/// implementation at once. +/// +/// Instances are single-use per search and must never be cached by Lucene ([Weight#isCacheable] returns +/// false), since the accepted docs depend on the bitmap instance. +public abstract class BasePinotDocIdBitmapFilterQuery extends Query { + protected final ImmutableRoaringBitmap _bitmap; Review Comment: Renamed to `BaseDocIdBitmapFilterQuery`. The `Pinot` prefix was redundant inside the repo, and the neighbouring `DocIdTranslator` in `HnswVectorIndexReader` already uses unprefixed `DocId` for the Pinot side, so this matches what is there. The Lucene-vs-Pinot doc id distinction that motivated the prefix is stated in the class Javadoc instead, which is where it actually needs explaining. The subclasses keep their existing names, so the family now reads `BaseDocIdBitmapFilterQuery` -> `RoaringBitmapFilterQuery` / `NumericDocValuesBitmapFilterQuery`. Happy to use a different name if you had one in mind. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_ -- 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]
