Software

tiervec

A Java library of vector indexes for agent memory inside a database engine. A new vector is found by the next search. Experimental, on Maven Central.

Illustration of three solid blocks of falling height and a small open box holding a rose circle on one baseline, standing for sealed segments and a fresh vector that the next search finds.

What it is

A vector index that lives inside a database.

tiervec is a Java library of vector indexes. A database engine runs it in its own process, with no network between the engine and the index. It is written for an agent's memory: many small collections, a steady stream of small writes, deletes, and updates, and searches that must see a write at once.

Its main class, TieredIndex, keeps recent vectors in a tail that every search scans exactly, and older ones in sealed graph segments that are merged in the background. A small collection is always scanned exactly. The research page explains the design and what has been measured.

It is pure Java, with no dependency at run time. It is experimental: the API can change in any 0.x release, no database engine runs it yet, and no speed result is claimed.

Install

Add it with Maven.

tiervec is on Maven Central as ai.humem:tiervec. It needs JDK 21 or newer.

<dependency>
  <groupId>ai.humem</groupId>
  <artifactId>tiervec</artifactId>
  <version>0.1.1</version>
</dependency>

0.1.1 is the newest release. Many changes on the main branch are not released yet, and the changelog lists them.

The fast kernels use the Java Vector API, which is still an incubator module in these JDKs. Start the JVM with --add-modules jdk.incubator.vector to use them. Without it, every kernel falls back to plain Java code and gives the same answers.

Example

Add, search, delete.

import ai.humem.tiervec.Hit;
import ai.humem.tiervec.Metric;
import ai.humem.tiervec.TieredIndex;

public class Example {
    public static void main(String[] args) {
        try (TieredIndex index = new TieredIndex(3, Metric.COSINE)) {
            index.add(1, new float[] {0.9f, 0.1f, 0.0f});
            index.add(2, new float[] {0.0f, 1.0f, 0.0f});

            float[] query = {1.0f, 0.0f, 0.0f};
            Hit[] hits = index.search(query, 1, null);
            System.out.println(hits[0].id());

            index.delete(1);
            hits = index.search(query, 1, null);
            System.out.println(hits[0].id());
        }
    }
}

That prints 1, then 2. The next search finds a new vector at once, and after the delete it no longer returns it. An id is a long that the database chooses, such as its own record id. The third argument of search is a filter of allowed ids, and null allows them all.

Host contract

What the database gives, and what it gets.

The database keeps the records and owns transactions, persistence, and recovery. It hands tiervec ids, vectors, and filters of allowed ids.

tiervec keeps only state that it can rebuild from those records, and a committed vector is found by the next search. The host contract marks each of its lines as built, partly built, or planned.

Status

JVM, native image, and a Rust read pilot.

JVM. CI builds and tests it on JDK 21 and 25 on Linux x86-64, and runs the fast tests on Linux arm64, macOS arm64, and Windows x64.

Native image. It builds into a GraalVM native image. Smoke tests build and run an image on four platforms and compare every answer with an exact scan. They do not cover the segment files or concurrent writers, and no image is published.

Rust. A pilot in Rust reads the segment files that the Java library writes, and searches them. It is not published, and its API can change at any time (the pilot).

Not yet. No database engine runs it, no speed result is established, and there is no stable API before 1.0.