Zvec Logo

Open an Existing Collection

To open an existing collection, use the open() function to load it from disk.

The specified path must point to an existing Zvec collection. If no valid collection is found, open() will raise an error.

Usage

Open a collection
import zvec

existing_collection = zvec.open(  
    path="/path/to/my/collection",
    option=zvec.CollectionOption(read_only=False, enable_mmap=True),
)

Parameters

  • path:
    The filesystem path to the collection directory.
  • option:
    Runtime settings that control how the collection is accessed.
    • read_only:
      Opens the collection in read-only mode. Attempts to write will raise an error.

      Use read-only mode when sharing a collection across multiple processes — it ensures safe concurrent access without risking data corruption.

    • enable_mmap:
      Uses memory-mapped I/O for faster access (defaults to True). This trades slightly higher memory cache usage for improved performance.

On this page