-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Junqiu Lei <[email protected]>
- Loading branch information
1 parent
c315862
commit 9a52b2b
Showing
8 changed files
with
230 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/org/opensearch/knn/index/VectorQueryType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.index; | ||
|
||
import lombok.Getter; | ||
import org.opensearch.knn.common.KNNConstants; | ||
import org.opensearch.knn.plugin.stats.KNNCounter; | ||
|
||
@Getter | ||
public enum VectorQueryType { | ||
K(KNNConstants.K) { | ||
@Override | ||
public KNNCounter getQueryStatCounter() { | ||
return KNNCounter.KNN_QUERY_REQUESTS; | ||
} | ||
|
||
@Override | ||
public KNNCounter getQueryWithFilterStatCounter() { | ||
return KNNCounter.KNN_QUERY_WITH_FILTER_REQUESTS; | ||
} | ||
}, | ||
MIN_SCORE(KNNConstants.MIN_SCORE) { | ||
@Override | ||
public KNNCounter getQueryStatCounter() { | ||
return KNNCounter.MIN_SCORE_QUERY_REQUESTS; | ||
} | ||
|
||
@Override | ||
public KNNCounter getQueryWithFilterStatCounter() { | ||
return KNNCounter.MIN_SCORE_QUERY_WITH_FILTER_REQUESTS; | ||
} | ||
}, | ||
MAX_DISTANCE(KNNConstants.MAX_DISTANCE) { | ||
@Override | ||
public KNNCounter getQueryStatCounter() { | ||
return KNNCounter.MAX_DISTANCE_QUERY_REQUESTS; | ||
} | ||
|
||
@Override | ||
public KNNCounter getQueryWithFilterStatCounter() { | ||
return KNNCounter.MAX_DISTANCE_QUERY_WITH_FILTER_REQUESTS; | ||
} | ||
}; | ||
|
||
private final String queryTypeName; | ||
|
||
VectorQueryType(String queryTypeName) { | ||
this.queryTypeName = queryTypeName; | ||
} | ||
|
||
public abstract KNNCounter getQueryStatCounter(); | ||
|
||
public abstract KNNCounter getQueryWithFilterStatCounter(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/java/org/opensearch/knn/index/VectorQueryTypeTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
package org.opensearch.knn.index; | ||
|
||
import org.opensearch.knn.KNNTestCase; | ||
import org.opensearch.knn.plugin.stats.KNNCounter; | ||
|
||
public class VectorQueryTypeTests extends KNNTestCase { | ||
|
||
public void testGetQueryStatCounter() { | ||
assertEquals(KNNCounter.KNN_QUERY_REQUESTS, VectorQueryType.K.getQueryStatCounter()); | ||
assertEquals(KNNCounter.MIN_SCORE_QUERY_REQUESTS, VectorQueryType.MIN_SCORE.getQueryStatCounter()); | ||
assertEquals(KNNCounter.MAX_DISTANCE_QUERY_REQUESTS, VectorQueryType.MAX_DISTANCE.getQueryStatCounter()); | ||
} | ||
|
||
public void testGetQueryWithFilterStatCounter() { | ||
assertEquals(KNNCounter.KNN_QUERY_WITH_FILTER_REQUESTS, VectorQueryType.K.getQueryWithFilterStatCounter()); | ||
assertEquals(KNNCounter.MIN_SCORE_QUERY_WITH_FILTER_REQUESTS, VectorQueryType.MIN_SCORE.getQueryWithFilterStatCounter()); | ||
assertEquals(KNNCounter.MAX_DISTANCE_QUERY_WITH_FILTER_REQUESTS, VectorQueryType.MAX_DISTANCE.getQueryWithFilterStatCounter()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters