Skip to content

Commit 4c84d4f

Browse files
committed
fix(mol): complete MOL scalar readback support
Signed-off-by: xiejh <862103595@qq.com>
1 parent 97c76cd commit 4c84d4f

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

sdk-core/src/main/java/io/milvus/param/ParamUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,7 @@ public static ValueField objectToValueField(Object obj, DataType dataType) {
15621562
case String:
15631563
case Geometry:
15641564
case Timestamptz:
1565+
case Mol:
15651566
if (obj instanceof String) {
15661567
return builder.setStringData((String) obj).build();
15671568
}
@@ -1600,6 +1601,7 @@ public static Object valueFieldToObject(ValueField value, DataType dataType) {
16001601
case String:
16011602
case Geometry:
16021603
case Timestamptz:
1604+
case Mol:
16031605
return value.getStringData();
16041606
case JSON:
16051607
return JsonUtils.fromJson(value.getStringData(), JsonObject.class);

sdk-core/src/main/java/io/milvus/response/FieldDataWrapper.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ public long getRowCount() throws IllegalResponseException {
180180
return fieldData.getScalars().getStringData().getDataCount();
181181
case Geometry:
182182
return fieldData.getScalars().getGeometryWktData().getDataCount();
183+
case Mol:
184+
return fieldData.getScalars().getMolSmilesData().getDataCount();
183185
case JSON:
184186
return fieldData.getScalars().getJsonData().getDataCount();
185187
case Array:
@@ -254,6 +256,7 @@ private List<?> getFieldDataInternal() throws IllegalResponseException {
254256
case String:
255257
case Geometry:
256258
case Timestamptz:
259+
case Mol:
257260
case JSON:
258261
return getScalarData(dt, fieldData.getScalars(), fieldData.getValidDataList());
259262
case ArrayOfStruct:
@@ -357,6 +360,10 @@ private List<?> getScalarData(DataType dt, ScalarField scalar, List<Boolean> val
357360
ProtocolStringList protoGeoList = scalar.getGeometryWktData().getDataList();
358361
return setNoneData(protoGeoList.subList(0, protoGeoList.size()), validData);
359362
}
363+
case Mol: {
364+
ProtocolStringList protoMolList = scalar.getMolSmilesData().getDataList();
365+
return setNoneData(protoMolList.subList(0, protoMolList.size()), validData);
366+
}
360367
case JSON: {
361368
List<ByteString> dataList = scalar.getJsonData().getDataList();
362369
return dataList.stream().map(ByteString::toStringUtf8).collect(Collectors.toList());

sdk-core/src/main/java/io/milvus/v2/service/vector/request/InsertReq.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class InsertReq {
3030
* Sets the row data to insert. The rows list cannot be empty.
3131
* <p>
3232
* Internal class for insert data.
33-
* If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar/Geometry/Timestamptz, use JsonObject.addProperty(key, value) to input;
33+
* If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar/Geometry/Timestamptz/Mol, use JsonObject.addProperty(key, value) to input;
3434
* If dataType is FloatVector, use JsonObject.add(key, gson.toJsonTree(List[Float]) to input;
3535
* If dataType is BinaryVector/Float16Vector/BFloat16Vector/Int8Vector, use JsonObject.add(key, gson.toJsonTree(byte[])) to input;
3636
* If dataType is SparseFloatVector, use JsonObject.add(key, gson.toJsonTree(SortedMap[Long, Float])) to input;

sdk-core/src/main/java/io/milvus/v2/service/vector/request/UpsertReq.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class UpsertReq {
2828
* Sets the row data to insert. The rows list cannot be empty.
2929
* <p>
3030
* Internal class for insert data.
31-
* If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar/Geometry/Timestamptz, use JsonObject.addProperty(key, value) to input;
31+
* If dataType is Bool/Int8/Int16/Int32/Int64/Float/Double/Varchar/Geometry/Timestamptz/Mol, use JsonObject.addProperty(key, value) to input;
3232
* If dataType is FloatVector, use JsonObject.add(key, gson.toJsonTree(List[Float]) to input;
3333
* If dataType is BinaryVector/Float16Vector/BFloat16Vector, use JsonObject.add(key, gson.toJsonTree(byte[])) to input;
3434
* If dataType is SparseFloatVector, use JsonObject.add(key, gson.toJsonTree(SortedMap[Long, Float])) to input;

sdk-core/src/test/java/io/milvus/client/MilvusServiceClientTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,6 +2866,13 @@ void testFieldDataWrapper() {
28662866
}
28672867
testScalarField(ScalarField.newBuilder().setStringData(strBuilder).build(),
28682868
DataType.VarChar, dim);
2869+
2870+
MolSmilesArray.Builder molBuilder = MolSmilesArray.newBuilder();
2871+
for (long i = 0; i < dim; ++i) {
2872+
molBuilder.addData("C" + i);
2873+
}
2874+
testScalarField(ScalarField.newBuilder().setMolSmilesData(molBuilder).build(),
2875+
DataType.Mol, dim);
28692876
}
28702877

28712878
@Test

0 commit comments

Comments
 (0)