ó T!¶\c@sTddlZejeƒZd„Zdefd„ƒYZdefd„ƒYZdS(iÿÿÿÿNcKs|jdtƒdS(Ni(tinsertt TableResource(t base_classestkwargs((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pytregister_table_methodssRcBseZd„Zdd„ZRS(cOstt|ƒj||ŽdS(N(tsuperRt__init__(tselftargsR((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyRscCst|j|jjd|ƒS(sZCreate a batch writer object. This method creates a context manager for writing objects to Amazon DynamoDB in batch. The batch writer will automatically handle buffering and sending items in batches. In addition, the batch writer will also automatically handle any unprocessed items and resend them as needed. All you need to do is call ``put_item`` for any items you want to add, and ``delete_item`` for any items you want to delete. Example usage:: with table.batch_writer() as batch: for _ in xrange(1000000): batch.put_item(Item={'HashKey': '...', 'Otherstuff': '...'}) # You can also delete_items in a batch. batch.delete_item(Key={'HashKey': 'SomeHashKey'}) :type overwrite_by_pkeys: list(string) :param overwrite_by_pkeys: De-duplicate request items in buffer if match new request item on specified primary keys. i.e ``["partition_key1", "sort_key2", "sort_key3"]`` toverwrite_by_pkeys(t BatchWritertnametmetatclient(RR ((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyt batch_writer sN(t__name__t __module__RtNoneR(((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyRs R cBsneZdZdd d„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z RS( sAAutomatically handle batch writes to DynamoDB for a single table.icCs1||_||_g|_||_||_dS(sU :type table_name: str :param table_name: The name of the table. The class handles batch writes to a single table. :type client: ``botocore.client.Client`` :param client: A botocore client. Note this client **must** have the dynamodb customizations applied to it for transforming AttributeValues into the wire protocol. What this means in practice is that you need to use a client that comes from a DynamoDB resource if you're going to instantiate this class directly, i.e ``boto3.resource('dynamodb').Table('foo').meta.client``. :type flush_amount: int :param flush_amount: The number of items to keep in a local buffer before sending a batch_write_item request to DynamoDB. :type overwrite_by_pkeys: list(string) :param overwrite_by_pkeys: De-duplicate request items in buffer if match new request item on specified primary keys. i.e ``["partition_key1", "sort_key2", "sort_key3"]`` N(t _table_namet_clientt _items_buffert _flush_amountt_overwrite_by_pkeys(Rt table_nameR t flush_amountR ((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyRAs     cCs|jii|d6d6ƒdS(NtItemt PutRequest(t_add_request_and_process(RR((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pytput_itemdscCs|jii|d6d6ƒdS(NtKeyt DeleteRequest(R(RR((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyt delete_itemgscCs7|jr|j|ƒn|jj|ƒ|jƒdS(N(Rt _remove_dup_pkeys_request_if_anyRtappendt_flush_if_needed(Rtrequest((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyRjs cCs_|j|ƒ}xI|jD]>}|j|ƒ|kr|jj|ƒtjd|ƒqqWdS(Ns4With overwrite_by_pkeys enabled, skipping request:%s(t_extract_pkey_valuesRtremovetloggertdebug(RR#tpkey_values_newtitem((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyR ps  cCsn|jdƒr5g|jD]}|dd|^qS|jdƒrjg|jD]}|dd|^qNSdS(NRRRR(tgetRR(RR#tkey((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyR$xs##cCs)t|jƒ|jkr%|jƒndS(N(tlenRRt_flush(R((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyR"scCs¨|j|j }|j|j|_|jjdi||j6ƒ}|d}|ry||jry|jj||jƒn g|_tjdt|ƒt|jƒƒdS(Nt RequestItemstUnprocessedItemss$Batch write sent %s, unprocessed: %s( RRRtbatch_write_itemRtextendR&R'R,(Rt items_to_sendtresponsetunprocessed_items((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyR-…s    cCs|S(N((R((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyt __enter__•scCsx|jr|jƒqWdS(N(RR-(Rtexc_typet exc_valuettb((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyt__exit__˜s N(RRt__doc__RRRRRR R$R"R-R5R9(((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyR ?s "       (tloggingt getLoggerRR&RtobjectRR (((s5/tmp/pip-install-usGedi/boto3/boto3/dynamodb/table.pyt s  #