Skip to content

Commit

Permalink
close arena only if not alive, update version in pom.xml and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivek Narang committed Jan 27, 2025
1 parent daedfcd commit cf6efdd
Show file tree
Hide file tree
Showing 38 changed files with 240 additions and 249 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,3 @@ datasets/

# java
.classpath


2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ if (( ${NUMARGS} == 0 )) || hasArg rust; then
cargo test
fi

# Build the cuvs Java bindings
# Build the cuvs Java bindings
if (( ${NUMARGS} == 0 )) || hasArg java; then
# build libcuvs first as the Java API depends on it
./$0 libcuvs
Expand Down
2 changes: 1 addition & 1 deletion java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Prerequisites
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
--------

Expand Down
4 changes: 2 additions & 2 deletions java/cuvs-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* 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">
Expand Down Expand Up @@ -97,7 +97,7 @@
<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-->
<!--CUVS_JAVA#VERSION_UPDATE_MARKER_START--><version>25.02.00</version><!--CUVS_JAVA#VERSION_UPDATE_MARKER_END-->
<type>so</type>
<overWrite>false</overWrite>
<outputDirectory>
Expand Down
34 changes: 17 additions & 17 deletions java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
import com.nvidia.cuvs.panama.CuVSBruteForceIndex;

/**
*
*
* {@link BruteForceIndex} encapsulates a BRUTEFORCE index, along with methods
* to interact with it.
*
*
* @since 25.02
*/
public class BruteForceIndex {
Expand All @@ -58,7 +58,7 @@ public class BruteForceIndex {

/**
* Constructor for building the index using specified dataset
*
*
* @param dataset the dataset used for creating the BRUTEFORCE
* index
* @param resources an instance of {@link CuVSResources}
Expand All @@ -81,7 +81,7 @@ private BruteForceIndex(float[][] dataset, CuVSResources resources, BruteForceIn

/**
* Constructor for loading the index from an {@link InputStream}
*
*
* @param inputStream an instance of stream to read the index bytes from
* @param resources an instance of {@link CuVSResources}
*/
Expand All @@ -100,7 +100,7 @@ private BruteForceIndex(InputStream inputStream, CuVSResources resources) throws

/**
* Initializes the {@link MethodHandles} for invoking native methods.
*
*
* @throws IOException @{@link IOException} is unable to load the native library
*/
private void initializeMethodHandles() throws IOException {
Expand Down Expand Up @@ -141,7 +141,7 @@ public void destroyIndex() throws Throwable {
/**
* Invokes the native build_brute_force_index function via the Panama API to
* build the {@link BruteForceIndex}
*
*
* @return an instance of {@link IndexReference} that holds the pointer to the
* index
*/
Expand All @@ -162,7 +162,7 @@ private IndexReference build() throws Throwable {
/**
* Invokes the native search_brute_force_index via the Panama API for searching
* a BRUTEFORCE index.
*
*
* @param cuvsQuery an instance of {@link BruteForceQuery} holding the query
* vectors and other parameters
* @return an instance of {@link BruteForceSearchResults} containing the results
Expand Down Expand Up @@ -196,7 +196,7 @@ public BruteForceSearchResults search(BruteForceQuery cuvsQuery) throws Throwabl
/**
* A method to persist a BRUTEFORCE index using an instance of
* {@link OutputStream} for writing index bytes.
*
*
* @param outputStream an instance of {@link OutputStream} to write the index
* bytes into
*/
Expand All @@ -207,7 +207,7 @@ public void serialize(OutputStream outputStream) throws Throwable {
/**
* A method to persist a BRUTEFORCE index using an instance of
* {@link OutputStream} and path to the intermediate temporary file.
*
*
* @param outputStream an instance of {@link OutputStream} to write the index
* bytes to
* @param tempFile an intermediate {@link File} where BRUTEFORCE index is
Expand All @@ -232,7 +232,7 @@ public void serialize(OutputStream outputStream, File tempFile) throws Throwable
/**
* Gets an instance of {@link IndexReference} by deserializing a BRUTEFORCE
* index using an {@link InputStream}.
*
*
* @param inputStream an instance of {@link InputStream}
* @return an instance of {@link IndexReference}.
*/
Expand Down Expand Up @@ -271,7 +271,7 @@ public static class Builder {

/**
* Constructs this Builder with an instance of {@link CuVSResources}.
*
*
* @param cuvsResources an instance of {@link CuVSResources}
*/
public Builder(CuVSResources cuvsResources) {
Expand All @@ -281,7 +281,7 @@ public Builder(CuVSResources cuvsResources) {
/**
* Registers an instance of configured {@link BruteForceIndexParams} with this
* Builder.
*
*
* @param bruteForceIndexParams An instance of BruteForceIndexParams
* @return An instance of this Builder
*/
Expand All @@ -293,7 +293,7 @@ public Builder withIndexParams(BruteForceIndexParams bruteForceIndexParams) {
/**
* Sets an instance of InputStream typically used when index deserialization is
* needed.
*
*
* @param inputStream an instance of {@link InputStream}
* @return an instance of this Builder
*/
Expand All @@ -304,7 +304,7 @@ public Builder from(InputStream inputStream) {

/**
* Sets the dataset for building the {@link BruteForceIndex}.
*
*
* @param dataset a two-dimensional float array
* @return an instance of this Builder
*/
Expand All @@ -315,7 +315,7 @@ public Builder withDataset(float[][] dataset) {

/**
* Builds and returns an instance of {@link BruteForceIndex}.
*
*
* @return an instance of {@link BruteForceIndex}
*/
public BruteForceIndex build() throws Throwable {
Expand Down Expand Up @@ -344,7 +344,7 @@ protected IndexReference(CuVSResources resources) {
/**
* Constructs BruteForceIndexReference with an instance of MemorySegment passed
* as a parameter.
*
*
* @param indexMemorySegment the MemorySegment instance to use for containing
* index reference
*/
Expand All @@ -354,7 +354,7 @@ protected IndexReference(MemorySegment indexMemorySegment) {

/**
* Gets the instance of index MemorySegment.
*
*
* @return index MemorySegment
*/
protected MemorySegment getMemorySegment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

/**
* Supplemental parameters to build BRUTEFORCE index.
*
*
* @since 25.02
*/
public class BruteForceIndexParams {
Expand Down Expand Up @@ -50,7 +50,7 @@ public static class Builder {

/**
* Sets the number of writer threads to use for indexing.
*
*
* @param numWriterThreads number of writer threads to use
* @return an instance of Builder
*/
Expand All @@ -61,11 +61,11 @@ public Builder withNumWriterThreads(int numWriterThreads) {

/**
* Builds an instance of {@link BruteForceIndexParams}.
*
*
* @return an instance of {@link BruteForceIndexParams}
*/
public BruteForceIndexParams build() {
return new BruteForceIndexParams(numWriterThreads);
}
}
}
}
22 changes: 11 additions & 11 deletions java/cuvs-java/src/main/java/com/nvidia/cuvs/BruteForceQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/**
* BruteForceQuery holds the query vectors to be used while invoking search.
*
*
* @since 25.02
*/
public class BruteForceQuery {
Expand All @@ -34,7 +34,7 @@ public class BruteForceQuery {
/**
* Constructs an instance of {@link BruteForceQuery} using queryVectors,
* mapping, and topK.
*
*
* @param queryVectors 2D float query vector array
* @param mapping an instance of ID mapping
* @param topK the top k results to return
Expand All @@ -50,7 +50,7 @@ public BruteForceQuery(float[][] queryVectors, Map<Integer, Integer> mapping, in

/**
* Gets the query vector 2D float array.
*
*
* @return 2D float array
*/
public float[][] getQueryVectors() {
Expand All @@ -59,7 +59,7 @@ public float[][] getQueryVectors() {

/**
* Gets the passed map instance.
*
*
* @return a map of ID mappings
*/
public Map<Integer, Integer> getMapping() {
Expand All @@ -68,7 +68,7 @@ public Map<Integer, Integer> getMapping() {

/**
* Gets the topK value.
*
*
* @return an integer
*/
public int getTopK() {
Expand All @@ -77,7 +77,7 @@ public int getTopK() {

/**
* Gets the prefilter long array
*
*
* @return a long array
*/
public long[] getPrefilter() {
Expand All @@ -102,7 +102,7 @@ public static class Builder {

/**
* Registers the query vectors to be passed in the search call.
*
*
* @param queryVectors 2D float query vector array
* @return an instance of this Builder
*/
Expand All @@ -113,7 +113,7 @@ public Builder withQueryVectors(float[][] queryVectors) {

/**
* Sets the instance of mapping to be used for ID mapping.
*
*
* @param mapping the ID mapping instance
* @return an instance of this Builder
*/
Expand All @@ -124,7 +124,7 @@ public Builder withMapping(Map<Integer, Integer> mapping) {

/**
* Registers the topK value.
*
*
* @param topK the topK value used to retrieve the topK results
* @return an instance of this Builder
*/
Expand All @@ -135,7 +135,7 @@ public Builder withTopK(int topK) {

/**
* Sets the prefilter data for building the {@link BruteForceQuery}.
*
*
* @param prefilter a one-dimensional long array
* @return an instance of this Builder
*/
Expand All @@ -146,7 +146,7 @@ public Builder withPrefilter(long[] prefilter) {

/**
* Builds an instance of {@link BruteForceQuery}
*
*
* @return an instance of {@link BruteForceQuery}
*/
public BruteForceQuery build() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/**
* SearchResult encapsulates the logic for reading and holding search results.
*
*
* @since 25.02
*/
public class BruteForceSearchResults implements SearchResults {
Expand Down Expand Up @@ -83,7 +83,7 @@ private void readResultMemorySegments() {

/**
* Gets a list results as a map of neighbor IDs to distances.
*
*
* @return a list of results for each query as a map of neighbor IDs to distance
*/
@Override
Expand Down
Loading

0 comments on commit cf6efdd

Please sign in to comment.