You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/03/25 19:16:07 UTC

[GitHub] [lucene] javanna commented on a change in pull request #766: LUCENE-10002: Add FixedBitSetCollector and corresponding collector manager to test framework

javanna commented on a change in pull request #766:
URL: https://github.com/apache/lucene/pull/766#discussion_r835549312



##########
File path: lucene/test-framework/src/java/org/apache/lucene/tests/search/FixedBitSetCollector.java
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.tests.search;
+
+import java.io.IOException;
+import java.util.Collection;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.search.CollectorManager;
+import org.apache.lucene.search.ScoreMode;
+import org.apache.lucene.search.SimpleCollector;
+import org.apache.lucene.util.FixedBitSet;
+
+/** Collector that accumulates matching docs in a {@link FixedBitSet} */
+public class FixedBitSetCollector extends SimpleCollector {
+  private final FixedBitSet bitSet;
+
+  private int docBase;
+
+  FixedBitSetCollector(int maxDoc) {
+    this.bitSet = new FixedBitSet(maxDoc);

Review comment:
       we are going to create one fixed bit set with size maxDoc for each leaf slice. This is ok for testing, yet I am wondering if a similar collector could be useful in production code, in which case we may want to improve it. I see [KnnVectoryQuery](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/KnnVectorQuery.java#L205) has something similar that I am planning to move to a collector manager and I wonder whether we should try and share code between these two scenarios (test changed in this PR and knn vector query)




-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org