
    Rǻi5              	         U d Z ddlmZ ddlZddlZddlZ	ddl
mZ ddlmZ ej                   r	ddlZddlZnddlmZmZ 	 	 ddlmZ g d	Z e       Z G d
 d      Z  G d de!e      Z"e"ejF                  d   z  Z$ G d de!e      Z%e%ejF                  d   z  Z&ejF                  e%jN                  e%jP                  e%jR                  e%jT                  ddddf   Z+ejF                  e%jX                  e%jZ                  ddf   Z.d8dZ/d8dZ0d8dZ1eeZ2nee0Z2ne1Z2d9dZ3i Z4de5d<    G d dejl                        Z7 G d  d!e7ejl                        Z8 G d" d#e8      Z9 G d$ d%e8      Z: G d& d'e7ejl                        Z;d(Z<d)Z= G d* d+e;      Z>d,Z?d-Z@ G d. d/e;      ZAd0ZBd1ZC G d2 d3e;      ZDd4ZEd5ZF G d6 d7e;      ZGy# e$ r dZY xw xY w):z*Vector type to be exchanged with the DBMS.    )annotationsN)Enum   )_typing)nppa)swap_endian)VectorVectorDTypeVectorEndianc                     e Zd ZU dZdZded<   ej                  	 	 	 	 	 	 d!d       Zej                  	 	 	 	 	 	 d"d       Zej                  dd	 	 	 	 	 	 	 d#d	       Zej                  d$d
       Zej                  d%d       Zd&dZddd'dZ	dd	 	 	 	 	 d(dZ
ed)d       Zd*dZd+dZd+dZedd	 	 	 	 	 	 	 d,d       Zdd	 	 	 	 	 	 	 d-dZeej                  	 	 	 	 	 	 d.d              Zeej                  	 	 	 	 	 	 d/d              Ze	 	 	 	 	 	 d0d       Z	 	 	 	 	 	 d1dZd2dZed3d       Zd4dZd$dZed5d       Zd6dZd%dZy )7r
   a  
    A class representing a Neo4j vector.

    The constructor accepts various types of data to create a vector.
    Depending on ``data``'s type, further arguments may be required/allowed.
    Examples of valid invocations are::

        Vector([1, 2, 3], "i8")
        Vector(b"\x00\x01\x00\x02", VectorDType.I16)
        Vector(b"\x01\x00\x02\x00", "i16", byteorder="little")
        Vector(numpy.array([1, 2, 3]))
        Vector(pyarrow.array([1, 2, 3]))

    Internally, a vector is stored as a contiguous block of memory
    (:class:`bytes`), containing homogeneous values encoded in big-endian
    order. Support for this feature requires a DBMS supporting Bolt version
    6.0 or later.

    :param data:
        The data from which the vector will be constructed.
        The constructor accepts the following types:

        * ``Iterable[float]``, ``Iterable[int]`` (but not ``bytes`` or
          ``bytearray``):
          Use an iterable of floats or an iterable of ints to construct the
          vector from native Python values.
          The ``dtype`` parameter is required.
          See also: :meth:`.from_native`.
        * ``bytes``, ``bytearray``: Use raw bytes to construct the vector.
          The ``dtype`` parameter is required and ``byteorder`` is optional.
        * ``numpy.ndarray``: Use a numpy array to construct the vector.
          No further parameters are accepted.
          See also: :meth:`.from_numpy`.
        * ``pyarrow.Array``: Use a pyarrow array to construct the vector.
          No further parameters are accepted.
          See also: :meth:`.from_pyarrow`.
    :param dtype: The type of the vector.
        See :class:`.VectorDType` for currently supported inner data types.
        See also :attr:`.dtype`.

        This parameter is required if ``data`` is of type :class:`bytes`,
        :class:`bytearray`, ``Iterable[float]``, or ``Iterable[int]``.
        Otherwise, it must be omitted.
    :param byteorder: The endianness of the input data (default: ``"big"``).
        If ``"little"`` is given, ``neo4j-rust-ext`` or ``numpy`` is used to
        speed up the internal byte flipping (if either package is installed).
        Use :data:`sys.byteorder` if you want to use the system's native
        endianness.

        This parameter is optional if ``data`` is of type ``bytes`` or
        ``bytearray``. Otherwise, it must be omitted.

    :raises ValueError:
        Depending on the type of ``data``:
            * ``Iterable[float]``, ``Iterable[int]`` (excluding byte types):
                * If the dtype is not supported.
            * ``bytes``, ``bytearray``:
                * If the dtype is not supported or data's size is not a
                  multiple of dtype's size.
                * If byteorder is not one of ``"big"`` or ``"little"``.
            * ``numpy.ndarray``:
                * If the dtype is not supported.
                * If the array is not one-dimensional.
            * ``pyarrow.Array``:
                * If the array's type is not supported.
                * If the array contains null values.
    :raises TypeError:
        Depending on the type of ``data``:
            * ``Iterable[float]``, ``Iterable[int]`` (excluding byte types):
                * If data's elements don't match the expected type depending on
                  dtype.
    :raises OverflowError:
        Depending on the type of ``data``:
            * ``Iterable[float]``, ``Iterable[int]`` (excluding byte types):
                * If the value is out of range for the given type.

    .. versionadded: 6.0
    )__weakref___inner_InnerVectorr   c                    y N selfdatadtypes      J/opt/lhia/marcimex/agent/venv/lib/python3.12/site-packages/neo4j/vector.py__init__zVector.__init__            c                    y r   r   r   s      r   r   zVector.__init__   r   r   big	byteorderc                   y r   r   r   r   r   r   s       r   r   zVector.__init__   s     r   c                    y r   r   r   r   s     r   r   zVector.__init__   s    69r   c                    y r   r   r#   s     r   r   zVector.__init__   s    47r   c                x   t        |t        t        f      r  | j                  t        |      g|i | y t        1t        |t        j
                        r | j                  |g|i | y t        1t        |t        j                        r | j                  |g|i | y  | j                  |g|i | y r   )
isinstancebytes	bytearray
_set_bytes_npndarray
_set_numpy_paArray_set_pyarrow_set_native)r   r   argskwargss       r   r   zVector.__init__   s    dUI./DOOE$K9$9&9_D#++!>DOOD24262_D#))!<Dd4T4V4DT3D3F3r   c                  |xdk(  r | j                   j                  S dk(  r| j                   j                  S 	 t        d|d      )a  
        Get the raw bytes of the vector.

        The data is a continuous block of memory, containing an array of the
        vector's data type. The data is stored in big-endian order. Pass
        another byte-order to this method to get the converted data.

        :param byteorder: The endianness the data should be returned in.
            If the data's byte-order needs flipping, this method tries to use
            ``neo4j-rust-ext`` or ``numpy``, if installed, to speed up the
            process. Use :data:`sys.byteorder` if you want to use the system's
            native endianness.

        :returns: The raw bytes of the vector.

        :raises ValueError:
            If byteorder is not one of ``"big"`` or ``"little"``.
        r   littleInvalid byteorder: . Must be 'big' or 'little'.r   r   data_le
ValueError)r   r   s     r   rawz
Vector.raw   sN    & {{'''{{*** )) 71 1 r   c                  |xdk(  r || j                   _        ydk(  r|| j                   _        y	 t        d|d      )a  
        Set the raw bytes of the vector.

        :param data: The new raw bytes of the vector.
        :param byteorder: The endianness of ``data``.
            The data will always be stored in big-endian order. If passed-in
            byte-order needs flipping, this method tries to use
            ``neo4j-rust-ext`` or ``numpy``, if installed, to speed up the
            process. Use :data:`sys.byteorder` if you want to use the system's
            native endianness.

        :raises ValueError:
          * If data's size is not a multiple of dtype's size.
          * If byteorder is not one of ``"big"`` or ``"little"``.
        :raises TypeError: If the data is not of type bytes.
        r   r4   r5   r6   Nr7   )r   r   r   s      r   set_rawzVector.set_raw   sF    . #' &*# )) 71 1 r   c                .    | j                   j                  S )zX
        Get the type of the vector.

        :returns: The type of the vector.
        )r   r   r   s    r   r   zVector.dtype   s     {{   r   c                ,    t        | j                        S )zt
        Get the number of elements in the vector.

        :returns: The number of elements in the vector.
        )lenr   r>   s    r   __len__zVector.__len__  s     4;;r   c                ,    t        | j                        S r   )strr   r>   s    r   __str__zVector.__str__  s    4;;r   c                    | j                   j                   d| j                         d| j                  j                  dS )N(, ))	__class____name__r:   r   valuer>   s    r   __repr__zVector.__repr__  s9    ~~&&'qb9I9I8LAN	
r   c              P    | j                  |       }|j                  |||       |S )a  
        Create a Vector instance from raw bytes.

        :param data: The raw bytes to create the vector from.
        :param dtype: The type of the vector.
            See also :attr:`.dtype`.
        :param byteorder: The endianness of the data.
            If ``"little"``, the bytes in data will be flipped to big-endian.
            If installed, ``neo4j-rust-ext`` or ``numpy`` will be used to speed
            up the byte flipping. Use :data:`sys.byteorder` if you want to use
            the system's native endianness.

        :raises ValueError:
          * If data's size is not a multiple of dtype's size.
          * If byteorder is not one of ``"big"`` or ``"little"``.
        :raises TypeError: If the data is not of type bytes.
        r   )__new__r)   )clsr   r   r   objs        r   
from_byteszVector.from_bytes  s)    4 kk#tUi8
r   c              4     t        |      ||      | _        y )Nr   )	_get_typer   r!   s       r   r)   zVector._set_bytes2  s     'i&tyAr   c                    y r   r   rO   r   r   s      r   from_nativezVector.from_native<       r   c                    y r   r   rU   s      r   rV   zVector.from_nativeB  rW   r   c               L    | j                  |       }|j                  ||       |S )a`  
        Create a Vector instance from an iterable of values.

        :param data: The list, tuple, or other iterable of values to create the
            vector from.
        :param dtype: The type of the vector.
            See also :attr:`.dtype`.

        ``data`` must contain values that match the expected type given by
        ``dtype``:

        * ``dtype == "f32"``: :class:`float`
        * ``dtype == "f64"``: :class:`float`
        * ``dtype == "i8"``: :class:`int`
        * ``dtype == "i16"``: :class:`int`
        * ``dtype == "i32"``: :class:`int`
        * ``dtype == "i64"``: :class:`int`

        :raises ValueError: If the dtype is not supported.
        :raises TypeError: If data's elements don't match the expected type
            depending on dtype.
        :raises OverflowError: If the value is out of range for the given type.
        )rN   r0   )rO   r   r   rP   s       r   rV   zVector.from_nativeH  s%    < kk#e$
r   c               B    t        |      j                  |      | _        y r   )rS   rV   r   r   s      r   r0   zVector._set_nativej  s      &2248r   c                6    | j                   j                         S )a   
        Convert the vector to a native Python list.

        The type of the elements in the list depends on the dtype of the
        vector. See :meth:`Vector.from_native` for details.

        :returns: A list of values representing the vector.
        )r   	to_nativer>   s    r   r\   zVector.to_nativer  s     {{$$&&r   c               J    | j                  |       }|j                  |       |S )af  
        Create a Vector instance from a numpy array.

        :param data: The numpy array to create the vector from.
            The array must be one-dimensional and have a dtype that is
            supported by Neo4j vectors: ``float64``, ``float32``,
            ``int64``, ``int32``, ``int16``, or ``int8``.
            See also :class:`.VectorDType`.

        :raises ValueError:
          * If the dtype is not supported.
          * If the array is not one-dimensional.
        :raises ImportError: If numpy is not installed.

        :returns: A Vector instance constructed from the numpy array.
        )rN   r,   rO   r   rP   s      r   
from_numpyzVector.from_numpy}  s#    $ kk#t
r   c                6    | j                   j                         S )a   
        Convert the vector to a numpy array.

        The array's dtype depends on the dtype of the vector. However, it will
        always be in big-endian order.

        :returns: A numpy array representing the vector.

        :raises ImportError: If numpy is not installed.
        )r   to_numpyr>   s    r   ra   zVector.to_numpy  s     {{##%%r   c               l   |j                   dk7  rt        d      |j                  j                  xdk(  r t        }nbxdk(  r t
        }nUxdk(  r t        }nHxdk(  r t        }n;xdk(  r t        }n.dk(  rt        }n#	 t        d	|j                  j                         |j                  |      | _        y )
Nr   zData must be one-dimensionalfloat64float32int64int32int16int8zUnsupported numpy dtype: )ndimr9   r   name_VecF64_VecF32_VecI64_VecI32_VecI16_VecI8r_   r   )r   r   type_s      r   r,   zVector._set_numpy  s    99>;<<jjoo #<TZZ__<M!NOO&&t,r   c               J    | j                  |       }|j                  |       |S )a  
        Create a Vector instance from a pyarrow array.

        PyArrow stores data in little endian. Therefore, the byte-order needs
        to be swapped. If ``neo4j-rust-ext`` or ``numpy`` is installed, it will
        be used to speed up the byte flipping.

        :param data: The pyarrow array to create the vector from.
            The array must have a type that is supported by Neo4j.
            See also :class:`.VectorDType`.
        :raises ValueError:
          * If the array's type is not supported.
          * If the array contains null values.
        :raises ImportError: If pyarrow is not installed.

        :returns: A Vector instance constructed from the pyarrow array.
        )rN   r/   r^   s      r   from_pyarrowzVector.from_pyarrow  s%    & kk#
r   c                6    | j                   j                         S )z
        Convert the vector to a pyarrow array.

        :returns: A pyarrow array representing the vector.

        :raises ImportError: If pyarrow is not installed.
        )r   
to_pyarrowr>   s    r   ru   zVector.to_pyarrow  s     {{%%''r   c                  dd l }|j                  |j                         k(  rt        }n|j                  |j	                         k(  rt
        }n|j                  |j                         k(  rt        }n|j                  |j                         k(  rt        }n`|j                  |j                         k(  rt        }n<|j                  |j                         k(  rt        }nt        d|j                         |j                  |      }|| _        y )Nr   zUnsupported pyarrow dtype: )pyarrowtyperc   rk   rd   rl   re   rm   rf   rn   rg   ro   rh   rp   r9   rs   r   )r   r   rw   rq   inners        r   r/   zVector._set_pyarrow  s     99))EYY'//++EYY'--/)EYY'--/)EYY'--/)EYY',,.(E:499+FGG""4(r   N)r   _t.Iterable[float]r   _T_VectorDTypeFloatreturnNone)r   _t.Iterable[int]r   _T_VectorDTypeIntr|   r}   )r   zbytes | bytearrayr   _T_VectorDTyper   _T_VectorEndianr|   r}   )r   _np.ndarrayr|   r}   )r   	_pa.Arrayr|   r}   r|   r}   )r   r   r|   r'   r   r'   r   r   r|   r}   )r|   r   r|   intr|   rC   )r   r'   r   r   r   r   r|   _t.Self)r   r'   r   r   r   r   r|   r}   )r   rz   r   r{   r|   r   )r   r~   r   r   r|   r   )r   %_t.Iterable[float] | _t.Iterable[int]r   r   r|   r   )r   r   r   r   r|   r}   r|   zlist[object]r   r   r|   r   r|   r   r   r   r|   r   r|   r   )rJ   
__module____qualname____doc__	__slots____annotations___toverloadr   r:   r<   propertyr   rA   rD   rL   classmethodrQ   r)   rV   r0   r\   r_   ra   r,   rs   ru   r/   r   r   r   r
   r
   =   s   M^ *I[[  #
 
  [[ !
 
  [[ &+  # 
  [[9 9[[7 74 6; F &+  
 #  
 D ! !  

  &+  # 
 F &+BB B #B 
B [[%.A	   [[#,=	   3 
 
 B939 9
 
9	'  *&-*  ,(r   r
   c                      e Zd ZdZdZdZy)r   a  
    Data endianness (i.e., byte order) of the elements in a :class:`Vector`.

    Inherits from :class:`str` and :class:`enum.Enum`.
    Every driver API accepting a :class:`.VectorEndian` value will also accept
    a string::

        >>> VectorEndian.BIG == "big"
        True
        >>> VectorEndian.LITTLE == "little"
        True

    .. seealso:: :attr:`Vector.raw`

    .. versionadded:: 6.0
    r   r4   N)rJ   r   r   r   BIGLITTLEr   r   r   r   r     s    " CFr   r   )r   r4   c                  (    e Zd ZdZdZdZdZdZdZdZ	y)	r   a  
    The data type of the elements in a :class:`Vector`.

    Currently supported types are:

        * ``f32``: 32-bit floating point number (single)
        * ``f64``: 64-bit floating point number (double)
        * ``i8``: 8-bit integer
        * ``i16``: 16-bit integer
        * ``i32``: 32-bit integer
        * ``i64``: 64-bit integer

    Inherits from :class:`str` and :class:`enum.Enum`.
    Every driver API accepting a :class:`.VectorDType` value will also accept
    a string::

        >>> VectorDType.F32 == "f32"
        True
        >>> VectorDType.I8 == "i8"
        True

    .. seealso:: :attr:`Vector.dtype`

    .. versionadded:: 6.0
    f32f64i8i16i32i64N)
rJ   r   r   r   F32F64I8I16I32I64r   r   r   r   r   
  s'    4 C
C	B
C
C
Cr   r   )r   r   r   r   r   r   r   r   r   r   r   r   c                   | dk(  r|S | dvrt        d|        t        |      | z  dk7  rt        dt        |       d|        t        | |      S )z&Swap from big endian to little endian.r   >            Unsupported type size: r   Data length  is not a multiple of )r9   r@   _swap_endian_unchecked)	type_sizer   s     r   _swap_endianr   ?  sk    A~	!29+>??
4y9!3t9+%;I;G
 	
 ")T22r   c               ,   | xdk(  r t        j                  d      }nExdk(  r t        j                  d      }n)dk(  rt        j                  d      }n	 t        d|        t        j                  ||      j	                         j                         S )	Nr   z<i2r   z<i4r   z<i8r   r   )r*   r   r9   
frombufferbyteswaptobytes)r   r   r   s      r   _swap_endian_unchecked_npr   L  sq    
IIe$EIIe$EIIe$E6ykBCC>>$e,557??AAr   c                   | xdk(  r d}nxdk(  r d}ndk(  rd}n	 t        d|        t        |      | z  }d| | }d	| | }t        j                  |gt        j                  ||       S )
Nr   hr   ir   qr   ><)r9   r@   _structpackunpack)r   r   fmtcountfmt_befmt_les         r   _swap_endian_unchecked_pyr   Z  s    
CCC6ykBCCI"EuFuF<<>!=>>r   c               &   t        | t              r:| t        j                  j	                         vrt        d| d      t        |       } t        | t              st        dt        |        d      | t        vrt        d| d      t        |    S )NzUnsupported vector type: .z#Expected a VectorDType or str, got )	r&   rC   r   __members__valuesr9   	TypeErrorrx   _TYPESr   s    r   rS   rS   r  s    %//66888	CDDE"e[)=d5k]!LMMF4UIQ?@@%=r   z%dict[VectorDType, type[_InnerVector]]r   c                      e Zd ZU dZded<   ded<   ded<   ded	<   d
ed<   dd	 	 	 	 	 d fdZedd       Zej                  d d       Zedd       Z	e	j                  d d       Z	d! fdZ
d"dZd#dZej                  d#d       Zd#dZeej                  d$d              Zej                  d%d       Zed&d       Zej                  d'd       Zed(d       Zej                  d)d       Z xZS )*r   )_data_data_lez_t.ClassVar[VectorDType]r   z_t.ClassVar[int]sizez_t.ClassVar[str]cypher_inner_type_reprr'   r   zbytes | Noner   r   r   c                  t         |           | j                  t        k(  rt	        d      |xdk(  r || _        d | _        y dk(  r#t        | j                  |      | _        || _        y 	 t        d|d      )Nz-Cannot instantiate abstract class InnerVectorr   r4   r5   r6   )
superr   rI   r   r   r   r   r   r   r9   )r   r   r   rI   s      r   r   z_InnerVector.__init__  sy     	>>\)KLL 	 $(D9	 $ )) 71 1 r   c                    | j                   S r   )r   r>   s    r   r   z_InnerVector.data  s    zzr   c                   t        |t              st        d      t        |      | j                  z  dk(  s$t        dt        |       d| j                         || _        y )NzData must be of type bytesr   r   r   )r&   r'   r   r@   r   r9   r   r#   s     r   r   z_InnerVector.data  s\    $&8994y499$)s4yk)?		{K  
r   c                |    | j                   %t        | j                  | j                        | _         | j                   S r   )r   r   r   r   r>   s    r   r8   z_InnerVector.data_le  s,    == (DII>DM}}r   c               H    t        | j                  |      | _        || _        y r   )r   r   r   r   r#   s     r   r8   z_InnerVector.data_le  s     D1	r   c                   t         |           t        j                  | j                  v ry t        | dd       }t        |t              st        d| j                   d      t        t        | dd       t              st        d| j                   d      | j                  dvr%t        d| j                   d| j                         |t        v rt        d| j                   d| d	      | t        |<   y )
Nr   zClass z) must have a VectorDType attribute'dtype'r   z! must have a str attribute 'size'>   r   r   r   r   z has an unhandled size z has a duplicate type '')r   __init_subclass___abcABC	__bases__getattrr&   r   r   rJ   r   r   r9   r   )rO   r   rI   s     r   r   z_InnerVector.__init_subclass__  s    !#88s}}$Wd+%- '   '#vt4c:&GH  88<' &=chhZH  F?&=eWAF  ur   c                F    t        | j                        | j                  z  S r   )r@   r   r   r>   s    r   rA   z_InnerVector.__len__  s    499~**r   c                h    t        |       }| j                  }| j                         }d| d| d| dS )Nzvector(rG   rH   )r@   r   _cypher_values_repr)r   r   	type_reprvalues_reprs       r   rD   z_InnerVector.__str__  s?    4y//	..0RvR	{!<<r   c                     y r   r   r>   s    r   r   z _InnerVector._cypher_values_repr  s    *-r   c                R    | j                   j                  }| d| j                  dS )NrF   rH   )rI   rJ   r   )r   cls_names     r   rL   z_InnerVector.__repr__  s(    >>**1TYYM++r   c                    y r   r   rO   r   s     r   rV   z_InnerVector.from_native  s    CFr   c                     y r   r   r>   s    r   r\   z_InnerVector.to_native  s    ),r   c                   |j                   j                  dk(  s,|j                   j                  dk(  r#t        j                  dk(  r|j                         } | |j	                               S )Nr   =r4   )r   r   _sysr   r   r   s     r   r_   z_InnerVector.from_numpy  sM    ::3&JJ  C'DNNh,F==?D4<<>""r   c                     y r   r   r>   s    r   ra   z_InnerVector.to_numpy      '*r   c                  |j                   j                  }| j                  |k(  sJ t        j                  j                  |d      j                         rt        d      |j                         \  }}||j                  |z  |j                  t        |      z   |z   } | t        |      t        j                        S )N	only_null)modez/PyArrow array must not contain any null values.r   )rx   
byte_widthr   r-   computer   as_pyr9   buffersoffsetr@   r'   r   r   )rO   r   width_buffers        r   rs   z_InnerVector.from_pyarrow  s    		$$xx5   ;;T4::<NOOLLN	6KK%4;;T#:e"C
 5=DNN;;r   c                     y r   r   r>   s    r   ru   z_InnerVector.to_pyarrow  r   r   r   )r|   r'   )r   r'   r|   r}   r   r   r   r   z_t.Iterable[object]r|   r   r   r   r   r   r   )rJ   r   r   r   r   r   r   r   setterr8   r   rA   rD   r   abstractmethodr   rL   r   rV   r\   r_   ra   rs   ru   __classcell__)rI   s   @r   r   r     sL   %I##
,,L ?D,;	&   
[[   
 ^^ 4+= 
- -, 	F  F	, ,# # 
* *	< 	< 
* *r   r   c                      e Zd ZdZddZy)_InnerVectorFloatr   c                x    t        | j                               }|j                  dd      j                  dd      S )NnanNaNinfInfinity)rC   r\   replace)r   ress     r   r   z%_InnerVectorFloat._cypher_values_repr  s1    $.."#{{5%(00
CCr   Nr   rJ   r   r   r   r   r   r   r   r   r     s    IDr   r   c                  Z    e Zd ZdZej
                  ZdZdZe	d	d       Z
d
dZddZddZy)rk   r   r   zFLOAT NOT NULLc               4   t        |t        j                        st        |      }t	        d |D              s9|D ]4  }t        |t
              rt        dt        |      j                   d        | t        j                  dt        |       dg|       S )Nc              3  <   K   | ]  }t        |t                y wr   r&   float.0items     r   	<genexpr>z&_VecF64.from_native.<locals>.<genexpr>       <t:dE*<   zCannot build f64 vector from , expected float.r   d)r&   r   Sizedtupleallr  r   rx   rJ   r   r   r@   )rO   r   r  s      r   rV   z_VecF64.from_native  s    $);D<t<< !$.#7T
8K8K7L M* *  7<<!CI;a 084899r   c                    dt        | j                        | j                  z   d}t        t	        j
                  || j                              S )Nr   r  r@   r   r   listr   r   r   struct_formats     r   r\   z_VecF64.to_native  <    C		Ndii78:GNN=$))<==r   c                b    dd l }|j                  | j                  |j                  d            S )Nr   z>f8r   numpyr   r   r   r   r!  s     r   ra   z_VecF64.to_numpy"  (    		U1CDDr   c                    dd l }|j                  | j                        }|j                  j	                  |j                         t        |       d |gd      S Nr   )rw   	py_bufferr8   r.   from_buffersrc   r@   r   rw   r   s      r   ru   z_VecF64.to_pyarrow'  H    ""4<<0}}))OOs4y4.!
 	
r   Nr   r   r   r   )rJ   r   r   r   r   r   r   r   r   r   rV   r\   ra   ru   r   r   r   rk   rk   
  s=    IOOED-
: 
:>E

r   rk   c                  Z    e Zd ZdZej
                  ZdZdZe	d	d       Z
d
dZddZddZy)rl   r   r   zFLOAT32 NOT NULLc                  t        |t        j                        st        |      }t	        d |D              s9|D ]4  }t        |t
              rt        dt        |      j                   d       	 t        j                  dt        |       dg| } | |      S # t        $ r= |D ]6  }	 t        j                  d|       # t        $ r t        d| d      d w xY w  w xY w)	Nc              3  <   K   | ]  }t        |t                y wr   r  r  s     r   r  z&_VecF32.from_native.<locals>.<genexpr>;  r  r  zCannot build f32 vector from r  r   fz>fValue z9 is out of range for f32: [-3.4028234e+38, 3.4028234e+38])r&   r   r  r  r  r  r   rx   rJ   r   r   r@   OverflowError)rO   r   r  bytes_s       r   rV   z_VecF32.from_native7  s   $);D<t<< !$.#7T
8K8K7L M* * 	\\Ac$i["2:T:F 6{  		   LLt,$  '  ': ;      		s$   2#B C#,CC#CC#c                    dt        | j                        | j                  z   d}t        t	        j
                  || j                              S )Nr   r-  r  r  s     r   r\   z_VecF32.to_nativeP  r  r   c                b    dd l }|j                  | j                  |j                  d            S )Nr   z>f4r   r   r"  s     r   ra   z_VecF32.to_numpyT  r#  r   c                    dd l }|j                  | j                        }|j                  j	                  |j                         t        |       d |gd      S r%  )rw   r&  r8   r.   r'  rd   r@   r(  s      r   ru   z_VecF32.to_pyarrowY  r)  r   Nr   r   r   r   )rJ   r   r   r   r   r   r   r   r   r   rV   r\   ra   ru   r   r   r   rl   rl   0  s=    IOOED/ 0>E

r   rl   c                      e Zd ZdZddZy)_InnerVectorIntr   c                4    t        | j                               S r   )rC   r\   r>   s    r   r   z#_InnerVectorInt._cypher_values_repre  s    4>>#$$r   Nr   r  r   r   r   r5  r5  b  s    I%r   r5  l         l    c                  Z    e Zd ZdZej
                  ZdZdZe	d	d       Z
d
dZddZddZy)rm   r   r   zINTEGER NOT NULLc                  t        |t        j                        st        |      }	 t	        j
                  dt        |       dg| } | |      S # t        j                  $ ro |D ]h  }t        |t              s#t        dt        |      j                   d      d t        |cxk  r
t        k  rJn t        d| dt         dt         d      d   w xY w)	Nr   r   zCannot build i64 vector from , expected int.r.  z is out of range for i64: [rG   ])r&   r   r  r  r   r   r@   errorr   r   rx   rJ   _I64_MIN_I64_MAXr/  rO   r   r0  r  s       r   rV   z_VecI64.from_nativet      $);D	\\Ac$i["2:T:F 6{ }} 	 
 !$,#7T
8K8K7L M( (     4383'  '$:Rz4   
  	   #A AC1#Cc                    dt        | j                        | j                  z   d}t        t	        j
                  || j                              S )Nr   r   r  r  s     r   r\   z_VecI64.to_native  r  r   c                b    dd l }|j                  | j                  |j                  d            S )Nr   z>i8r   r   r"  s     r   ra   z_VecI64.to_numpy  r#  r   c                    dd l }|j                  | j                        }|j                  j	                  |j                         t        |       d |gd      S r%  )rw   r&  r8   r.   r'  re   r@   r(  s      r   ru   z_VecI64.to_pyarrow  G    ""4<<0}}))MMOSYv
 	
r   Nr   r   r   r   )rJ   r   r   r   r   r   r   r   r   r   rV   r\   ra   ru   r   r   r   rm   rm   m  s=    IOOED/ (>E

r   rm   i   ic                  Z    e Zd ZdZej
                  ZdZdZe	d	d       Z
d
dZddZddZy)rn   r   r   zINTEGER32 NOT NULLc                  t        |t        j                        st        |      }	 t	        j
                  dt        |       dg| } | |      S # t        j                  $ ro |D ]h  }t        |t              s#t        dt        |      j                   d      d t        |cxk  r
t        k  rJn t        d| dt         dt         d      d   w xY w)	Nr   r   zCannot build i32 vector from r9  r.  z is out of range for i32: [rG   r:  )r&   r   r  r  r   r   r@   r;  r   r   rx   rJ   _I32_MIN_I32_MAXr/  r>  s       r   rV   z_VecI32.from_native  r?  r@  c                    dt        | j                        | j                  z   d}t        t	        j
                  || j                              S )Nr   r   r  r  s     r   r\   z_VecI32.to_native  r  r   c                b    dd l }|j                  | j                  |j                  d            S )Nr   z>i4r   r   r"  s     r   ra   z_VecI32.to_numpy  r#  r   c                    dd l }|j                  | j                        }|j                  j	                  |j                         t        |       d |gd      S r%  )rw   r&  r8   r.   r'  rf   r@   r(  s      r   ru   z_VecI32.to_pyarrow  rD  r   Nr   r   r   r   )rJ   r   r   r   r   r   r   r   r   r   rV   r\   ra   ru   r   r   r   rn   rn     =    IOOED1 (>E

r   rn   i i  c                  Z    e Zd ZdZej
                  ZdZdZe	d	d       Z
d
dZddZddZy)ro   r   r   zINTEGER16 NOT NULLc                  t        |t        j                        st        |      }	 t	        j
                  dt        |       dg| } | |      S # t        j                  $ ro |D ]h  }t        |t              s#t        dt        |      j                   d      d t        |cxk  r
t        k  rJn t        d| dt         dt         d      d   w xY w)	Nr   r   zCannot build i16 vector from r9  r.  z is out of range for i16: [rG   r:  )r&   r   r  r  r   r   r@   r;  r   r   rx   rJ   _I16_MIN_I16_MAXr/  r>  s       r   rV   z_VecI16.from_native  r?  r@  c                    dt        | j                        | j                  z   d}t        t	        j
                  || j                              S )Nr   r   r  r  s     r   r\   z_VecI16.to_native  r  r   c                b    dd l }|j                  | j                  |j                  d            S )Nr   z>i2r   r   r"  s     r   ra   z_VecI16.to_numpy  r#  r   c                    dd l }|j                  | j                        }|j                  j	                  |j                         t        |       d |gd      S r%  )rw   r&  r8   r.   r'  rg   r@   r(  s      r   ru   z_VecI16.to_pyarrow  rD  r   Nr   r   r   r   )rJ   r   r   r   r   r   r   r   r   r   rV   r\   ra   ru   r   r   r   ro   ro     rL  r   ro   i   c                  Z    e Zd ZdZej
                  ZdZdZe	d	d       Z
d
dZddZddZy)rp   r   r   zINTEGER8 NOT NULLc                  t        |t        j                        st        |      }	 t	        j
                  dt        |       dg| } | |      S # t        j                  $ ro |D ]h  }t        |t              s#t        dt        |      j                   d      d t        |cxk  r
t        k  rJn t        d| dt         dt         d      d   w xY w)	Nr   bzCannot build i8 vector from r9  r.  z is out of range for i8: [rG   r:  )r&   r   r  r  r   r   r@   r;  r   r   rx   rJ   _I8_MIN_I8_MAXr/  r>  s       r   rV   z_VecI8.from_native
  s    $);D	\\Ac$i["2:T:F 6{ }} 	 
 !$,#6tDz7J7J6K L( (    $1'1'  '#9Bwiq2   
  	r@  c                    dt        | j                        | j                  z   d}t        t	        j
                  || j                              S )Nr   rW  r  r  s     r   r\   z_VecI8.to_native  r  r   c                b    dd l }|j                  | j                  |j                  d            S )Nr   z>i1r   r   r"  s     r   ra   z_VecI8.to_numpy#  r#  r   c                    dd l }|j                  | j                        }|j                  j	                  |j                         t        |       d |gd      S r%  )rw   r&  r8   r.   r'  rh   r@   r(  s      r   ru   z_VecI8.to_pyarrow(  sG    ""4<<0}}))LLNCIf~q
 	
r   Nr   r   r   r   )rJ   r   r   r   r   r   r   r   r   r   rV   r\   ra   ru   r   r   r   rp   rp     s=    INNED0 (>E

r   rp   )r   r   r   r'   r|   r'   )r   r   r|   ztype[_InnerVector])Hr   
__future__r   r   abcr   structr   sysr   enumr   _Enum r   r   TYPE_CHECKINGr!  r*   rw   r-   _optional_depsr   r   typing_rust.vectorr	   _swap_endian_unchecked_rustImportError__all__object_DEFAULTr
   rC   r   Literalr   r   r   r   r   r   r   r   r   r   r{   r   r   r   r   rS   r   r   r   r   r   rk   rl   r5  r<  r=  rm   rG  rH  rn   rO  rP  ro   rX  rY  rp   r   r   r   <module>rn     s    1 '        	
'H
 8l lh3 , O!<< #u  H "**DEE  JJNNOOOOOO				  jjOO[__eU2 

3B?  *8_66	 13- 2~+488 ~+BDdhh D#
 #
L/
 /
d%lDHH % &$+
o +
\ +
o +
\ +
o +
\ 
+
_ +
i  '"&'s   F5 5G ?G 