Skip to navigation

Utils

View as Markdown

Java package: com.nvidia.cuvs.lucene

public class Utils

This class provides common static utility methods.

Public Members

handleThrowable

static RuntimeException handleThrowable(Throwable t) throws IOException

A utility method that rethrows known throwable types without changing their identity.

In particular, Error instances must not be converted to a RuntimeException; callers rely on errors retaining their original type and stack trace.

This method never returns normally; its return type exists solely so callers can write throw handleThrowable(t);, letting the compiler verify that the enclosing statement always completes abruptly.

Parameters

NameDescription
tthe throwable object

Returns

never returns; always throws

Throws

TypeDescription
IOException

Source: java/cuvs-lucene/src/main/java/com/nvidia/cuvs/lucene/Utils.java:40

closeAll

static Throwable closeAll(Throwable failure, AutoCloseable... closeables)

Closes every non-null closeable, even if some fail, and returns the first failure with the others added as suppressed.

Parameters

NameDescription
failurea failure already in flight to attach close failures to, or null
closeableswhat to close; null entries are skipped

Returns

failure, or the first close failure if it is null; null if nothing failed

Source: java/cuvs-lucene/src/main/java/com/nvidia/cuvs/lucene/Utils.java:58

createFloatMatrix

static CuVSMatrix createFloatMatrix(List<float[]> data, int dimensions, CuVSResources resources)

A method to build a CuVSMatrix from a list of float vectors.

Uses CuVSMatrix.Builder to copy vectors directly to device memory without creating intermediate heap arrays.

Parameters

NameDescription
dataThe float vectors
dimensionsThe number float elements in each vector
resourcesThe CuVS resources for device matrix creation

Returns

an instance of CuVSMatrix

Source: java/cuvs-lucene/src/main/java/com/nvidia/cuvs/lucene/Utils.java:88

createHostByteMatrixFromArray

static CuVSHostMatrix createHostByteMatrixFromArray(byte[][] data, int bytesPerVector)

Builds a host-memory CuVSMatrix from a 2D byte array.

Source: java/cuvs-lucene/src/main/java/com/nvidia/cuvs/lucene/Utils.java:107

nanosToMillis

static long nanosToMillis(long nanos)

A utility method to convert nanoseconds to milliseconds.

Parameters

NameDescription
nanos

Returns

milliseconds

Source: java/cuvs-lucene/src/main/java/com/nvidia/cuvs/lucene/Utils.java:188

cuVSResourcesOrNull

static CuVSResources cuVSResourcesOrNull()

Creates an instance of CuVSResources.

Returns

an instance of CuVSResources

Source: java/cuvs-lucene/src/main/java/com/nvidia/cuvs/lucene/Utils.java:197

handleThrowableWithIgnore

static void handleThrowableWithIgnore(Throwable t, String msg) throws IOException

A utility method that conditionally ignores certain throwable objects

Parameters

NameDescription
tthe throwable object
msgthe message to check

Throws

TypeDescription
IOException

Source: java/cuvs-lucene/src/main/java/com/nvidia/cuvs/lucene/Utils.java:225

info

static void info(InfoStream infoStream, String component, String msg)

Utility to print info/debug messages via InfoStream.

Parameters

NameDescription
infoStreamthe writer’s infostream
componentthe name of the index writer
msgthe log message to push via the InfoStream

Source: java/cuvs-lucene/src/main/java/com/nvidia/cuvs/lucene/Utils.java:239

Source: java/cuvs-lucene/src/main/java/com/nvidia/cuvs/lucene/Utils.java:23