You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "easyice (via GitHub)" <gi...@apache.org> on 2024/04/17 06:55:17 UTC
[PR] Fix test failure TestKnnByteVectorQuery.testTimeLimitingKnnCollectorManager [lucene]
easyice opened a new pull request, #13312:
URL: https://github.com/apache/lucene/pull/13312
`TopKnnCollectorManager#newCollector` will return `MultiLeafKnnCollector` instance if the index has multiple segments
```
org.apache.lucene.search.TestKnnByteVectorQuery > testTimeLimitingKnnCollectorManager FAILED
java.lang.AssertionError
at __randomizedtesting.SeedInfo.seed([A0DCCB76BFBF940C:8E1E7418F5C62B46]:0)
at org.junit.Assert.fail(Assert.java:87)
at org.junit.Assert.assertTrue(Assert.java:42)
at org.junit.Assert.assertTrue(Assert.java:53)
at org.apache.lucene.search.BaseKnnVectorQueryTestCase.testTimeLimitingKnnCollectorManager(BaseKnnVectorQueryTestCase.java:787)
at org.apache.lucene.search.TestKnnByteVectorQuery.testTimeLimitingKnnCollectorManager(TestKnnByteVectorQuery.java:30)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
```
```
gradlew test --tests TestKnnByteVectorQuery.testTimeLimitingKnnCollectorManager -Dtests.seed=A0DCCB76BFBF940C -Dtests.nightly=true
```
--
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
Re: [PR] Fix test failure TestKnnByteVectorQuery#testTimeLimitingKnnCollectorManager [lucene]
Posted by "easyice (via GitHub)" <gi...@apache.org>.
easyice commented on code in PR #13312:
URL: https://github.com/apache/lucene/pull/13312#discussion_r1568742254
##########
lucene/core/src/java/org/apache/lucene/search/TimeLimitingKnnCollectorManager.java:
##########
@@ -42,54 +42,62 @@ public KnnCollector newCollector(int visitedLimit, LeafReaderContext context) th
if (queryTimeout == null) {
return collector;
}
- return new KnnCollector() {
- @Override
- public boolean earlyTerminated() {
- return queryTimeout.shouldExit() || collector.earlyTerminated();
- }
-
- @Override
- public void incVisitedCount(int count) {
- collector.incVisitedCount(count);
- }
-
- @Override
- public long visitedCount() {
- return collector.visitedCount();
- }
-
- @Override
- public long visitLimit() {
- return collector.visitLimit();
- }
-
- @Override
- public int k() {
- return collector.k();
- }
-
- @Override
- public boolean collect(int docId, float similarity) {
- return collector.collect(docId, similarity);
- }
-
- @Override
- public float minCompetitiveSimilarity() {
- return collector.minCompetitiveSimilarity();
- }
-
- @Override
- public TopDocs topDocs() {
- TopDocs docs = collector.topDocs();
-
- // Mark results as partial if timeout is met
- TotalHits.Relation relation =
- queryTimeout.shouldExit()
- ? TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO
- : docs.totalHits.relation;
-
- return new TopDocs(new TotalHits(docs.totalHits.value, relation), docs.scoreDocs);
- }
- };
+ return new TimeoutingKnnCollector(collector);
+ }
+
+ class TimeoutingKnnCollector implements KnnCollector {
Review Comment:
Thank you @kaivalnp , it looks better, fixed.
--
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
Re: [PR] Fix test failure TestKnnByteVectorQuery#testTimeLimitingKnnCollectorManager [lucene]
Posted by "easyice (via GitHub)" <gi...@apache.org>.
easyice merged PR #13312:
URL: https://github.com/apache/lucene/pull/13312
--
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
Re: [PR] Fix test failure TestKnnByteVectorQuery#testTimeLimitingKnnCollectorManager [lucene]
Posted by "kaivalnp (via GitHub)" <gi...@apache.org>.
kaivalnp commented on code in PR #13312:
URL: https://github.com/apache/lucene/pull/13312#discussion_r1568720556
##########
lucene/core/src/java/org/apache/lucene/search/TimeLimitingKnnCollectorManager.java:
##########
@@ -42,54 +42,62 @@ public KnnCollector newCollector(int visitedLimit, LeafReaderContext context) th
if (queryTimeout == null) {
return collector;
}
- return new KnnCollector() {
- @Override
- public boolean earlyTerminated() {
- return queryTimeout.shouldExit() || collector.earlyTerminated();
- }
-
- @Override
- public void incVisitedCount(int count) {
- collector.incVisitedCount(count);
- }
-
- @Override
- public long visitedCount() {
- return collector.visitedCount();
- }
-
- @Override
- public long visitLimit() {
- return collector.visitLimit();
- }
-
- @Override
- public int k() {
- return collector.k();
- }
-
- @Override
- public boolean collect(int docId, float similarity) {
- return collector.collect(docId, similarity);
- }
-
- @Override
- public float minCompetitiveSimilarity() {
- return collector.minCompetitiveSimilarity();
- }
-
- @Override
- public TopDocs topDocs() {
- TopDocs docs = collector.topDocs();
-
- // Mark results as partial if timeout is met
- TotalHits.Relation relation =
- queryTimeout.shouldExit()
- ? TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO
- : docs.totalHits.relation;
-
- return new TopDocs(new TotalHits(docs.totalHits.value, relation), docs.scoreDocs);
- }
- };
+ return new TimeoutingKnnCollector(collector);
+ }
+
+ class TimeoutingKnnCollector implements KnnCollector {
Review Comment:
Should we make this `TimeLimitingKnnCollector` for name parity with `TimeLimitingKnnCollectorManager`?
--
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
Re: [PR] Fix test failure TestKnnByteVectorQuery#testTimeLimitingKnnCollectorManager [lucene]
Posted by "easyice (via GitHub)" <gi...@apache.org>.
easyice commented on code in PR #13312:
URL: https://github.com/apache/lucene/pull/13312#discussion_r1568402988
##########
lucene/core/src/test/org/apache/lucene/search/BaseKnnVectorQueryTestCase.java:
##########
@@ -784,7 +785,9 @@ public void testTimeLimitingKnnCollectorManager() throws IOException {
noTimeoutManager.newCollector(Integer.MAX_VALUE, searcher.leafContexts.getFirst());
// Check that a normal collector is created without timeout
- assertTrue(noTimeoutCollector instanceof TopKnnCollector);
+ assertTrue(
Review Comment:
Thanks for you suggestions! you are right, I like the idea!
--
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
Re: [PR] Fix test failure TestKnnByteVectorQuery#testTimeLimitingKnnCollectorManager [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on code in PR #13312:
URL: https://github.com/apache/lucene/pull/13312#discussion_r1568342142
##########
lucene/core/src/test/org/apache/lucene/search/BaseKnnVectorQueryTestCase.java:
##########
@@ -784,7 +785,9 @@ public void testTimeLimitingKnnCollectorManager() throws IOException {
noTimeoutManager.newCollector(Integer.MAX_VALUE, searcher.leafContexts.getFirst());
// Check that a normal collector is created without timeout
- assertTrue(noTimeoutCollector instanceof TopKnnCollector);
+ assertTrue(
Review Comment:
Thanks for trying to fix this. I think this type of test is problematic in that it restricts the implementations that are, in theory, an open set... I would change the implementation returned inside TimeLimitingKnnCollectorManager to a package-private class, then check for that using assertFalse(noTimeoutCollector instanceof TimeLimitingKnnCollectorManager.TimeoutingKnnCollector)?
--
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