-
Notifications
You must be signed in to change notification settings - Fork 140
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
2386/integrate jvector knn engine #2505
Open
sam-herman
wants to merge
1
commit into
opensearch-project:main
Choose a base branch
from
sam-herman:2386/integrate-jvector-knn-engine
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 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 |
---|---|---|
|
@@ -316,6 +316,10 @@ dependencies { | |
} | ||
testFixturesImplementation "org.opensearch:common-utils:${version}" | ||
implementation 'com.github.oshi:oshi-core:6.4.13' | ||
|
||
implementation 'io.github.jbellis:jvector:4.0.0-beta.2-SNAPSHOT' | ||
implementation 'org.agrona:agrona:1.20.0' | ||
|
||
api "net.java.dev.jna:jna:5.13.0" | ||
api "net.java.dev.jna:jna-platform:5.13.0" | ||
// OpenSearch core is using slf4j 1.7.36. Therefore, we cannot change the version here. | ||
|
@@ -331,7 +335,7 @@ task windowsPatches(type:Exec) { | |
task cmakeJniLib(type:Exec) { | ||
workingDir 'jni' | ||
def args = [] | ||
args.add("cmake") | ||
args.add("/opt/homebrew/bin/cmake") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will fix this one |
||
args.add(".") | ||
args.add("-DKNN_PLUGIN_VERSION=${opensearch_version}") | ||
args.add("-DAVX2_ENABLED=${avx2_enabled}") | ||
|
@@ -364,6 +368,8 @@ test { | |
dependsOn buildJniLib | ||
systemProperty 'tests.security.manager', 'false' | ||
systemProperty "java.library.path", "$rootDir/jni/release" | ||
systemProperty 'log4j.configurationFile', "$rootDir/src/test/resources/log4j2.properties" | ||
|
||
//this change enables mockito-inline that supports mocking of static classes/calls | ||
systemProperty "jdk.attach.allowAttachSelf", true | ||
if (Os.isFamily(Os.FAMILY_WINDOWS)) { | ||
|
@@ -378,6 +384,11 @@ integTest { | |
dependsOn buildJniLib | ||
} | ||
systemProperty 'tests.security.manager', 'false' | ||
println "Project root directory: ${project.rootDir}" | ||
systemProperty "java.security.policy", "file://${project.rootDir}/src/main/plugin-metadata/plugin-security.policy" | ||
systemProperty 'log4j.configurationFile', "${project.rootDir}/src/test/resources/log4j2.properties" | ||
testLogging.showStandardStreams = true | ||
systemProperty 'tests.output', 'true' | ||
systemProperty 'java.io.tmpdir', opensearch_tmp_dir.absolutePath | ||
systemProperty "java.library.path", "$rootDir/jni/release" | ||
// allows integration test classes to access test resource from project root path | ||
|
@@ -421,7 +432,8 @@ integTest { | |
|
||
testClusters.integTest { | ||
testDistribution = "ARCHIVE" | ||
|
||
systemProperty "java.security.policy", "file://${project.rootDir}/src/main/plugin-metadata/plugin-security.policy" | ||
systemProperty 'log4j.configurationFile', "${project.rootDir}/src/test/resources/log4j2.properties" | ||
// Optionally install security | ||
if (System.getProperty("security.enabled") != null) { | ||
configureSecurityPlugin(testClusters.integTest) | ||
|
@@ -460,7 +472,7 @@ task integTestRemote(type: RestIntegTestTask) { | |
systemProperty 'cluster.number_of_nodes', "${_numNodes}" | ||
|
||
systemProperty 'tests.security.manager', 'false' | ||
|
||
systemProperty 'tests.output', 'true' | ||
// Run tests with remote cluster only if rest case is defined | ||
if (System.getProperty("tests.rest.cluster") != null) { | ||
filter { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will move this to resources or as part of a |
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,77 @@ | ||
#!/bin/bash | ||
|
||
./gradlew run -PcustomDistributionUrl=file://${HOME}/projects/OpenSearch/distribution/archives/darwin-tar/build/distributions/opensearch-min-3.0.0-SNAPSHOT-darwin-x64.tar.gz | ||
|
||
# ping local cluster | ||
curl localhost:9200 | ||
|
||
# Check test cluster status | ||
curl -X GET "http://localhost:9200/_cluster/health?pretty" | ||
|
||
# Create new knn index with 1 shard and 0 replicas | ||
curl -X PUT "localhost:9200/my_knn_index?pretty" -H 'Content-Type: application/json' -d' | ||
{ | ||
"settings": { | ||
"index.knn": true, | ||
"index.number_of_shards": 1, | ||
"index.number_of_replicas": 0, | ||
"index.use_compound_file": false | ||
} | ||
}' | ||
|
||
# Check index settings | ||
curl -X GET "localhost:9200/my_knn_index/_settings?pretty" | ||
|
||
# Add mapping for knn_vector field with jVector engine | ||
curl -X PUT "localhost:9200/my_knn_index/_mapping?pretty" -H 'Content-Type: application/json' -d' | ||
{ | ||
"properties": { | ||
"my_vector": { | ||
"type": "knn_vector", | ||
"dimension": 3, | ||
"method": { | ||
"name": "disk_ann", | ||
"space_type": "l2", | ||
"engine": "jvector" | ||
} | ||
} | ||
} | ||
}' | ||
|
||
|
||
# Check index mapping | ||
curl -X GET "localhost:9200/my_knn_index/_mapping?pretty" | ||
|
||
# Add document with knn_vector field | ||
curl -X POST "localhost:9200/_bulk?pretty" -H 'Content-Type: application/json' -d' | ||
{"index": {"_index": "my_knn_index"}} | ||
{"my_vector": [1, 2, 3]} | ||
{"index": {"_index": "my_knn_index"}} | ||
{"my_vector": [4, 5, 6]} | ||
{"index": {"_index": "my_knn_index"}} | ||
{"my_vector": [7, 8, 9]} | ||
' | ||
|
||
# refresh index | ||
curl -X POST "localhost:9200/my_knn_index/_refresh?pretty" | ||
|
||
|
||
# Search for nearest neighbors | ||
curl -X GET "localhost:9200/my_knn_index/_search?pretty" -H 'Content-Type: application/json' -d' | ||
{ | ||
"query": { | ||
"knn": { | ||
"my_vector": { | ||
"vector": [1, 2, 3], | ||
"k": 3 | ||
} | ||
} | ||
} | ||
}' | ||
|
||
# Delete index | ||
curl -X DELETE "localhost:9200/my_knn_index?pretty" | ||
|
||
|
||
# Check test cluster location | ||
ls -lah build/testclusters/integTest-0/data/nodes/0/indices |
Binary file not shown.
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 |
---|---|---|
@@ -1,12 +1,7 @@ | ||
# | ||
# Copyright OpenSearch Contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionSha256Sum=f2b9ed0faf8472cbe469255ae6c86eddb77076c75191741b4a462f33128dd419 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this used? I didnt see in the codec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be runtimeOnly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a transient dependency of jvector, I had to include it because it doesn't resolve automatically. Can make it a runtimeOnly because it's not explicitly used.