Skip to content

Commit de9bfcf

Browse files
authored
fix: support List<Float> in vector index (#3090)
1 parent 9e964ef commit de9bfcf

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

engine/src/main/java/com/arcadedb/index/vector/ArcadePageVectorValues.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,16 @@ else if (vectorIndex != null)
232232
return null; // Property not found
233233
}
234234

235-
if (!(vectorObj instanceof float[] vector)) {
235+
float[] vector = null;
236+
if (vectorObj instanceof float[] f) {
237+
vector = f;
238+
} else if (vectorObj instanceof java.util.List<?> list) {
239+
vector = new float[list.size()];
240+
for (int i = 0; i < list.size(); i++)
241+
vector[i] = ((Number) list.get(i)).floatValue();
242+
} else {
236243
com.arcadedb.log.LogManager.instance().log(this, java.util.logging.Level.WARNING,
237-
"Vector property '%s' is not float[] (type=%s, RID=%s)",
244+
"Vector property '%s' is not float[] or List (type=%s, RID=%s)",
238245
vectorPropertyName, vectorObj.getClass().getName(), loc.rid);
239246
return null;
240247
}

engine/src/main/java/com/arcadedb/index/vector/LSMVectorIndex.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,15 @@ private void buildGraphFromScratchWithRetry(final GraphBuildCallback graphCallba
878878
if (record != null) {
879879
final com.arcadedb.database.Document doc = (com.arcadedb.database.Document) record;
880880
final Object vectorObj = doc.get(vectorProp);
881-
if (vectorObj instanceof float[] vector && vector.length == metadata.dimensions) {
881+
float[] vector = null;
882+
if (vectorObj instanceof float[] f) {
883+
vector = f;
884+
} else if (vectorObj instanceof java.util.List<?> list) {
885+
vector = new float[list.size()];
886+
for (int i = 0; i < list.size(); i++)
887+
vector[i] = ((Number) list.get(i)).floatValue();
888+
}
889+
if (vector != null && vector.length == metadata.dimensions) {
882890
// Validate vector is not all zeros (would cause NaN in cosine similarity)
883891
boolean hasNonZero = false;
884892
for (float v : vector) {

0 commit comments

Comments
 (0)