Expand description
Oracle VECTOR wire codec (reference impl/base/vector.pyx).
A VECTOR value is serialized as a self-describing binary “image” that the
server stores/returns inside a LOB wrapper (see parse_vector_value /
write_vector_bind in thin.rs). This module is concerned only with the
image itself: the header, the element values, and the optional sparse
index list.
Image layout (all multi-byte integers are big-endian):
u8 magic byte (0xDB)
u8 version (0 base / 1 binary / 2 sparse)
u16 flags
u8 element format (2=f32, 3=f64, 4=int8, 5=binary)
u32 num_elements (for binary format: number of *bits*; for sparse:
the number of dimensions)
[8] reserved norm space (zero on write; skipped on read when a NORM
flag is set)
-- dense: num_elements values
-- sparse: u16 num_sparse_elements,
num_sparse_elements * u32 indices,
num_sparse_elements valuesThe codec is fail-closed: unknown magic bytes, versions, or element formats produce an error rather than a best-effort guess.
Enums§
- Vector
- A decoded VECTOR value: either dense (values only) or sparse (a dimension count plus parallel index/value arrays of the non-zero entries).
- Vector
Values - Decoded VECTOR element values, one variant per storage format.
Constants§
- TNS_
VECTOR_ FLAG_ NORM - VECTOR image flags (
TNS_VECTOR_FLAG_*). - TNS_
VECTOR_ FLAG_ NORM_ RESERVED - TNS_
VECTOR_ FLAG_ SPARSE - TNS_
VECTOR_ MAGIC_ BYTE - VECTOR image magic byte (
TNS_VECTOR_MAGIC_BYTE). - TNS_
VECTOR_ VERSION_ BASE - VECTOR image versions (
TNS_VECTOR_VERSION_*). - TNS_
VECTOR_ VERSION_ WITH_ BINARY - TNS_
VECTOR_ VERSION_ WITH_ SPARSE - VECTOR_
FORMAT_ BINARY - VECTOR_
FORMAT_ FLOA T32 - VECTOR element storage formats (
VECTOR_FORMAT_*). - VECTOR_
FORMAT_ FLOA T64 - VECTOR_
FORMAT_ INT8
Functions§
- decode_
vector - Decode a VECTOR image (the bytes carried inside the LOB wrapper).
- decode_
vector_ with_ limits - Decode a VECTOR image under the caller’s protocol resource policy.
- encode_
vector - Encode a VECTOR value into its image (the bytes that go inside the LOB
wrapper). Mirrors
VectorEncoder.encodeinvector.pyx. - write_
oson_ aq_ payload - Writes an OSON image as an AQ JSON payload (reference
write_osonwithwrite_length=False): a QLocator without the 1-byte chunk-length prefix, followed by the OSON bytes as_write_raw_bytes_and_length. - write_
vector_ image - Convenience for the bind path: a VECTOR image written inside the LOB
wrapper is the qlocator (40 bytes, data-length encoded) followed by the
raw image bytes-with-length. This helper writes just that pair given a
pre-encoded image, mirroring
write_vector->write_qlocator+_write_raw_bytes_and_lengthinpacket.pyx.