Skip to content
Merged
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
138 changes: 88 additions & 50 deletions java/cuvs-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.44.5</version>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -194,56 +200,88 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
<execution>
<id>test-jars</id>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<excludeResources>true</excludeResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<excludePackageNames>com.nvidia.cuvs.examples,com.nvidia.cuvs.panama</excludePackageNames>
<doclint>all,-missing</doclint>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
<execution>
<id>test-jars</id>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<excludeResources>true</excludeResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.11.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<excludePackageNames>com.nvidia.cuvs.examples,com.nvidia.cuvs.panama</excludePackageNames>
<doclint>all,-missing</doclint>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.44.5</version>
<executions>
<execution>
<goals>
<goal>apply</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
<configuration>
<java>
<includes>
<include>src/**/*.java</include>
</includes>
<excludes>
<exclude>src/**/panama/*.java</exclude>
</excludes>
<googleJavaFormat>
<version>1.27.0</version>
<style>GOOGLE</style>
<reflowLongStrings>true</reflowLongStrings>
<formatJavadoc>false</formatJavadoc>
</googleJavaFormat>
<licenseHeader>
<file>${project.basedir}/../license-header.txt</file>
</licenseHeader>
</java>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nvidia.cuvs;

import com.nvidia.cuvs.spi.CuVSProvider;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Path;
import java.util.Objects;

import com.nvidia.cuvs.spi.CuVSProvider;

/**
*
* {@link BruteForceIndex} encapsulates a BRUTEFORCE index, along with methods
Expand Down Expand Up @@ -56,6 +54,7 @@ public interface BruteForceIndex {
* bytes into
*/
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nvidia.cuvs;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nvidia.cuvs;

import java.util.Arrays;
Expand Down Expand Up @@ -45,7 +44,8 @@ public class BruteForceQuery {
* @param numDocs Maximum of bits in each prefilter, representing number of documents in this index.
* Used only when prefilter(s) is/are passed.
*/
public BruteForceQuery(float[][] queryVectors, List<Integer> mapping, int topK, BitSet[] prefilters, int numDocs) {
public BruteForceQuery(
float[][] queryVectors, List<Integer> mapping, int topK, BitSet[] prefilters, int numDocs) {
this.queryVectors = queryVectors;
this.mapping = mapping;
this.topK = topK;
Expand Down Expand Up @@ -100,8 +100,15 @@ public int getNumDocs() {

@Override
public String toString() {
return "BruteForceQuery [mapping=" + mapping + ", queryVectors=" + Arrays.toString(queryVectors) + ", prefilter="
+ Arrays.toString(prefilters) + ", topK=" + topK + "]";
return "BruteForceQuery [mapping="
+ mapping
+ ", queryVectors="
+ Arrays.toString(queryVectors)
+ ", prefilter="
+ Arrays.toString(prefilters)
+ ", topK="
+ topK
+ "]";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nvidia.cuvs;

/**
Expand Down Expand Up @@ -47,8 +46,13 @@ public class CagraCompressionParams {
* @param pqKmeansTrainsetFraction the fraction of data to use during iterative
* kmeans building (PQ phase)
*/
private CagraCompressionParams(int pqBits, int pqDim, int vqNCenters, int kmeansNIters,
double vqKmeansTrainsetFraction, double pqKmeansTrainsetFraction) {
private CagraCompressionParams(
int pqBits,
int pqDim,
int vqNCenters,
int kmeansNIters,
double vqKmeansTrainsetFraction,
double pqKmeansTrainsetFraction) {
this.pqBits = pqBits;
this.pqDim = pqDim;
this.vqNCenters = vqNCenters;
Expand Down Expand Up @@ -119,9 +123,19 @@ public double getPqKmeansTrainsetFraction() {

@Override
public String toString() {
return "CagraCompressionParams [pqBits=" + pqBits + ", pqDim=" + pqDim + ", vqNCenters=" + vqNCenters
+ ", kmeansNIters=" + kmeansNIters + ", vqKmeansTrainsetFraction=" + vqKmeansTrainsetFraction
+ ", pqKmeansTrainsetFraction=" + pqKmeansTrainsetFraction + "]";
return "CagraCompressionParams [pqBits="
+ pqBits
+ ", pqDim="
+ pqDim
+ ", vqNCenters="
+ vqNCenters
+ ", kmeansNIters="
+ kmeansNIters
+ ", vqKmeansTrainsetFraction="
+ vqKmeansTrainsetFraction
+ ", pqKmeansTrainsetFraction="
+ pqKmeansTrainsetFraction
+ "]";
}

/**
Expand All @@ -136,8 +150,7 @@ public static class Builder {
private double vqKmeansTrainsetFraction = 0;
private double pqKmeansTrainsetFraction = 0;

public Builder() {
}
public Builder() {}

/**
* Sets the bit length of the vector element after compression by PQ.
Expand Down Expand Up @@ -225,7 +238,12 @@ public Builder withPqKmeansTrainsetFraction(double pqKmeansTrainsetFraction) {
* @return an instance of {@link CagraCompressionParams}
*/
public CagraCompressionParams build() {
return new CagraCompressionParams(pqBits, pqDim, vqNCenters, kmeansNIters, vqKmeansTrainsetFraction,
return new CagraCompressionParams(
pqBits,
pqDim,
vqNCenters,
kmeansNIters,
vqKmeansTrainsetFraction,
pqKmeansTrainsetFraction);
}
}
Expand Down
Loading