Package org.zvec.binding
Class Doc
java.lang.Object
org.zvec.binding.Doc
- All Implemented Interfaces:
AutoCloseable
High-level wrapper for
zvec_doc_t.
Documents are the fundamental unit of data. Each document has a primary key and a set of typed fields. Use the typed add/get methods for convenient access.
After close() every operation on this object throws a
ZvecException with ErrorCode.FAILED_PRECONDITION. The C API
treats a NULL document as a no-op, so without this guard a document
reused after being closed would silently discard writes instead of failing.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBinaryField(String name, byte[] data) Add a binary field.voidaddBoolField(String name, boolean value) voidaddDoubleField(String name, double value) voidaddFloatField(String name, float value) voidaddInt32Field(String name, int value) voidaddInt64Field(String name, long value) voidaddStringField(String name, String value) voidaddUint32Field(String name, long value) voidaddUint64Field(String name, long value) voidaddVectorFP32Field(String name, float[] vector) Add a float32 vector field.voidclear()voidclose()static Docdeserialize(byte[] data) voiddestroy()static voidFree a list of docs.byte[]getBinaryField(String name) Get a binary field.booleangetBoolField(String name) longgetDocID()doublegetDoubleField(String name) intfloatgetFloatField(String name) intgetInt32Field(String name) longgetInt64Field(String name) getPK()floatgetScore()getStringField(String name) longgetUint32Field(String name) longgetUint64Field(String name) float[]getVectorFP32Field(String name) Get a float32 vector field.booleanbooleanhasFieldValue(String name) booleanisEmpty()booleanisFieldNull(String name) booleanisOpen()Returnstruewhile the native handle is still usable.longvoidvoidremoveField(String name) byte[]voidsetDocID(long docID) voidsetFieldNull(String name) voidvoidvoidsetScore(float score)
-
Constructor Details
-
Doc
public Doc()
-
-
Method Details
-
isOpen
public boolean isOpen()Returnstruewhile the native handle is still usable. -
setPK
-
getPK
-
setDocID
public void setDocID(long docID) -
getDocID
public long getDocID() -
setScore
public void setScore(float score) -
getScore
public float getScore() -
setOperator
-
getOperator
-
getFieldCount
public int getFieldCount() -
isEmpty
public boolean isEmpty() -
clear
public void clear() -
hasField
-
hasFieldValue
-
isFieldNull
-
setFieldNull
-
removeField
-
getFieldNames
-
addStringField
-
addBoolField
-
addInt32Field
-
addInt64Field
-
addUint32Field
-
addUint64Field
-
addFloatField
-
addDoubleField
-
addVectorFP32Field
Add a float32 vector field. The data is copied into C-managed memory. -
addBinaryField
Add a binary field. -
getStringField
-
getBoolField
-
getInt32Field
-
getInt64Field
-
getUint32Field
-
getUint64Field
-
getFloatField
-
getDoubleField
-
getVectorFP32Field
Get a float32 vector field. Returns a copy of the underlying data. -
getBinaryField
Get a binary field. Returns a copy of the underlying data; the C API keeps ownership of the document-internal buffer. -
serialize
public byte[] serialize() -
deserialize
-
merge
-
memoryUsage
public long memoryUsage() -
toDetailString
-
destroy
public void destroy() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
freeDocs
Free a list of docs.
-