
    Kg                       d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ erdd
lmZ ddlmZ ddlmZ  G d de	j,                  ee      Z G d de	j.                  ee      Z G d de	j0                  ee      Zy)z%Here is defined the IndexArray class.    )annotations)bisect_leftbisect_right)TYPE_CHECKING   )indexesextension)NotLoggedMixin)CArray)EArray)Atom)Group)Filtersc                      e Zd ZdZdZy)
CacheArrayz8Container for keeping index caches of 1st and 2nd level.
CACHEARRAYN__name__
__module____qualname____doc__
_c_classid     .lib/python3.12/site-packages/tables/indexes.pyr   r      s    B Jr   r   c                      e Zd ZdZdZy)LastRowArrayzDContainer for keeping sorted indices values of last row of an index.LASTROWARRAYNr   r   r   r   r   r      s    N  Jr   r   c                       e Zd ZdZdZed	d       Zed	d       Z	 	 	 	 d
	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZ	 	 	 	 	 	 ddZ	ddZ
ddZ xZS )
IndexArrayaD  Represent the index (sorted or reverse index) dataset in HDF5 file.

    All NumPy typecodes are supported except for complex datatypes.

    Parameters
    ----------
    parentnode
        The Index class from which this object will hang off.

        .. versionchanged:: 3.0
           Renamed from *parentNode* to *parentnode*.

    name : str
        The name of this node in its parent group.
    atom
        An Atom object representing the shape and type of the atomic objects to
        be saved. Only scalar atoms are supported.
    title
        Sets a TITLE attribute on the array entity.
    filters : Filters
        An instance of the Filters class that provides information about the
        desired I/O filters to be applied during the life of this object.
    byteorder
        The byteroder of the data on-disk.

    
INDEXARRAYc                     | j                   d   S )z!Size of the chunk for the object.r   )
chunkshapeselfs    r   	chunksizezIndexArray.chunksizeB   s     q!!r   c                     | j                   d   S )z!Size of the slice for the object.r   )shaper#   s    r   	slicesizezIndexArray.slicesizeG   s     zz!}r   c           
        |j                  |      | _        |Q|dk(  r/|j                  }d|j                  |z  f}d|j                  |z  f}	n!d|j                  f}d|j                  f}	nd}d}	t
        
|   |||||||	|       y)zCreate an IndexArray instance.Nsortedr   r   )r"   	byteorder)_g_join_v_pathname	reductionr(   r%   super__init__)r$   
parentnodenameatomtitlefiltersr+   r.   r'   r"   	__class__s             r   r0   zIndexArray.__init__L   s     &--d3x&00	J00I=>!5!5!BC
J001!5!56
 EJ! 	 		
r   c                N   |\  }}d}d}| j                   d   }| j                  j                  }| j                  }	||df   }
||
k  rd}||
k  rd}|dk\  r	|dk\  r||fS ||df   }|dk  r||kD  r|}|dk  r||k\  r|}|dk\  r	|dk\  r||fS | j                  }d}|	j                  |      }|dk\  r|	j                  |      }nE| j                  j                  |   }|j                  |j                  z  }|	j                  |||       |dk  rGt        ||      }| j                  |||z  ||dz   z        }t        j                  |||      }|||z  z  }|dk  rLt        ||      }||k7  r| j                  |||z  ||dz   z        }t        j                   ||      }|||z  z  }||fS )Nr   r   )r'   	_v_parentrvcacheboundscacher%   getslotgetitemboundssizeitemsizesetitemr   _read_sorted_slicer   _bisect_leftr   _bisect_right)r$   nrowitemitem1item2result1result2hirangesr;   beginendr%   nchunknslotr>   r?   chunknchunk2s                      r   _search_binzIndexArray._search_bint   s    uZZ]''&&tQwE>G5=Ga<GqLW%%T1WoQ;s{Q;|a<GqLW%% NN	##D)A: ((/F ^^**40F;;0Dfd3Q; /F++i&()vz*BE '33E5)LGy6))GQ;"651G& //)g-yGaK/H '44UE9MGy7**G!!r   c                "    d| j                    dS )z0Compact representation of the IndexArray object.zIndexArray(path=))r-   r#   s    r   __str__zIndexArray.__str__   s    !$"2"2!3155r   c                    |  d| j                   d| j                   d| j                   d| j                   d| j                   d| j
                  S )z:Retunr the string representation of the IndexArray object.z

  atom = z
  shape = z
  nrows = z
  chunksize = z
  slicesize = z
  byteorder = )r3   r'   nrowsr%   r(   r+   r#   s    r   __repr__zIndexArray.__repr__   sh    6 

)) ::, ::, ~~ ~~ ~~ $ 	$r   )returnint)N NN)r1   r   r2   strr3   zAtom | Noner4   r]   r5   zFilters | Noner+   z
str | NonerZ   None)rE   r[   rF   ztuple[float | int, float | int]rZ   ztuple[int, int])rZ   r]   )r   r   r   r   r   propertyr%   r(   r0   rS   rV   rY   __classcell__)r6   s   @r   r   r   #   s    8 J" "   !"& $"
"
 "
 	"

 "
  "
 "
 
"
P<"<"><"	<"|6$r   r   N)r   
__future__r   bisectr   r   typingr   r\   r   noder	   carrayr
   earrayr   r3   r   groupr   r5   r   r   r   r   r   r   r   <module>rh      sp    + " ,        
!,,nf  #00.&  [$!,,nf [$r   