
    i                       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	 d dl
mZ d dlZd dlZd dlZd dlZd dlmZ d dlZd dlZdZ	 d d	lmZ n# e$ r
ZY dZ[ndZ[ww xY wd d
lmZmZ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'm(Z( d dl)m*Z*m+Z+ d dl,m-Z- d dl.m/Z/  ej0        e1          Z2 e3d          Z4	  e3d          Z5	 e4e5z
  Z6	  e!            Z7 G d de8          Z9dZ:d Z;i Z< G d de=          Z> G d de8e>          Z?e?Z@ G d de8          ZA G d d e@          ZB G d! d"e8          ZC G d# d$e@          ZD G d% d&e@          ZE G d' d(e@          ZF G d) d*e8          ZG G d+ d,e8          ZH G d- d.e8          ZI G d/ d0e8          ZJ G d1 d2e8          ZK G d3 d4eK          ZL G d5 d6eL          ZM G d7 d8e8          ZN G d9 d:e=          ZO G d; d<eNeO          ZPd= ZQd> ZRd? ZS ejT        d@          ZUdA ZVdB ZWdC ZX G dD dEe8          ZY G dF dGe8          ZZ G dH dIe8          Z[e	 G dJ dKe8                      Z\dLZ]dMZ^ G dN dOe_          Z` G dP dQe\          Za G dR dSea          Zb G dT dUea          Zc G dV dWe\          Zd G dX dYe8          Ze G dZ d[e8          Zf G d\ d]ef          Zg G d^ d_eg          Zh G d` daeh          Zi G db dceh          Zj G dd deej          Zk G df dgek          Zl G dh die8          Zm G dj dke8          Zn G dl dme8          Zodn Zpdo Zq G dp dqeP          Zr e8            Zsdr Zt G ds dte8          ZudS )u    )	unhexlify)bisect_left)defaultdict)Mapping)total_ordering)md5N)RLock)murmur3)SignatureDescriptorConsistencyLevelInvalidRequestUnauthorized)Encoder)varint_unpack)QueryMessage)dict_factorybind_params)OrderedDictVersion)HostDistance)EndPoint)add	aggregateallallowalterandapplyasascascii	authorizebatchbeginbigintblobbooleanbycalled
clusteringcolumnfamilycompactcontainscountcountercreatecustomdatedecimaldefaultdeletedescdescribedeterministicdistinctdoubledropentriesexecuteexists	filtering	finalfuncfloatfromfrozenfullfunction	functionsgrantifinindexinetinfinityinitcondinputinsertintintoisjsonkeykeyskeyspace	keyspaceslanguagelimitlistloginmapmaterializedmbeanmbeansmodify	monotonicnannologinnorecursivenosuperusernotnullofonoptionsororderpassword
permissionpermissionsprimaryrenamereplacereturnsrevokerolerolesschemaselectsetsfuncsmallintstaticstoragestype	superusertabletexttime	timestamptimeuuidtinyinttotokentriggertruncatettltupletypeunloggedunsetupdateuseuserusersusinguuidvaluesvarcharvarintviewwherewith	writetimenodenodesplanactiveapplicationapplicationsjavaexecutor	executorsstd_outstd_errrenew
delegationnoredactr   lowercasestringclusterauthenticationschemesschemeinternalldapkerberosremoteobjectmethodcallcallssearchrw   configrowscolumnsprofilescommitreloadrebuildfieldworkpoolany
submissionindicesrestrict
unrestrict)Fr   r   r   r!   r%   r&   r'   r)   r*   r,   r-   r.   r/   r1   r2   r3   r8   r9   r:   r>   r?   r@   rA   rC   rE   rF   rK   rM   rN   rP   rS   rT   rU   rW   rX   rZ   r[   r\   ra   rc   re   rj   rm   rn   ro   rs   ru   rv   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c                       e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 d Z	d Z
ddZd ZddZd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZddZddZ d Z!dS )MetadatazD
    Holds a representation of the cluster schema and topology.
    NFc                 V    i | _         d| _        i | _        t                      | _        d S NF)rW   dbaas_hostsr	   _hosts_lockselfs    d/Users/user/workspace/sujinbaek/cqa-test-app/venv/lib/python3.11/site-packages/cassandra/metadata.py__init__zMetadata.__init__z   s)    
 77    c                 n    d                     d | j                                        D                       S )z
        Returns a string that can be executed as a query in order to recreate
        the entire schema.  The string is formatted to be human readable.
        

c              3   >   K   | ]}|                                 V  d S Nexport_as_string).0kss     r   	<genexpr>z3Metadata.export_schema_as_string.<locals>.<genexpr>   s.      SSR2..00SSSSSSr   )joinrW   r   r   s    r   export_schema_as_stringz Metadata.export_schema_as_string   s3    
 {{SS4>;P;P;R;RSSSSSSr   c                 v   |                      |j                  j        }|                      |j                  j        }t	          ||||          }|s|                     |           d S |                                }		 t          |d|	z             }
 |
| j        fi |}|r\t          | d|	z             }|	dk    r6|j	        dk     r+ |j
        | j        fi |}|                     ||           d S  ||           d S t          | d|	z             } |di | d S # t          $ r t          d|z            w xY w)Nget__update_rV      _drop_z Unknown schema target_type: '%s' )get_hostendpointrelease_versiondse_versionget_schema_parser_rebuild_alllowergetattrrW   protocol_versionget_types_map_update_keyspaceAttributeError
ValueError)r   
connectiontimeouttarget_typechange_typekwargsserver_versionr   parsertt_lowerparse_methodmetaupdate_method
user_typesdrop_methods                  r   refreshzMetadata.refresh   s   z':;;KmmJ$788D":~{GTT 	f%%%F$$&&	O"66H+<==L<99&99D 
& 'j8.C D Dz))j.IA.M.M!5!5dn!O!O!O!OJ))$
;;;;;!M$'''''%dHx,?@@%%f%%%%% 	O 	O 	O?+MNNN	Os   ?A0D 1D >D D8c                 >   t                      |                                D ]}                    |j                   | j                            |j        d           }|| j        |j        <   |r|                     |j                   h|                     |j                   fd| j                                        D             }t          fd| j        
                                D                       | _        |D ]}|                     |           d S )Nc                     g | ]}|v|	S r   r   )r   namecurrent_keyspacess     r   
<listcomp>z)Metadata._rebuild_all.<locals>.<listcomp>   s.     ? ? ?d $,= = = " = = =r   c              3   .   K   | ]\  }}|v 	||fV  d S r   r   )r   r  r   r  s      r   r   z(Metadata._rebuild_all.<locals>.<genexpr>   sB       < <ztT!%):!:!:  $Tl!:!:!:!:< <r   )ry   get_all_keyspacesr   r  rW   get_keyspace_updated_keyspace_addedrU   dictitems_keyspace_removed)r   r   keyspace_metaold_keyspace_metaremoved_keyspacesksnamer  s         @r   r   zMetadata._rebuild_all   sO   EE#5577 	9 	9M!!-"4555 $ 2 2=3Et L L1>DN=-.  9&&}'9::::$$]%78888? ? ? ?dn.A.A.C.C ? ? ? < < < <T^=Q=Q=S=S < < < < <' 	+ 	+F""6****	+ 	+r   c                 v   |j         }| j                            |d           }|| j        |<   |ru|j        |_        ||n|j        |_        |j        |_        |j        |_        |j        |_        |j        |_        |j	        |j	        k    r| 
                    |           d S d S |                     |           d S r   )r  rW   r  tablesr   indexesrF   
aggregatesviewsreplication_strategyr  r  )r   r  new_user_typesks_namer  s        r   r   zMetadata._update_keyspace   s    $ N..w=="/w 
	*#4#;M 9G9S~~YjYuM$$5$=M!&7&AM#'8'CM$"3"9M26G6\\\&&w///// ]\   )))))r   c                 j    | j                             |d           r|                     |           d S d S r   )rW   popr  r   rV   s     r   _drop_keyspacezMetadata._drop_keyspace   s@    >h-- 	-""8,,,,,	- 	-r   c                     	 | j         |j                 }t          |t                    r|                    |           d S |                    |           d S # t          $ r Y d S w xY wr   )rW   keyspace_name
isinstanceTableMetadata_add_table_metadata_add_view_metadataKeyError)r   r   r  s      r   _update_tablezMetadata._update_table   s    	 N4+=>M
 $.. 711$777770066666 	 	 	DD	s   <A  A 
A%$A%c                 n    	 | j         |         }|                    |           d S # t          $ r Y d S w xY wr   )rW   _drop_table_metadatar"  )r   rV   r   r  s       r   _drop_tablezMetadata._drop_table   sO    	 N84M..u55555 	 	 	DD	s   "& 
44c                 h    	 || j         |j                 j        |j        <   d S # t          $ r Y d S w xY wr   )rW   rV   r   r  r"  )r   	type_metas     r   _update_typezMetadata._update_type   sH    	LUDN9-.9).III 	 	 	DD	   # 
11c                 v    	 | j         |         j                            |d            d S # t          $ r Y d S w xY wr   )rW   r   r  r"  )r   rV   r   s      r   
_drop_typezMetadata._drop_type   sO    	N8$/33D$????? 	 	 	DD	s   &* 
88c                 h    	 || j         |j                 j        |j        <   d S # t          $ r Y d S w xY wr   )rW   rV   rF   	signaturer"  )r   function_metas     r   _update_functionzMetadata._update_function   sI    	XeDN=12<]=TUUU 	 	 	DD	r*  c                     	 | j         |         j                            |j        d            d S # t          $ r Y d S w xY wr   )rW   rF   r  r.  r"  )r   rV   rE   s      r   _drop_functionzMetadata._drop_function   sR    	N8$.2283EtLLLLL 	 	 	DD	   +/ 
==c                 h    	 || j         |j                 j        |j        <   d S # t          $ r Y d S w xY wr   )rW   rV   r  r.  r"  )r   aggregate_metas     r   _update_aggregatezMetadata._update_aggregate   sI    	[iDN>23>~?WXXX 	 	 	DD	r*  c                     	 | j         |         j                            |j        d            d S # t          $ r Y d S w xY wr   )rW   r  r  r.  r"  )r   rV   r   s      r   _drop_aggregatezMetadata._drop_aggregate  sR    	N8$/33I4GNNNNN 	 	 	DD	r3  c                 P    | j         r| j                             |d           d S d S NFbuild_if_absent	token_maprebuild_keyspacer   r  s     r   r  zMetadata._keyspace_added  :    > 	KN++FE+JJJJJ	K 	Kr   c                 P    | j         r| j                             |d           d S d S r:  r=  r@  s     r   r  zMetadata._keyspace_updated  rA  r   c                 L    | j         r| j                             |           d S d S r   )r>  remove_keyspacer@  s     r   r  zMetadata._keyspace_removed  s2    > 	3N**622222	3 	3r   c                    || _         |                    d          rt          }nC|                    d          rt          }n&|                    d          rt          }n	d| _        dS i }g }|                                D ]9\  }}|D ]1}|                    |          }	|                    |	           |||	<   2:t          |          }
t          |||
|           | _        dS )z
        Rebuild our view of the topology from fresh rows from the
        system topology tables.
        For internal use only.
        RandomPartitionerMurmur3PartitionerByteOrderedPartitionerN)partitionerendswithMD5TokenMurmur3Token
BytesTokenr>  r
  from_stringappendsortedTokenMap)r   rI  r>  token_classtoken_to_host_ownerringhosttoken_stringstoken_stringr   
all_tokenss              r   rebuild_token_mapzMetadata.rebuild_token_map  s    ' 344 	"KK!!"677 	&KK!!":;; 	$KK!DNF #,??#4#4 	2 	2D- - 2 2#//==E"""-1#E**2
 D\\
!,j$@ @r   c                     | j         }|sg S 	 |                    ||j                            |                    S # t          $ r g cY S w xY w)zq
        Returns a list of :class:`.Host` instances that are replicas for a given
        partition key.
        )r>  get_replicasrR  from_key	NoMurmur3)r   rV   rT   ts       r   r[  zMetadata.get_replicas1  se    
 N 	I	>>(AM,B,B3,G,GHHH 	 	 	III	s   -; A
	A
c                 L    | j                             d          r	t          dS dS )NrG  FT)rI  rJ  r
   r   s    r   can_support_partitionerz Metadata.can_support_partitioner>  s*    $$%9:: 	w54r   c                     | j         5  	 | j        |j                 dfcddd           S # t          $ r" || j        |j        <   |dfcY cddd           S w xY w# 1 swxY w Y   dS )z
        Returns a tuple (host, new), where ``host`` is a Host
        instance, and ``new`` is a bool indicating whether
        the host was newly added.
        FNT)r   r   r   r"  r   rU  s     r   add_or_return_hostzMetadata.add_or_return_hostD  s      	" 	""{4=158	" 	" 	" 	" 	" 	" 	" 	"  " " "-1DM*Tz!!	" 	" 	" 	" 	" 	" 	" 	""	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s,   A*AAAAA Ac                     | j         5  t          | j                            |j        d                    cd d d            S # 1 swxY w Y   d S r   )r   boolr   r  r   rb  s     r   remove_hostzMetadata.remove_hostQ  s     	? 	?u==>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s   -AA	Ac                     t          |t                    s|                     ||          S | j                            |          S )a  
        Find a host in the metadata for a specific endpoint. If a string inet address and port are passed,
        iterate all hosts to match the :attr:`~.pool.Host.broadcast_rpc_address` and
        :attr:`~.pool.Host.broadcast_rpc_port`attributes.
        )r  r   _get_host_by_addressr   r  )r   endpoint_or_addressports      r   r   zMetadata.get_hostU  sD     -x88 	H,,-@$GGG{2333r   c                     | j                                         D ]%}|j        |k    r||j        |j        |k    r|c S &d S r   )r   r   broadcast_rpc_addressbroadcast_rpc_port)r   addressrj  rU  s       r   rh  zMetadata._get_host_by_address`  sW    K&&(( 	 	D*g55\T%<%DH_cgHgHgtr   c                     | j         5  t          | j                                                  cddd           S # 1 swxY w Y   dS )zV
        Returns a list of all known :class:`.Host` instances in the cluster.
        N)r   rZ   r   r   r   s    r   	all_hostszMetadata.all_hostsh  s      	. 	.**,,--	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   &;??NNr   )"__name__
__module____qualname____doc__cluster_namerW   rI  r>  r   r   r   r   r   r   r  r#  r&  r)  r,  r0  r2  r6  r8  r  r  r  rY  r[  r`  rc  rf  r   rh  rp  r   r   r   r   r   b   s         L+I K IHE@# # #T T TO O O O8+ + +&* * * * - - -                K K KK K K3 3 3@ @ @:    " " "? ? ?	4 	4 	4 	4   . . . . .r   r   zorg.apache.cassandra.locator.c                 ^    |                      |          r| t          |          d          S | S r   )
startswithlen)sprefixs     r   trim_if_startswithr|  s  s/    ||F VHr   c                       e Zd Zd ZdS )ReplicationStrategyTypeTypec                     |                     d|           t                              | |||          }|                    d          s
|t          |<   |S )Nr  _)
setdefaultr   __new__rx  _replication_strategies)metaclsr  basesdctclss        r   r  z#ReplicationStrategyTypeType.__new__}  sQ    vt$$$ll7D%55s## 	0,/#D)
r   N)rr  rs  rt  r  r   r   r   r~  r~  |  s#            r   r~  c                   4    e Zd ZdZed             Zd Zd ZdS )_ReplicationStrategyNc                 (   |sd S t          |t                    }t                              |d           }|t	          |          }|t          |<   	  ||          }n5# t
          $ r(}t                              d|||           Y d }~d S d }~ww xY w|S )Nz&Failed creating %s with options %s: %s)r|  !REPLICATION_STRATEGY_CLASS_PREFIXr  r  _UnknownStrategyBuilder	Exceptionlogwarning)r  strategy_classoptions_mapstrategy_namers_classrs_instanceexcs          r   r0   z_ReplicationStrategy.create  s     	4*>;\]]*..}dCC.}==H5=#M2	"(;//KK 	 	 	KK@-Q\^abbb44444	 s   A 
B'B

Bc                     t                      r   NotImplementedErrorr   rS  rT  s      r   make_token_replica_mapz+_ReplicationStrategy.make_token_replica_map      !###r   c                     t                      r   r  r   s    r   export_for_schemaz&_ReplicationStrategy.export_for_schema  r  r   )rr  rs  rt  r  classmethodr0   r  r  r   r   r   r  r    sP        K  [&$ $ $$ $ $ $ $r   r  )	metaclassc                       e Zd Zd Zd ZdS )r  c                     || _         d S r   r  )r   r  s     r   r   z _UnknownStrategyBuilder.__init__  s    			r   c                 0    t          | j        |          }|S r   )_UnknownStrategyr  )r   r  strategy_instances      r   __call__z _UnknownStrategyBuilder.__call__  s    ,TYDD  r   N)rr  rs  rt  r   r  r   r   r   r  r    s2          ! ! ! ! !r   r  c                   &    e Zd Zd Zd Zd Zd ZdS )r  c                     || _         ||                                nt                      | _        | j         | j        d<   d S )Nclass)r  copyr	  r  )r   r  r  s      r   r   z_UnknownStrategy.__init__  s@    	1<1H;++---dff$(I!!!r   c                 l    t          |t                    o| j        |j        k    o| j        |j        k    S r   )r  r  r  r  r   others     r   __eq__z_UnknownStrategy.__eq__  s9    5"233 6	UZ'6 E$55	7r   c                     | j         r0t          d | j                                         D                       S d| j        dS )
        Returns a string version of these replication options which are
        suitable for use in a CREATE KEYSPACE statement.
        c              3   X   K   | ]%\  }}t          |          t          |          fV  &d S r   )str)r   rT   values      r   r   z5_UnknownStrategy.export_for_schema.<locals>.<genexpr>  s7      ZZ:3S3u::.ZZZZZZr   z{'class': ''})r  r	  r
  r  r   s    r   r  z"_UnknownStrategy.export_for_schema  sQ    
  	[ZZAQAWAWAYAYZZZZZZ	[$(III00r   c                     i S r   r   r  s      r   r  z'_UnknownStrategy.make_token_replica_map      	r   N)rr  rs  rt  r   r  r  r  r   r   r   r  r    sP        . . .
7 7 7
1 1 1    r   r  c                   N    e Zd ZdZdZ	 dZ	 dZ	 ddZed             Z	d Z
d ZdS )ReplicationFactorz9
    Represent the replication factor of a keyspace.
    Nc                 >    || _         || _        |r||z
  n|| _        d S r   )all_replicastransient_replicasfull_replicas)r   r  r  s      r   r   zReplicationFactor.__init__  s1    ("4DVhl-???\hr   c                 J   d}	 t          |           }n# t          $ rt 	 |                     d          } t          | d                   t          | d                   }}n0# t          $ r# t          d                    |                     w xY wY nw xY wt          ||          S )zp
        Given the inputted replication factor string, parse and return the ReplicationFactor instance.
        N/r      z/Unable to determine replication factor from: {})rP   r   splitr  formatr  )rfr  r  s      r   r0   zReplicationFactor.create  s    
 "	_r77LL 	_ 	_ 	__XXc]]36r!u::s2a5zz0 _ _ _ !R!Y!YZ\!]!]^^^_ 	_ !/ABBBs&    
B?AB-BBBc                 F    | j         rd| j        | j         fz  n	d| j        z  S )Nz%d/%dz%d)r  r  r   s    r   __str__zReplicationFactor.__str__  s2    JNJa .4,d.EFFFD--	/r   c                 p    t          |t                    sdS | j        |j        k    o| j        |j        k    S r   )r  r  r  r  r  s     r   r  zReplicationFactor.__eq__  s<    %!233 	5 E$66d4;MQVQd;ddr   r   )rr  rs  rt  ru  r  r  r  r   staticmethodr0   r  r  r   r   r   r  r    s          L M
 i i i i
 C C \C / / /e e e e er   r  c                   B    e Zd ZdZ	 ed             Zd Zd Zd Zd Z	dS )SimpleStrategyNc                     | j         j        S )a  
        The replication factor for this keyspace.

        For backward compatibility, this returns the
        :attr:`cassandra.metadata.ReplicationFactor.full_replicas` value of
        :attr:`cassandra.metadata.SimpleStrategy.replication_factor_info`.
        )replication_factor_infor  r   s    r   replication_factorz!SimpleStrategy.replication_factor  s     +99r   c                 P    t                               |d                   | _        d S )Nr  )r  r0   r  r   r  s     r   r   zSimpleStrategy.__init__  s$    '8'?'?L`@a'b'b$$$r   c                    i }t          t          |                    D ]}dt                      }}t          |          | j        k     r|t          |          k     rl|||z   t          |          z           }||         }||vr|                    |           |dz  }t          |          | j        k     r|t          |          k     l||||         <   |S )Nr   r  )rangery  rZ   r  rO  )	r   rS  rT  replica_mapijhostsr   rU  s	            r   r  z%SimpleStrategy.make_token_replica_map  s    s4yy!! 		) 		)A$&&uAe**t6661s4yy==a!es4yy01*51u$$LL&&&Q e**t6661s4yy== $)KQ  r   c                 2    dt          | j                  dS )r  z3{'class': 'SimpleStrategy', 'replication_factor': 'r  )r  r  r   s    r   r  z SimpleStrategy.export_for_schema#  s$      d233336 	6r   c                     t          |t                    sdS t          | j                  t          |j                  k    S r   )r  r  r  r  r  s     r   r  zSimpleStrategy.__eq__+  s:    %00 	54/00C8U4V4VVVr   )
rr  rs  rt  r  propertyr  r   r  r  r  r   r   r   r  r     s~        " : : X:c c c  6 6 6W W W W Wr   r  c                   2    e Zd ZdZ	 dZ	 d Zd Zd Zd ZdS )NetworkTopologyStrategyNc                     t          d |                                D                       | _        t          d | j                                        D                       | _        d S )Nc              3   n   K   | ]0\  }}t          |          t                              |          fV  1d S r   )r  r  r0   r   kvs      r   r   z3NetworkTopologyStrategy.__init__.<locals>.<genexpr>B  sY       0^ 0^6:aSVV&--a0010^ 0^ 0^ 0^ 0^ 0^r   c              3   .   K   | ]\  }}||j         fV  d S r   )r  )r   dcr  s      r   r   z3NetworkTopologyStrategy.__init__.<locals>.<genexpr>D  sG       +[ +['-r2R!"+[ +[ +[ +[ +[ +[r   )r	  r
  dc_replication_factors_infodc_replication_factors)r   r  s     r   r   z NetworkTopologyStrategy.__init__A  s    +/ 0^ 0^>T>Z>Z>\>\0^ 0^ 0^ ,^ ,^(&* +[ +[151Q1W1W1Y1Y+[ +[ +[ '[ '[###r   c                 D   t          d | j                                        D                       }t          t                    }t          t
                    }t          t
                    }t          |          D ]\  }}||         }	||	j                                     |           |	j        rL|	j	        rE||	j                 
                    |	j	                   ||	j                 
                    |	           t          t                    }
t          t                    }t          t          |                    D ]}|||                  }|                                D ]}||vr||         }|
|         }t          |          }||k     r#||         |k     r|dz  }||k     r||         |k     ||
|<   ||         }d}g }t                      }||         }t          ||                   }t          |||z             D ]}|t          |          k    r|t          |          z
  }||         }|||                  }	|dk    s||k    r n|	|v rQ|	j	        |v r6t          |          t          |          k     r|                    |	           |                    |	           |dz  }|dz  }|
                    |	j	                   t          |          t          |          k    r,|D ]$}	|dk    r n|                    |	           |dz  }%|d d = |S )Nc              3   0   K   | ]\  }}|d k    ||fV  dS )r   Nr   )r   r  r  s      r   r   zANetworkTopologyStrategy.make_token_replica_map.<locals>.<genexpr>H  sB       " "$5Bq       " "r   r  r   )r	  r  r
  r   rZ   ry   	enumerate
datacenterrO  rackr   rP   r  ry  rU   )r   rS  rT  	dc_rf_mapdc_to_token_offsetdc_rackshosts_per_dcr  r   rU  dc_to_current_indexr  replicasr  token_offsetsrJ   
num_tokensreplicas_remainingreplicas_this_dcskipped_hostsracks_placedracks_this_dchosts_this_dctoken_offset_indextoken_offsets                            r   r  z.NetworkTopologyStrategy.make_token_replica_mapG  s    " "9=9T9Z9Z9\9\" " " " "	 )..s##"3''!$ 	8 	8HAu&u-Dt/66q999 849 8)--di888T_-11$777 *#..!$''s4yy!! 3	- 3	-A"47+H )--// /- /-Y&& !32 6+B/ //
j((]5-AA-E-EQJE j((]5-AA-E-E*/#B'%.r]"#$  ""uu ( #L$4 5 5*/uZ7G*H*H - -&)S-?-???-?#mBTBT-T*#01C#DL.tL/ABD)Q..2Bm2S2Sx'' yL00S5F5F]I[I[5[5[%,,T222 OOD)))$)$&!+& $$TY///<((C,>,>>>$1 4 4D1Q66 %$OOD111.!3..)!!!,_/-b r   c                     d}t          | j                                                  D ]\  }}|d|dt          |          dz  }|dz   S )r  z#{'class': 'NetworkTopologyStrategy'z, '': ''})rP  r  r
  r  )r   retr  r  s       r   r  z)NetworkTopologyStrategy.export_for_schema  s^    
 4T=CCEEFF 	2 	2FBCRRRR11CCSyr   c                 P    t          |t                    sdS | j        |j        k    S r   )r  r  r  r  s     r   r  zNetworkTopologyStrategy.__eq__  s+    %!899 	5/53TTTr   )	rr  rs  rt  r  r  r   r  r  r  r   r   r   r  r  2  st        "& "[ [ [K K KZ  U U U U Ur   r  c                   &    e Zd Zd Zd Zd Zd ZdS )LocalStrategyc                     d S r   r   r  s     r   r   zLocalStrategy.__init__  s    r   c                     i S r   r   r  s      r   r  z$LocalStrategy.make_token_replica_map  r  r   c                     dS )r  z{'class': 'LocalStrategy'}r   r   s    r   r  zLocalStrategy.export_for_schema  s
    
 ,+r   c                 ,    t          |t                    S r   )r  r  r  s     r   r  zLocalStrategy.__eq__  s    %///r   N)rr  rs  rt  r   r  r  r  r   r   r   r  r    sP            , , ,0 0 0 0 0r   r  c                       e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 dZ		 dZ
	 dZ	 dZ	 dZ	 dZ	 dZ	 ddZed             Zd Zd Zd	 Zd
 Zd Zd Zd ZdS )KeyspaceMetadataz?
    A representation of the schema for a single keyspace.
    NTFc                     || _         || _        t                              ||          | _        i | _        i | _        i | _        i | _        i | _	        i | _
        || _        d S r   )r  durable_writesReplicationStrategyr0   r  r  r  r   rF   r  r  graph_engine)r   r  r  r  strategy_optionsr  s         r   r   zKeyspaceMetadata.__init__  sb    	,$7$>$>~O_$`$`!
(r   c                     | j         d uS r   )r  r   s    r   is_graph_enabledz!KeyspaceMetadata.is_graph_enabled
  s     ,,r   c                 z   d | j                                         D             fd| j                                         D             }d                    |                                 dz   g|                                 z   d | j                                        D             z   d | j                                        D             z   d |z   D             z             }| j        r/dd	l}d
| j	        z  } |j
        | j         D ]}||z  }|d|z  z  }|S | j        rd                    | j	        |          S |S )z
        Returns a CQL query string that can be used to recreate the entire keyspace,
        including user-defined types and tables.
        c                 @    g | ]}t          |d           |j        |S )vertex)hasattrr  r   r^  s     r   r  z5KeyspaceMetadata.export_as_string.<locals>.<listcomp>  s0    cccAHAUAUcZ[Zbcacccr   c                     g | ]}|v|	S r   r   )r   r^  tables_with_vertexs     r   r  z5KeyspaceMetadata.export_as_string.<locals>.<listcomp>  s$    WWWa1DV;V;V;V;V;Vr   r   ;c                 6    g | ]}|                                 S r   r   )r   fs     r   r  z5KeyspaceMetadata.export_as_string.<locals>.<listcomp>  s$    CCCaQ!!CCCr   c                 6    g | ]}|                                 S r   r   )r   as     r   r  z5KeyspaceMetadata.export_as_string.<locals>.<listcomp>  s$    DDDaQ!!DDDr   c                 6    g | ]}|                                 S r   r   r  s     r   r  z5KeyspaceMetadata.export_as_string.<locals>.<listcomp>  s$    MMMaQ!!MMMr   r   NzO/*
Warning: Keyspace %s is incomplete because of an error processing metadata.
`
Approximate structure, for reference:
(this should not be used to reproduce this schema)

%s
*/zt/*
Warning: Keyspace {ks} is a virtual keyspace and cannot be recreated with CQL.
Structure, for reference:*/
{cql}
)r   cql)r  r   r   as_cql_queryuser_type_stringsrF   r  	_exc_info	tracebackr  format_exceptionvirtualr  )r   other_tablesr  r  r  liner  s         @r   r   z!KeyspaceMetadata.export_as_string  s    dc););)=)=cccWWWW4;#5#5#7#7WWWkk  3&'""$$%CC4>+@+@+B+BCCCD ED4?+A+A+C+CDDDE NM+=+LMMM	NO O > 	e9C2	2DNC  tz  ~A  A  ACJ< 	6 $)556 
r   c                    | j         r'd                    t          | j                            S dt          | j                  d| j                                        d}|d| j        rdndz  z   }| j        |d	| j        z  z   }|S )
z
        Returns a CQL query string that can be used to recreate just this keyspace,
        not including user-defined types and tables.
        z// VIRTUAL KEYSPACE {}zCREATE KEYSPACE z WITH replication =  z AND durable_writes = %struefalseNz AND graph_engine = '%s')r   r  protect_namer  r  r  r  r  r   r  s     r   r  zKeyspaceMetadata.as_cql_query-  s    
 < 	L+22<	3J3JKKK	L ####%779999; /T=P3]66V]^_(3d6GGHC
r   c                     g }| j                                         }t          |                                          }|D ]}||v r|                     |||           |S r   )r   r  rP  rU   resolve_user_types)r   r  r   rU   r  s        r   r  z"KeyspaceMetadata.user_type_strings<  sl    _))++
joo''(( 	J 	JAJ'':7HIII  r   c                     |                     |          }|j        D ]4}t          j        |          D ]}||v r|                     |||           5|                    |                                           d S r   )r  field_typestypescql_types_from_stringr*  rO  r   )r   rT   r   r  	user_type	type_namesub_types          r   r*  z#KeyspaceMetadata.resolve_user_typesE  s    NN3''	". 	U 	UI!7	BB U Uz))++HjBSTTTU 	  !;!;!=!=>>>>>r   c                 >   i }| j                             j        d           }|r|j        _        |j        }j                                        D ]\  }}|| j        |<   fd|D             D ]}| j                            |d            | j         j        <   d S )Nc              3   .   K   | ]}|j         v|V  d S r   )r  )r   ntable_metadatas     r   r   z7KeyspaceMetadata._add_table_metadata.<locals>.<genexpr>[  s0      UUQn>T5T5T15T5T5T5TUUr   )r  r  r  r  r  r
  r  )r   r5  old_indexesold_meta
index_nameindex_metadatas    `    r   r   z$KeyspaceMetadata._add_table_metadataM  s    ;??>#6== 	+#+>N "*K +9*@*F*F*H*H 	6 	6&J'5DL$$UUUUkUUU 	/ 	/JLZ....+9N'(((r   c                    | j                             |d           }|rL|j        D ]}| j                            |d            |j        D ]}| j                            |d            d S | j                            |d           }|r?	 | j         |j                 j                            |d            d S # t
          $ r Y d S w xY wd S r   )r  r  r  r  base_table_namer"  )r   
table_name
table_metar8  	view_name	view_metas         r   r%  z%KeyspaceMetadata._drop_table_metadata`  s    [__Z66
 	(0 3 3
  T2222'- 0 0	
y$////F JNN:t44	 	I56<@@TRRRRR   	 	s   +B5 5
CCc                     	 || j         |j                 j        |j        <   || j        |j        <   d S # t          $ r Y d S w xY wr   )r  r;  r  r  r"  )r   view_metadatas     r   r!  z#KeyspaceMetadata._add_view_metadataq  sX    	S`DK56<]=OP-:DJ})*** 	 	 	DD	s   .2 
A A r   )rr  rs  rt  ru  r  r  r  r  r  r   rF   r  r  r   r  r  r   r  r  r   r  r  r*  r   r%  r!  r   r   r   r  r    sA         D,N
   F G J I J E G L I*
) 
) 
) 
) - - X-  >  ! ! !? ? ?: : :&  "    r   r  c                   >    e Zd ZdZdZ	 dZ	 dZ	 dZ	 d ZddZ	d Z
dS )UserTypez
    A user defined type, as created by ``CREATE TYPE`` statements.

    User-defined types were introduced in Cassandra 2.1.

    .. versionadded:: 2.1.0
    Nc                 F    || _         || _        |pg | _        |pg | _        d S r   )rV   r  field_namesr,  )r   rV   r  rE  r,  s        r   r   zUserType.__init__  s0     	&,"&,"r   Fc                 p   dt          | j                  dt          | j                  d|rdnd}|rd}dnd}dg }t          | j        | j                  D ],\  }}|                    t          |          d	|           -||                    fd
|D                       z  }||rdndz  }|S )z
        Returns a CQL query that can be used to recreate this type.
        If `formatted` is set to :const:`True`, extra whitespace will
        be added to make the query more readable.
        zCREATE TYPE . (
 ,
    , r$  c              3   $   K   | ]
}|V  d S r   r   )r   r   paddings     r   r   z(UserType.as_cql_query.<locals>.<genexpr>  s,      MMU%%8MMMMMMr   z
)))r'  rV   r  ziprE  r,  rO  r   )r   	formattedr  
field_joinfields
field_name
field_typerO  s          @r   r  zUserType.as_cql_query  s      ''''####%DD2%'
  	JGGJG&)$*:D<L&M&M 	L 	L"J
MM\*%=%=%=%=zzJKKKKzMMMMfMMMMMM	*uus*
r   c                 4    |                      d          dz   S NTrR  r  r  r   s    r   r   zUserType.export_as_string        4 00366r   F)rr  rs  rt  ru  rV   r  rE  r,  r   r  r   r   r   r   rC  rC  y  s          H D K K- - -   47 7 7 7 7r   rC  c                   r    e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 dZ		 dZ
	 dZ	 dZ	 d ZddZd Zed             ZdS )		Aggregatez
    A user defined aggregate function, as created by ``CREATE AGGREGATE`` statements.

    Aggregate functions were introduced in Cassandra 2.2

    .. versionadded:: 2.6.0
    Nc
                     || _         || _        || _        || _        || _        || _        || _        || _        |	| _        d S r   )	rV   r  argument_types
state_func
state_type
final_funcinitial_conditionreturn_typer8   )
r   rV   r  r`  ra  rb  rc  rd  re  r8   s
             r   r   zAggregate.__init__  sM     !	,$$$!2&*r   Fc                 &   |rdnd}t          | j                  }t          | j                  }d                    d | j        D                       }t          | j                  }t          j        | j                  }dt                      z  }|| j
        r*d                    |dt          | j
                  f          ndz  }|| j        d                    |d	| j        f          ndz  }|| j        rd
                    |          ndz  }|S )z
        Returns a CQL query that can be used to recreate this aggregate.
        If `formatted` is set to :const:`True`, extra whitespace will
        be added to make the query more readable.
        
    r$  rM  c                 6    g | ]}t          j        |          S r   )r-  strip_frozen)r   arg_types     r   r  z*Aggregate.as_cql_query.<locals>.<listcomp>  s#    ```u1(;;```r   zkCREATE AGGREGATE %(keyspace)s.%(name)s(%(type_list)s)%(sep)sSFUNC %(state_func)s%(sep)sSTYPE %(state_type)srJ  z
FINALFUNC Nz	INITCOND z{}DETERMINISTIC)r'  rV   r  r   r`  ra  r-  ri  rb  localsrc  rd  r8   r  )	r   rR  seprV   r  	type_listra  rb  r  s	            r   r  zAggregate.as_cql_query  s    $,hh..DI&&II``DL_```aa	!$/22
'88
%'-xx0 	doerww\<+H+HIJJJceedF\Fhrww[$*@ABBBnpp0BJ '',,,J
r   c                 4    |                      d          dz   S rX  rZ  r   s    r   r   zAggregate.export_as_string  r[  r   c                 @    t          j        | j        | j                  S r   r   format_signaturer  r`  r   s    r   r.  zAggregate.signature      "3DIt?RSSSr   r\  )rr  rs  rt  ru  rV   r  r`  rc  rd  re  ra  rb  r8   r   r  r   r  r.  r   r   r   r^  r^    s          H D N J  K J J M
+ + +   .7 7 7 T T XT T Tr   r^  c                   ~    e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 dZ		 dZ
	 dZ	 dZ	 dZ	 dZ	 d ZddZd Zed             ZdS )	Functionz
    A user defined function, as created by ``CREATE FUNCTION`` statements.

    User-defined functions were introduced in Cassandra 2.2

    .. versionadded:: 2.6.0
    Nc                     || _         || _        || _        |pg | _        || _        || _        || _        || _        |	| _        |
| _	        || _
        d S r   )rV   r  r`  argument_namesre  rX   bodycalled_on_null_inputr8   ra   monotonic_on)r   rV   r  r`  rv  re  rX   rw  rx  r8   ra   ry  s               r   r   zFunction.__init__b  sd     !	, -2& 	$8!*"(r   Fc                    |rdnd}t          | j                  }t          | j                  }d                    d t	          | j        | j                  D                       }| j        }| j        }| j	        }| j
        rdnd}	| j        rd                    |          nd}
d}| j        rd	                    |          }n(| j        r!d
                    | j        d         |          }dt                      z  S )
        Returns a CQL query that can be used to recreate this function.
        If `formatted` is set to :const:`True`, extra whitespace will
        be added to make the query more readable.
        rg  r$  rM  c                 `    g | ]+\  }}t          |          d t          j        |          ,S )r$  )r'  r-  ri  )r   r4  r^  s      r   r  z)Function.as_cql_query.<locals>.<listcomp>|  sO     X X X!%A *6a%:LQ:O:O:OP X X Xr   CALLEDzRETURNS NULLzDETERMINISTIC{}rJ  zMONOTONIC{}zMONOTONIC ON {}{}r   zCREATE FUNCTION %(keyspace)s.%(name)s(%(arg_list)s)%(sep)s%(on_null)s ON NULL INPUT%(sep)sRETURNS %(typ)s%(sep)s%(deterministic_token)s%(monotonic_tokens)sLANGUAGE %(lang)s%(sep)sAS $$%(body)s$$)r'  rV   r  r   rQ  rv  r`  re  rX   rw  rx  r8   r  ra   ry  rk  )r   rR  rl  rV   r  arg_listtyplangrw  on_nulldeterministic_tokenmonotonic_tokenss               r   r  zFunction.as_cql_querys  s5    $,hh..DI&&99 X X),T-@$BU)V)VX X X Y Y}y"7K((^"&"4 "077<<<! 	 > 	?,33C88 	?  399$:KA:N:= ?  ?! $*88, 	,r   c                 4    |                      d          dz   S rX  rZ  r   s    r   r   zFunction.export_as_string  r[  r   c                 @    t          j        | j        | j                  S r   rp  r   s    r   r.  zFunction.signature  rr  r   r\  )rr  rs  rt  ru  rV   r  r`  rv  re  rX   rw  rx  r8   ra   ry  r   r  r   r  r.  r   r   r   rt  rt    s          H D N N K H D  
 M
 I
 L
) ) )"#, #, #, #,J7 7 7 T T XT T Tr   rt  c                       e Zd ZdZdZ	 dZ	 dZ	 dZ	 ed             Z	dZ
	 dZ	 dZdZ	 ddddZdZ	 dZ	 dZ	 dZ	 ed	             ZdZ	 dd
Zd Zd ZddZedd            Zed             ZdS )r  z<
    A representation of the schema for a single table.
    Nc                      | j         | j        z   S )z{
        A list of :class:`.ColumnMetadata` representing the components of
        the primary key for this table.
        partition_keyclustering_keyr   s    r   primary_keyzTableMetadata.primary_key  s     !D$777r   Fmin_thresholdmax_thresholdr  )min_compaction_thresholdmax_compaction_thresholdcompaction_strategy_classc                     | j         rdS t          | dd          }|rO| j        oDt          | j                  t          | j                  dz   k    ot          | j                  dk    }| S dS )zX
        A boolean indicating if this table can be represented as CQL in export
        F
comparatorNr  T)r   r   is_compact_storagery  r   r  r  )r   r  incompatibles      r   is_cql_compatiblezTableMetadata.is_cql_compatible  s    
 < 	5T<66
 	$ !3 :--D4D0E0E0II: 3449  $##tr   c	                     || _         || _        |g n|| _        |g n|| _        |t	                      n|| _        i | _        |i n|| _        d | _        |t	                      n|| _	        i | _
        || _        d S r   )r  r  r  r  r   r   r  rj   r  triggersr  r   )	r   r  r  r  r  r   r  rj   r   s	            r   r   zTableMetadata.__init__  s    *	#0#8RRm$2$:bb(/{}}}W$_rr')1)9x
r   c                    | j         rIddl}d| j        d| j        d} |j        | j          D ]}||z  }|d|                                 z  z  }n| j        s.d| j        d| j        d}|d|                                 z  z  }nP| j        r5d                    | j        | j        |                                 	          }n|                                 }|S )
z
        Returns a string of CQL queries that can be used to recreate this table
        along with all indexes on it.  The returned string is formatted to
        be human readable.
        r   Nz/*
Warning: Table rG  z8 is incomplete because of an error processing metadata.
r  zY omitted because it has constructs not compatible with CQL (was created via legacy API).
zt/*
Warning: Table {ks}.{tab} is a virtual table and cannot be recreated with CQL.
Structure, for reference:
{cql}
*/)r   tabr  )	r  r  r  r  r  _all_as_cqlr  r   r  )r   r  r  r"  s       r   r   zTableMetadata.export_as_string  sP    > 	%%%%tyyy2C2	2DNC  tz  ~B  ~N  ~N  ~P  ~P  P  PCC' 	% 	% %%%tyyy2Cz  ~B  ~N  ~N  ~P  ~P  P  PCC\ 	% &$*<$)QUQaQaQcQc d d C
 ""$$C
r   c                 T   |                      d          }|dz  }| j                                        D ]}|d|                                 z  z  }| j                                        D ]}|d|                                 dz  }| j                                        D ]}|d|                     d          dz  } | j        r_t          j        }|                                | j        z  D ]6}||         }|	                    | || j        |                   }|r|d|z  }7|S )NTrY  r  z
%s;rI  r   )
r  r  r   r  r  
extensions_RegisteredExtensionType_extension_registryrU   after_table_cql)	r   r  rJ   trigger_metar?  registryr  extr  s	            r   r  zTableMetadata._all_as_cql0  sX   $//s
\((** 	2 	2E7U//1111CC M0022 	< 	<LCl779999;;CC**,, 	I 	IIC	 6 6 6 F F F FHHCC? 	-/CH]]__t6 - -qk))$4?13EFF -Css,,C
r   c                    | j         rdnddt          | j                  dt          | j                  d|rdnd}|rd}d	nd
}dg }| j                                        D ]>}|                    t          |j                  d|j        |j        rdnd           ?t          | j
                  dk    r| j        s|dxx         dz  cc<   ||                    fd|D                       z  }t          | j
                  dk    s| j        r||dz  }t          | j
                  dk    r+|dd
                    d | j
        D                       z  z  }n"|t          | j
        d         j                  z  }| j        r*|dd
                    d | j        D                       z  z  }|dz  }|d|rdndz  z  }||                     || j        | j        | j                  z  }|S )z
        Returns a CQL query that can be used to recreate this table (index
        creations are not included).  If `formatted` is set to :const:`True`,
        extra whitespace will be added to make the query human readable.
        VIRTUALCREATEz TABLE rG  rH  rI  rJ  rK  rL  rM  r$  z staticr  r   z PRIMARY KEYc              3   $   K   | ]
}|V  d S r   r   )r   colrO  s     r   r   z-TableMetadata.as_cql_query.<locals>.<genexpr>a  s,      KKC''33 7KKKKKKr   zPRIMARY KEY ((%s)c              3   >   K   | ]}t          |j                  V  d S r   r'  r  r   r  s     r   r   z-TableMetadata.as_cql_query.<locals>.<genexpr>h  s,      )_)_S,sx*@*@)_)_)_)_)_)_r   , %sc              3   >   K   | ]}t          |j                  V  d S r   r  r  s     r   r   z-TableMetadata.as_cql_query.<locals>.<genexpr>m  s,      )`)`S,sx*@*@)`)`)`)`)`)`r   rP  z	%s) WITH )r   r'  r  r  r   r   rO  cql_type	is_staticry  r  r  r   _property_stringrj   r  )r   rR  r  column_joinr   r  rO  s         @r   r  zTableMetadata.as_cql_queryG  s[    ,4YYH44+,,,,####%DD2%	'  	KGGKG<&&(( 	s 	sCNNSX(>(>(>(>[^[hNpiinpNpqrrrrt!""a''0C'AJJJ.(JJJ{KKKK7KKKKKK t!""Q&&$*=&++www??C4%&&**v		)_)_DL^)_)_)_ _ ___|D$6q$9$>???" av		)`)`DL_)`)`)` ` ```3JC 	{i7ddR88t$$Y0CT\SWSjkkk
r   c                    g }|r|                     d           |rpd}g }|D ]9}|j        rdnd}	|                     t          |j                  d|	           :|dd                    |          z  z  }|                     |           |                    |                     |                     |rdnd	}
|
                    |          S )
NzCOMPACT STORAGEzCLUSTERING ORDER BY DESCASCr$  r  rM  z	
    AND z AND )rO  is_reversedr'  r  r   extend_make_option_strings)r  rR  r  r  r  
propertiescluster_strinnerr  orderingjoin_strs              r   r  zTableMetadata._property_stringw  s    
 	1/000 		+0KE% K K%(_?66%SX(>(>(>(>IJJJJ6DIIe$4$444Kk***#22;??@@@#,9<<'}}Z(((r   c                    g }t          |                                          }t          j        |                    dd                    }|                    dd           }|                    d|           d |                                D             }|                    dd                    |          z             | j        	                                D ]}|                    |d            |                    dd            |
                    d	          sqt          j        |                    d
d                    }d |                                D             }	|                    dd                    |	          z             |                                D ]8\  }
}|1|
dk    r|pd}|                    |
dt          |                     9t          t          |                    S )Ncompaction_strategy_optionsz{}r  r  c                 &    g | ]\  }}d |d|d S r  r  r   r  s      r   r  z6TableMetadata._make_option_strings.<locals>.<listcomp>  s+    $^$^$^tq!!QQQ%:$^$^$^r   zcompaction = {%s}rM  compaction_strategy_optioncompressioncompression_parametersc                 &    g | ]\  }}d |d|d S r  r   r  s      r   r  z6TableMetadata._make_option_strings.<locals>.<listcomp>  s+    NNNtq!!QQQ2NNNr   zcompression = {%s}commentrJ   = )r	  r
  rS   loadsr  r  rO  r   compaction_optionsrU   r  protect_valuerZ   rP  )r  r  r  options_copyactual_optionsr  compaction_option_stringssystem_table_nameparamsparam_stringsr  s              r   r  z"TableMetadata._make_option_strings  s   K--//00L$4$45RTX$Y$YZZ  !<dCC!!'5111$^$^~G[G[G]G]$^$^$^!

&3L)M)MMNNN!$!7!<!<!>!> 	6 	6.55555t<<<.. 	HZ 0 01I4 P PQQFNNv||~~NNNMJJ+dii.F.FFGGG'--// 	E 	EKD% 9$$!KRE

mE.B.B.BCDDDF3KK   r   )NNNNNFr\  )rr  rs  rt  ru  r  r  r  r  r  r  r   r  r  rj   r  r  r  r  r   r  r  r   r   r  r  r  r  r  r   r   r   r  r    sx         M0D)M N 8 8 X8 G G G %4$3%,. .
 H E I*G   X" J     8  .. . . .` ) ) ) [)* ! ! [! ! !r   r  c                   J    e Zd ZdZi Zg dZed             Zed             Z	dS )TableMetadataV3z
    For C* 3.0+. `option_maps` take a superset of map names, so if  nothing
    changes structurally, new option maps can just be appended to the list.
    )
compactionr  cachingnodesyncc                     dS )NTr   r   s    r   r  z!TableMetadataV3.is_cql_compatible  s    tr   c                     g }t          |                                          }| j        D ]{}|                    |          }t	          |t
                    rO||= d |                                D             }|                    |dd                    |          d           ||                                D ]8\  }}|1|dk    r|pd}|                    |dt          |                     9t          t          |                    S )Nc              3   .   K   | ]\  }}d |d|d V  dS )r  r  Nr   r  s      r   r   z7TableMetadataV3._make_option_strings.<locals>.<genexpr>  s5      JJDAqq!!!QQQ/JJJJJJr   z = {rM  r  r  rJ  r  )r	  r
  option_mapsr  r  r   rO  r   r  rZ   rP  )r  r  r  r  optionr  r  r  s           r   r  z$TableMetadataV3._make_option_strings  s    K--//00o 	F 	FF $$V,,E%)) F (JJEKKMMJJJ

&&&$))F2C2C2C2CDEEE'--// 	E 	EKD% 9$$!KRE

mE.B.B.BCDDDF3KK   r   N)
rr  rs  rt  ru  r  r  r  r  r  r  r   r   r   r  r    sm            K
   X ! ! [! ! !r   r  c                   B     e Zd ZdZ	 dZ	 d fd	Zed             Z xZS )TableMetadataDSE68NFc                    t          t          |                               |          }| j        r|dt	          | j        j                  z  z  }| j        r|dt	          | j        j                  z  z  }||                     | j        j        | j        j	        | j        j
        d          z  }||                     | j        j        | j        j        | j        j        d          z  }|S )Nz AND VERTEX LABEL %sz AND EDGE LABEL %sFROMTO)superr  r  r  r'  
label_nameedge_export_edge_as_cql
from_labelfrom_partition_key_columnsfrom_clustering_columnsto_labelto_partition_key_columnsto_clustering_columns)r   rR  r  	__class__s      r   r  zTableMetadataDSE68.as_cql_query  s    &--::9EE; 	Q)L9O,P,PPPC9 	7',ty7K*L*LLLC4++	$	4	16; ; ;C
 4++	"	2	/7 7 7C
 
r   c                 ,   d|dt          |           d}t          |          dk    r|t          |d                   z  }n%|dd                    d |D                       z  z  }|r%|dd                    d	 |D                       z  z  }|d
z  }|S )Nr$  (r  r   r  rM  c                 ,    g | ]}t          |          S r   r'  r   r  s     r   r  z:TableMetadataDSE68._export_edge_as_cql.<locals>.<listcomp>  s    &O&O&O1|A&O&O&Or   r  c                 ,    g | ]}t          |          S r   r  r  s     r   r  z:TableMetadataDSE68._export_edge_as_cql.<locals>.<listcomp>  s    &S&S&S1|A&S&S&Sr   rP  )r'  ry  r   )r  partition_keysclustering_columnskeywordr  s        r   r  z&TableMetadataDSE68._export_edge_as_cql  s      #77L$<$<$<$<=~!##<q 1222CC6DII&O&O&O&O&OPPPPC 	U6DII&S&S@R&S&S&STTTTCs

r   r\  )	rr  rs  rt  r  r  r  r  r  __classcell__r  s   @r   r  r    sh        F?D=     *   \    r   r  c                   (    e Zd ZdZed             ZdS )TableExtensionInterfacez9
    Defines CQL/DDL for Cassandra table extensions.
    c                     dS )z
        Called to produce CQL/DDL to follow the table definition.
        Should contain requisite terminating semicolon(s).
        Nr   )r  ext_keyext_blobs      r   r  z'TableExtensionInterface.after_table_cql  s	     	r   N)rr  rs  rt  ru  r  r  r   r   r   r  r    s9            [  r   r  c                   "     e Zd Zi Z fdZ xZS )r  c                     t          t          |                               | |||          }|dk    r|| j        |j        <   |S )NRegisteredTableExtension)r  r  r  r  r  )mcsr  r  r  r  r  s        r   r  z _RegisteredExtensionType.__new__  sG    ,c22::3eSQQ---03C#CH-
r   )rr  rs  rt  r  r  r  r  s   @r   r  r    s>                r   r  c                       e Zd ZdZdZdS )r  zu
    Extending this class registers it by name (associated by key in the `system_schema.tables.extensions` map).
    N)rr  rs  rt  ru  r  r   r   r   r  r    s%          D r   r  c                      t          |           S r   )maybe_escape_namer  s    r   r'  r'  !  s    T"""r   c                     d | D             S )Nc                 ,    g | ]}t          |          S r   r  )r   r4  s     r   r  z!protect_names.<locals>.<listcomp>&  s    +++LOO+++r   r   )namess    r   protect_namesr  %  s    ++U++++r   c                     | dS t          | t          t          t          f          r!t	          |                                           S d|                     dd          z  S )NNULLz'%s'r  z'')r  rP   rA   re  r  r   rr   r  s    r   r  r  )  sV    }v%#ud+,, "5zz!!!EMM#t,,,,r   z^[a-z][0-9a-z_]*$c                 |    | dS |                                  t          v rdS t                              |           d uS r   )r   cql_keywords_reservedvalid_cql3_word_rematchr  s    r   is_valid_namer  4  s>    |uzz||,,,u##D))55r   c                 B    t          |           r| S t          |           S r   )r  escape_namer  s    r   r   r   <  s%    T tr   c                 6    d|                      dd          dS )N"z"")rr   r  s    r   r  r  B  s!     \\#t,,,,..r   c                   B    e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 dZ	ddZ
d ZdS )ColumnMetadataz9
    A representation of a single column in a table.
    NFc                 L    || _         || _        || _        || _        || _        d S r   )r   r  r  r  r  )r   r5  column_namer  r  r  s         r   r   zColumnMetadata.__init__c  s,    #
	 "&r   c                 $    | j         d| j        S )Nr$  )r  r  r   s    r   r  zColumnMetadata.__str__j  s    )))T]]33r   )FF)rr  rs  rt  ru  r   r  r  r  r  
_cass_typer   r  r   r   r   r  r  F  s|          E?D+H I
 K J' ' ' '4 4 4 4 4r   r  c                   B    e Zd ZdZdZ	 dZ	 dZ	 dZ	 i Z	 d Z	d Z
d ZdS )IndexMetadataz<
    A representation of a secondary index on a column.
    Nc                 L    || _         || _        || _        || _        || _        d S r   )r  r<  r  kindindex_options)r   r  r<  r8  r  r  s         r   r   zIndexMetadata.__init__  s-    *$		*r   c                    t          | j                  }|                    d          }| j        dk    rEdt	          | j                  dt	          | j                  dt	          | j                  d|d	S |                    d          }d	t	          | j                  dt	          | j                  dt	          | j                  d|d
|d}|r$t          	                    |d          }|d|z  z  }|S )zN
        Returns a CQL query that can be used to recreate this index.
        targetCUSTOMzCREATE INDEX  ON rG  rH  rP  
class_namezCREATE CUSTOM INDEX z	) USING 'r  T)as_text_typez WITH OPTIONS = %s)
r	  r  r  r  r'  r  r  r<  _encodercql_encode_all_types)r   rj   index_targetr   r  opts_cql_encodeds         r   r  zIndexMetadata.as_cql_query  s    t)**{{8,,9   TY''''T/0000T_----	  !\22JJTY''''T/0000T_----

C  ?#+#@#@W[#@#\#\ +.>>>Jr   c                 0    |                                  dz   S )zU
        Returns a CQL query string that can be used to recreate this index.
        r  rZ  r   s    r   r   zIndexMetadata.export_as_string  s       ""S((r   )rr  rs  rt  ru  r  r<  r  r  r  r   r  r   r   r   r   r  r  n  su          M*J8D(DLM$+ + +  4) ) ) ) )r   r  c                   N    e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZd Z	d	dZ
d Zd Zd ZdS )
rQ  z3
    Information about the layout of the ring.
    Nc                 r    || _         || _        || _        i | _        || _        t                      | _        d S r   )rR  rT  rS  tokens_to_hosts_by_ks	_metadatar	   _rebuild_lock)r   rR  rS  rX  metadatas        r   r   zTokenMap.__init__  s:    &	#6 %'"!"WWr   Fc                    | j         5  	 | j                            |d           }|r||sR|P| j        j                            |          }|r/|                     | j        j        |                   }|| j        |<   n;# t          $ r. i | j        |<   t                              d|| j	                   Y nw xY wd d d            d S # 1 swxY w Y   d S )Nz}Failed creating a token map for keyspace '%s' with %s. PLEASE REPORT THIS: https://datastax-oss.atlassian.net/projects/PYTHON)
r+  r)  r  r*  rW   replica_map_for_keyspacer  r  	exceptionrS  )r   rV   r<  currentks_metar  s         r   r?  zTokenMap.rebuild_keyspace  ss    	C 	CC4884HH# KU\Uh"n6::8DDG K&*&C&CDND\]eDf&g&g?J28< C C C 8:*84  ^  `h  jn  jB  C  C  C  C  C	C	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	Cs5   CA3A>=C>5B63C5B66CC
C
c                 X    |j         }|r |                    | j        | j                  S d S r   )r  r  rS  rT  )r   ks_metadatastrategys      r   r.  z!TokenMap.replica_map_for_keyspace  s2    3 	2243KTYWWW4r   c                 <    | j                             |d            d S r   )r)  r  r  s     r   rD  zTokenMap.remove_keyspace  s!    "&&x66666r   c                 N   | j                             |d          }|2|                     |d           | j                             |d          }|rSt          | j        |          }|t          | j                  k    r|| j        d                  S || j        |                  S g S )z
        Get  a set of :class:`.Host` instances representing all of the
        replica nodes for a given :class:`.Token`.
        NTr;  r   )r)  r  r?  r   rT  ry  )r   rV   r   tokens_to_hostspoints        r   r[  zTokenMap.get_replicas  s    
 4884HH"!!(D!AAA"8<<XtLLO 	9  	511EDI&&&ty|44&ty'788	r   r\  )rr  rs  rt  ru  rR  rS  r)  rT  r*  r   r?  r.  rD  r[  r   r   r   rQ  rQ    s          K  !
 D I% % %C C C C  7 7 7    r   rQ  c                   v    e Zd ZdZd Zed             Zed             Zed             Zd Z	d Z
d Zd	 ZeZd
S )Tokenz.
    Abstract class representing a token.
    c                     || _         d S r   r  r   r   s     r   r   zToken.__init__  s    


r   c                     |S r   r   r  rT   s     r   hash_fnzToken.hash_fn  s    
r   c                 >     | |                      |                    S r   )r?  r>  s     r   r\  zToken.from_key	  s    s3;;s##$$$r   c                     t                      r   r  r  rW  s     r   rN  zToken.from_string  s    !###r   c                 "    | j         |j         k    S r   r  r  s     r   r  zToken.__eq__  s    zU[((r   c                 "    | j         |j         k     S r   r  r  s     r   __lt__zToken.__lt__  s    zEK''r   c                 *    t          | j                  S r   )hashr  r   s    r   __hash__zToken.__hash__  s    DJr   c                 2    d| j         j        d| j        dS )N<z: >)r  rr  r  r   s    r   __repr__zToken.__repr__  s      !^444djjjAAr   N)rr  rs  rt  ru  r   r  r?  r\  rN  r  rE  rH  rL  r  r   r   r   r:  r:    s              [ % % [% $ $ [$) ) )( ( (     B B BGGGr   r:  l         l    c                       e Zd ZdS )r]  N)rr  rs  rt  r   r   r   r]  r]  #  s        Dr   r]  c                   $    e Zd Zed             ZdS )	HashTokenc                 2     | t          |                    S )E `token_string` should be the string representation from the server. )rP   rB  s     r   rN  zHashToken.from_string)  s     s3|$$%%%r   N)rr  rs  rt  r  rN  r   r   r   rO  rO  '  s-        & & [& & &r   rO  c                   .    e Zd ZdZed             Zd ZdS )rL  z-
    A token for ``Murmur3Partitioner``.
    c                     t           0t          t          |                    }|t          k    r|nt          S t	                      r   )r
   rP   MIN_LONGMAX_LONGr]  )r  rT   hs      r   r?  zMurmur3Token.hash_fn5  s7    GCLL!!AX1183++r   c                 .    t          |          | _        dS )z5 `token` is an int or string representing the token. N)rP   r  r<  s     r   r   zMurmur3Token.__init__=  s    ZZ


r   N)rr  rs  rt  ru  r  r?  r   r   r   r   rL  rL  0  sH            [         r   rL  c                   (    e Zd ZdZed             ZdS )rK  z,
    A token for ``RandomPartitioner``.
    c                     t          |t                    r|                    d          }t          t	          t          |                                                              S )NzUTF-8)r  r  encodeabsr   r   digestr>  s     r   r?  zMD5Token.hash_fnG  sK    c3 	&**W%%C=S!2!233444r   N)rr  rs  rt  ru  r  r?  r   r   r   rK  rK  B  s9          5 5 [5 5 5r   rK  c                   (    e Zd ZdZed             ZdS )rM  z1
    A token for ``ByteOrderedPartitioner``.
    c                     t          |t                    r|                    d          } | t          |                    S )rQ  r!   )r  r  rZ  r   rB  s     r   rN  zBytesToken.from_stringS  sA     lC(( 	8'..w77Ls9\**+++r   N)rr  rs  rt  ru  r  rN  r   r   r   rM  rM  N  s9          , , [, , ,r   rM  c                   8    e Zd ZdZdZ	 dZ	 dZ	 ddZd Zd Z	dS )TriggerMetadataz4
    A representation of a trigger for a table.
    Nc                 0    || _         || _        || _        d S r   )r   r  rj   )r   r5  trigger_namerj   s       r   r   zTriggerMetadata.__init__m  s    #
 	r   c                     dt          | j                  dt          | j        j                  dt          | j        j                  dt	          | j        d                   }|S )NzCREATE TRIGGER r  rG   USING r  )r'  r  r   r  r  rj   r(  s     r   r  zTriggerMetadata.as_cql_queryr  se     ####12222))))$,w/000	
 
r   c                 0    |                                  dz   S )Nr  rZ  r   s    r   r   z TriggerMetadata.export_as_string{  s      ""S((r   r   )
rr  rs  rt  ru  r   r  rj   r   r  r   r   r   r   r`  r`  ]  sl          E@D,G   
  ) ) ) ) )r   r`  c                   :    e Zd Zd Z e            fdZd Zd ZdS )_SchemaParserc                 "    || _         || _        d S r   )r   r   )r   r   r   s      r   r   z_SchemaParser.__init__  s    $r   c                 n    |st          ||          rg S |r|rt          |j        |j                  ng S |)a  
        Given a bool and a ResultSet (the form returned per result from
        Connection.wait_for_responses), return a dictionary containing the
        results. Used to process results from asynchronous queries to system
        tables.

        ``expected_failures`` will usually be used to allow callers to ignore
        ``InvalidRequest`` errors caused by a missing system keyspace. For
        example, some DSE versions report a 4.X server version, but do not have
        virtual tables. Thus, running against 4.X servers, SchemaParserV4 uses
        expected_failures to make a best-effort attempt to read those
        keyspaces, but treat them as empty if they're not found.

        :param success: A boolean representing whether or not the query
        succeeded
        :param result: The resultset in question.
        :expected_failures: An Exception class or an iterable thereof. If the
        query failed, but raised an instance of an expected failure class, this
        will ignore the failure and return an empty list.
        )r  r   column_namesparsed_rows)r   successresultexpected_failuress       r   _handle_resultsz_SchemaParser._handle_results  sQ    *  	:f.?@@ 	I 	LRZ< 3V5GHHHXZZLr   c                 F    |                      ||          }|r|d         nd S )Nr   )_query_build_rows)r   query_string
build_funcrm  s       r   _query_build_rowz_SchemaParser._query_build_row  s*    ''jAA",vayy,r   c                 N   t          |t          j                  }| j                            || j        d          }|d         \  }}|r(t          |j        |j                  }fd|D             S t          |t                    rt                              d           g S |)Nqueryconsistency_levelFr   fail_on_errorr   c                 &    g | ]} |          S r   r   )r   rowrs  s     r   r  z3_SchemaParser._query_build_rows.<locals>.<listcomp>  s!    666JJsOO666r   user types table not found)r   r   ONEr   wait_for_responsesr   r   rj  rk  r  r   r  debug)r   rr  rs  rw  	responsesrl  responserm  s     `     r   rq  z_SchemaParser._query_build_rows  s    <CSCWXXXO66di6jj	'l( 	!("79MNNF6666v6666.11 	II2333INr   N)rr  rs  rt  r   r   ro  rt  rq  r   r   r   rg  rg    sb           BG    8- - -    r   rg  c                   T    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ fdZd Zd Zd Zd Zd Zd Zd Zed             Zed             Zed             Zed             Zed             Zd"dZd Zed             Zed             Z ed             Z!d Z"d  Z#ed!             Z$ xZ%S )#SchemaParserV22z
    For C* 2.2+
    z%SELECT * FROM system.schema_keyspacesz*SELECT * FROM system.schema_columnfamiliesz#SELECT * FROM system.schema_columnsz$SELECT * FROM system.schema_triggersz%SELECT * FROM system.schema_usertypesz%SELECT * FROM system.schema_functionsz&SELECT * FROM system.schema_aggregatescolumnfamily_namer.  )r  read_repair_chancedclocal_read_repair_chancelocal_read_repair_chancereplicate_on_writegc_grace_secondsbloom_filter_fp_chancer  r  r  r  r  r  min_index_intervalmax_index_intervalindex_intervalspeculative_retryrows_per_partition_to_cachememtable_flush_period_in_mspopulate_io_cache_on_flushr  default_time_to_livec                    t          t          |                               ||           g | _        g | _        g | _        g | _        g | _        g | _        g | _	        t          t                    | _        t          d           | _        t          t                    | _        t          t                    | _        t          t                    | _        t          d           | _        d S )Nc                  *    t          t                    S r   r   rZ   r   r   r   <lambda>z*SchemaParserV22.__init__.<locals>.<lambda>  s    ;t;L;L r   c                  *    t          t                    S r   r  r   r   r   r  z*SchemaParserV22.__init__.<locals>.<lambda>  s    {4?P?P r   )r  r  r   keyspaces_resulttables_resultcolumns_resulttriggers_resulttypes_resultfunctions_resultaggregates_resultr   rZ   keyspace_table_rowskeyspace_table_col_rowskeyspace_type_rowskeyspace_func_rowskeyspace_agg_rowskeyspace_table_trigger_rowsr   r   r   r  s      r   r   zSchemaParserV22.__init__  s    ot$$--j'BBB " ! "!##.t#4#4 '23L3L'M'M$"-d"3"3"-d"3"3!,T!2!2+67P7P+Q+Q(((r   c              #   T  K   |                                   | j        D ]}|                     |          }	 | j                            |j        g           D ],}|                     |          }|                    |           -| j                            |j        g           D ]&}| 	                    |          }||j
        |j        <   '| j                            |j        g           D ]&}|                     |          }||j        |j        <   '| j                            |j        g           D ]&}	|                     |	          }
|
|j        |
j        <   'nH# t$          $ r; t&                              d|j                   t+          j                    |_        Y nw xY w|V  d S )NzPError while parsing metadata for keyspace %s. Metadata model will be incomplete.)
_query_allr  _build_keyspace_metadatar  r  r  _build_table_metadatar   r  _build_user_typer   r  _build_functionrF   r.  r  _build_aggregater  r  r  r/  sysexc_infor  )r   r|  r  	table_rowr=  usertype_rowusertypefn_rowfnagg_rowaggs              r   r  z!SchemaParserV22.get_all_keyspaces  s     ( 	  	 C 99#>>M9!%!9!=!=m>PRT!U!U B BI!%!;!;I!F!FJ!55jAAAA$($;$?$?@RTV$W$W G GL#44\BBH>FM,X];;"599-:LbQQ ? ?F--f55B<>M+BL99#599-:LbQQ B BG//88C>AM,S];;B  9 9 9pr  sE  F  F  F*-,..'''9  /	  	 s   D"EAFFc                 (   t           j        }t          d| j        d||ft                    }t          | j        |z   |          }t          | j        |z   |          }t          | j        |z   |          }| j	        
                    |||| j        d          \  \  }	}
\  }}\  }}|                     |	|
          }|                     ||          }|                     ||t                    }|r|                     |d         ||          S d S )Nz WHERE keyspace_name = %s AND  = %srv  Fry  rn  r   )r   r~  r   _table_name_colr"  r   _SELECT_COLUMN_FAMILIES_SELECT_COLUMNS_SELECT_TRIGGERSr   r  r   ro  r   r  )r   rW   rV   r   clwhere_clausecf_query	col_querytriggers_query
cf_success	cf_resultcol_success
col_resulttriggers_successr  table_results                   r   	get_tablezSchemaParserV22.get_table  sU   !"{PTPdPdPd#fiqsxhy  |D  E  Ed&B\&Qeghhh t';l'J^`aaa	%D,AL,Pdfgggo009n^b^jz0  A  A 	`Y!:+z<_=M++J	BB))+zBB
 ../?AO / Q Q  	\--l1oz?[[[	\ 	\r   c                 x    t          d||ft                    }|                     | j        |z   | j                  S )Nz, WHERE keyspace_name = %s AND type_name = %s)r   r"  rt  _SELECT_TYPESr  )r   rW   rV   r   r  s        r   get_typezSchemaParserV22.get_type  s=    "#QT\^bScemnn$$T%7,%FH]^^^r   c                     t          d|ft                    }|                     | j        |z   | j                  }t          d |D                       S )N WHERE keyspace_name = %sc              3   (   K   | ]}|j         |fV  d S r   r  r  s     r   r   z0SchemaParserV22.get_types_map.<locals>.<genexpr>!  s(      //AQVQK//////r   )r   r"  rq  r  r  r	  )r   rW   rV   r  r-  s        r   r   zSchemaParserV22.get_types_map  sS    "#>XVV&&t'9L'H$J_``////////r   c                     t          d| j        d||j        |j        ft                    }|                     | j        |z   | j                  S )Nz5 WHERE keyspace_name = %s AND function_name = %s AND r  )r   _function_agg_arument_type_colr  r`  r"  rt  _SELECT_FUNCTIONSr  )r   rW   rV   rE   r  s        r   get_functionzSchemaParserV22.get_function#  sf    "{hl  iL  iL  iL  $N$,hmX=T#UW_a a$$T%;l%JDL`aaar   c                     t          d| j        d||j        |j        ft                    }|                     | j        |z   | j                  S )Nz6 WHERE keyspace_name = %s AND aggregate_name = %s AND r  )r   r  r  r`  r"  rt  _SELECT_AGGREGATESr  )r   rW   rV   r   r  s        r   get_aggregatezSchemaParserV22.get_aggregate(  sh    "{im  jM  jM  jM  $O$,ini>V#WYac c $$T%<|%KTMbcccr   c                 v    t          d|ft                    }|                     | j        |z   | j                  S )Nr  )r   r"  rt  _SELECT_KEYSPACESr  )r   rW   rV   r  s       r   get_keyspacezSchemaParserV22.get_keyspace.  s7    "#>XVV$$T%;l%JDLijjjr   c                     	 |                      |          }n^# t          $ rQ |d         }t          |ddi           }t          j                    |_        t                              d||           Y nw xY w|S )Nr  FUNKNOWNz4Error while parsing metadata for keyspace %s row(%s))!_build_keyspace_metadata_internalr  r  r  r  r  r  r/  )r  r|  ksmr  s       r   r  z(SchemaParserV22._build_keyspace_metadata2  s    	]77<<CC 	] 	] 	]'D"4	2>>CLNNCMMMPRVX[\\\\\		]
 
s    AA32A3c                     | d         }| d         }| d         }t          j        | d                   }t          ||||          S )Nr  r  r  r	  )rS   r  r  )r|  r  r  r  r	  s        r   r  z1SchemaParserV22._build_keyspace_metadata_internal=  sM    ?#-.-.:c*<&=>>nnFVWWWr   c                     t          t          | j        |d                             }t          |d         |d         |d         |          S )Nr,  r  r0  rE  )rZ   r\   _schema_type_to_cqlrC  )r  r  r,  s      r   r  z SchemaParserV22._build_user_typeE  sN    3s6]8STTUU_5|K7P$]3[B B 	Br   c                 L   |                      |d                   }|                    dd          }|                    dd          }|                    dd          }t          |d         |d         || j                 |d	         ||d
         |d         |d         |||          S )Nre  r8   Fra   ry  r   r  function_namerv  rX   rw  rx  )r  r  rt  r  )r  function_rowre  r8   ra   ry  s         r   r  zSchemaParserV22._build_functionK  s    --l=.IJJ$((%@@ $$[%88	#'';;_5|O7T$S%GH,WgJh#\*%=|F?S$%;<%y,	@ @ 	@r   c                    t          j        |d                   }|d         }|.t                              |                    |d                    }t          |          }|                     |d                   }t          |d         |d         |d         |d         ||d	         |||                    d
d          	  	        S )Nrb  rM   r   re  r  aggregate_namer.  ra  rc  r8   F)	r-  lookup_casstyper"  r#  deserialize_cql_from_cass_typer  r^  r  )r  aggregate_rowcass_state_typerd  rb  re  s         r   r  z SchemaParserV22._build_aggregateW  s    /l0KLL)*5( ( = =o>Y>YZkmn>o>o p p(99
--mM.JKK7GW9X&{3]<5PR\&|46G&**?EBBD D 	Dr   Nc                 ,   |d         }|| j                  }|p| j        |         |         }|p| j        |         |         }|st                              d||           t          ||          }	 t          j        |d                   }||_        t          |t          j
                  }t          |t          j                  }	|	r|j        n|f}
t          |
          }|
d         }|                    dd           }d |D             }t          |          dk    rt          |d 	          }|t!          j        |          }|sd
 |D             }|	rt          |t          j                  r
d}d}|dz
  }n|t          |          |dz
  k    r$t          |t          j                  r
d}d}|dz
  }nBd}|p| }|}|s%t)          |d          rt+          d |j                  }nd}|s|r|rd}|}nd}d}d |D             }t          |          dk    rt          |d 	          }|                    d          }||rt!          j        |          ng }nd |D             }|                    d          }|9t          j        |          }t          |t          j                  r|j        n|g}nd |D             }t/          |          D ]v\  }}t          |          |k    r	||         }n|dk    rd}nd|z  }t1          |||                                          }||j        |<   |j                            |           wt;          |          D ]}t          |          |k    r	||         }nd|dz   z  }|
|         }t=          |          }t          j        |          }t1          ||||          }||j        |<   |j                             |           |rd |D             }|sd}n5|                    dd           }||r|d                             d          }|                    d          } | rt          j        |           }!n/|r-t          j        |d                             d                    }!t=          |!          }t1          |||          }|r
||j        |<   |D ]U}"| !                    ||"          }#|#j"        6|#|j        |#j"        <   | #                    |#|"          }$|$r|$|j$        |$j"        <   V|D ]'}%| %                    ||%          }&|&|j&        |&j"        <   (| '                    |          |_(        ||_)        nF# tT          $ r9 tW          j,                    |_-        t          .                    d ||||           Y nw xY w|S )!Nr  z5Building table metadata with no column meta for %s.%sr  column_aliasesc                 F    g | ]}|                     d d          dk    |S )r   Nr  r  r   rs     r   r  z9SchemaParserV22._build_table_metadata.<locals>.<listcomp>~  s>     K K KQ"#%%"5"59I"I"I  !"I"I"Ir   r  c                 ,    |                      d          S Ncomponent_indexr  r|  s    r   r  z7SchemaParserV22._build_table_metadata.<locals>.<lambda>  s    #''RcJdJd r   rT   c                 8    g | ]}|                     d           S r  r  r  s     r   r  z9SchemaParserV22._build_table_metadata.<locals>.<listcomp>  s$    !P!P!P1!%%"6"6!P!P!Pr   F   T
fieldnamesr   c                 F    g | ]}|                     d d          dk    |S )r   Nr  r  r  s     r   r  z9SchemaParserV22._build_table_metadata.<locals>.<listcomp>  s=     I I IA!"vt!4!4!G!G  !G!G!Gr   c                 ,    |                      d          S r  r  r  s    r   r  z7SchemaParserV22._build_table_metadata.<locals>.<lambda>  s    PaHbHb r   key_aliasesc                 8    g | ]}|                     d           S r  r  r  s     r   r  z9SchemaParserV22._build_table_metadata.<locals>.<listcomp>  s$    LLLquu]33LLLr   key_validatorc                 \    g | ])}t          j        |                    d                     *S )	validator)r-  r  r  r  s     r   r  z9SchemaParserV22._build_table_metadata.<locals>.<listcomp>  s/    ___1U21553E3EFF___r   rT   zkey%dzcolumn%d)r  c                 F    g | ]}|                     d d          dk    |S )r   Ncompact_valuer  r  s     r   r  z9SchemaParserV22._build_table_metadata.<locals>.<listcomp>  s=     $O $O $O!'(uuVT':':o'M'M %&'M'M'Mr   r  value_aliasr  default_validatorr  @Error while parsing metadata for table %s.%s row(%s) columns(%s))/r  r  r  r  r  r  r-  r  r  
issubclassDynamicCompositeTypeCompositeTypesubtypesry  r  rP  rS   r  ColumnToCollectionTypeUTF8Typer  filterr  r  r  cql_parameterized_typer   r  rO  r  r  is_reversed_casstyper  _build_column_metadatar  _build_index_metadatar  _build_trigger_metadatar  _build_table_optionsrj   r  r  r  r  r  r/  )'r   r|  col_rowstrigger_rowsr  cfnamer=  r  is_dct_comparatoris_composite_comparatorcolumn_name_typesnum_column_name_componentslast_colr  clustering_rows
is_compact	has_valueclustering_sizepartition_rowsr  r  key_type	key_typesr  col_typer  r  	data_typer  r  value_alias_rowsr  r  r  col_rowcolumn_meta
index_metatrigger_rowr  s'                                          r   r  z%SchemaParserV22._build_table_metadatad  s   O,T)*Rt;MJ6R#^t'G'VW]'^ 	/KKO%v/ / / #=&99
O	D.s</@AAJ$.J! *:u7Q R R&0U=P&Q&Q#7N a
 3 3U_Ta),->)?)?&(,H WW%5t<<NK K( K K KO?##a''"(>d>d"e"e"e)!%N!;!;! Q!P!P!P!P!P& (h(DEE M!&J %I&@1&DOO.))-G!-KKK 5>:: L "'J %I&@1&DOO "&J . >h,I&@O * Mgj,.O.O M)/j6K)L)L!
! ( (5F ( $I&@OO %I&'OI I I I IN >""Q&&!'<b<b!c!c!c''-00K&9DLdj555" ML^LLLGGO44M( 0??1;HeFY1Z1ZjH--ai`j		__P^___	(33 
5 
58{##a''"-a.KK!VV"'KK")A+K$Zh>]>]>_>_``25
";/(//4444 ?++ 6 6~&&**"0"3KK",A"6K-a0	.y99#8CC$ZhT_```25
";/)005555  :$O $Ox $O $O $O  # M")KK"%''-">">K"*/?*&6q&9&=&=m&L&L$'GG,?$@$@!$ ` % 56G H HII' `$)$9:J1:M:Q:QR]:^:^$_$_	.y99$ZhGG :69J&{3 $ I I"99*gNN#/;FJ&{'78!%!;!;K!Q!QJ! I>H
*:?;+ F F#;;JTT9E
#L$566!%!:!:3!?!?J,6J)) 	D 	D 	D#&<>>J MM\^kmsux  {C  D  D  D  D  D	D s   /SU A VVc                     t          fd| j        D                       }d|v r|                    d          }||d<   |S )B Setup the mostly-non-schema table options, like caching settings c              3   N   K   | ]}|v |                     |          fV   d S r   r  r   or|  s     r   r   z7SchemaParserV22._build_table_options.<locals>.<genexpr>	  s=      ZZ1QRVYQYQY3771::QYQYQYQYZZr   r  r  )r	  recognized_table_optionsr  )r   r|  rj   vals    `  r   r  z$SchemaParserV22._build_table_options	  sW    ZZZZ0MZZZZZ &00++899C47G01r   c                     |d         }|d         }t          j        |          }t          |          }|                    dd           dk    }t          j        |          }t          |||||          }	||	_        |	S )Nr  r  r   r|   )r-  r  r  r  r  r  r  )
r  r5  r|  r  type_stringr$  r  r  r  r'  s
             r   r  z&SchemaParserV22._build_column_metadata	  s    =!+&)+66	&y11GGFD))X5	0;;$^T8YP[\\!*r   c                    |                     d          }|                     d          }|s|r|                     d          }|rt          j        |          ni }|pi }t          | j                  }|dk    r>d|v rd|d}n3d|v rn.| j        }d	}|j        d
k    r|j        d         j        |v rd|d}||d<   t          | j	        j
        | j	        j        |||          S d S )Nr8  
index_typer  r  
index_keyszkeys(rP  index_values)r\   ry   rZ   rC   r   zfull(r  )r  rS   r  r'  r  r  typenamer
  r  r   r  )column_metadatar|  r8  r  rj   r  r$  collection_typess           r   r  z%SchemaParserV22._build_index_metadata	  s-   WW\**
ww|$$ 	} 	}ggo..G-4<dj)))"GmG "/"677Fx7***+1663FF#w.. !0 :I'=$ )X55):LQ:O:X\l:l:l:l/5vv!7 &GH !6!DoF[F`blnrt{|||1	} 	}r   c                 H    |d         }|d         }t          | ||          }|S )Nrb  trigger_optionsr`  r5  r|  r  rj   r  s        r   r  z'SchemaParserV22._build_trigger_metadata=	  s.    >"'(&~tWEEr   c           
         t           j        }t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j	        |          g} | j
        j        || j        dd\  \  }}\  }}\  }}\  }	}
\  }}\  }}\  }}|                     ||          | _        |                     ||          | _        |                     ||          | _        |r t#          |j        |j                  | _        nbt+          |t,                    rt.                              d           n2t+          |t2                    rt.                              d           n||	r t#          |
j        |
j                  | _        n9t+          |
t,                    r"t.                              d           i | _        n|
|r t#          |j        |j                  | _        n2t+          |t,                    rt.                              d           n||r t#          |j        |j                  | _        n2t+          |t,                    rt.                              d           n||                                  d S )	Nrv  Fry  ztriggers table not foundzthis version of Cassandra does not allow access to schema_triggers metadata with authorization enabled (CASSANDRA-7967); The driver will operate normally, but will not reflect triggers in the local metadata model, or schema strings.r}  zuser functions table not foundzuser aggregates table not found)r   r~  r   r  r  r  r  r  r  r  r   r  r   ro  r  r  r  r   rj  rk  r  r  r   r  r  r   r  r  r  r  _aggregate_results)r   r  queries
ks_success	ks_resulttable_successr  r  r  types_successr  functions_successr  aggregates_successr  r  r  s                    r   r  zSchemaParserV22._query_allD	  s   !t5LLLt;rRRRt3rJJJt1RHHHt5LLLt6"MMMt4KKK
" 0T_/$,>CE E E	.	 *i	&-	"+z	&-	.
-	0
/	,
O
 !% 4 4Z K K!11-NN"22;
KK  		&#/0LoNi#j#jD  />:: &		45555O\:: & N O O O O &%  	# ,\-FH` a aD,77 #		6777$&!!""  	'$01A1NP`Pl$m$mD!!*N;; '		:;;;;&&  	(%12C2PRcRo%p%pD""+^<< (		;<<<<''!!!!!r   c                    | j         }| j        D ]#}||d                                      |           $| j        }| j        D ]8}|d         }|| j                 }||         |                             |           9| j        }| j        D ]#}||d                                      |           $| j        }| j	        D ]#}||d                                      |           $| j
        }| j        D ]#}||d                                      |           $| j        }| j        D ]8}|d         }|| j                 }||         |                             |           9d S Nr  )r  r  rO  r  r  r  r  r  r  r  r  r  r  r  )r   mr|  r  r  s        r   r?  z"SchemaParserV22._aggregate_results	  s   $% 	0 	0Cc/"#**3////(& 	* 	*C)F-.FfIf$$S))))#$ 	0 	0Cc/"#**3////#( 	0 	0Cc/"#**3////") 	0 	0Cc/"#**3////,' 	* 	*C)F-.FfIf$$S))))	* 	*r   c                 H    t          j        |           }t          |          S r   )r-  r  r  )r2  	cass_types     r   r  z#SchemaParserV22._schema_type_to_cql	  s     )+66	"9---r   rq  )&rr  rs  rt  ru  r  r  r  r  r  r  r  r  r  r/  r   r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r?  r  r  r  s   @r   r  r    sI         @J;O=;M?A)O%0"  0R R R R R"     8\ \ \$_ _ _0 0 0
b b b
d d dk k k   [ X X \X B B [B
 	@ 	@ [	@ 
D 
D [
D^ ^ ^ ^@   	 	 [	 } } \}:   \C" C" C"J* * *: . . \. . . . .r   r  c                       e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZeZdZ fdZ fdZd Zed             Zed             ZddZd Zd dZd!dZed             Zed             Zed             Zd Z fdZ ed             Z! xZ"S )"SchemaParserV3z
    For C* 3.0+
    z%SELECT * FROM system_schema.keyspacesz"SELECT * FROM system_schema.tablesz#SELECT * FROM system_schema.columnsz#SELECT * FROM system_schema.indexesz$SELECT * FROM system_schema.triggersz!SELECT * FROM system_schema.typesz%SELECT * FROM system_schema.functionsz&SELECT * FROM system_schema.aggregatesz!SELECT * FROM system_schema.viewsr<  r`  )r  r  cdcr  r  r  crc_check_chancer  r  r  r  r  r  r  r  c                     t          t          |                               ||           g | _        t	          d           | _        t	          t                    | _        d S )Nc                  *    t          t                    S r   r  r   r   r   r  z)SchemaParserV3.__init__.<locals>.<lambda>	  s    [=N=N r   )r  rM  r   indexes_resultr   keyspace_table_index_rowsrZ   keyspace_view_rowsr  s      r   r   zSchemaParserV3.__init__	  sU    nd##,,ZAAA )45N5N)O)O&"-d"3"3r   c              #      K   t          t          |                                           D ]E}| j        |j                 D ],}|                     |          }|                    |           -|V  Fd S r   )r  rM  r  rT  r  _build_view_metadatar!  )r   r  r|  r?  r  s       r   r  z SchemaParserV3.get_all_keyspaces	  s      ">488JJLL 	  	 M.}/AB < < 55c::	00;;;;		  	 r   c           	      V   t           j        }t          d| j        z  ||ft                    }t          | j        |z   |          }t          | j        |z   |          }t          | j        |z   |          }t          | j	        |z   |          }	t          d||ft                    }t          | j
        |z   |          }
| j                            ||||	|
| j        d          \  \  }}\  }}\  }}\  }}\  }}|                     ||          }|                     ||          }|rJ|                     ||          }|                     ||          }|                     |d         |||          S |                     ||          }|r|                     |d         |          S d S )N' WHERE keyspace_name = %%s AND %s = %%srv  z, WHERE keyspace_name = %s AND view_name = %sFry  r   )r   r~  r   r  r"  r   _SELECT_TABLESr  _SELECT_INDEXESr  _SELECT_VIEWSr   r  r   ro  r  rV  )r   rW   rV   r   r  r  r  r  indexes_queryr  
view_queryr  r  r  r  indexes_sucessrR  r  r  view_successview_resultr  s                         r   r  zSchemaParserV3.get_table	  s   !"#LPTPd#ehprwgx  {C  D  Dd&9L&H\^___ t';l'J^`aaa	$4+?,+Nbdeee%D,AL,Pdfggg ##QT\^cSdfnoo!(:\(I468 8 8

 _//9m^T\ 0 H H	&	 *i";;
	)..+N,<o	$,
 ++J	BB))+zBB
 	l!11..QQN"223C_UUO--l1oz?\jkkk**<EE 	I,,[^ZHHH	I 	Ir   c                     | d         }| d         }t          | d                   }|                    d          }t          ||||          S )Nr  r  replicationr  )r	  r  r  )r|  r  r  r	  r  s        r   r  z0SchemaParserV3._build_keyspace_metadata_internal	  sR    ?#-.M 233)--g66nnFVWWWr   c                     t          | d         | d         | d         | d         | d         | d         | d         | d         |                     d	d
          	  	        S )Nr  r  r`  ra  rb  rc  rM   re  r8   F)r^  r  )r  s    r   r  zSchemaParserV3._build_aggregate
  sj    7GW9X&'78-:UWdeqWr&|4mJ6OQ^_lQm&**?EBBD D 	Dr   NFc                 n   |d         }|| j                  }|p| j        |         |         }|p| j        |         |         }|p| j        |         |         }|                     |||          }	 |                     |          |_        |                    dt                                }	|	rd|	v }
|
 od|	vod|	v}|
pd|	v pd|	v|_	        n|rd}d|_	        d}
nd}d|_	        d}
| 
                    ||||
|           |D ]'}|                     ||          }||j        |j        <   (|D ])}|                     ||          }|r||j        |j        <   *|                    d	i           |_        nF# t"          $ r9 t%          j                    |_        t*                              d
||||           Y nw xY w|S )Nr  )r   flagsdenser  compoundFTr  r  )r  r  r  rS  _table_metadata_classr  rj   r  ry   r  _build_table_columnsr  r  r  r  r  r  r  r  r  r  r  r/  )r   r|  r  r  
index_rowsr   r  r<  r=  re  is_densecompact_staticr)  r  	index_rowr(  s                   r   r  z$SchemaParserV3._build_table_metadata
  sF   O,-.
Vt;MJ:V#bt'G'VWa'b\4#A-#PQ[#\
//zSZ/[[
	H!%!:!:3!?!?JGGGSUU++E !"e+%-!b'2F!b:]bKb080gGu<L0gPZbgPg
-- !!&05
- !%04
- %%j(NHV]^^^+ F F#;;JTT9E
#L$566' E E	!77
INN
 E:DJ&z7$'GGL"$=$=J!! 	H 	H 	H#&<>>J MM\^kmwy|  G  H  H  H  H  H	H s   .D E/ /A F21F2c                 D    t          fd| j        D                       S )r+  c              3   N   K   | ]}|v |                     |          fV   d S r   r  r-  s     r   r   z6SchemaParserV3._build_table_options.<locals>.<genexpr>8
  s6      WWaSVhhQ

OhhhhWWr   )r	  r/  )r   r|  s    `r   r  z#SchemaParserV3._build_table_options6
  s)    WWWWT-JWWWWWWr   c                    d |D             }t          |          dk    rt          |d           }|D ]_}|                     ||          }||j        |j        <   |j                            |j        |                    d                              `|sd |D             }	t          |	          dk    rt          |	d           }	|	D ]_}|                     ||          }||j        |j        <   |j                            |j        |                    d                              `d |D             D ]R}
|                     ||
          }|r|j	        t          j        k    r0|r|j        s:|rd	|_        ||j        |j        <   Sd S )
Nc                 F    g | ]}|                     d d          dk    |S )r  Nr  r  r  s     r   r  z7SchemaParserV3._build_table_columns.<locals>.<listcomp><
  s=     E E EUU6400OCC CCCr   r  c                 ,    |                      d          S Npositionr  r  s    r   r  z5SchemaParserV3._build_table_columns.<locals>.<lambda>?
  s    CGGJDWDW r   r  r  c                 F    g | ]}|                     d d          dk    |S )r  Nr*   r  r  s     r   r  z7SchemaParserV3._build_table_columns.<locals>.<listcomp>I
  s=     G G GQ"#%%"5"5"E"E  !"E"E"Er   c                 ,    |                      d          S rs  r  r  s    r   r  z5SchemaParserV3._build_table_columns.<locals>.<lambda>L
  s    #''R\J]J] r   c              3   J   K   | ]}|                     d d          dv|V  dS )r  Nr  r  r  s     r   r   z6SchemaParserV3._build_table_columns.<locals>.<genexpr>R
  sK       [ [a55..6YYY YYYY[ [r   F)ry  rP  r  r   r  r  rO  r  r  r  r-  cql_empty_typer  )r   r   r  rl  rk  r   r   r  r'  r  r&  s              r   ri  z#SchemaParserV3._build_table_columns:
  s   E EX E E E~""#N8W8WXXXN 	J 	JA 55dA>>K-8DL)*%%dl1553G3G&HIIII  	OG G( G G GO?##a''"(>]>]"^"^"^$ O O"99$BB1<[-.#**4<m8L8L+MNNNN[ [8 [ [ [ 	9 	9G55dGDDK K0E4HHH k&;   .(-%-8DL)**	9 	9r   c           
      0   |d         }|d         }|d         }|d         }|d         }|p| j         |         |         }t          ||||||                     |                    }|                     ||           |                    di           |_        |S )Nr  r>  r;  include_all_columnsr  r  )r  MaterializedViewMetadatar  ri  r  r  )	r   r|  r  r  r>  r;  rz  r  r?  s	            r   rV  z#SchemaParserV3._build_view_metadata_
  s    O,$	/0!"78>*Ut;MJ9U,]I-@,PTPiPijmPnPnp p	!!)X666"ww|R88	r   c                     |d         }|d         }|                     dd           dk    }|d                                         dk    }t          | ||||          }|S )Nr  r   r  r|   clustering_orderr  )r  upperr  )r5  r|  r  r  r  r  r'  s          r   r  z%SchemaParserV3._build_column_metadatam
  se    =!v;GGFD))X5	,-3355?$^T8YP[\\r   c                     |                     d          }|                     d          }|s|r2|                     d          }t          | j        | j        |||          S d S )Nr8  r  rj   )r  r  r  r  )r5  r|  r8  r  r  s        r   r  z$SchemaParserV3._build_index_metadatav
  sf    WW\**
wwv 	 	GGI..M !=~?RT^`dfsttt4r   c                 H    |d         }|d         }t          | ||          }|S )Nrb  rj   r<  r=  s        r   r  z&SchemaParserV3._build_trigger_metadata
  s,    >"i.&~tWEEr   c                 $   t           j        }t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j	        |          t          | j
        |          t          | j        |          g	} | j        j        || j        dd\	  \  }}\  }}\  }}\  }	}
\  }}\  }}\  }}\  }}\  }}|                     ||          | _        |                     ||          | _        |                     ||          | _        |                     ||          | _        |                     |	|
          | _        |                     ||          | _        |                     ||          | _        |                     ||          | _        |                     ||          | _        |                                  d S )Nrv  Fry  )r   r~  r   r  rY  r  r  r  r  r  rZ  r[  r   r  r   ro  r  r  r  r  r  r  r  rR  views_resultr?  )r   r  r@  rA  rB  rC  r  r  r  rD  r  rE  r  rF  r  r  r  indexes_successrR  views_successr  s                        r   r  zSchemaParserV3._query_all
  s!   !t5LLLt2bIIIt3rJJJt1RHHHt5LLLt6"MMMt4KKKt3rJJJt1RHHH

( +M$/*Lt|5+
 +
 +
	(	 *i	&-	"+z	&-	.
-	0
/	,
O	*/>	&- !% 4 4Z K K!11-NN"22;
KK#334DoVV 00MM $ 4 45FHX Y Y!%!5!56HJ[!\!\"22?NSS 00MM!!!!!r   c                 H   t          t          |                                            | j        }| j        D ]8}|d         }|| j                 }||         |                             |           9| j        }| j        D ]#}||d                                      |           $d S rH  )	r  rM  r?  rS  rR  r  rO  rT  r  r   rI  r|  r  r  r  s        r   r?  z!SchemaParserV3._aggregate_results
  s    nd##66888*& 	* 	*C)F-.FfIf$$S))))#$ 	0 	0Cc/"#**3////	0 	0r   c                     | S r   r   )r2  s    r   r  z"SchemaParserV3._schema_type_to_cql
  s    r   )NNNF)FFFr   )#rr  rs  rt  ru  r  rY  r  rZ  r  r  r  r  r[  r  r  r  rh  r/  r   r  r  r  r  r  r  r  ri  rV  r  r  r  r  r?  r  r  r  s   @r   rM  rM  	  s         @9N;O;O=7M?A7M"O%5"+ "4 4 4 4 4         I I I< X X \X D D \D) ) ) )VX X X#9 #9 #9 #9J      \   \   \$" $" $"L0 0 0 0 0   \    r   rM  c                   &    e Zd ZdZej        dz   ZdS )SchemaParserDSE60z
    For DSE 6.0+
    r  N)rr  rs  rt  ru  rM  r/  r   r   r   r  r  
  -          !/ G -!.r   r  c                   b     e Zd ZdZdZdZdZ fdZd Z fdZ	 fdZ
e fd	            Z xZS )
SchemaParserV4)additional_write_policyr  r  rN  r  r  r  rO  r  r  r  r  r  read_repairr  z-SELECT * from system_virtual_schema.keyspacesz*SELECT * from system_virtual_schema.tablesz+SELECT * from system_virtual_schema.columnsc                     t          t          |                               ||           t          t                    | _        t          t                    | _        t          d           | _        d S )Nc                  *    t          t                    S r   r  r   r   r   r  z)SchemaParserV4.__init__.<locals>.<lambda>
  s    D8I8I r   )r  r  r   r   rZ   virtual_keyspaces_rowsvirtual_tables_rowsvirtual_columns_rowsr  s      r   r   zSchemaParserV4.__init__
  s]    nd##,,ZAAA&1$&7&7##.t#4#4 $/0I0I$J$J!!!r   c                    t           j        }t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j	        |          t          | j
        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          g} | j        j        || j        dd}|\  \  }}\  }}\  }}	\  }
}\  }}\  }}\  }}\  }}\  }}\  }}\  }}\  }}|                     ||          | _        |                     ||          | _        |                     ||	          | _        |                     ||          | _        |                     |
|          | _        |                     ||          | _        |                     ||          | _        |                     ||          | _        |                     ||          | _        |                     ||t8          f          | _        |                     ||t8          f          | _        |                     ||t8          f          | _        |                                   d S Nrv  Fry  r  )!r   r~  r   r  rY  r  r  r  r  r  rZ  r[  _SELECT_VIRTUAL_KEYSPACES_SELECT_VIRTUAL_TABLES_SELECT_VIRTUAL_COLUMNSr   r  r   ro  r  r  r  r  r  r  r  rR  r  r   virtual_keyspaces_resultvirtual_tables_resultvirtual_columns_resultr?  )r   r  r@  r  rA  rB  rC  r  r  r  rD  r  rE  r  rF  r  r  r  r  rR  r  r  virtual_ks_successvirtual_ks_resultvirtual_table_successvirtual_table_resultvirtual_column_successvirtual_column_results                               r   r  zSchemaParserV4._query_all
  s   !
 t5LLLt2bIIIt3rJJJt1RHHHt5LLLt6"MMMt4KKKt3rJJJt1RHHHt=QSTTTt:bQQQt;rRRR
" 7DO6dl%A A A	" 	
#Z)]L%[*)]L1 03!2/-_n)]L3!29"$8;#%: !% 4 4Z K K!11-NN"22;
KK#334DoVV 00MM $ 4 45FHX Y Y!%!5!56HJ[!\!\"22?NSS 00MM )-(<(< 1-/ )= )
 )
% &*%9%9!#7-/ &: &
 &
" '+&:&:"$9-/ '; '
 '
#
 	!!!!!r   c                 H   t          t          |                                            | j        }| j        D ]#}||d                                      |           $| j        }| j        D ]8}|d         }|| j                 }||         |                             |           9d S rH  )	r  r  r?  r  r  rO  r  r  r  )r   rI  r|  r  tab_namer  s        r   r?  z!SchemaParserV4._aggregate_results(  s    nd##66888$- 	0 	0Cc/"#**3////%. 	- 	-C/*G4/0HgJx '',,,,	- 	-r   c           	   #     K   t          t          |                                           D ]}|V  | j        D ]}|d         }|                     |          }d|_        | j                            |g           D ]M}|| j                 }| j	        |         |         }|
                    |                     ||d                     N|V  d S )Nr  T)r  r   )r  r  r  r  r  r   r  r  r  r  r   r  )	r   xr|  r  r  r  r<  r  r  s	           r   r  z SchemaParserV4.get_all_keyspaces5  s     ~t,,>>@@ 	 	AGGGG0 	  	 C/*G 99#>>M$(M!!599'2FF  	&t';<
4W=jI11..y8@7; / = =   
  	  	 r   c                    |                      dd           | d<   |                      di           | d<   | d                              dd           | d         d<   t          t          t                                        |           S )Nr  rb  r  )r  r  r  r  )r|  r  s    r   r  z0SchemaParserV4._build_keyspace_metadata_internalI  sz     !$(8$ ? ? WW]B77M&)-&8&<&<Wd&K&KM7#^^44VVWZ[[[r   )rr  rs  rt  r/  r  r  r  r   r  r?  r  r  r  r  r  s   @r   r  r  
  s         " !PIKK K K K KB" B" B"H- - - - -         ( \ \ \ \ \\ \ \ \ \r   r  c                   &    e Zd ZdZej        dz   ZdS )SchemaParserDSE67z
    For DSE 6.7+
    r  N)rr  rs  rt  ru  r  r/  r   r   r   r  r  R  r  r   r  c                        e Zd ZdZdZdZeZ fdZ fdZ	 fdZ
ed             Zd Zed	             Zed
             Zd Z fdZ xZS )SchemaParserDSE68z
    For DSE 6.8+
    z$SELECT * FROM system_schema.verticesz!SELECT * FROM system_schema.edgesc                     t          t          |                               ||           t          d           | _        t          d           | _        d S )Nc                  *    t          t                    S r   r  r   r   r   r  z,SchemaParserDSE68.__init__.<locals>.<lambda>f  s    k$>O>O r   c                  *    t          t                    S r   r  r   r   r   r  z,SchemaParserDSE68.__init__.<locals>.<lambda>g  s    K<M<M r   )r  r  r   r   keyspace_table_vertex_rowskeyspace_table_edge_rowsr  s      r   r   zSchemaParserDSE68.__init__d  sR    &&//
GDDD*56O6O*P*P'(34M4M(N(N%%%r   c              #      K   t          t          |                                           D ]}|                     |           |V  d S r   )r  r  r  _build_graph_metadata)r   r  r  s     r   r  z#SchemaParserDSE68.get_all_keyspacesi  sZ      "#4d;;MMOO 	  	 M&&}555	  	 r   c                    t          t          |                               |||          }t          j        }t          d| j        z  ||ft                    }t          | j	        |z   |          }t          | j
        |z   |          }| j                            ||| j        d          \  \  }	}
\  }}|                     |	|
          }
|                     ||          }	 |
r!|                     |
d                   |_        n)|r'|                     ||         |d                   |_        nR# t&          $ rE d |_        d |_        t)          j                    |_        t.                              d||           Y nw xY w|S )NrX  rv  Fry  r   z3Error while parsing graph metadata for table %s.%s.)r  r  r  r   r~  r   r  r"  r   _SELECT_VERTICES_SELECT_EDGESr   r  r   ro  _build_table_vertex_metadatar  _build_table_edge_metadatar  r  r  r  r  r  r/  )r   rW   rV   r   r=  r  r  vertices_queryedges_queryvertices_successvertices_resultedges_successedges_resultr  s                r   r  zSchemaParserDSE68.get_tablen  s   ,d33==iSXYY
!"#LPTPd#ehprwgx  {C  D  D%D,AL,Pdfggg");l)J^`aaa o00VZVbrw0xx 	K+	?-Jm\../?QQ++M<HH		b h$($E$EoVWFX$Y$Y
!! h"&"A"A)HBUWcdeWf"g"g
 	b 	b 	b $J"JO#&<>>J MMOQY[`aaaaa		b s   #AD0 0AE?>E?c                    | d         }|                      dd           }d| v r"t          |                      d                    ni }d|v r|                    d          nd }|                      dd           }t          |||||          S )Nr  r  rb  r  r  )r  r	  r  r  )r|  r  r  rb  replication_classr  s         r   r  z3SchemaParserDSE68._build_keyspace_metadata_internal  s    ?#!14886Cs6J6Jd377=11222PR8?;8N8NKOOG444TXww~t44n6GVbcccr   c                      fd}	  fdj                                         D             D ]} ||            fdj                                         D             D ]} ||           d S # t          $ rf j                                         D ]}d x|_        |_        t          j                    _        t          	                    dj
                   Y d S w xY w)Nc                     j         j                 | j                 D ]}                    |          | _        j        j                 | j                 D ]}                    |          | _        d S r   )r  r  r  r  r  r  r  )r=  r|  r  r   s     r   _build_table_graph_metadatazLSchemaParserDSE68._build_graph_metadata.<locals>._build_table_graph_metadata  s    6}7IJ:?[ K K$($E$Ec$J$J
!!4]5GHY V V"&"A"A-QT"U"U
V Vr   c                 F    g | ]}|j         j        j                  v |S r   r  r  r   r^  r  r   s     r   r  z;SchemaParserDSE68._build_graph_metadata.<locals>.<listcomp>  s=     a a aQ"#&D,KML^,_"_"_  !"_"_"_r   c                 F    g | ]}|j         j        j                  v|S r   r  r  s     r   r  z;SchemaParserDSE68._build_graph_metadata.<locals>.<listcomp>  s>     e e eQ"#&0OP]Pb0c"c"c  !"c"c"cr   z2Error while parsing graph metadata for keyspace %s)r  r   r  r  r  r  r  r  r  r/  r  )r   r  r  r=  r^  s   ``   r   r  z'SchemaParserDSE68._build_graph_metadata  sy   	V 	V 	V 	V 	V 	V	da a a a a-*>*E*E*G*G a a a 8 8
++J7777e e e e e-*>*E*E*G*G e e e 8 8
++J77778 8  	d 	d 	d")0022 ) )$((&)lnnM#MMNP]Pbcccccc	ds   A(A4 4A,C$#C$c                     t          |                     d          |                     d          |                     d                    S )Nr  r<  r  )VertexMetadatar  r  s    r   r  z.SchemaParserDSE68._build_table_vertex_metadata  s?    cggo668M8M!ggl335 5 	5r   c                 *   |                     d          }| j                             |          }|j        j        }|                     d          }| j                             |          }|j        j        }t	          |                     d          |                     d          |                     d          |||                     d          |                     d          |||                     d          |                     d	                    S )
N
from_tableto_tabler  r<  r  r  r  r  r  )r  r  r  r  EdgeMetadata)r  r|  r  from_table_metar  r  to_table_metar  s           r   r  z,SchemaParserDSE68._build_table_edge_metadata  s    WW\**
'.22:>>$+6
77:&&%,00:: '2GGO$$cggl&;&;GGL!!:zGG011GG-..(GG.//GG+,,. . 	.r   c                 `   t           j        }t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j	        |          t          | j
        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          t          | j        |          g} | j        j        || j        dd}|\  \  }}\  }}\  }}	\  }
}\  }}\  }}\  }}\  }}\  }}\  }}\  }}\  }}\  }}\  }}|                     ||          | _        |                     ||          | _        |                     ||	          | _        |                     ||          | _        |                     |
|          | _        |                     ||          | _        |                     ||          | _        |                     ||          | _        |                     ||          | _        |                     ||t<          f          | _        |                     ||t<          f          | _         |                     ||t<          f          | _!        |                     ||          | _"        |                     ||          | _#        | $                                 d S r  )%r   r~  r   r  rY  r  r  r  r  r  rZ  r[  r  r  r  r  r  r   r  r   ro  r  r  r  r  r  r  r  rR  r  r   r  r  r  r  r  r?  ) r   r  r@  r  rA  rB  rC  r  r  r  rD  r  rE  r  rF  r  r  r  r  rR  r  r  r  r  r  r  r  r  r  r  r  r  s                                    r   r  zSchemaParserDSE68._query_all  sj   ! t5LLLt2bIIIt3rJJJt1RHHHt5LLLt6"MMMt4KKKt3rJJJt1RHHHt=QSTTTt:bQQQt;rRRRt4KKKt1RHHH!
& 7DO6dl%A A A	& #	
#Z)]L%[*)]L1 03!2/-_n)]L3!29"$8;#%:/)]L !% 4 4Z K K!11-NN"22;
KK#334DoVV 00MM $ 4 45FHX Y Y!%!5!56HJ[!\!\"22?NSS 00MM )-(<(< 1-/ )= )
 )
% &*%9%9!#7-/ &: &
 &
" '+&:&:"$9-/ '; '
 '
#  $334DoVV 00MM!!!!!r   c                 ^   t          t          |                                            | j        }| j        D ]3}|d         }|d         }||         |                             |           4| j        }| j        D ]3}|d         }|d         }||         |                             |           4d S )Nr  r<  )r  r  r?  r  r  rO  r  r  r  s        r   r?  z$SchemaParserDSE68._aggregate_results
  s    &&99;;;+' 	* 	*C)F&FfIf$$S)))))$ 	* 	*C)F&FfIf$$S))))	* 	*r   )rr  rs  rt  ru  r  r  r  rh  r   r  r  r  r  r  r  r  r  r?  r  r  s   @r   r  r  Z  s         >7M.O O O O O
         
    2 d d \dd d d4 5 5 \5 . . \. H" H" H"T* * * * * * * * *r   r  c                   b    e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 dZ		 dZ
	 dZ	 dZ	 dZ	 d ZddZd ZdS )r{  z<
    A representation of a materialized view on a table
    Nc                     || _         || _        || _        g | _        g | _        t                      | _        || _        || _        |pi | _	        d S r   )
r  r  r;  r  r  r   r   rz  r  rj   )r   r  r>  r;  rz  r  rj   s          r   r   z!MaterializedViewMetadata.__init__N  sS    *	. "}}#6 (}"r   Fc                 J   |rdnd}t          | j                  }t          | j                  }| j        rdn5d                    d | j                                        D                       }t          | j                  }| j        }d                    d | j	        D                       }t          | j	                  dk    rd|z  }	nd	|z  }	| j        r*|	d
d                    d | j        D                       z  z  }	|	dz  }	t                              || j        | j                  }
dt                      z  }| j        r_t"          j        }|                                | j        z  D ]6}||         }|                    | || j        |                   }|r|d|z  }7|S )r{  rg  r$  *rM  c              3   >   K   | ]}t          |j                  V  d S r   r  r  s     r   r   z8MaterializedViewMetadata.as_cql_query.<locals>.<genexpr>c  s/      FFbe|TWT\G]G]FFFFFFr   c              3   >   K   | ]}t          |j                  V  d S r   r  r  s     r   r   z8MaterializedViewMetadata.as_cql_query.<locals>.<genexpr>g  s,      RR\#(33RRRRRRr   r  z((%s)z(%sr  c              3   >   K   | ]}t          |j                  V  d S r   r  r  s     r   r   z8MaterializedViewMetadata.as_cql_query.<locals>.<genexpr>m  s,      $[$[\#(%;%;$[$[$[$[$[$[r   rP  zCREATE MATERIALIZED VIEW %(keyspace)s.%(name)s AS%(sep)sSELECT %(selected_cols)s%(sep)sFROM %(keyspace)s.%(base_table)s%(sep)sWHERE %(where_clause)s%(sep)sPRIMARY KEY %(pk)s%(sep)sWITH %(properties)sr   )r'  r  r  rz  r   r   r   r;  r  r  ry  r  r  r  rj   rk  r  r  r  rU   r  )r   rR  rl  rV   r  selected_cols
base_tabler  part_keypkr  r  r  r  r  r  s                   r   r  z%MaterializedViewMetadata.as_cql_queryY  s    $,hh 233DI&&#7TYYFFimiui|i|i~i~FFF==!$"677
(99RRt?QRRRRRt!""Q&&8#BB!B 	\&499$[$[tGZ$[$[$[[[[[B
c	$55iATVZVbcc
%
 )/1 ? 	-/CH]]__t6 - -qk))$4?13EFF -Css,,C
r   c                 4    |                      d          dz   S rX  rZ  r   s    r   r   z)MaterializedViewMetadata.export_as_string  r[  r   r\  )rr  rs  rt  ru  r  r  r;  r  r  r   rz  r  rj   r  r   r  r   r   r   r   r{  r{    s          M6D%O9M N G FLSG
 J	% 	% 	%' ' ' 'R7 7 7 7 7r   r{  c                   *    e Zd ZdZdZ	 dZ	 dZ	 d ZdS )r  z1
    A representation of a vertex on a table
    Nc                 0    || _         || _        || _        d S r   )r  r<  r  )r   r  r<  r  s       r   r   zVertexMetadata.__init__  s    *$$r   )rr  rs  rt  ru  r  r<  r  r   r   r   r   r  r    sG          M*J9J5% % % % %r   r  c                   Z    e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 dZ		 dZ
	 dZ	 dZ	 dZ	 dZ	 d ZdS )r  z0
    A representation of an edge on a table
    Nc                     || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        d S r   )r  r<  r  r  r  r  r  r  r  r  r  )r   r  r<  r  r  r  r  r  r  r  r  r  s               r   r   zEdgeMetadata.__init__  s\    
 +$$$$*D''>$  (@%%:"""r   )rr  rs  rt  ru  r  r<  r  r  r  r  r  r  r  r  r  r   r   r   r   r  r    s          M(J4J1JHJN!%P"UHFHL#P U; ; ; ; ;r   r  c                    t          |          }|rxt          |          }|t          d          k    rt          | |          S |t          d          k    rt          | |          S |t          d          k    rt          | |          S |t          d          k    rt	          | |          S |t          d          k    rt          | |          S t          | |          S )Nz6.8.0z6.7.0z6.0.0z	4.0-alphaz3.0.0)r   r  r  r  r  rM  r  )r   r   r   r   versionr  s         r   r   r     s    n%%G :K      $Z999''""""$Z999''""""$Z999'+&&&&j'222	GG$$	$	$j'222 z7333r   c                     t          | t          j                  r| j        d                                         S |                                 S )zk
    A string representation of the type for this column, such as "varchar"
    or "map<string, int>".
    r   )r  r-  ReversedTyper
  r  )rK  s    r   r  r    sE    
 )U/00 2!!$;;===//111r   c                   (    e Zd ZdZed             ZdS )RLACTableExtension	DSE_RLACAc           
          dt          |j                  dt          |j                  dt          |                    d                    dS )NzRESTRICT ROWS ON rG  rd  zutf-8r  )r'  r  r  decode)r  r=  r  r  s       r   r  z"RLACTableExtension.after_table_cql  sU     5A*BZ5[5[5[5[5A*/5R5R5R5R5A(//RYBZBZ5[5[5[5[] 	]r   N)rr  rs  rt  r  r  r  r   r   r   r  r    s7        D] ] [] ] ]r   r  c                    | j         j        j        |         j        |         j        }t          d |D                       }t          t
                    }j        j        |D ]}fdt          ||          D             }t          |          dk    r	|d         }	nd                    d |D                       }	j                            ||	          }
fd|
D             }|sd |
D             }|r.|t          j        |                                       |           |t                                        |           t#          |          S )	a  
    Returns a :class:`dict` with the keys grouped per host. This can be
    used to more accurately group by IN clause or to batch the keys per host.

    If a valid replica is not found for a particular key it will be grouped under
    :class:`~.NO_VALID_REPLICA`

    Example usage::
        result = group_keys_by_replica(
                     session, "system", "peers",
                     (("127.0.0.1", ), ("127.0.0.2", ))
                 )
    c              3   D   K   | ]}t           j        |j                 V  d S r   )r-  	_cqltypesr  )r   r  s     r   r   z(group_keys_by_replica.<locals>.<genexpr>  s,      cc=u}'=>ccccccr   c                 L    g | ] \  }}|                     |j                  !S r   )	serializer   )r   
serializerr  r   s      r   r  z)group_keys_by_replica.<locals>.<listcomp>  sF     G G G,j" %..r73KLL G G Gr   r  r   r   c              3   ~   K   | ]8}t          j        d t          |          z  t          |          |d          V  9dS )z>H%dsBr   N)structpackry  )r   ps     r   r   z(group_keys_by_replica.<locals>.<genexpr>  sD      "h"hTU6;x#a&&/@#a&&!Q#O#O"h"h"h"h"h"hr   c                 T    g | ]$}|j         r |          t          j        k    "|%S r   )is_upr   LOCAL)r   rU  distances     r   r  z)group_keys_by_replica.<locals>.<listcomp>  sF     O O O4*O)1$<;M)M)M )M)M)Mr   c                      g | ]}|j         	|S r   )r  )r   rU  s     r   r  z)group_keys_by_replica.<locals>.<listcomp>  s    JJJttzJdJJJr   )r   r,  rW   r  r  rZ   r   _default_load_balancing_policyr  rQ  ry  r   r[  randomchoicerO  NO_VALID_REPLICAr	  )sessionrV   r   rU   r  serializerskeys_per_hostrT   serialized_keyrouting_keyr  valid_replicasr   r  s               @@r   group_keys_by_replicar    s    oG%/9@GUNccTbcccccK%%M5>H 8 8G G G G03K0E0EG G G~!##(+KK(("h"hYg"h"h"hhhK'44X{KKO O O O< O O O 	KJJ|JJJN 	8&-778??DDDD *+2237777r   c                   j    e Zd ZdZed             Zed             Zed             Zed             ZdS )	_NodeInfozs
    Internal utility functions to determine the different host addresses/ports
    from a local or peers row.
    c                     |                      d          }d| v r|                      d          }d| v r|                      d          }|r|dv r|                      d          }|S )Nrpc_addressnative_addressnative_transport_address)z0.0.0.0z::peerr  r|  addrs     r   get_broadcast_rpc_addressz#_NodeInfo.get_broadcast_rpc_address2  sv     ww}%%s""77+,,D%,,77566D 	#t000776??Dr   c                 ~    |                      d          }||dk    r|                      d          }|r|dk    r|nd S )Nrpc_portr   native_portr  r|  rj  s     r   get_broadcast_rpc_portz _NodeInfo.get_broadcast_rpc_port@  sH    wwz""<419977=))D2qttd2r   c                 ^    |                      d          }||                      d          }|S )Nbroadcast_addressr
  r  r  s     r   get_broadcast_addressz_NodeInfo.get_broadcast_addressH  s-    ww*++<776??Dr   c                 ~    |                      d          }||dk    r|                      d          }|r|dk    r|nd S )Nbroadcast_portr   	peer_portr  r  s     r   get_broadcast_portz_NodeInfo.get_broadcast_portP  sI    ww'((<419977;''D2qttd2r   N)	rr  rs  rt  ru  r  r  r  r  r  r   r   r   r  r  ,  s         
   \ 3 3 \3   \ 3 3 \3 3 3r   r  )vbinasciir   bisectr   collectionsr   collections.abcr   	functoolsr   hashlibr   rS   loggingrer  	threadingr	   r  r  r
   cassandra.murmur3ImportErrore	cassandrar   r   r   r   cassandra.cqltypescqltypesr-  cassandra.encoderr   cassandra.marshalr   cassandra.protocolr   cassandra.queryr   r   cassandra.utilr   r   cassandra.poolr   cassandra.connectionr   	getLoggerrr  r  ry   cql_keywordscql_keywords_unreservedr	  r"  r   r   r  r|  r  r   r~  r  r  r  r  r  r  r  r  r  rC  r^  rt  r  r  r  r  r  r  r'  r  r  compiler
  r  r   r  r  r  rQ  r:  rT  rU  r  r]  rO  rL  rK  rM  r`  rg  r  rM  r  r  r  r  r{  r  r  r   r  r  r  r  r  r   r   r   <module>r4     s
  "             # # # # # # # # # # # # $ $ $ $ $ $         				 



        
	))))))) 	 	 	DDDD	 Z Y Y Y Y Y Y Y Y Y Y Y " " " " " " % % % % % % + + + + + + + + + + + + 5 5 5 5 5 5 5 5 / / / / / / / / ' ' ' ' ' ' ) ) ) ) ) )g!!s   ( #     %'>>  799K. K. K. K. K.v K. K. K.\ %D !        $   $ $ $ $ $6-H $ $ $ $< + ! ! ! ! !f ! ! !    *   05e 5e 5e 5e 5e 5e 5e 5ep/W /W /W /W /W( /W /W /WdpU pU pU pU pU1 pU pU pUf0 0 0 0 0' 0 0 0$    v   D?7 ?7 ?7 ?7 ?7v ?7 ?7 ?7D`T `T `T `T `T `T `T `TFT T T T Tv T T TDH! H! H! H! H!F H! H! H!V"! "! "! "! "!m "! "! "!J+ + + + + + + +\    f       t       6BZ    # # #, , ,- - -  RZ 455 6 6 6  / / /%4 %4 %4 %4 %4V %4 %4 %4P8) 8) 8) 8) 8)F 8) 8) 8)vP P P P Pv P P Pf     F   D 	 	 	 	 		 	 	 	& & & & & & & &         9      $	5 	5 	5 	5 	5y 	5 	5 	5, , , , , , , ,) ) ) ) )f ) ) )D1 1 1 1 1F 1 1 1hv. v. v. v. v.m v. v. v.rP P P P P_ P P Pf/ / / / / / / /H\ H\ H\ H\ H\^ H\ H\ H\V/ / / / / / / /}* }* }* }* }*) }* }* }*@i7 i7 i7 i7 i7v i7 i7 i7X% % % % %V % % %(5; 5; 5; 5; 5;6 5; 5; 5;p4 4 4*2 2 2] ] ] ] ]1 ] ] ] 688 + + +^*3 *3 *3 *3 *3 *3 *3 *3 *3 *3s   A AA