Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public enum FunctionType {
UNKNOWN("Unknown", 0), // in milvus-proto, the name is "Unknown"
BM25("BM25", 1), // Added missing name parameter
TEXTEMBEDDING("TextEmbedding", 2), // in milvus-proto, the name is "TextEmbedding"
RERANK("RERANK", 3); // Added missing name parameter
RERANK("RERANK", 3), // Added missing name parameter
MOL_FINGERPRINT("MolFingerprint", 5);

private final String name;
private final int code;
Expand Down
4 changes: 4 additions & 0 deletions sdk-core/src/main/java/io/milvus/param/IndexType.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public enum IndexType {

// Only for varchar type field
TRIE("Trie", 100),
// Only for geometry type field
RTREE(120),
// Only for mol type field
PATTERN(121),
// Only for scalar type field
STL_SORT(200), // only for numeric type field
INVERTED(201), // works for all scalar fields except JSON type field
Expand Down
9 changes: 9 additions & 0 deletions sdk-core/src/main/java/io/milvus/param/ParamUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ public static void checkFieldData(FieldType fieldSchema, List<?> values, boolean
case String:
case Geometry:
case Timestamptz:
case Mol:
for (Object value : values) {
if (checkNullableFieldData(fieldSchema, value, verifyElementType)) {
continue;
Expand Down Expand Up @@ -423,6 +424,7 @@ public static Object checkFieldValue(String fieldName, DataType dataType, DataTy
case String:
case Geometry:
case Timestamptz:
case Mol:
if (!(value.isJsonPrimitive())) {
throw new ParamException(String.format(errMsgs.get(dataType), fieldName));
}
Expand Down Expand Up @@ -1414,6 +1416,11 @@ public static ScalarField genScalarField(DataType dataType, DataType elementType
GeometryWktArray wktArray = GeometryWktArray.newBuilder().addAllData(strings).build();
return ScalarField.newBuilder().setGeometryWktData(wktArray).build();
}
case Mol: {
List<String> strings = objects.stream().map(p -> (p == null) ? null : (String) p).collect(Collectors.toList());
MolSmilesArray smilesArray = MolSmilesArray.newBuilder().addAllData(strings).build();
return ScalarField.newBuilder().setMolSmilesData(smilesArray).build();
}
case JSON: {
List<ByteString> byteStrings = objects.stream().map(p -> (p == null) ? null : ByteString.copyFromUtf8(p.toString()))
.collect(Collectors.toList());
Expand Down Expand Up @@ -1555,6 +1562,7 @@ public static ValueField objectToValueField(Object obj, DataType dataType) {
case String:
case Geometry:
case Timestamptz:
case Mol:
if (obj instanceof String) {
return builder.setStringData((String) obj).build();
}
Expand Down Expand Up @@ -1593,6 +1601,7 @@ public static Object valueFieldToObject(ValueField value, DataType dataType) {
case String:
case Geometry:
case Timestamptz:
case Mol:
return value.getStringData();
case JSON:
return JsonUtils.fromJson(value.getStringData(), JsonObject.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ public long getRowCount() throws IllegalResponseException {
return fieldData.getScalars().getStringData().getDataCount();
case Geometry:
return fieldData.getScalars().getGeometryWktData().getDataCount();
case Mol:
return fieldData.getScalars().getMolSmilesData().getDataCount();
case JSON:
return fieldData.getScalars().getJsonData().getDataCount();
case Array:
Expand Down Expand Up @@ -254,6 +256,7 @@ private List<?> getFieldDataInternal() throws IllegalResponseException {
case String:
case Geometry:
case Timestamptz:
case Mol:
case JSON:
return getScalarData(dt, fieldData.getScalars(), fieldData.getValidDataList());
case ArrayOfStruct:
Expand Down Expand Up @@ -357,6 +360,10 @@ private List<?> getScalarData(DataType dt, ScalarField scalar, List<Boolean> val
ProtocolStringList protoGeoList = scalar.getGeometryWktData().getDataList();
return setNoneData(protoGeoList.subList(0, protoGeoList.size()), validData);
}
case Mol: {
ProtocolStringList protoMolList = scalar.getMolSmilesData().getDataList();
return setNoneData(protoMolList.subList(0, protoMolList.size()), validData);
}
case JSON: {
List<ByteString> dataList = scalar.getJsonData().getDataList();
return dataList.stream().map(ByteString::toStringUtf8).collect(Collectors.toList());
Expand Down
1 change: 1 addition & 0 deletions sdk-core/src/main/java/io/milvus/v2/common/DataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public enum DataType {
JSON(23),
Geometry(24),
Timestamptz(26),
Mol(27),

BinaryVector(100),
FloatVector(101),
Expand Down
2 changes: 2 additions & 0 deletions sdk-core/src/main/java/io/milvus/v2/common/IndexParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ public enum IndexType {

// Only for geometry type field
RTREE(120),
// Only for mol type field
PATTERN(121),

// Only for scalar type field
STL_SORT(200), // only for numeric type field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class InsertReq {
* Sets the row data to insert. The rows list cannot be empty.
* <p>
* Internal class for insert data.
* If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar/Geometry/Timestamptz, use JsonObject.addProperty(key, value) to input;
* If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar/Geometry/Timestamptz/Mol, use JsonObject.addProperty(key, value) to input;
* If dataType is FloatVector, use JsonObject.add(key, gson.toJsonTree(List[Float]) to input;
* If dataType is BinaryVector/Float16Vector/BFloat16Vector/Int8Vector, use JsonObject.add(key, gson.toJsonTree(byte[])) to input;
* If dataType is SparseFloatVector, use JsonObject.add(key, gson.toJsonTree(SortedMap[Long, Float])) to input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class UpsertReq {
* Sets the row data to insert. The rows list cannot be empty.
* <p>
* Internal class for insert data.
* If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar/Geometry/Timestamptz, use JsonObject.addProperty(key, value) to input;
* If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar/Geometry/Timestamptz/Mol, use JsonObject.addProperty(key, value) to input;
* If dataType is FloatVector, use JsonObject.add(key, gson.toJsonTree(List[Float]) to input;
* If dataType is BinaryVector/Float16Vector/BFloat16Vector, use JsonObject.add(key, gson.toJsonTree(byte[])) to input;
* If dataType is SparseFloatVector, use JsonObject.add(key, gson.toJsonTree(SortedMap[Long, Float])) to input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2866,6 +2866,13 @@ void testFieldDataWrapper() {
}
testScalarField(ScalarField.newBuilder().setStringData(strBuilder).build(),
DataType.VarChar, dim);

MolSmilesArray.Builder molBuilder = MolSmilesArray.newBuilder();
for (long i = 0; i < dim; ++i) {
molBuilder.addData("C" + i);
}
testScalarField(ScalarField.newBuilder().setMolSmilesData(molBuilder).build(),
DataType.Mol, dim);
}

@Test
Expand Down
Loading