Skip to content

Commit

Permalink
feat: support the mmap_enable param in the field schema
Browse files Browse the repository at this point in the history
Signed-off-by: SimFG <[email protected]>
  • Loading branch information
SimFG committed Aug 27, 2024
1 parent 42a66f1 commit baf050e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pymilvus/client/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ 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
4 changes: 3 additions & 1 deletion pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def get_schema_from_collection_schema(
is_clustering_key=f.is_clustering_key,
)
for k, v in f.params.items():
if k == "mmap_enabled":
k = "mmap.enabled"
kv_pair = common_types.KeyValuePair(key=str(k), value=str(v))
field_schema.type_params.append(kv_pair)

Expand Down Expand Up @@ -188,7 +190,7 @@ 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

0 comments on commit baf050e

Please sign in to comment.