
    &g                       % S r SSKJr  SSKJrJrJrJrJr  SSK	J
r
Jr  SSKJr  SSKJrJrJr  \(       a  SSKJr  SrS\S	'   S
rS\S'   SrS\S'   SrS\S'   SrS\S'   SrS\S'    " S S5      r          SS jrSS jrg)zKConstants, types, and classes shared across Bulk Write API implementations.    )annotations)TYPE_CHECKINGAnyMappingMutableMappingNoReturn)BulkWriteErrorOperationFailure)_get_wce_doc)_DELETE_INSERT_UPDATE)_DocumentOutint_DELETE_ALL   _DELETE_ONE   
_BAD_VALUE   _UNKNOWN_ERROR@   _WRITE_CONCERN_ERROR)insertupdatedeleteztuple[str, str, str]	_COMMANDSc                  6    \ rS rSrSrSS jrS	S jrS
S jrSrg)_Run,   z'Represents a batch of write operations.c                :    Xl         / U l        / U l        SU l        g)zInitialize a new Run object.r   N)op_type	index_mapops
idx_offset)selfr"   s     XC:\Suresh\moveshuttle\MDcreated\moveengine\venv\Lib\site-packages\pymongo/bulk_shared.py__init___Run.__init__/   s    #$&      c                     U R                   U   $ )zpGet the original index of an operation in this run.

:param idx: The Run index that maps to the original index.
)r#   )r&   idxs     r'   index
_Run.index6   s    
 ~~c""r*   c                p    U R                   R                  U5        U R                  R                  U5        g)zAdd an operation to this Run instance.

:param original_index: The original index of this operation
    within a larger bulk operation.
:param operation: The operation document.
N)r#   appendr$   )r&   original_index	operations      r'   add_Run.add=   s&     	n-	"r*   )r%   r#   r"   r$   N)r"   r   returnNone)r,   r   r5   r   )r1   r   r2   r   r5   r6   )	__name__
__module____qualname____firstlineno____doc__r(   r-   r3   __static_attributes__ r*   r'   r   r   ,   s    1!##r*   r   c                4   UR                  SS5      nU R                  [        :X  a  US==   U-  ss'   OU R                  [        :X  a  US==   U-  ss'   OU R                  [        :X  a  UR                  S5      nU(       a_  [        U5      nU H  nU R                  US   U-   5      US'   M     US   R                  U5        US==   U-  ss'   US==   XF-
  -  ss'   OUS==   U-  ss'   US	==   US	   -  ss'   UR                  S
5      nU(       a[  U HU  nUR                  5       n	US   U-   n
U R                  U
5      U	S'   U R                  U
   U	S'   US
   R                  U	5        MW     [        U5      nU(       a  US   R                  U5        gg)z7Merge a write command result into the full bulk result.nr   	nInsertednRemovedupsertedr-   	nUpsertednMatched	nModifiedwriteErrorsopwriteConcernErrorsN)getr"   r   r   r   lenr-   extendcopyr$   r0   r   )runfull_resultoffsetresultaffectedrB   
n_upserteddocwrite_errorsreplacementr,   wces               r'   _merge_commandrW   H   s    zz#q!H
{{gK H, 		J8+		::j)XJ"yyW)>?G  
#**84$
2$
#x'<<#
#x/#K F;$77 ::m,LC((*Kg,'C#&99S>K  #K&--k:   v
C
()005 r*   c                    U S   (       aO  U S   R                  S S9  U S   S   nUS   nUS   nUS:X  a$  UR                  S5      (       a  S	n[        XBU 5      e[        U 5      e)
z5Raise a BulkWriteError from the full bulk api result.rF   c                    U S   $ )Nr-   r=   )errors    r'   <lambda>)_raise_bulk_write_error.<locals>.<lambda>x   s    %.r*   )keyr   codeerrmsg   zTransaction numberszrThis MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.)sort
startswithr
   r	   )rN   errr^   msgr_   s        r'   _raise_bulk_write_errorre   t   s~     =!M"'',H'I-(+6{(m2:#..)>??- 
 #6==

%%r*   N)
rM   r   rN   zMutableMapping[str, Any]rO   r   rP   zMapping[str, Any]r5   r6   )rN   r   r5   r   )r;   
__future__r   typingr   r   r   r   r   pymongo.errorsr	   r
   pymongo.helpers_sharedr   pymongo.messager   r   r   pymongo.typingsr   r   __annotations__r   r   r   r   r   r   rW   re   r=   r*   r'   <module>rm      s     R " H H ; /  , S S  
C   c "@	 @# #8)6	)6))6 )6 	)6
 
)6X&r*   