Skip to content
97 changes: 97 additions & 0 deletions qa/vector/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

apply plugin: 'elasticsearch.java'
apply plugin: 'elasticsearch.build'

dependencies {
api "org.apache.lucene:lucene-core:${versions.lucene}"
api "org.apache.lucene:lucene-queries:${versions.lucene}"
api "org.apache.lucene:lucene-codecs:${versions.lucene}"
api "commons-logging:commons-logging:${versions.commonslogging}"
api "commons-codec:commons-codec:${versions.commonscodec}"
implementation project(':libs:logging')
implementation project(':server')
}

/**
* Task to run the KnnIndexTester with the provided parameters.
*
*
*/
tasks.register("checkVec", JavaExec) {
group = "Execution"
description = "Runs KnnIndexTester with the provided parameters to validate recall and performance."
classpath = sourceSets.main.runtimeClasspath
mainClass.set("org.elasticsearch.test.knn.KnnIndexTester")
// Configure logging to console
systemProperty "es.logger.out", "console"
systemProperty "es.logger.level", "INFO" // Change to DEBUG if needed

if (buildParams.getRuntimeJavaVersion().map { it.majorVersion.toInteger() }.get() >= 21) {
jvmArgs '-Xms4g', '-Xmx4g', '--add-modules=jdk.incubator.vector', '--enable-native-access=ALL-UNNAMED', '-Djava.util.concurrent.ForkJoinPool.common.parallelism=8', '-XX:+UnlockDiagnosticVMOptions', '-XX:+DebugNonSafepoints', '-XX:+HeapDumpOnOutOfMemoryError'
}
}

tasks.register("checkVecHelp", JavaExec) {
group = "Help"
description = "Prints help for the KnnIndexTester task."
classpath = sourceSets.main.runtimeClasspath
mainClass.set("org.elasticsearch.test.knn.KnnIndexTester")
args = ["--help"]
doLast {
println """
=============================================================================
KnnIndexTester Help
=============================================================================

Run with Gradle:
----------------
# Using default configuration file
./gradlew :qa:vector:checkVec

# Using custom configuration file
./gradlew :qa:vector:checkVec --args="path/to/your/config.json"

# Adjust heap size
./gradlew :qa:vector:checkVec -Dorg.gradle.jvmargs="-Xmx8g" --args="path/to/your/config.json"

# Set environment variable for more extensive JVM options
export GRADLE_OPTS="-Xmx8g -XX:+UseG1GC -XX:MaxGCPauseMillis=100"
./gradlew :qa:vector:checkVec


Run directly with Java:
----------------------
# Generate classpath (run once to create the file)
./gradlew :qa:vector:printClasspath

# Then use the classpath file with java
java -cp "\$(cat build/vector_classpath.txt)" \\
--add-modules=jdk.incubator.vector \\
--enable-native-access=ALL-UNNAMED \\
-Djava.util.concurrent.ForkJoinPool.common.parallelism=8 \\
-Xmx4g \\
-Xms4g \\\\
org.elasticsearch.test.knn.KnnIndexTester path/to/your/config.json
"""
}
}

tasks.register("printClasspath") {
group = "Help"
description = "Prints the classpath needed to run KnnIndexTester directly with java"

doLast {
def classpathFile = new File("${buildDir}/vector_classpath.txt")
classpathFile.parentFile.mkdirs()
classpathFile.text = sourceSets.main.runtimeClasspath.asPath
println "Classpath written to: ${classpathFile.absolutePath}"
}
}
20 changes: 20 additions & 0 deletions qa/vector/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

module org.elasticsearch.test.knn {
requires org.elasticsearch.base;
requires org.elasticsearch.server;
requires org.elasticsearch.xcontent;
requires org.apache.lucene.core;
requires org.apache.lucene.codecs;
requires org.apache.lucene.queries;
requires org.elasticsearch.logging;
requires org.apache.logging.log4j;
requires java.management;
}
Loading