Package org.zvec.binding
Class Zvec
java.lang.Object
org.zvec.binding.Zvec
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 Summary
Modifier and TypeMethodDescriptionstatic booleancheckVersion(int major, int minor, int patch) static voidClear the last error status.static CollectioncreateAndOpen(String path, CollectionSchema schema, CollectionOptions options) Create a new collection at the given path and open it.static StringGet the process-wide default jieba dictionary directory.static StringHuman-readable description of the current I/O backend.static IoBackendTypeGet the I/O backend used for DiskAnn disk reads.static StringReturns the human-readable name of the given I/O backend type.static Stringstatic intstatic intstatic intstatic voidinitialize(ConfigData config) Initialize the Zvec library.static booleanReturns true if the library has been initialized.static booleanReturns true when a jieba dictionary source is configured: a process-wide default, theZVEC_JIEBA_DICT_DIRenvironment variable, or the dictionary bundled in this JAR.static Collectionopen(String path, CollectionOptions options) Open an existing collection.static voidSet the process-wide default jieba dictionary directory (a directory containingjieba.dict.utf8andhmm_model.utf8).static voidshutdown()Shutdown the Zvec library and release all global resources.static StringExtract the jieba dictionary files bundled in this JAR (underzvec/jieba_dict/) into a stable cache directory and register that directory as the process-wide default.
-
Method Details
-
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
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
Returns the human-readable name of the given I/O backend type. -
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
Set the process-wide default jieba dictionary directory (a directory containingjieba.dict.utf8andhmm_model.utf8). Per-fieldextra_params.jieba_dict_dirand theZVEC_JIEBA_DICT_DIRenvironment variable take precedence. -
getDefaultJiebaDictDir
Get the process-wide default jieba dictionary directory. -
useBundledJiebaDict
Extract the jieba dictionary files bundled in this JAR (underzvec/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, theZVEC_JIEBA_DICT_DIRenvironment variable, or the dictionary bundled in this JAR. -
initialize
Initialize the Zvec library. Passnullfor default config.When no jieba dictionary source is configured (neither in
config, nor viaZVEC_JIEBA_DICT_DIR, nor viasetDefaultJiebaDictDir(java.lang.String)), the dictionary bundled in the JAR is automatically extracted and registered so thejiebaFTS 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
Open an existing collection.
-