Skip to content

Commit

Permalink
Support delete with consistency level
Browse files Browse the repository at this point in the history
Signed-off-by: aoiasd <[email protected]>
  • Loading branch information
aoiasd committed Dec 27, 2023
1 parent 0266fd0 commit a342f8d
Show file tree
Hide file tree
Showing 10 changed files with 413 additions and 326 deletions.
7 changes: 6 additions & 1 deletion pymilvus/client/grpc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,12 @@ def delete(
):
check_pass_param(collection_name=collection_name)
try:
req = Prepare.delete_request(collection_name, partition_name, expression)
req = Prepare.delete_request(
collection_name,
partition_name,
expression,
consistency_level=kwargs.get("consistency_level", 0),
)
future = self._stub.Delete.future(req, timeout=timeout)

if kwargs.get("_async", False):
Expand Down
20 changes: 17 additions & 3 deletions pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@

from . import blob, entity_helper, ts_utils
from .check import check_pass_param, is_legal_collection_properties
from .constants import DEFAULT_CONSISTENCY_LEVEL, GROUP_BY_FIELD, REDUCE_STOP_FOR_BEST
from .constants import (
DEFAULT_CONSISTENCY_LEVEL,
GROUP_BY_FIELD,
REDUCE_STOP_FOR_BEST,
ConsistencyLevel,
)
from .types import DataType, PlaceholderType, get_consistency_level
from .utils import traverse_info, traverse_rows_info

Expand Down Expand Up @@ -535,7 +540,13 @@ def batch_upsert_param(
return cls._parse_batch_request(request, entities, fields_info, location)

@classmethod
def delete_request(cls, collection_name: str, partition_name: str, expr: str):
def delete_request(
cls,
collection_name: str,
partition_name: str,
expr: str,
consistency_level: ConsistencyLevel | str | None,
):
def check_str(instr: str, prefix: str):
if instr is None:
raise ParamError(message=f"{prefix} cannot be None")
Expand All @@ -550,7 +561,10 @@ def check_str(instr: str, prefix: str):
check_str(expr, "expr")

return milvus_types.DeleteRequest(
collection_name=collection_name, partition_name=partition_name, expr=expr
collection_name=collection_name,
partition_name=partition_name,
expr=expr,
consistency_level=consistency_level,
)

@classmethod
Expand Down
36 changes: 18 additions & 18 deletions pymilvus/grpc_gen/common_pb2.py

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions pymilvus/grpc_gen/common_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class MsgType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
DescribeIndex: _ClassVar[MsgType]
DropIndex: _ClassVar[MsgType]
GetIndexStatistics: _ClassVar[MsgType]
AlterIndex: _ClassVar[MsgType]
Insert: _ClassVar[MsgType]
Delete: _ClassVar[MsgType]
Flush: _ClassVar[MsgType]
Expand Down Expand Up @@ -278,6 +279,11 @@ class ObjectPrivilege(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
PrivilegeDropDatabase: _ClassVar[ObjectPrivilege]
PrivilegeListDatabases: _ClassVar[ObjectPrivilege]
PrivilegeFlushAll: _ClassVar[ObjectPrivilege]
PrivilegeCreatePartition: _ClassVar[ObjectPrivilege]
PrivilegeDropPartition: _ClassVar[ObjectPrivilege]
PrivilegeShowPartitions: _ClassVar[ObjectPrivilege]
PrivilegeHasPartition: _ClassVar[ObjectPrivilege]
PrivilegeGetFlushState: _ClassVar[ObjectPrivilege]

class StateCode(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = []
Expand Down Expand Up @@ -409,6 +415,7 @@ CreateIndex: MsgType
DescribeIndex: MsgType
DropIndex: MsgType
GetIndexStatistics: MsgType
AlterIndex: MsgType
Insert: MsgType
Delete: MsgType
Flush: MsgType
Expand Down Expand Up @@ -532,6 +539,11 @@ PrivilegeCreateDatabase: ObjectPrivilege
PrivilegeDropDatabase: ObjectPrivilege
PrivilegeListDatabases: ObjectPrivilege
PrivilegeFlushAll: ObjectPrivilege
PrivilegeCreatePartition: ObjectPrivilege
PrivilegeDropPartition: ObjectPrivilege
PrivilegeShowPartitions: ObjectPrivilege
PrivilegeHasPartition: ObjectPrivilege
PrivilegeGetFlushState: ObjectPrivilege
Initializing: StateCode
Healthy: StateCode
Abnormal: StateCode
Expand Down
602 changes: 308 additions & 294 deletions pymilvus/grpc_gen/milvus_pb2.py

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions pymilvus/grpc_gen/milvus_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -700,20 +700,22 @@ class MutationResult(_message.Message):
def __init__(self, status: _Optional[_Union[_common_pb2.Status, _Mapping]] = ..., IDs: _Optional[_Union[_schema_pb2.IDs, _Mapping]] = ..., succ_index: _Optional[_Iterable[int]] = ..., err_index: _Optional[_Iterable[int]] = ..., acknowledged: bool = ..., insert_cnt: _Optional[int] = ..., delete_cnt: _Optional[int] = ..., upsert_cnt: _Optional[int] = ..., timestamp: _Optional[int] = ...) -> None: ...

class DeleteRequest(_message.Message):
__slots__ = ["base", "db_name", "collection_name", "partition_name", "expr", "hash_keys"]
__slots__ = ["base", "db_name", "collection_name", "partition_name", "expr", "hash_keys", "consistency_level"]
BASE_FIELD_NUMBER: _ClassVar[int]
DB_NAME_FIELD_NUMBER: _ClassVar[int]
COLLECTION_NAME_FIELD_NUMBER: _ClassVar[int]
PARTITION_NAME_FIELD_NUMBER: _ClassVar[int]
EXPR_FIELD_NUMBER: _ClassVar[int]
HASH_KEYS_FIELD_NUMBER: _ClassVar[int]
CONSISTENCY_LEVEL_FIELD_NUMBER: _ClassVar[int]
base: _common_pb2.MsgBase
db_name: str
collection_name: str
partition_name: str
expr: str
hash_keys: _containers.RepeatedScalarFieldContainer[int]
def __init__(self, base: _Optional[_Union[_common_pb2.MsgBase, _Mapping]] = ..., db_name: _Optional[str] = ..., collection_name: _Optional[str] = ..., partition_name: _Optional[str] = ..., expr: _Optional[str] = ..., hash_keys: _Optional[_Iterable[int]] = ...) -> None: ...
consistency_level: _common_pb2.ConsistencyLevel
def __init__(self, base: _Optional[_Union[_common_pb2.MsgBase, _Mapping]] = ..., db_name: _Optional[str] = ..., collection_name: _Optional[str] = ..., partition_name: _Optional[str] = ..., expr: _Optional[str] = ..., hash_keys: _Optional[_Iterable[int]] = ..., consistency_level: _Optional[_Union[_common_pb2.ConsistencyLevel, str]] = ...) -> None: ...

class SearchRequest(_message.Message):
__slots__ = ["base", "db_name", "collection_name", "partition_names", "dsl", "placeholder_group", "dsl_type", "output_fields", "search_params", "travel_timestamp", "guarantee_timestamp", "nq", "not_return_all_meta", "consistency_level", "use_default_consistency", "search_by_primary_keys"]
Expand Down Expand Up @@ -1212,22 +1214,24 @@ class GetFlushAllStateResponse(_message.Message):
def __init__(self, status: _Optional[_Union[_common_pb2.Status, _Mapping]] = ..., flushed: bool = ...) -> None: ...

class ImportRequest(_message.Message):
__slots__ = ["collection_name", "partition_name", "channel_names", "row_based", "files", "options", "db_name"]
__slots__ = ["collection_name", "partition_name", "channel_names", "row_based", "files", "options", "db_name", "clustering_info"]
COLLECTION_NAME_FIELD_NUMBER: _ClassVar[int]
PARTITION_NAME_FIELD_NUMBER: _ClassVar[int]
CHANNEL_NAMES_FIELD_NUMBER: _ClassVar[int]
ROW_BASED_FIELD_NUMBER: _ClassVar[int]
FILES_FIELD_NUMBER: _ClassVar[int]
OPTIONS_FIELD_NUMBER: _ClassVar[int]
DB_NAME_FIELD_NUMBER: _ClassVar[int]
CLUSTERING_INFO_FIELD_NUMBER: _ClassVar[int]
collection_name: str
partition_name: str
channel_names: _containers.RepeatedScalarFieldContainer[str]
row_based: bool
files: _containers.RepeatedScalarFieldContainer[str]
options: _containers.RepeatedCompositeFieldContainer[_common_pb2.KeyValuePair]
db_name: str
def __init__(self, collection_name: _Optional[str] = ..., partition_name: _Optional[str] = ..., channel_names: _Optional[_Iterable[str]] = ..., row_based: bool = ..., files: _Optional[_Iterable[str]] = ..., options: _Optional[_Iterable[_Union[_common_pb2.KeyValuePair, _Mapping]]] = ..., db_name: _Optional[str] = ...) -> None: ...
clustering_info: bytes
def __init__(self, collection_name: _Optional[str] = ..., partition_name: _Optional[str] = ..., channel_names: _Optional[_Iterable[str]] = ..., row_based: bool = ..., files: _Optional[_Iterable[str]] = ..., options: _Optional[_Iterable[_Union[_common_pb2.KeyValuePair, _Mapping]]] = ..., db_name: _Optional[str] = ..., clustering_info: _Optional[bytes] = ...) -> None: ...

class ImportResponse(_message.Message):
__slots__ = ["status", "tasks"]
Expand Down
Loading

0 comments on commit a342f8d

Please sign in to comment.