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

feat: support the mmap_enable param in the field schema #2238

Merged
merged 1 commit into from
Aug 27, 2024
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
5 changes: 5 additions & 0 deletions pymilvus/client/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def __pack(self, raw: Any):

self.params[type_param.key] = json.loads(type_param.value)
else:
if type_param.key in ["mmap.enabled"]:
self.params["mmap_enabled"] = (
bool(type_param.value) if type_param.value.lower() != "false" else False
)
continue
self.params[type_param.key] = type_param.value
if type_param.key in ["dim"]:
self.params[type_param.key] = int(type_param.value)
Expand Down
11 changes: 9 additions & 2 deletions pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def get_schema_from_collection_schema(
is_clustering_key=f.is_clustering_key,
)
for k, v in f.params.items():
kv_pair = common_types.KeyValuePair(key=str(k), value=str(v))
kv_pair = common_types.KeyValuePair(
key=str(k) if k != "mmap_enabled" else "mmap.enabled", value=str(v)
)
field_schema.type_params.append(kv_pair)

schema.fields.append(field_schema)
Expand Down Expand Up @@ -188,7 +190,12 @@ def get_field_schema(
type_params = field.get("params", {})
if not isinstance(type_params, dict):
raise ParamError(message="params should be dictionary type")
kvs = [common_types.KeyValuePair(key=str(k), value=str(v)) for k, v in type_params.items()]
kvs = [
common_types.KeyValuePair(
key=str(k) if k != "mmap_enabled" else "mmap.enabled", value=str(v)
)
for k, v in type_params.items()
]
field_schema.type_params.extend(kvs)

return field_schema, primary_field, auto_id_field
Expand Down
2 changes: 2 additions & 0 deletions pymilvus/orm/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ def __init__(self, name: str, dtype: DataType, description: str = "", **kwargs)
self.is_partition_key = kwargs.get("is_partition_key", False)
self.is_clustering_key = kwargs.get("is_clustering_key", False)
self.element_type = kwargs.get("element_type", None)
if "mmap_enabled" in kwargs:
self._type_params["mmap_enabled"] = kwargs["mmap_enabled"]
self._parse_type_params()

def __repr__(self) -> str:
Expand Down