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 2fa1b74
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
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

0 comments on commit 2fa1b74

Please sign in to comment.