§ w<ˆj³#ãó–—dZddlmZddlmZddlmZddlmZddgZGd„de¦«Z Gd „d e ¦«Z Gd „de¦«Z d S) aHorizontal sharding support. Defines a rudimental 'horizontal sharding' system which allows a Session to distribute queries and persistence operations across multiple databases. For a usage example, see the :ref:`examples_sharding` example included in the source distribution. é)Úinspect)Úutil)ÚQuery)ÚSessionÚShardedSessionÚ ShardedQuerycóL‡—eZdZˆfd„Zd„Zd„Zd„Z dˆfd„ Zd ˆfd„ ZˆxZ S) rcóš•—tt|¦«j|i|¤Ž|jj|_|jj|_d|_dS©N)ÚsuperrÚ__init__ÚsessionÚ id_chooserÚ query_chooserÚ _shard_id)ÚselfÚargsÚkwargsÚ __class__s €ús/builddir/build/BUILD/cloudlinux-venv-1.0.12/venv/lib64/python3.11/site-packages/sqlalchemy/ext/horizontal_shard.pyr zShardedQuery.__init__sIø€Ø*��l˜DÑ!Ô!Ô*¨DÐ;°FÐ;Ð;Ð;Øœ,Ô1ˆŒØ!œ\Ô7ˆÔ؈Œˆˆócó<—| ¦«}||_|S)zºReturn a new query, limited to a single shard ID. All subsequent operations with the returned query will be against the single shard regardless of other state. )Ú_cloner)rÚshard_idÚqs rÚ set_shardzShardedQuery.set_shard!s€ð �KŠK‰MŒMˆØˆŒ ؈rcóü‡‡—ˆˆfd„}‰j�|‰j¦«S‰j�|‰j¦«Sg}‰ ‰¦«D] }| ||¦«¦«Œ!t |¦«S)Ncóà•—|x‰jd<‰_‰ ‰ ¦«|¬¦« ‰j‰j¦«}‰ |‰¦«S)Nr)Úmapperr)Ú attributesÚidentity_tokenÚ_connection_from_sessionÚ _bind_mapperÚexecuteÚ statementÚ_paramsÚ instances)rÚresultÚcontextrs €€rÚiter_for_shardz;ShardedQuery._execute_and_instances..iter_for_shard.spø€ØFNÐ NˆGÔ ˜zÑ *¨WÔ-CØ×2Ò2Ø×(Ò(Ñ*Ô*°Xð3ñôçŠg�gÔ'¨¬Ñ6Ô6ð ð—>’> &¨'Ñ2Ô2Ð 2r)r!rrÚextendÚiter)rr)r*Úpartialrs`` rÚ_execute_and_instancesz#ShardedQuery._execute_and_instances-s©øø€ð 3ð 3ð 3ð 3ð 3ð 3ð Ô !Ð -Ø!�> 'Ô"8Ñ9Ô9Ð 9Ø Œ^Ð 'Ø!�> $¤.Ñ1Ô1Ð 1àˆGØ ×.Ò.¨tÑ4Ô4ð 9ð 9�Ø—’˜~˜~¨hÑ7Ô7Ñ8Ô8Ð8Ð8õ˜‘=”=Ð rcóð‡‡‡—ˆˆˆfd„}‰j�|‰j¦«Sd}g}‰ ‰¦«D],}||¦«}||jz }| |¦«Œ-t ||¦«S)Ncóp•—‰ ‰|‰d¬¦«}| ‰‰j¦«}|S)NT)rrÚclauseÚclose_with_result)r"r$r&)rÚconnr(rrÚstmts €€€rÚexec_for_shardz2ShardedQuery._execute_crud..exec_for_shardCsEø€Ø×0Ò0ØØ!ØØ"&ð 1ñôˆDð —\’\ $¨¬ Ñ5Ô5ˆF؈Mré)rrÚrowcountÚappendÚ ShardedResult)rr4rr5r7Úresultsrr(s``` rÚ _execute_crudzShardedQuery._execute_crudBs«øøø€ð ð ð ð ð ð ð ð Œ>Ð %Ø!�> $¤.Ñ1Ô1Ð 1àˆH؈GØ ×.Ò.¨tÑ4Ô4ð 'ð '�Ø'˜¨Ñ1Ô1�ؘFœOÑ+�Ø—’˜vÑ&Ô&Ð&Ð&å  ¨(Ñ3Ô3Ð 3rNc ó<•—|�$tt|¦«j||fd|i|¤ŽS|j |¦«}|r| |¦«}| ||¦«D],}tt|¦«j||fd|i|¤Ž}|�|cSŒ-dS)z¿Override the default Query._identity_lookup method so that we search for a given non-token primary key identity across all possible identity tokens (e.g. shard ids). Nr!)r rÚ_identity_lookuprÚqueryÚ_set_lazyload_fromr) rrÚprimary_key_identityr!Úlazy_loaded_fromÚkwrrÚobjrs €rr=zShardedQuery._identity_lookupYsñø€ð Ð %Ø=•5� tÑ,Ô,Ô=ØØ$ððð .ððð ðð ð” ×"Ò" 6Ñ*Ô*ˆAØð ;Ø×(Ò(Ð)9Ñ:Ô:�Ø ŸOšO¨AÐ/CÑDÔDð ð �Ø@•e�L¨$Ñ/Ô/Ô@ØÐ0ððØAIðØMOðð�ð�?Ø�J�J�Jð#ð�4rc󊕇‡—ˆˆfd„}|€‰j�‰j}tt‰¦« |||¬¦«S)z©Override the default Query._get_impl() method so that we emit a query to the DB for each possible identity token, if we don't have one already. cóÖ•—‰j� ‰‰|¦«Stj|¦«}‰ ‰|¦«D])}‰ |¦«}‰||¦«}|�|cSŒ*dSr )rrÚto_listrr)r>r@ÚidentrrÚoÚ db_load_fnrs €€rÚ _db_load_fnz+ShardedQuery._get_impl.._db_load_fn‚s‹ø€ðŒ~Ð)Ø!�z $Ð(<Ñ=Ô=Ð=åœ Ð%9Ñ:Ô:�ð!%§¢°°eÑ <Ô <ð ð �HØŸš xÑ0Ô0�AØ"˜  1 eÑ,Ô,�AØ�}Ø ˜˜˜ð%ð ˜4rN)r!)rr rÚ _get_impl)rr@rIr!rJrs` ` €rrKzShardedQuery._get_impl{sgøøø€ð ð ð ð ð ð ð$ Ð ! d¤nÐ&@Ø!œ^ˆNå•\ 4Ñ(Ô(×2Ò2Ø  +¸nð3ñ ô ð r)NNr ) Ú__name__Ú __module__Ú __qualname__r rr.r;r=rKÚ __classcell__©rs@rrrsªø€€€€€ðððððð ð ð ð!ð!ð!ð*4ð4ð4ð6Øð ð ð ð ð ð ðD ð ð ð ð ð ð ð ð ð rcó2—eZdZdZdZd„Zed„¦«ZdS)r9aøA value object that represents multiple :class:`_engine.ResultProxy` objects. This is used by the :meth:`.ShardedQuery._execute_crud` hook to return an object that takes the place of the single :class:`_engine.ResultProxy`. Attribute include ``result_proxies``, which is a sequence of the actual :class:`_engine.ResultProxy` objects, as well as ``aggregate_rowcount`` or ``rowcount``, which is the sum of all the individual rowcount values. .. versionadded:: 1.3 ©Úresult_proxiesÚaggregate_rowcountcó"—||_||_dSr rR)rrSrTs rr zShardedResult.__init__®s€Ø,ˆÔØ"4ˆÔÐÐrcó—|jSr )rT)rs rr7zShardedResult.rowcount²s €àÔ&Ð&rN)rLrMrNÚ__doc__Ú __slots__r Úpropertyr7©rrr9r9œsO€€€€€ð ð ð9€Ið5ð5ð5ðð'ð'ñ„Xð'ð'ð'rr9cóB‡—eZdZdefˆfd„ Zd„Zdd„Z dd„Zd„ZˆxZ S)rNc óæ•—tt|¦«jdd|i|¤Ž||_||_||_i|_|j|_|�!|D] }|  |||¦«ŒdSdS)aConstruct a ShardedSession. :param shard_chooser: A callable which, passed a Mapper, a mapped instance, and possibly a SQL clause, returns a shard ID. This id may be based off of the attributes present within the object, or on some round-robin scheme. If the scheme is based on a selection, it should set whatever state on the instance to mark it in the future as participating in that shard. :param id_chooser: A callable, passed a query and a tuple of identity values, which should return a list of shard ids where the ID might reside. The databases will be queried in the order of this listing. :param query_chooser: For a given Query, returns the list of shard_ids where the query should be issued. Results from all shards returned will be combined together into a single listing. :param shards: A dictionary of string shard names to :class:`~sqlalchemy.engine.Engine` objects. Ú query_clsNrZ) r rr Ú shard_chooserrrÚ_ShardedSession__bindsÚ connectionÚconnection_callableÚ bind_shard) rr^rrÚshardsr]rÚkrs €rr zShardedSession.__init__¸s—ø€ð< -��n˜dÑ#Ô#Ô,ÐKÐK°yÐKÀFÐKÐKÐKØ*ˆÔØ$ˆŒØ*ˆÔ؈Œ Ø#'¤?ˆÔ Ø Ð Øð .ð .�Ø—’  6¨!¤9Ñ-Ô-Ð-Ð-ð Ð ð .ð .rc ó¨—|�7t|¦«}|jr|jd}|€J‚|S|jr|jS|j||fi|¤Ž}|�||_|S)Nr)rÚkeyr!r^)rrÚinstancerBÚstateÚtokenrs rÚ_choose_shard_and_assignz'ShardedSession._choose_shard_and_assignàs~€Ø РݘHÑ%Ô%ˆEØŒyð ,Øœ  !œ �ØÐ(Ð(Ð(Ø� ØÔ%ð ,ØÔ+Ð+à%�4Ô% f¨hÐ=Ð=¸"Ð=Ð=ˆØ Ð Ø#+ˆEÔ Øˆrc ó¾—|€| ||¦«}|j�|j ||¬¦«S| |||¬¦«jdi|¤ŽS)N)r)rrgrZ)rjÚ transactionr`Úget_bindÚ_contextual_connect)rrrgrrs rr`zShardedSession.connectionïs‚€Ø Ð Ø×4Ò4°V¸XÑFÔFˆHà Ô Ð 'ØÔ#×.Ò.¨vÀÐ.ÑIÔIÐ Ið"�4—=’=Ø °Hð!ñôä!ð,ð,à$*ð,ð,ð ,rc óP—|€| |||¬¦«}|j|S)N)r1)rjr_)rrrrgr1rBs rrmzShardedSession.get_bindús:€ð Ð Ø×4Ò4ؘ¨ð5ñôˆHðŒ|˜HÔ%Ð%rcó—||j|<dSr )r_)rrÚbinds rrbzShardedSession.bind_shards€Ø!%ˆŒ �XÑÐÐr)NNN) rLrMrNrr rjr`rmrbrOrPs@rrr·s’ø€€€€€ð Øð &.ð&.ð&.ð&.ð&.ð&.ðP ð ð ð ,ð ,ð ,ð ,ð<@ð&ð&ð&ð&ð&ð&ð&ð&ð&ð&ð&rN) rWÚrrÚ orm.queryrÚ orm.sessionrÚ__all__rÚobjectr9rrZrrúrwsþððððÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØ!Ð!Ð!Ð!Ð!Ð!à ˜^Ð ,€ð ð ð ð ð �5ñ ô ð ðD'ð'ð'ð'ð'�Fñ'ô'ð'ð6M&ðM&ðM&ðM&ðM&�WñM&ôM&ðM&ðM&ðM&r