
    ,h                        S SK Jr  S SKrS SKJr  S SKJr  S SKJr  S SK	J
r
  S SK	Jr   " S S\5      r " S	 S
\5      r " S S\5      r\ " S S5      5       r " S S\
R                   5      rg)    )annotationsN)	dataclass)Enum)Optional)Floatc                  "    \ rS rSrSrSr SrSrg)VectorIndexType   zEnum representing different types of VECTOR index structures.

See :ref:`oracle_vector_datatype` for background.

.. versionadded:: 2.0.41

HNSWIVF N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__r       Y/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/dialects/oracle/vector.pyr	   r	      s     D Cr   r	   c                  .    \ rS rSrSrSr Sr Sr SrSr	g)	VectorDistanceType(   zEnum representing different types of vector distance metrics.

See :ref:`oracle_vector_datatype` for background.

.. versionadded:: 2.0.41

	EUCLIDEANDOTCOSINE	MANHATTANr   N)
r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   (   s7     I C F Ir   r   c                  .    \ rS rSrSrSr Sr Sr SrSr	g)	VectorStorageFormatG   zEnum representing the data format used to store vector components.

See :ref:`oracle_vector_datatype` for background.

.. versionadded:: 2.0.41

INT8BINARYFLOAT32FLOAT64r   N)
r   r   r   r   r   r    r!   r"   r#   r   r   r   r   r   r   G   s7     D F G Gr   r   c                      \ rS rSr% Sr\R                  rS\S'   Sr	S\S'   Sr
S\S	'   SrS\S
'   SrS\S'   SrS\S'   SrS\S'   SrS\S'   SrS\S'   S rSrg)VectorIndexConfigb   a8  Define the configuration for Oracle VECTOR Index.

See :ref:`oracle_vector_datatype` for background.

.. versionadded:: 2.0.41

:param index_type: Enum value from :class:`.VectorIndexType`
 Specifies the indexing method. For HNSW, this must be
 :attr:`.VectorIndexType.HNSW`.

:param distance: Enum value from :class:`.VectorDistanceType`
 specifies the metric for calculating distance between VECTORS.

:param accuracy: interger. Should be in the range 0 to 100
 Specifies the accuracy of the nearest neighbor search during
 query execution.

:param parallel: integer. Specifies degree of parallelism.

:param hnsw_neighbors: interger. Should be in the range 0 to
 2048. Specifies the number of nearest neighbors considered
 during the search. The attribute :attr:`.VectorIndexConfig.hnsw_neighbors`
 is HNSW index specific.

:param hnsw_efconstruction: integer. Should be in the range 0
 to 65535. Controls the trade-off between indexing speed and
 recall quality during index construction. The attribute
 :attr:`.VectorIndexConfig.hnsw_efconstruction` is HNSW index
 specific.

:param ivf_neighbor_partitions: integer. Should be in the range
 0 to 10,000,000. Specifies the number of partitions used to
 divide the dataset. The attribute
 :attr:`.VectorIndexConfig.ivf_neighbor_partitions` is IVF index
 specific.

:param ivf_sample_per_partition: integer. Should be between 1
 and ``num_vectors / neighbor partitions``. Specifies the
 number of samples used per partition. The attribute
 :attr:`.VectorIndexConfig.ivf_sample_per_partition` is IVF index
 specific.

:param ivf_min_vectors_per_partition: integer. From 0 (no trimming)
 to the total number of vectors (results in 1 partition). Specifies
 the minimum number of vectors per partition. The attribute
 :attr:`.VectorIndexConfig.ivf_min_vectors_per_partition`
 is IVF index specific.

r	   
index_typeNzOptional[VectorDistanceType]distancezOptional[int]accuracyhnsw_neighborshnsw_efconstructionivf_neighbor_partitionsivf_sample_per_partitionivf_min_vectors_per_partitionparallelc                    [        U R                  5      U l        S HK  n[        X5      nUc  M  [        U[        5      (       a  M*  [        U S[        U5      R                   35      e   g )N)r*   r+   r,   r-   r.   r/   r)   z$ must be an integer ifprovided, got )r	   r'   getattr
isinstanceint	TypeErrortyper   )selffieldvalues      r   __post_init__VectorIndexConfig.__post_init__   sh    )$//:
E D(E E3)?)?g %%)%[%9%9$:< 
r   )r'   )r   r   r   r   r   r	   r   r'   __annotations__r(   r)   r*   r+   r,   r-   r.   r/   r9   r   r   r   r   r%   r%   b   st    0d #2"6"6J6-1H*1"Hm"$(NM()---1]1.2m237!=7"Hm"r   r%   c                      \ rS rSrSrSrS r\R                  S\R                  S\R                  S\R                  S0rSS	 jrS
 rS rS r " S S\R$                  R&                  5      rSrg)VECTOR   zOracle VECTOR datatype.

For complete background on using this type, see
:ref:`oracle_vector_datatype`.

.. versionadded:: 2.0.41

TbBfdNc                    Ub   [        U[        5      (       d  [        S5      eUb   [        U[        5      (       d  [        S5      eXl        X l        g)a   Construct a VECTOR.

:param dim: integer. The dimension of the VECTOR datatype. This
 should be an integer value.

:param storage_format: VectorStorageFormat. The VECTOR storage
 type format. This may be Enum values form
 :class:`.VectorStorageFormat` INT8, BINARY, FLOAT32, or FLOAT64.

Nzdim must be an intergerz:storage_format must be an enum of type VectorStorageFormat)r2   r3   r4   r   dimstorage_format)r6   rD   rE   s      r   __init__VECTOR.__init__   sX     ?:c3#7#7566%j//
 /
 L  ,r   c                   ^  U 4S jnU$ )zD
Convert a list to a array.array before binding it to the database.
c                   > U b  [        U [        R                  5      (       a  U $ [        U [        5      (       a3  TR                  TR                  5      n[        R                  " X5      n U $ [        S5      e)Nz$VECTOR accepts list or array.array())r2   arraylist_array_typecoderE   r4   )r8   typecoder6   s     r   process.VECTOR._cached_bind_processor.<locals>.process   sc    }
5%++ > > E4((//0C0CDH4   FGGr   r   )r6   dialectrN   s   `  r   _cached_bind_processorVECTOR._cached_bind_processor   s    
	H r   c                    S nU$ )zB
Convert a array.array to list before binding it to the database.
c                X    [        U [        R                  5      (       a  [        U 5      $ g )N)r2   rJ   rK   )r8   s    r   rN   0VECTOR._cached_result_processor.<locals>.process   s"    %--E{" .r   r   )r6   rP   coltyperN   s       r   _cached_result_processorVECTOR._cached_result_processor   s    
	# r   c                :    U R                   R                  US5      $ )z'
Map storage format to array typecode.
rB   )_typecode_mapget)r6   rM   s     r   rL   VECTOR._array_typecode   s     !!%%h44r   c                  &    \ rS rSrS rS rS rSrg)VECTOR.comparator_factoryi  c                6    U R                  S[        S9" U5      $ )Nz<->return_typeopr   r6   others     r   l2_distance%VECTOR.comparator_factory.l2_distance      775e74U;;r   c                6    U R                  S[        S9" U5      $ )Nz<#>r`   rb   rd   s     r   inner_product'VECTOR.comparator_factory.inner_product  rh   r   c                6    U R                  S[        S9" U5      $ )Nz<=>r`   rb   rd   s     r   cosine_distance)VECTOR.comparator_factory.cosine_distance	  rh   r   r   N)r   r   r   r   rf   rj   rm   r   r   r   r   comparator_factoryr^     s    	<	<	<r   ro   )rD   rE   )NN)r   r   r   r   r   cache_ok__visit_name__r   r    r!   r"   r#   rZ   rF   rQ   rW   rL   types
TypeEngine
Comparatorro   r   r   r   r   r=   r=      st     HN 	  #""C##S##S	M-,(	5<U--88 <r   r=   )
__future__r   rJ   dataclassesr   enumr   typingr   sqlalchemy.typesrr   r   r	   r   r   r%   rs   r=   r   r   r   <module>rz      sq    #  !     "d & >$ 6 M M M`W<U W<r   