Class Zvec

java.lang.Object
org.zvec.binding.Zvec

public final class Zvec extends Object
Top-level entry point for the Zvec Java binding.

Provides library lifecycle (initialize(org.zvec.binding.ConfigData), shutdown()), version information, and collection factory methods.

Typical usage:


 Zvec.initialize(null);
 try (Collection coll = Zvec.createAndOpen("/tmp/mydb", schema, null)) {
     // ...
 }
 Zvec.shutdown();
 
  • Method Details

    • getVersion

      public static String getVersion()
    • getVersionMajor

      public static int getVersionMajor()
    • getVersionMinor

      public static int getVersionMinor()
    • getVersionPatch

      public static int getVersionPatch()
    • checkVersion

      public static boolean checkVersion(int major, int minor, int patch)
    • getIoBackendType

      public static IoBackendType getIoBackendType()
      Get the I/O backend used for DiskAnn disk reads. On Linux zvec selects the first usable backend in this order: io_uring, libaio, pread; macOS uses pread.
    • getIoBackendTypeName

      public static String getIoBackendTypeName(IoBackendType type)
      Returns the human-readable name of the given I/O backend type.
    • getIoBackendDescription

      public static String getIoBackendDescription()
      Human-readable description of the current I/O backend. On Linux with the pread fallback it also explains how to enable an async backend.
    • setDefaultJiebaDictDir

      public static void setDefaultJiebaDictDir(String dir)
      Set the process-wide default jieba dictionary directory (a directory containing jieba.dict.utf8 and hmm_model.utf8). Per-field extra_params.jieba_dict_dir and the ZVEC_JIEBA_DICT_DIR environment variable take precedence.
    • getDefaultJiebaDictDir

      public static String getDefaultJiebaDictDir()
      Get the process-wide default jieba dictionary directory.
    • useBundledJiebaDict

      public static String useBundledJiebaDict()
      Extract the jieba dictionary files bundled in this JAR (under zvec/jieba_dict/) into a stable cache directory and register that directory as the process-wide default. Idempotent.
      Returns:
      the directory holding the dictionary files
      Throws:
      ZvecException - when the JAR does not bundle the dictionary
    • isJiebaDictAvailable

      public static boolean isJiebaDictAvailable()
      Returns true when a jieba dictionary source is configured: a process-wide default, the ZVEC_JIEBA_DICT_DIR environment variable, or the dictionary bundled in this JAR.
    • initialize

      public static void initialize(ConfigData config)
      Initialize the Zvec library. Pass null for default config.

      When no jieba dictionary source is configured (neither in config, nor via ZVEC_JIEBA_DICT_DIR, nor via setDefaultJiebaDictDir(java.lang.String)), the dictionary bundled in the JAR is automatically extracted and registered so the jieba FTS tokenizer works out of the box.

    • shutdown

      public static void shutdown()
      Shutdown the Zvec library and release all global resources.
    • isInitialized

      public static boolean isInitialized()
      Returns true if the library has been initialized.
    • clearError

      public static void clearError()
      Clear the last error status.
    • createAndOpen

      public static Collection createAndOpen(String path, CollectionSchema schema, CollectionOptions options)
      Create a new collection at the given path and open it.
    • open

      public static Collection open(String path, CollectionOptions options)
      Open an existing collection.