Skip to content
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

avs client 0.2.0 example #42

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions avs-client-java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Proximus Java Client

This project demonstrates the use of Aerospike's vector database capabilities with `AdminClient` and `Client` classes. The project is configured with Maven and includes sample data for testing vector search functionalities.

## Overview
- This is a demo project to illustrate how can a simple image search application can be built with Aerospike Vector database using vector database java client.

## Prerequisites

- Java 21
- __An AVS 0.4.0 running and accessible from the application.__


## Project Structure

```
client-test/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── aerospike/
│ │ │ ├── App.java
│ │ │ └── SetupUtils.java
│ └── resources/
│ └── sift/
│ ├── siftsmall_base.fvecs
│ ├── siftsmall_groundtruth.ivecs
│ └── siftsmall_query.fvecs
└── pom.xml
```

## Maven Configuration

Necessary `pom.xml` configuration for the project:

```xml
<dependencies>
<!-- avs java client dependency -->
<dependency>
<groupId>com.aerospike</groupId>
<artifactId>avs-client-java</artifactId>
<version>0.2.0</version>
</dependency>
</dependencies>
```


## Application Code
`App.java` This class initializes the setup and test methods for the vector database.

### SetupUtils.java
- This class handles the setup of the vector database and the asynchronous vector search tests.
- What it does: Load Data:
- Loads base vectors, query vectors, and ground truth vectors from files.
- Initialize Clients:
- Sets up `Client` and `AdminClient` using the provided Aerospike host(`localhost`) and port (`10000`).
- Create Index: Creates an index in the Aerospike database for storing vector data.
- Insert Vectors: Inserts the base vectors into the Aerospike database.
- Wait for Merge: Waits until all records are merged in the index.
- Perform Vector Search: Executes asynchronous vector searches using the query vectors.
- Computes recall metrics to evaluate the search results.

- Key Methods:
- `setup(String host, int port)`: Handles data loading, client initialization, index creation, vector insertion, and waiting for records to merge.
- `testVectorSearchAsync()`: Executes the vector search tests and computes recall metrics.


### Javadocs
Please refer to the [javadocs](https://javadoc.io/doc/com.aerospike/avs-client-java/latest/index.html) for more details.

81 changes: 81 additions & 0 deletions avs-client-java/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.aerospike</groupId>
<artifactId>aerospike-vectordb-java-client-demo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>aerospike-vectordb-java-client-demo</name>
<description>Aerospike Vector Database Java Client Demo Project</description>
<url>https://aerospike.com/docs/vector </url>

<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<organization>
<name>Aerospike Inc.</name>
<url>https://www.aerospike.com</url>
</organization>

<developers>
<developer>
<id>rkumar-aerospike</id>
<name>Rahul Kumar</name>
<email>[email protected]</email>
<url>http://www.yourcompany.com/team/your-name</url>
<organization>Aerospike Inc.</organization>
<organizationUrl>https://www.aerospike.com</organizationUrl>
<roles>
<role>developer</role>
</roles>
<timezone>America/Los_Angeles</timezone>
</developer>
</developers>


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>

<!-- Logback dependencies -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>

<!-- Aerospike client dependencies -->
<dependency>
<groupId>com.aerospike</groupId>
<artifactId>avs-client-java</artifactId>
<version>0.2.0</version>
</dependency>
</dependencies>

</project>
16 changes: 16 additions & 0 deletions avs-client-java/src/main/java/com/aerospike/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.aerospike;

public class App {

public static void main(String[] args) {

try {
SetupUtils.setup();
SetupUtils.testVectorSearchAsync();
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Loading