-
Notifications
You must be signed in to change notification settings - Fork 214
Add graph creation stats to the KNNStats API #1141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
martin-gaievski
merged 14 commits into
opensearch-project:main
from
ryanbogan:graph_creation_stats
Oct 3, 2023
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0553620
Add graph stats to KNN Stats API
27acb63
Extract variables to new class and add one test
f3a6733
Merge branch 'main' into graph_creation_stats
104da3b
Minor changes and add tests
ed14e8b
Change tests
3394066
Update CHANGELOG
82df6c9
Fix typos
ad86e74
Merge branch 'main' into graph_creation_stats
cd41e46
Address PR feedback
f3e6722
Add logging for time taken by merge/refresh operations
fe891e6
Change array calculations
a73ddd8
Merge branch 'main' into graph_creation_stats
4faab0e
Minor change
49f6d46
Merge branch 'main' into graph_creation_stats
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
95 changes: 95 additions & 0 deletions
95
src/main/java/org/opensearch/knn/plugin/stats/KNNGraphValue.java
This file contains hidden or 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,95 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package org.opensearch.knn.plugin.stats; | ||
|
|
||
| import java.util.concurrent.atomic.AtomicLong; | ||
|
|
||
| /** | ||
| * Contains a map to keep track of different graph values | ||
| */ | ||
| public enum KNNGraphValue { | ||
|
|
||
| REFRESH_TOTAL_OPERATIONS("total"), | ||
| REFRESH_TOTAL_TIME_IN_MILLIS("total_time_in_millis"), | ||
| MERGE_CURRENT_OPERATIONS("current"), | ||
| MERGE_CURRENT_DOCS("current_docs"), | ||
| MERGE_CURRENT_SIZE_IN_BYTES("current_size_in_bytes"), | ||
| MERGE_TOTAL_OPERATIONS("total"), | ||
| MERGE_TOTAL_TIME_IN_MILLIS("total_time_in_millis"), | ||
| MERGE_TOTAL_DOCS("total_docs"), | ||
| MERGE_TOTAL_SIZE_IN_BYTES("total_size_in_bytes"); | ||
|
|
||
| private String name; | ||
| private AtomicLong value; | ||
|
|
||
| /** | ||
| * Constructor | ||
| * | ||
| * @param name name of the graph value | ||
| */ | ||
| KNNGraphValue(String name) { | ||
| this.name = name; | ||
| this.value = new AtomicLong(0); | ||
| } | ||
|
|
||
| /** | ||
| * Get name of value | ||
| * | ||
| * @return name | ||
| */ | ||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| /** | ||
| * Get the graph value | ||
| * | ||
| * @return value | ||
| */ | ||
| public Long getValue() { | ||
| return value.get(); | ||
| } | ||
|
|
||
| /** | ||
| * Increment the graph value | ||
| */ | ||
| public void increment() { | ||
| value.getAndIncrement(); | ||
| } | ||
|
|
||
| /** | ||
| * Decrement the graph value | ||
| */ | ||
| public void decrement() { | ||
| value.getAndDecrement(); | ||
| } | ||
|
|
||
| /** | ||
| * Increment the graph value by a specified amount | ||
| * | ||
| * @param delta The amount to increment | ||
| */ | ||
| public void incrementBy(long delta) { | ||
| value.getAndAdd(delta); | ||
| } | ||
|
|
||
| /** | ||
| * Decrement the graph value by a specified amount | ||
| * | ||
| * @param delta The amount to decrement | ||
| */ | ||
| public void decrementBy(long delta) { | ||
| value.set(value.get() - delta); | ||
| } | ||
|
|
||
| /** | ||
| * @param value graph value | ||
| * Set the graph value | ||
| */ | ||
| public void set(long value) { | ||
| this.value.set(value); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.