Class Collection
- All Implemented Interfaces:
AutoCloseable
zvec_collection_t.
Obtain via Zvec.createAndOpen(java.lang.String, org.zvec.binding.CollectionSchema, org.zvec.binding.CollectionOptions) or Zvec.open(java.lang.String, org.zvec.binding.CollectionOptions).
Always call close() when done.
After close() every operation on this object throws a
ZvecException with ErrorCode.FAILED_PRECONDITION instead of
passing a released handle into the native layer.
close() and destroy() are safe to call from any thread
and are idempotent. The operations themselves are not synchronized: the
native collection is safe to use from several threads, but a caller must not
use a collection concurrently with closing it.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPer-document write result.static classWrite result aggregate counts. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddColumn(FieldSchema fieldSchema, String defaultExpr) voidalterColumn(String columnName, String newName, FieldSchema newSchema) voidclose()Close the collection.voidcreateIndex(String fieldName, IndexParams params) createIterator(IteratorOptions options) Create a snapshot document iterator over this collection.voiddeleteByFilter(String filter) voiddestroy()Destroy collection data on disk AND close the handle.voiddropColumn(String columnName) voidFetch documents by primary key.voidflush()Get the collection options.Get the collection schema.getStats()Get collection statistics.booleanisOpen()Returnstruewhile the native handle is still usable.voidoptimize()query(MultiQuery query) Execute a multi-query (e.g., vector + FTS fusion).query(VectorQuery query) Execute a vector query.
-
Method Details
-
isOpen
public boolean isOpen()Returnstruewhile the native handle is still usable. -
close
public void close()Close the collection. Safe to call multiple times and from any thread.- Specified by:
closein interfaceAutoCloseable
-
destroy
public void destroy()Destroy collection data on disk AND close the handle. -
flush
public void flush() -
optimize
public void optimize() -
getSchema
Get the collection schema. Caller must destroy the returned schema. -
getOptions
Get the collection options. Caller must destroy the returned options. -
getStats
Get collection statistics. The C stats pointer is consumed internally. -
createIndex
-
dropIndex
-
addColumn
-
dropColumn
-
alterColumn
-
insert
-
update
-
upsert
-
delete
-
deleteByFilter
-
query
Execute a vector query. Returns a list of owned Docs; caller must free them. -
query
Execute a multi-query (e.g., vector + FTS fusion). Returns a list of owned Docs. -
fetch
Fetch documents by primary key. Returns a list of owned Docs; caller must free them. -
createIterator
Create a snapshot document iterator over this collection.The iterator sees an isolated snapshot taken at call time. While any iterator is open, schema changes (create/drop index, add/alter/drop column) and
destroy()return an error; close every iterator before releasing the last collection handle.- Parameters:
options- iterator options, ornullfor defaults (all fields, vectors included)
-