feat: 支持以只读模式打开已有 zvec#12
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a readOnly configuration option to the Context and Store classes, allowing users to query existing .zvec files without mutating them or creating missing stores. In read-only mode, any write operations (such as load() or addDoc()) or attempts to open non-existent stores will throw an error. The feedback suggests wrapping the store cleanup in try...finally blocks within the new unit tests to ensure resources are always closed even if assertions fail.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
增加 readonly 是解决什么问题? 如果真的需要 readonly,应该是 ZevcOpen 调用的时候,传入 readonly 就可以,这样不用自己去做 throw。 |
|
验证对的,确实需要 readonly 模式,也验证了直接使用 zvec 的 readonly 效果一致,就不外置判断 readonly,自己 throw 了。 |
当前
Context在访问某个 library 时,如果对应的.zvec文件不存在,会自动创建新的 zvec 文件;同时load()会写入或更新向量数据。但在一些使用场景中,zvec 文件已经由构建流程、离线任务或其他服务提前生成,线上/消费端进程只需要查询,不应该
再创建或修改向量文件。
变更内容
ContextOptions.readOnly配置,用于声明当前 Context 只消费已有 zvecZVecOpen打开已有${library}.zvecload()和写入操作,避免运行时意外修改向量数据