Skip to content

Commit

Permalink
new: deepcopy new payload (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
joein authored May 21, 2024
1 parent 5cd966b commit c9f6543
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions qdrant_client/local/local_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,9 @@ def _scroll_by_value(

def _update_point(self, point: models.PointStruct) -> None:
idx = self.ids[point.id]
self.payload[idx] = to_jsonable_python(point.payload) if point.payload is not None else {}
self.payload[idx] = deepcopy(
to_jsonable_python(point.payload) if point.payload is not None else {}
)

if isinstance(point.vector, list):
vectors = {DEFAULT_VECTOR_NAME: point.vector}
Expand Down Expand Up @@ -1274,7 +1276,9 @@ def _add_point(self, point: models.PointStruct) -> None:
self.ids[point.id] = idx
self.ids_inv.append(point.id)

self.payload.append(to_jsonable_python(point.payload) if point.payload is not None else {})
self.payload.append(
deepcopy(to_jsonable_python(point.payload) if point.payload is not None else {})
)
assert len(self.payload) == len(self.ids_inv), "Payload and ids_inv must be the same size"
self.deleted = np.append(self.deleted, 0)

Expand Down Expand Up @@ -1506,7 +1510,7 @@ def set_payload(
key: Optional[str] = None,
) -> None:
ids = self._selector_to_ids(selector)
jsonable_payload = to_jsonable_python(payload)
jsonable_payload = deepcopy(to_jsonable_python(payload))

keys: Optional[List[JsonPathItem]] = parse_json_path(key) if key is not None else None

Expand All @@ -1533,7 +1537,7 @@ def overwrite_payload(
ids = self._selector_to_ids(selector)
for point_id in ids:
idx = self.ids[point_id]
self.payload[idx] = to_jsonable_python(payload) or {}
self.payload[idx] = deepcopy(to_jsonable_python(payload)) or {}
self._persist_by_id(point_id)

def delete_payload(
Expand Down

0 comments on commit c9f6543

Please sign in to comment.