+\h.UdZddlmZddlmZmZmZmZmZddl m Z m Z ddl m Z ddlmZmZmZerddlmZdZded <d Zded <d Zded <dZded<dZded<dZded<GddZ ddZddZy)zKConstants, types, and classes shared across Bulk Write API implementations.) annotations) TYPE_CHECKINGAnyMappingMutableMappingNoReturn)BulkWriteErrorOperationFailure) _get_wce_doc)_DELETE_INSERT_UPDATE) _DocumentOutint _DELETE_ALL _DELETE_ONE _BAD_VALUE_UNKNOWN_ERROR@_WRITE_CONCERN_ERROR)insertupdatedeleteztuple[str, str, str] _COMMANDSc(eZdZdZddZddZddZy) _Runz'Represents a batch of write operations.c<||_g|_g|_d|_y)zInitialize a new Run object.rN)op_type index_mapops idx_offset)selfr!s V/root/niggaflix-v3/playground/venv/lib/python3.12/site-packages/pymongo/bulk_shared.py__init__z _Run.__init__/s# $&  c |j|S)zGet the original index of an operation in this run. :param idx: The Run index that maps to the original index. )r")r%idxs r&indexz _Run.index6s ~~c""r(cp|jj||jj|y)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&addz_Run.add=s& n-  "r(N)r!rreturnNone)r*rr1r)r.rr/rr1r2)__name__ __module__ __qualname____doc__r'r+r0r(r&rr,s1!##r(rc |jdd}|jtk(r|dxx|z cc<n|jtk(r|dxx|z cc<n|jtk(r|jd}|r^t |}|D]}|j |d|z|d<|dj||dxx|z cc<|dxx||z z cc<n |dxx|z cc<|d xx|d z cc<|jd }|rY|D]T}|j} |d|z} |j | | d<|j| | d <|d j| Vt|} | r|d j| y y )z7Merge a write command result into the full bulk result.nr nInsertednRemovedupsertedr+ nUpsertednMatched nModified writeErrorsopwriteConcernErrorsN) getr!r r rlenr+extendcopyr#r-r ) run full_resultoffsetresultaffectedr< n_upserteddoc write_errors replacementr*wces r&_merge_commandrQHszz#q!H {{gK H,  J8+  ::j) XJ @"yyW)>?G  @  # * *8 4  $ 2 $  #x*'< < #  #x / #K F;$77 ::m,L ;C((*Kg,'C#&99S>K # K   & - -k : ; v C ()005 r(c|drM|djd|dd}|d}|d}|dk(r |jdrd }t|||t|) z5Raise a BulkWriteError from the full bulk api result.r@c |dS)Nr+r7)errors r&z)_raise_bulk_write_error..xs %.r()keyrcodeerrmsgzTransaction numberszrThis MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.)sort startswithr r )rHerrrWmsgrXs r&_raise_bulk_write_errorr^ts}=!M"'',H'I-(+6{(m 2:#..)>?-  #64= =  %%r(N) rGrrHzMutableMapping[str, Any]rIrrJzMapping[str, Any]r1r2)rHrr1r)r6 __future__rtypingrrrrrpymongo.errorsr r pymongo.helpers_sharedr pymongo.messager r rpymongo.typingsrr__annotations__rrrrrrrQr^r7r(r&rfs R"HH;/ , S S Cc"@ @##8)6 )6))6 )6  )6  )6X&r(