Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion java/src/main/java/com/genexus/db/GXEmbedding.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public GXEmbedding(String model, int dimensions) {
public GXEmbedding(Float[] embedding, String model, int dimensions) {
this.model = model;
this.dimensions = dimensions;
this.embedding = Arrays.asList(embedding);
if (embedding == null)
this.embedding = new ArrayList<>(Collections.nCopies(dimensions, 0.0f));
else
this.embedding = Arrays.asList(embedding);
}

public GXEmbedding(List<Float> embedding) {
Expand Down
18 changes: 14 additions & 4 deletions java/src/main/java/com/genexus/db/driver/GXResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,20 @@ public Float[] getGxembedding (int columnIndex) throws SQLException
if (DEBUG )
log(GXDBDebug.LOG_MAX, "Warning: getEmbedding");

if (con.getDBMS().getId() == GXDBMS.DBMS_POSTGRESQL)
return convertVectorStringToFloatArray(result.getArray(columnIndex).toString());
else
return byteArrayToFloatObjectArray(result.getBytes(columnIndex));
if (con.getDBMS().getId() == GXDBMS.DBMS_POSTGRESQL) {
Object array = result.getArray(columnIndex);
if (array == null)
return null;
else
return convertVectorStringToFloatArray(array.toString());
}
else {
byte[] bytes = result.getBytes(columnIndex);
if (bytes == null)
return null;
else
return byteArrayToFloatObjectArray(bytes);
}
}

private static Float[] byteArrayToFloatObjectArray(byte[] bytes) {
Expand Down
Loading