Class SparseVector
java.lang.Object
com.mcpdbwizard.pub.SparseVector
A sparse Oracle
VECTOR value (23ai): a high-dimensional vector stored as its non-zero
entries only. Distinct from a dense VECTOR (read/written as double[]) and a binary
VECTOR (read/written as byte[]) — a sparse vector of a million dimensions with a
handful of non-zeros must NOT be densified to a million-element array, so it carries its own
{length, indices, values} shape.
length— the total number of dimensions.indices— the positions (0-based, ascending) of the non-zero entries.values— the non-zero values;values[k]lives atindices[k].
Read from a sparse column/param via ReadOnlyRowSet.getVectorSparse(String); written via
WriteableRowSet.setVectorSparse(String, SparseVector) /
StatementParameters2.setVectorSparseParam. The value carries only double magnitudes
— it binds as a FLOAT64 sparse vector and Oracle coerces to the column/param element format
(a FLOAT32 column keeps the value; an INT8 column rounds, as it must).
Fields are public to match the field-visibility JSON mapping the generated MCP server uses, so a
sparse vector round-trips as a {"length":…, "indices":[…], "values":[…]} object with no
extra mapping.
Requires ojdbc 23.26+ (the sparse oracle.sql.VECTOR accessors); earlier drivers cannot
read or write sparse vectors.
- Since:
- Oracle 23ai Copyright 2003-2026 ATB Consultancy Services Ltd (formerly Orinda Software Ltd, Dublin, Ireland)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNo-arg constructor (for the JSON mapper).SparseVector(int length, int[] indices, double[] values) -
Method Summary
Modifier and TypeMethodDescriptionstatic SparseVectorfromVector(oracle.sql.VECTOR theVector) Build aSparseVectorfrom a sparseoracle.sql.VECTOR(itstoSparseDoubleArray()view).double[]toString()oracle.sql.VECTORtoVector()Turn this value into a bindableoracle.sql.VECTOR(a FLOAT64 sparse vector — Oracle coerces to the target column/param element format).
-
Field Details
-
length
public int lengthTotal number of dimensions. -
indices
public int[] indicesPositions (0-based, ascending) of the non-zero entries. -
values
public double[] valuesThe non-zero values;values[k]lives atindices[k].
-
-
Constructor Details
-
SparseVector
public SparseVector()No-arg constructor (for the JSON mapper). -
SparseVector
public SparseVector(int length, int[] indices, double[] values)
-
-
Method Details
-
fromVector
Build aSparseVectorfrom a sparseoracle.sql.VECTOR(itstoSparseDoubleArray()view). Returnsnullfor anullinput.- Throws:
SQLException- if the VECTOR cannot be read as a sparse double array
-
toVector
Turn this value into a bindableoracle.sql.VECTOR(a FLOAT64 sparse vector — Oracle coerces to the target column/param element format).- Throws:
SQLException- if the sparse vector cannot be constructed
-
toDenseArray
-
toString
-