Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,20 @@ public VectorScoreScript(Map<String, Object> params) {

// get query inputVector - convert to primitive
final Object vector = params.get("vector");
if(vector != null) {
final ArrayList<Double> tmp = (ArrayList<Double>) vector;
inputVector = new double[tmp.size()];
for (int i = 0; i < inputVector.length; i++) {
inputVector[i] = tmp.get(i);
}
if (vector != null) {
final ArrayList<Object> tmp = (ArrayList<Object>) vector;
inputVector = new double[tmp.size()];
for (int i = 0; i < inputVector.length; i++) {
Object obj = tmp.get(i);
if (obj instanceof Double) {
inputVector[i] = ((Double)obj).doubleValue();
} else if (obj instanceof Integer) {
inputVector[i] = ((Integer)obj).doubleValue();
} else {
throw new IllegalArgumentException("Cannot convert vector to double array");
}
}

} else {
final Object encodedVector = params.get("encoded_vector");
if(encodedVector == null) {
Expand Down Expand Up @@ -190,4 +198,4 @@ public final Object run() {
}
}

}
}