Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleteIds Marked as deprecated #679

Merged
merged 1 commit into from
Oct 24, 2023
Merged
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 @@ -2974,7 +2974,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(>=2.3.2), 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 @@ -2107,6 +2107,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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public void delete() {
.withPrimaryIds(integers)
.build());
Assert.assertEquals(delete.getStatus().intValue(), R.Status.Success.getCode());
Assert.assertEquals(delete.getData().getDeleteIds().size(), integers.size());
}

@Severity(SeverityLevel.BLOCKER)
Expand Down Expand Up @@ -240,7 +239,6 @@ public void deleteVarcharPKData() {
.withPrimaryIds(pks)
.build());
Assert.assertEquals(delete.getStatus().intValue(), R.Status.Success.getCode());
Assert.assertEquals(delete.getData().getDeleteIds().size(), pks.size());
}


Expand Down