forked from opensearch-project/k-NN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forcess ann only search with delete docs filter
- Loading branch information
Showing
5 changed files
with
97 additions
and
22 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
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
39 changes: 39 additions & 0 deletions
39
src/main/java/org/opensearch/knn/plugin/stats/KNNTimer.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,39 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.plugin.stats; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.opensearch.search.profile.Timer; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum KNNTimer { | ||
|
||
FILTER_WEIGHT_TIME("filter_weight", new Timer()), | ||
FILTER_SCORER_TIME("filter_scorer", new Timer()), | ||
EXACT_SEARCH_TIME("exact_search", new Timer()), | ||
FILTER_ID_SELECTOR_TIME("filter_id_selector", new Timer()), | ||
ANN_TIME("ann_search", new Timer()); | ||
|
||
private final String name; | ||
private final Timer timer; | ||
|
||
public void start() { | ||
timer.start(); | ||
} | ||
|
||
public void stop() { | ||
timer.stop(); | ||
} | ||
|
||
public long average() { | ||
if (timer.getCount() > 1) { | ||
return timer.getApproximateTiming() / timer.getCount(); | ||
} | ||
return timer.getApproximateTiming(); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/java/org/opensearch/knn/plugin/stats/suppliers/KNNTimerSupplier.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,22 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.plugin.stats.suppliers; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.opensearch.knn.plugin.stats.KNNTimer; | ||
|
||
import java.util.function.Supplier; | ||
|
||
@RequiredArgsConstructor | ||
public class KNNTimerSupplier implements Supplier<Long> { | ||
|
||
private final KNNTimer knnTimer; | ||
|
||
@Override | ||
public Long get() { | ||
return knnTimer.average(); | ||
} | ||
} |