Skip to content

Commit

Permalink
update logging for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivek Narang committed Feb 7, 2025
1 parent 81f065e commit c6da45c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 53 deletions.
3 changes: 3 additions & 0 deletions java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CuVS Java API attempts to provide a Java based simple, efficient, and a robust v
> [!CAUTION]
> This is an experimental release and updates to this API should be expected in the coming days.

## Prerequisites

- gcc 11.4
Expand All @@ -24,10 +25,12 @@ do `./build.sh java` in the top level directory or just do `./build.sh` in this

:warning: If you notice the tests failing please replace `mvn verify` with `mvn clean package` in the `build.sh` script found in this directory and try again. This should build the API (and skip the tests).


## Examples

For easy understanding we have provided starter examples for CAGRA, HNSW, and Bruteforce and these can be found in the `examples` directory.


## Javadocs

To generate javadocs, in this directory (after building the API) please do:
Expand Down
32 changes: 18 additions & 14 deletions java/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ java --enable-native-access=ALL-UNNAMED -cp target/cuvs-java-examples-25.02.0.ja
```
Should output the following (with different timestamps):
```
[2025-02-07 10:18:26.660] [RAFT] [info] optimizing graph
[2025-02-07 10:18:26.660] [RAFT] [info] Graph optimized, creating index
[2025-02-07 10:18:26.670] [RAFT] [info] Saving CAGRA index with dataset
[{3=0.038782578, 2=0.3590463, 0=0.83774555}, {0=0.12472608, 2=0.21700792, 1=0.31918612}, {3=0.047766715, 2=0.20332818, 0=0.48305473}, {1=0.15224178, 0=0.59063464, 3=0.5986642}]
[{3=0.038782578, 2=0.3590463, 0=0.83774555}, {0=0.12472608, 2=0.21700792, 1=0.31918612}, {3=0.047766715, 2=0.20332818, 0=0.48305473}, {1=0.15224178, 0=0.59063464, 3=0.5986642}]
[2025-02-07 13:08:45.640] [RAFT] [info] optimizing graph
[2025-02-07 13:08:45.641] [RAFT] [info] Graph optimized, creating index
[2025-02-07 13:08:45.650] [RAFT] [info] Saving CAGRA index with dataset
Feb 07, 2025 1:08:45 PM com.nvidia.cuvs.examples.CagraExample main
INFO: [{3=0.038782578, 2=0.3590463, 0=0.83774555}, {0=0.12472608, 2=0.21700792, 1=0.31918612}, {3=0.047766715, 2=0.20332818, 0=0.48305473}, {1=0.15224178, 0=0.59063464, 3=0.5986642}]
Feb 07, 2025 1:08:45 PM com.nvidia.cuvs.examples.CagraExample main
INFO: [{3=0.038782578, 2=0.3590463, 0=0.83774555}, {0=0.12472608, 2=0.21700792, 1=0.31918612}, {3=0.047766715, 2=0.20332818, 0=0.48305473}, {1=0.15224178, 0=0.59063464, 3=0.5986642}]
```

### HNSW Example
Expand All @@ -31,21 +32,24 @@ java --enable-native-access=ALL-UNNAMED -cp target/cuvs-java-examples-25.02.0.ja
```
Should output the following (with different timestamps):
```
[2025-02-07 10:43:20.917] [RAFT] [warning] Intermediate graph degree cannot be larger than dataset size, reducing it to 4
[2025-02-07 10:43:20.917] [RAFT] [warning] Graph degree (64) cannot be larger than intermediate graph degree (3), reducing graph_degree.
[2025-02-07 13:09:51.443] [RAFT] [warning] Intermediate graph degree cannot be larger than dataset size, reducing it to 4
[2025-02-07 13:09:51.443] [RAFT] [warning] Graph degree (64) cannot be larger than intermediate graph degree (3), reducing graph_degree.
using ivf_pq::index_params nrows 4, dim 2, n_lists 4, pq_dim 8
[2025-02-07 10:43:21.015] [RAFT] [info] optimizing graph
[2025-02-07 10:43:21.016] [RAFT] [info] Graph optimized, creating index
[{3=0.038782578, 2=0.35904628, 0=0.8377455}, {0=0.12472608, 2=0.21700794, 1=0.31918612}, {3=0.047766715, 2=0.20332818, 0=0.48305473}, {1=0.15224178, 0=0.59063464, 3=0.59866416}]
[2025-02-07 13:09:51.524] [RAFT] [info] optimizing graph
[2025-02-07 13:09:51.525] [RAFT] [info] Graph optimized, creating index
Feb 07, 2025 1:09:51 PM com.nvidia.cuvs.examples.HnswExample main
INFO: [{3=0.038782578, 2=0.35904628, 0=0.8377455}, {0=0.12472608, 2=0.21700794, 1=0.31918612}, {3=0.047766715, 2=0.20332818, 0=0.48305473}, {1=0.15224178, 0=0.59063464, 3=0.59866416}]
```

### Bruteforce Example
Doing the following in the current directory:
```
java --enable-native-access=ALL-UNNAMED -cp target/cuvs-java-examples-25.02.0.jar:$HOME/.m2/repository/com/nvidia/cuvs/cuvs-java/25.02.0/cuvs-java-25.02.0.jar com.nvidia.cuvs.examples.BruteForceExample
```
Should output the following:
Should output the following (with different timestamps):
```
[{3=0.038782537, 2=0.35904616, 0=0.83774555}, {0=0.12472606, 2=0.21700788, 1=0.3191862}, {3=0.047766685, 2=0.20332813, 0=0.48305476}, {1=0.15224183, 0=0.5906347, 3=0.5986643}]
[{3=0.038782537, 2=0.35904616, 0=0.83774555}, {0=0.12472606, 2=0.21700788, 1=0.3191862}, {3=0.047766685, 2=0.20332813, 0=0.48305476}, {1=0.15224183, 0=0.5906347, 3=0.5986643}]
Feb 07, 2025 1:10:33 PM com.nvidia.cuvs.examples.BruteForceExample main
INFO: [{3=0.038782537, 2=0.35904616, 0=0.83774555}, {0=0.12472606, 2=0.21700788, 1=0.3191862}, {3=0.047766685, 2=0.20332813, 0=0.48305476}, {1=0.15224183, 0=0.5906347, 3=0.5986643}]
Feb 07, 2025 1:10:33 PM com.nvidia.cuvs.examples.BruteForceExample main
INFO: [{3=0.038782537, 2=0.35904616, 0=0.83774555}, {0=0.12472606, 2=0.21700788, 1=0.3191862}, {3=0.047766685, 2=0.20332813, 0=0.48305476}, {1=0.15224183, 0=0.5906347, 3=0.5986643}]
```
11 changes: 0 additions & 11 deletions java/examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
<!-- NOTE: The version automatically gets updated when ci/release/update-version.sh is invoked. -->
<!--CUVS_JAVA#VERSION_UPDATE_MARKER_START--><version>25.02.0</version><!--CUVS_JAVA#VERSION_UPDATE_MARKER_END-->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.13</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.13</version>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
import java.util.UUID;
import java.util.logging.Logger;

import com.nvidia.cuvs.SearchResults;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.nvidia.cuvs.BruteForceIndex;
import com.nvidia.cuvs.BruteForceIndexParams;
Expand All @@ -18,7 +16,7 @@

public class BruteForceExample {

private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final Logger log = Logger.getLogger(BruteForceExample.class.getName());

public static void main(String[] args) throws Throwable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
import java.util.UUID;
import java.util.logging.Logger;

import com.nvidia.cuvs.SearchResults;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.nvidia.cuvs.CagraIndex;
import com.nvidia.cuvs.CagraIndexParams;
Expand All @@ -21,7 +19,7 @@

public class CagraExample {

private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final Logger log = Logger.getLogger(CagraExample.class.getName());

public static void main(String[] args) throws Throwable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
import java.util.UUID;

import com.nvidia.cuvs.SearchResults;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;

import com.nvidia.cuvs.CagraIndex;
import com.nvidia.cuvs.CagraIndexParams;
Expand All @@ -20,10 +16,12 @@
import com.nvidia.cuvs.HnswIndexParams;
import com.nvidia.cuvs.HnswQuery;
import com.nvidia.cuvs.HnswSearchParams;
import com.nvidia.cuvs.SearchResults;


public class HnswExample {

private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final Logger log = Logger.getLogger(HnswExample.class.getName());

public static void main(String[] args) throws Throwable {

Expand Down
Empty file.
14 changes: 0 additions & 14 deletions java/examples/src/main/resources/log4j2.xml

This file was deleted.

0 comments on commit c6da45c

Please sign in to comment.