Skip to content

Commit 2bd4134

Browse files
authored
feat: [2.4] support the mmap_enable param in the field schema (#2239)
- issue: milvus-io/milvus#35273 - pr: #2238 Signed-off-by: SimFG <[email protected]>
1 parent fda125f commit 2bd4134

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

pymilvus/bulk_writer/buffer.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,8 @@ def _persist_parquet(self, local_path: str, **kwargs):
267267
buffer_row_count = kwargs.get("buffer_row_count", 1)
268268
size_per_row = int(buffer_size / buffer_row_count) + 1
269269
row_group_size = int(row_group_bytes / size_per_row)
270-
if row_group_size < row_group_size_min:
271-
row_group_size = row_group_size_min
272-
if row_group_size > row_group_size_max:
273-
row_group_size = row_group_size_max
270+
row_group_size = max(row_group_size, row_group_size_min)
271+
row_group_size = min(row_group_size, row_group_size_max)
274272

275273
# write to Parquet file
276274
data_frame = pd.DataFrame(data=data)

pymilvus/client/abstract.py

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def __pack(self, raw: Any):
5252

5353
self.params[type_param.key] = json.loads(type_param.value)
5454
else:
55+
if type_param.key in ["mmap.enabled"]:
56+
self.params["mmap_enabled"] = (
57+
bool(type_param.value) if type_param.value.lower() != "false" else False
58+
)
59+
continue
5560
self.params[type_param.key] = type_param.value
5661
if type_param.key in ["dim"]:
5762
self.params[type_param.key] = int(type_param.value)

pymilvus/client/prepare.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ def get_schema_from_collection_schema(
130130
is_clustering_key=f.is_clustering_key,
131131
)
132132
for k, v in f.params.items():
133-
kv_pair = common_types.KeyValuePair(key=str(k), value=str(v))
133+
kv_pair = common_types.KeyValuePair(
134+
key=str(k) if k != "mmap_enabled" else "mmap.enabled", value=str(v)
135+
)
134136
field_schema.type_params.append(kv_pair)
135137

136138
schema.fields.append(field_schema)
@@ -187,7 +189,12 @@ def get_field_schema(
187189
type_params = field.get("params", {})
188190
if not isinstance(type_params, dict):
189191
raise ParamError(message="params should be dictionary type")
190-
kvs = [common_types.KeyValuePair(key=str(k), value=str(v)) for k, v in type_params.items()]
192+
kvs = [
193+
common_types.KeyValuePair(
194+
key=str(k) if k != "mmap_enabled" else "mmap.enabled", value=str(v)
195+
)
196+
for k, v in type_params.items()
197+
]
191198
field_schema.type_params.extend(kvs)
192199

193200
return field_schema, primary_field, auto_id_field

pymilvus/orm/iterator.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ def extend_batch_size(batch_size: int, next_param: dict, to_extend_batch_size: b
5151
extend_rate = DEFAULT_SEARCH_EXTENSION_RATE
5252
if EF in next_param[PARAMS]:
5353
real_batch = min(MAX_BATCH_SIZE, batch_size * extend_rate, next_param[PARAMS][EF])
54-
if next_param[PARAMS][EF] > real_batch:
55-
next_param[PARAMS][EF] = real_batch
54+
next_param[PARAMS][EF] = min(real_batch, next_param[PARAMS][EF])
5655
return real_batch
5756
return min(MAX_BATCH_SIZE, batch_size * extend_rate)
5857

pymilvus/orm/schema.py

+2
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ def __init__(self, name: str, dtype: DataType, description: str = "", **kwargs)
318318
self.is_partition_key = kwargs.get("is_partition_key", False)
319319
self.is_clustering_key = kwargs.get("is_clustering_key", False)
320320
self.element_type = kwargs.get("element_type", None)
321+
if "mmap_enabled" in kwargs:
322+
self._type_params["mmap_enabled"] = kwargs["mmap_enabled"]
321323
self._parse_type_params()
322324

323325
def __repr__(self) -> str:

0 commit comments

Comments
 (0)