Skip to content

Commit c169d6d

Browse files
HNSW index: add set parameter method
1 parent db72a37 commit c169d6d

File tree

1 file changed

+27
-0
lines changed
  • objectbox-java/src/main/java/io/objectbox/query

1 file changed

+27
-0
lines changed

objectbox-java/src/main/java/io/objectbox/query/Query.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ native void nativeSetParameters(long handle, int entityId, int propertyId, @Null
114114
native void nativeSetParameter(long handle, int entityId, int propertyId, @Nullable String parameterAlias,
115115
byte[] value);
116116

117+
native void nativeSetParameter(long handle, int entityId, int propertyId, @Nullable String parameterAlias,
118+
float[] values);
119+
117120
final Box<T> box;
118121
private final BoxStore store;
119122
private final QueryPublisher<T> publisher;
@@ -792,6 +795,30 @@ public Query<T> setParameter(String alias, byte[] value) {
792795
return this;
793796
}
794797

798+
/**
799+
* Sets parameters previously given to {@link Property#nearestNeighborsF32(float[], int)}.
800+
*
801+
* @param property Property reference from generated entity underscore class, like {@code Example_.example}.
802+
*/
803+
public Query<T> setParametersNearestNeighborsF32(Property<?> property, float[] queryVector, int maxResultCount) {
804+
checkOpen();
805+
nativeSetParameter(handle, property.getEntityId(), property.getId(), null, queryVector);
806+
nativeSetParameter(handle, property.getEntityId(), property.getId(), null, maxResultCount);
807+
return this;
808+
}
809+
810+
/**
811+
* Sets parameters previously given to {@link Property#nearestNeighborsF32(float[], int)}.
812+
*
813+
* @param alias as defined using {@link PropertyQueryCondition#alias(String)}.
814+
*/
815+
public Query<T> setParametersNearestNeighborsF32(String alias, float[] queryVector, int maxResultCount) {
816+
checkOpen();
817+
nativeSetParameter(handle, 0, 0, alias, queryVector);
818+
nativeSetParameter(handle, 0, 0, alias, maxResultCount);
819+
return this;
820+
}
821+
795822
/**
796823
* Removes (deletes) all Objects matching the query
797824
*

0 commit comments

Comments
 (0)