def __init__(self, bucket_class, db, limit, key, records,<EOL>stop_uuid=None, stop_summarize=False):
<EOL>self.bucket = None<EOL>self.updates = <NUM_LIT:0><EOL>self.delay = None<EOL>self.summarized = False<EOL>self.last_summarize_idx = None<EOL>self.last_summarize_rec = None<EOL>self.last_summarize_ts = None<EOL>unpacked = [msgpack.loads(rec) for rec in records]<EOL>if stop_summarize:<EOL><INDENT>for i, rec in enumerate(reversed(unpacked)):<EOL><INDENT>if '<STR_LIT>' in rec:<EOL><INDENT>self.summarized = True<EOL>self.last_summarize_ts = rec['<STR_LIT>']<EOL>self.last_summarize_idx = len(records) - i - <NUM_LIT:1><EOL>self.last_summarize_rec = records[self.last_summarize_idx]<EOL>break<EOL><DEDENT><DEDENT><DEDENT>no_update = False<EOL>for i, rec in enumerate(unpacked):<EOL><INDENT>if (self.last_summarize_idx is not None and<EOL>i == self.last_summarize_idx):<EOL><INDENT>break<EOL><DEDENT>if '<STR_LIT>' in rec:<EOL><INDENT>if no_update:<EOL><INDENT>continue<EOL><DEDENT>self.bucket = bucket_class.hydrate(db, rec['<STR_LIT>'],<EOL>limit, key)<EOL><DEDENT>elif '<STR_LIT>' in rec:<EOL><INDENT>if no_update:<EOL><INDENT>continue<EOL><DEDENT>if self.bucket is None:<EOL><INDENT>self.bucket = bucket_class(db, limit, key)<EOL><DEDENT>self.delay = self.bucket.delay(rec['<STR_LIT>']['<STR_LIT>'],<EOL>rec['<STR_LIT>']['<STR_LIT:time>'])<EOL>self.updates += <NUM_LIT:1><EOL><DEDENT>elif '<STR_LIT>' in rec:<EOL><INDENT>self.summarized = True<EOL>ts = rec['<STR_LIT>']<EOL>if (self.last_summarize_ts is None or<EOL>ts > self.last_summarize_ts):<EOL><INDENT>self.last_summarize_ts = ts<EOL><DEDENT><DEDENT>if stop_uuid is not None and rec.get('<STR_LIT>') == stop_uuid:<EOL><INDENT>no_update = True<EOL><DEDENT><DEDENT>if self.bucket is None:<EOL><INDENT>self.bucket = bucket_class(db, limit, key)<EOL><DEDENT>
Initialize a BucketLoader.  Generates the bucket from the list
of records.

:param bucket_class: The class of the bucket.
:param db: The database handle for the bucket.
:param limit: The limit object asociated with the bucket.
:param key: The database key identifying the bucket record
            list.
:param records: A list of msgpack'd strings containing the
                change records for the bucket.
:param stop_uuid: The UUID of the last record (typically an
                  update record) which should be processed.
:param stop_summarize: If True, indicates that processing
                       should be stopped once the _last_
                       summarize record is encountered.