Skip to content

Commit

Permalink
Signed-off-by: lentitude2tk <[email protected]>
Browse files Browse the repository at this point in the history
deleteIds Marked as deprecated
  • Loading branch information
lentitude2tk committed Oct 24, 2023
1 parent 1c7d102 commit b73483a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2883,7 +2883,7 @@ public R<DeleteResponse> delete(DeleteIdsParam requestParam) {
.build();
R<MutationResult> resultR = delete(deleteParam);
MutationResultWrapper resultWrapper = new MutationResultWrapper(resultR.getData());
return R.success(DeleteResponse.builder().deleteIds(resultWrapper.getInsertIDs()).build());
return R.success(DeleteResponse.builder().deleteIds(resultWrapper.getDeleteIDs()).build());
} catch (StatusRuntimeException e) {
logError("Delete RPC failed! Collection name:{}",
requestParam.getCollectionName(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@
@Getter
@ToString
public class DeleteResponse {
/**
* In the new version, this method only returns an empty list and does not return specific values
* Mark is as deprecated, keep it to compatible with the legacy code
*/
@Deprecated
public List<?> deleteIds;
}
16 changes: 16 additions & 0 deletions src/main/java/io/milvus/response/MutationResultWrapper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.milvus.response;

import com.google.common.collect.Lists;
import io.milvus.exception.ParamException;
import io.milvus.grpc.MutationResult;

Expand Down Expand Up @@ -70,6 +71,21 @@ public List<?> getInsertIDs() {
}
}

/**
* Gets the ID array from returned by delete interface.
*
* @return List of Ids, ID array returned by delete interface
*/
public List<?> getDeleteIDs() {
if (result.getIDs().hasIntId()) {
return result.getIDs().getIntId().getDataList();
} else if (result.getIDs().hasStrId()) {
return result.getIDs().getStrId().getDataList();
} else {
return Lists.newArrayList();
}
}

/**
* Gets the row count of the deleted entities. Currently, this value is always equal to input row count
*
Expand Down
1 change: 0 additions & 1 deletion src/test/java/io/milvus/client/MilvusClientDockerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,5 @@ private static void testHighLevelDelete(String collectionName, List primaryIds)
String outPutStr = String.format("collectionName:%s, primaryIds:%s, deleteResponseR:%s", collectionName, primaryIds, deleteResponseR);
System.out.println(outPutStr);
Assertions.assertEquals(R.Status.Success.getCode(), deleteResponseR.getStatus().intValue());
Assertions.assertEquals(primaryIds.size(), deleteResponseR.getData().getDeleteIds().size());
}
}

0 comments on commit b73483a

Please sign in to comment.