-
Notifications
You must be signed in to change notification settings - Fork 78
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
Initial cut for a cuVS Java API #450
base: branch-25.02
Are you sure you want to change the base?
Changes from 64 commits
c777924
f9c2df7
1597158
6f405e9
8531be2
c9b8891
9bb865a
d40b3d0
1e03585
3222536
c5536b6
2d79580
84c6121
20562ee
ad11369
6a851ef
68e8b94
3852f6e
479e488
43f5e15
3438dbf
4411629
b7da0ef
c4346d9
cefadb8
8492c72
8e7c62c
eb94a0f
d32f8f9
bbcbba1
696f015
b95bb7f
9ab2754
638092c
51eb397
fb295dd
80174d2
61ea9ac
1803dee
7cda1e5
53dfa23
6f708eb
b98d2bb
81b60f1
dca835d
e3757c0
0aa2665
a89fe5d
b44baa9
98c3c93
feed385
1d80b41
2f0f143
2c0e4cd
72bc6e3
b79a17e
6819bdf
bc280e4
392d0ff
a0dba4a
bfd355b
ab1c53f
a197d52
69ef479
7eb00d5
fd5e1c1
a24b3df
daedfcd
cf6efdd
704d8d6
37c5dba
c0d146b
8e42da0
136f658
94a02fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,3 +83,8 @@ ivf_pq_index | |
# cuvs_bench | ||
datasets/ | ||
/*.json | ||
|
||
# java | ||
.classpath | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,3 +96,9 @@ find .devcontainer/ -type f -name devcontainer.json -print0 | while IFS= read -r | |
sed_runner "s@rapidsai/devcontainers/features/rapids-build-utils:[0-9.]*@rapidsai/devcontainers/features/rapids-build-utils:${NEXT_SHORT_TAG_PEP440}@" "${filename}" | ||
sed_runner "s@rapids-\${localWorkspaceFolderBasename}-${CURRENT_SHORT_TAG}@rapids-\${localWorkspaceFolderBasename}-${NEXT_SHORT_TAG}@g" "${filename}" | ||
done | ||
|
||
# Update Java API version | ||
sed_runner "s/VERSION=\".*\"/VERSION=\"${NEXT_FULL_TAG}\"/g" java/build.sh | ||
for FILE in java/*/pom.xml; do | ||
sed_runner "/<!--CUVS_JAVA#VERSION_UPDATE_MARKER_START-->.*<!--CUVS_JAVA#VERSION_UPDATE_MARKER_END-->/s//<!--CUVS_JAVA#VERSION_UPDATE_MARKER_START--><version>${NEXT_FULL_TAG}<\/version><!--CUVS_JAVA#VERSION_UPDATE_MARKER_END-->/g" "${FILE}" | ||
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. This is currently inconsistent with our normal use of the script. We usually run Please look at https://github.com/rapidsai/cudf/blob/133e0c869531af94474e0bbb66cb22c5f8ba80f2/ci/release/update-version.sh#L87-L91 and https://github.com/rapidsai/cudf/blob/133e0c869531af94474e0bbb66cb22c5f8ba80f2/java/pom.xml#L24 and see whether we should adopt the same patterns here. 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. Thanks Bradley, I've updated the version number format to include a patch number also. This should be better for Java artifacts. 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. 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. Hey @bdice I will update the versioning following your suggestion above and push this change soon. |
||
done |
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. Please revert any files with only copyright changes. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,14 @@ | ||||||
Prerequisites | ||||||
------------- | ||||||
|
||||||
* JDK 22 | ||||||
* Maven 3.9.6 or later | ||||||
|
||||||
To build this API, please do `./build.sh java` in the top level directory. Since this API is dependent on `libcuvs` it must be noted that `libcuvs` gets built automatically before building this API. | ||||||
|
||||||
Alternatively, please build libcuvs (`./build.sh libcuvs` from top level directory) before building the Java API with `./build.sh` from this directory. | ||||||
|
||||||
Building | ||||||
-------- | ||||||
|
||||||
`./build.sh` will generate the libcuvs_java.so file in internal/ directory, and then build the final jar file for the cuVS Java API in cuvs-java/ directory. | ||||||
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.
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
VERSION="25.02" # Note: The version is updated automatically when ci/release/update-version.sh is invoked | ||
bdice marked this conversation as resolved.
Show resolved
Hide resolved
|
||
GROUP_ID="com.nvidia.cuvs" | ||
SO_FILE_PATH="./internal" | ||
|
||
if [ -z "$CMAKE_PREFIX_PATH" ]; then | ||
export CMAKE_PREFIX_PATH=`pwd`/../cpp/build | ||
fi | ||
|
||
cd internal && cmake . && cmake --build . \ | ||
&& cd .. \ | ||
&& mvn install:install-file -DgroupId=$GROUP_ID -DartifactId=cuvs-java-internal -Dversion=$VERSION -Dpackaging=so -Dfile=$SO_FILE_PATH/libcuvs_java.so \ | ||
&& cd cuvs-java \ | ||
&& mvn package \ | ||
&& mvn install:install-file -Dfile=./target/cuvs-java-$VERSION-jar-with-dependencies.jar -DgroupId=$GROUP_ID -DartifactId=cuvs-java -Dversion=$VERSION -Dpackaging=jar |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
<!-- | ||
/* | ||
* Copyright (c) 2025, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.nvidia.cuvs</groupId> | ||
<artifactId>cuvs-java</artifactId> | ||
<!-- NOTE: The version automatically gets updated when ci/release/update-version.sh is invoked. --> | ||
<!--CUVS_JAVA#VERSION_UPDATE_MARKER_START--><version>25.02</version><!--CUVS_JAVA#VERSION_UPDATE_MARKER_END--> | ||
bdice marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<name>cuvs-java</name> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<maven.compiler.target>22</maven.compiler.target> | ||
<maven.compiler.source>22</maven.compiler.source> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>1.7.36</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<version>1.7.36</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.carrotsearch.randomizedtesting</groupId> | ||
<artifactId>randomizedtesting-runner</artifactId> | ||
<version>2.8.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>3.5.2</version> | ||
<configuration> | ||
<parallel>suites</parallel> | ||
<threadCountSuites>1</threadCountSuites> | ||
<perCoreThreadCount>false</perCoreThreadCount> | ||
<systemPropertyVariables> | ||
<java.library.path>${project.build.directory}/classes</java.library.path> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>2.10</version> | ||
<executions> | ||
<execution> | ||
<id>copy</id> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>copy</goal> | ||
</goals> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>com.nvidia.cuvs</groupId> | ||
<artifactId>cuvs-java-internal</artifactId> | ||
<!-- NOTE: The version automatically gets updated when ci/release/update-version.sh is invoked. --> | ||
<!--CUVS_JAVA#VERSION_UPDATE_MARKER_START--><version>25.02</version><!--CUVS_JAVA#VERSION_UPDATE_MARKER_END--> | ||
<type>so</type> | ||
<overWrite>false</overWrite> | ||
<outputDirectory> | ||
${project.build.directory}/classes</outputDirectory> | ||
<destFileName>libcuvs_java.so</destFileName> | ||
</artifactItem> | ||
</artifactItems> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>3.4.2</version> | ||
<configuration> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
<archiverConfig> | ||
<duplicateBehavior>add</duplicateBehavior> | ||
</archiverConfig> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>assemble-all</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.2</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass> | ||
com.nvidia.cuvs.examples.CagraExample</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.6.2</version> | ||
<configuration> | ||
<excludePackageNames>com.nvidia.cuvs.examples,com.nvidia.cuvs.panama</excludePackageNames> | ||
<reportOutputDirectory>${project.build.directory}</reportOutputDirectory> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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.
I'm not sure if it is good practice to call this script recursively to build the C++ code. It seems like it will lead to unexpected behavior. For example, how do you ensure that the CLI arguments such as
--allgpuarch
or--no-mg
are being passed through?I would recommend removing this line, and users must call
./build.sh libcuvs java
if the C++ has not yet been built. Perhaps a warning can be issued ifhasArg libcuvs
is false. I believe this is how we handle the Python builds, which also depend on C++ libraries being built.