43 Vector Types
To support arbitrary vector types, Coherence provides the
com.oracle.coherence.ai.Vector<T>
interface, with three built-in
implementations:
BitVector
, which internally uses ajava.util.Bitset
to represent each vector element using a single bit.Int8Vector
, which internally uses abyte[]
.Float32Vector
, which internally uses afloat[]
.
These types allow you to add a vector property to your own classes the same way that you would add any other property, by simply creating a field and accessors for it.
@PortableType(id = 2001) public class Book { @Portable private String isbn; @Portable private String title; @Portable private String author; @Portable private String summary; @Portable private Vector<float[]> summaryEmbedding; // constructors, getters and setters omitted }
In the preceding example, the summaryEmbedding
field is used
to store a vector representation of the summary field, so you can use vector similarity
to search book summaries.
In subsequent chapters, you'll see how you can use the
summaryEmbedding
property to define both standard and vector
indexes, and how to perform a similarity search against them.