Repository navigation
Description
put() checks only the length of a vector (LSMVectorIndex.java#L8389), so an all-zero vector is stored without an error, but every read path then drops it as unscorable (ArcadePageVectorValues.java#L311, and the comment at LSMVectorIndex.java#L5991: "an all-zero one, is not something this index can score against"). That holds for COSINE, where the similarity of a zero vector is undefined, but the rule is applied to EUCLIDEAN too, where the origin has a well-defined distance: in the repro the record at [0, 0] is the nearest one to [0.01, 0.01] and is missing from a k = 10 answer over 5 records, with nothing logged about it at insert or at the graph build (which logs Building graph with 4 vectors for the 5 records). The search instead logs Graph search returned only 3 results (expected 4, available 4) ... falling back to brute-force scan (graph may need rebuilding) at WARNING.
The opposite holds for non-finite components: a vector with a NaN or an Infinity is accepted, indexed, and returned, with a distance of NaN, -Infinity, or 3.4028235E38. Under DOT_PRODUCT the [Infinity, 1] record is the first hit, at -Infinity; its dot product with any query whose first component is positive is +Infinity, so it comes first for every such query.
Repro
javac -cp 'lib/*' -d cls ZeroVectorNeverReturned.java
java -Xmx8g -XX:+UseCompactObjectHeaders --add-modules=jdk.incubator.vector --enable-native-access=ALL-UNNAMED -cp 'lib/*:cls' ZeroVectorNeverReturned /tmp/zero-db
lib/ holds the engine jar and its dependencies. On Temurin 21 the same command without -XX:+UseCompactObjectHeaders.
import com.arcadedb.database.*;
import com.arcadedb.query.sql.executor.*;
import java.util.*;
public class ZeroVectorNeverReturned {
public static void main(String[] args) {
DatabaseFactory factory = new DatabaseFactory(args[0]);
if (factory.exists())
factory.open().drop();
Database db = factory.create();
for (String similarity : List.of("EUCLIDEAN", "DOT_PRODUCT", "COSINE")) {
String type = "P" + similarity.charAt(0);
db.command("sql", "CREATE DOCUMENT TYPE " + type);
db.command("sql", "CREATE PROPERTY " + type + ".name STRING");
db.command("sql", "CREATE PROPERTY " + type + ".vector ARRAY_OF_FLOATS");
db.command("sql", "CREATE INDEX ON " + type + " (vector) LSM_VECTOR METADATA { \"dimensions\": 2, \"similarity\": \"" + similarity + "\" }");
db.transaction(() -> {
db.newDocument(type).set("name", "origin", "vector", new float[] { 0f, 0f }).save();
db.newDocument(type).set("name", "near", "vector", new float[] { 0.1f, 0.1f }).save();
db.newDocument(type).set("name", "far", "vector", new float[] { 3f, 4f }).save();
db.newDocument(type).set("name", "nan", "vector", new float[] { Float.NaN, 1f }).save();
db.newDocument(type).set("name", "inf", "vector", new float[] { Float.POSITIVE_INFINITY, 1f }).save();
});
float[] query = { 0.01f, 0.01f };
List<String> hits = new ArrayList<>();
ResultSet rs = db.query("sql", "SELECT name, distance FROM (SELECT expand(vectorNeighbors('" + type + "[vector]', ?, 10)))", query);
while (rs.hasNext()) {
Result r = rs.next();
hits.add(r.getProperty("name") + " " + r.getProperty("distance"));
}
System.out.println(similarity + ", 5 records, k = 10, query [0.01, 0.01]: " + hits);
}
db.close();
}
}Output on main at bda510bca0, embedded, identical on Temurin 25 (with compact object headers) and Temurin 21:
EUCLIDEAN, 5 records, k = 10, query [0.01, 0.01]: [near 0.016199946, far 24.860199, inf 3.4028235E38, nan 3.4028235E38]
DOT_PRODUCT, 5 records, k = 10, query [0.01, 0.01]: [inf -Infinity, far -0.535, near -0.501, nan NaN]
COSINE, 5 records, k = 10, query [0.01, 0.01]: [near 0.0, far 0.010050535, inf NaN, nan NaN]
Versions affected: main 417314c18 (2026-09-17) and 26.9.1 print the same three lines.
Also on main at 9319980f60 (2026-10-02, after #8947): the same output on Temurin 25 and Temurin 21.
Expected: under EUCLIDEAN, origin is the first hit (squared distance 0.0002), ahead of near. Whatever the rule for zero vectors under COSINE (and DOT_PRODUCT, which requires unit vectors), a vector the index will never return would better be rejected at put() with an error, as a wrong dimension is, rather than stored and silently left out of every answer; the same check could reject NaN and Infinity components, which no similarity can rank.
Activity
Merge pull request #8969 from ArcadeData/fix/8960-8961-8962-8963-vect…
lvca commentedon Oct 2, 2026
Confirmed and fixed in #8969 (26.10.1). A vector with a NaN or Infinity component is now rejected with an
IllegalArgumentExceptionon insert, and so is a NaN or Infinity query vector. UnderEUCLIDEANan all-zero vector is now indexed and returned (the origin is a valid point). UnderCOSINEandDOT_PRODUCTzero vectors are still accepted but not returned, since inserting a zero placeholder and updating it later is a common pattern and their similarity is undefined.❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.
Vector and unique index fixes: ArcadeData#8960 ArcadeData#8961 Arcade…
tae898 commentedon Oct 3, 2026
Verified on main at
66541f57d9(which carries the #8969 mergea556c94456and the #8971 merge66541f57d9) againstbda510bca0, the build this was filed on, with the issue's reproduction, on Temurin 25 with-XX:+UseCompactObjectHeadersand on Temurin 21, same results on both. The filed program now stops at its NaN insert, which is the fix, so I ran it with the three finite records in one transaction and the NaN and Infinity vectors each tried in its own:bda510bca066541f57d9[near, far, inf, nan](origin missing)[origin 0.0002, near, far][inf -Infinity, far, near, nan][far, near][near, far, inf, nan][near, far][NaN, 1]/[Infinity, 1]IllegalArgumentException: Vector components must be finite numbersUnder DOT_PRODUCT and COSINE the zero vector is accepted and not returned, as you describe for the placeholder pattern. The Python bindings suite is green on a wheel built with that engine. Thanks!
Vector and unique index fixes: #8960 #8961 #8962 #8963