Skip to main content

Module vector

Module vector 

Source
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 values

The 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).
VectorValues
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_FLOAT32
VECTOR element storage formats (VECTOR_FORMAT_*).
VECTOR_FORMAT_FLOAT64
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.encode in vector.pyx.
write_oson_aq_payload
Writes an OSON image as an AQ JSON payload (reference write_oson with write_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_length in packet.pyx.