Package com.oracle.coherence.ai
Class DocumentChunk
java.lang.Object
com.tangosol.io.AbstractEvolvable
com.oracle.coherence.ai.DocumentChunk
- All Implemented Interfaces:
Evolvable
,ExternalizableLite
,EvolvablePortableObject
,PortableObject
,Serializable
public final class DocumentChunk
extends AbstractEvolvable
implements EvolvablePortableObject, ExternalizableLite
A chunk of text extracted from a document.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for serialization.DocumentChunk
(String text) Create aDocumentChunk
.DocumentChunk
(String text, Vector<float[]> vector) Create aDocumentChunk
.DocumentChunk
(String text, Map<String, Object> metadata) Create aDocumentChunk
.Create aDocumentChunk
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
Determine the serialization version supported by the implementing class.int
hashCode()
static DocumentChunk.Id
Create anDocumentChunk.Id
.boolean
Returntrue
if this chunk has a vector embedding.metadata()
Returns the optional metadata associated with this document chunk.void
Restore the contents of a user type instance by reading its state using the specified PofReader object.void
Restore the contents of this object by loading the object's state from the passed DataInput object.setVector
(float[] vector) Set the float vector for this chunk.Set the float vector for this chunk.text()
Return the text chunk extracted from the document.toString()
Vector
<float[]> vector()
Get the float vector for this chunk.void
writeExternal
(PofWriter out) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.void
writeExternal
(DataOutput out) Save the contents of this object by storing the object's state into the passed DataOutput object.Methods inherited from class com.tangosol.io.AbstractEvolvable
getDataVersion, getFutureData, setDataVersion, setFutureData
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.tangosol.io.Evolvable
getDataVersion, getFutureData, setDataVersion, setFutureData
-
Field Details
-
IMPL_VERSION
public static final int IMPL_VERSIONThe POF implementation version.- See Also:
-
-
Constructor Details
-
DocumentChunk
public DocumentChunk()Default constructor for serialization. -
DocumentChunk
Create aDocumentChunk
.- Parameters:
text
- the chunk of text extracted from a document
-
DocumentChunk
Create aDocumentChunk
.- Parameters:
text
- the chunk of text extracted from a documentvector
- the vector associated with the document chunk
-
DocumentChunk
Create aDocumentChunk
.- Parameters:
text
- the chunk of text extracted from a documentmetadata
- optional document metadata
-
DocumentChunk
Create aDocumentChunk
.- Parameters:
text
- the chunk of text extracted from a documentmetadata
- optional document metadatavector
- the vector associated with the document chunk
-
-
Method Details
-
text
Return the text chunk extracted from the document.- Returns:
- the text chunk extracted from the document
-
metadata
Returns the optional metadata associated with this document chunk.- Returns:
- the optional metadata associated with this document chunk
-
isEmbedded
public boolean isEmbedded()Returntrue
if this chunk has a vector embedding.- Returns:
true
if this chunk has a vector embedding;false
otherwise
-
vector
Get the float vector for this chunk.- Returns:
- the float vector for this chunk
-
setVector
Set the float vector for this chunk.- Parameters:
vector
- the float vector for this chunk
-
setVector
Set the float vector for this chunk.- Parameters:
vector
- the float vector for this chunk
-
equals
-
hashCode
public int hashCode() -
toString
-
getImplVersion
public int getImplVersion()Description copied from class:AbstractEvolvable
Determine the serialization version supported by the implementing class.- Specified by:
getImplVersion
in interfaceEvolvable
- Specified by:
getImplVersion
in classAbstractEvolvable
- Returns:
- the serialization version supported by this object
-
readExternal
Description copied from interface:PortableObject
Restore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
readExternal
in interfacePortableObject
- Parameters:
in
- the PofReader from which to read the object's state- Throws:
IOException
- if an I/O error occurs
-
writeExternal
Description copied from interface:PortableObject
Save the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
writeExternal
in interfacePortableObject
- Parameters:
out
- the PofWriter to which to write the object's state- Throws:
IOException
- if an I/O error occurs
-
readExternal
Description copied from interface:ExternalizableLite
Restore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
readExternal
in interfaceExternalizableLite
- Parameters:
in
- the DataInput stream to read data from in order to restore the state of this object- Throws:
IOException
- if an I/O exception occurs
-
writeExternal
Description copied from interface:ExternalizableLite
Save the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
writeExternal
in interfaceExternalizableLite
- Parameters:
out
- the DataOutput stream to write the state of this object to- Throws:
IOException
- if an I/O exception occurs
-
id
Create anDocumentChunk.Id
.- Parameters:
sDocId
- the document identifiernIndex
- the chunk index- Returns:
- an
DocumentChunk.Id
with the specified document identifier and chunk index
-