o ckF[Êã@s$Gdd„deƒZGdd„deƒZdS)csZeZdZdZd‡fdd„ Zedd„ƒZdd„Zd d „Zd d „Z e Z d d„Z dd„Z ‡Z S)Ú ResultSeta¼ A class used to lazily handle page-to-page navigation through a set of results. It presents a transparent iterator interface, so that all the user has to do is use it in a typical ``for`` loop (or list comprehension, etc.) to fetch results, even if they weren't present in the current page of results. This is used by the ``Table.query`` & ``Table.scan`` methods. Example:: >>> users = Table('users') >>> results = ResultSet() >>> results.to_call(users.query, username__gte='johndoe') # Now iterate. When it runs out of results, it'll fetch the next page. >>> for res in results: ... print res['username'] NcsNtt|ƒ ¡d|_g|_i|_g|_d|_d|_d|_ d|_ ||_ d|_ dS)NéÿÿÿÿTé) ÚsuperrÚ__init__Ú the_callableÚ call_argsÚ call_kwargsÚ_resultsÚ_offsetÚ _results_leftÚ_last_key_seenÚ_fetchesÚ_max_page_sizeÚ_limit)ÚselfÚ max_page_size©Ú __class__©ú8/usr/lib/python3/dist-packages/boto/dynamodb2/results.pyrs zResultSet.__init__cCsdS)NÚexclusive_start_keyr©rrrrÚ first_key$szResultSet.first_keycCsg|_d|_dS)zº Resets the internal state of the ``ResultSet``. This prevents results from being cached long-term & consuming excess memory. Largely internal. rN)r r rrrrÚ_reset(s zResultSet._resetcCs|S©NrrrrrÚ__iter__4szResultSet.__iter__cCs¨|jd7_|jt|jƒkr/|jdurtƒ‚| ¡t|jƒs/|jr/| ¡t|jƒs/|js#|jt|jƒkrQ|jdurK|jd8_|jdkrKtƒ‚|j|jStƒ‚)NéFr)r Úlenr r Ú StopIterationÚ fetch_morerrrrrÚ__next__7s ÿ   zResultSet.__next__cOsNt|ƒstdƒ‚| dd¡|_|jdur|jdkrd|_||_||_||_dS)aê Sets up the callable & any arguments to run it with. This is stored for subsequent calls so that those queries can be run without requiring user intervention. Example:: # Just an example callable. >>> def squares_to(y): ... for x in range(1, y): ... yield x**2 >>> rs = ResultSet() # Set up what to call & arguments. >>> rs.to_call(squares_to, y=3) z3You must supply an object or function to be called.ÚlimitNr)ÚcallableÚ ValueErrorÚpoprrrr)rrÚargsÚkwargsrrrÚto_callSsÿ zResultSet.to_callcCs | ¡|jdd…}|j ¡}|jdur|j||j<|jr+|jr+|j|jkr+|j|_|jdur6|j|d<n |jdur@|j|d<|j|i|¤Ž}|j d7_ |  dg¡}|  dd¡|_t |ƒrh|j   |d¡|jdur„|jdkr„|j}|t |dƒ8}|dkr„d|_|jdurŽd|_dSdS)z¯ When the iterator runs out of results, this method is run to re-execute the callable (& arguments) to fetch the next page. Largely internal. Nr!rÚresultsÚlast_keyrF)rrrÚcopyr rrrrr Úgetrr Úextendr )rr%r&r(Ú new_resultsr!rrrrvs2          ÿzResultSet.fetch_morer)Ú__name__Ú __module__Ú __qualname__Ú__doc__rÚpropertyrrrr Únextr'rÚ __classcell__rrrrrs  #rcs$eZdZ‡fdd„Zdd„Z‡ZS)ÚBatchGetResultSetcs6| dg¡|_| dd¡|_tt|ƒj|i|¤ŽdS)NÚkeysÚ max_batch_getéd)r$Ú _keys_leftÚ_max_batch_getrr5r)rr%r&rrrr¨szBatchGetResultSet.__init__cCsø| ¡|jdd…}|j ¡}|jd|j…|d<|j|jd…|_t|jƒdkr-d|_|j|i|¤Ž}t|  dg¡ƒs?dS|j   |d¡t |  dg¡ƒD] \}}|j  ||¡qOt|jƒdkred|_|j  d¡rz|jdt|dƒ8<dSdS)Nr6rFr(Úunprocessed_keysTr!)rrrr*r9r:rr rr+r r,Ú enumerateÚinsert)rr%r&r(ÚoffsetÚkey_datarrrr­s$  ÿzBatchGetResultSet.fetch_more)r.r/r0rrr4rrrrr5§s r5N)Úobjectrr5rrrrÚs'