public class Main {
public static void main(String[] arguments) {
DenseOptions options = new DenseOptions().dimensions(3).metric(DenseMetric.ANGULAR).quantization(Scalar.BF16);
try (Executor pool = Executor.forRam(new int[0], null, 0);
Arena arena = new Arena(pool);
DenseIndex index = DenseIndex.initRam(options, new int[0])) {
index.reserve(100); // Optional capacity hint; inserts grow on demand
index.insert(
new Key[] {Key.of(42), Key.of(43)},
RowsView.of(new float[] {0.1f, 0.2f, 0.3f, 0.3f, 0.2f, 0.1f}, 3));
RowsView query = RowsView.of(new float[] {0.1f, 0.2f, 0.3f}, 3);
Matches matches = index.search(query, 10, arena); // the calling thread
matches = index.on(pool).search(query, 10, arena); // the same verb, on an executor
for (int rank = 0; rank < matches.count(0); ++rank) {
System.out.println(matches.key(0, rank) + " at " + matches.score(0, rank));
}
}
}
}