qdrant-client icon indicating copy to clipboard operation
qdrant-client copied to clipboard

Local qdrant client should return deepcopy of Payloads

Open hv0905 opened this issue 1 year ago • 1 comments

Currently, there's a discrepancy in behavior between the local and remote Qdrant clients regarding the payloads returned by search or scroll operations.

Problem: In the local Qdrant client, whether using in-memory storage or local files, the payload returned by search or scroll operations is the original copy. Consequently, any edits made to this payload affect the corresponding data in the database directly, without necessitating a call to set_payload.

However, the behavior is different in the remote Qdrant client. Each payload returned by a search operation is a fresh copy. Modifications to this payload do not impact the corresponding data in the database unless set_payload is called to explicitly update the new payload.

Proposal: To align the behavior of the local Qdrant client with that of the remote client and ensure consistency across both, I propose modifying the local client to return a deepcopy of the payload when querying. This approach will maintain the expected behavior where modifications to the returned payload do not directly affect the data in the database unless set_payload is invoked.

Implementation: Introduce a deepcopy mechanism within the local Qdrant client's search and scroll functions to ensure that a new copy of the payload is returned for each query. This would involve utilizing Python's copy.deepcopy() method or a similar mechanism to create a deep copy of the payload object before returning it to the caller.

Expected Outcome: By implementing this modification, users of the local Qdrant client will experience behavior consistent with the remote client. This change will enhance the predictability and reliability of interactions with Qdrant across different client environments.

hv0905 avatar May 10 '24 07:05 hv0905

makes sense! Thanks for pointing out!

generall avatar May 10 '24 08:05 generall