expose min_id in allocator.py

This commit is contained in:
Quentin Machu 2016-02-16 15:16:22 -05:00
parent 8b61c69dad
commit c8d825c232

View file

@ -14,9 +14,9 @@ class NoAvailableKeysError(ValueError):
class CompletedKeys(object):
def __init__(self, max_index):
def __init__(self, min_index, max_index):
self._max_index = max_index
self._min_index = 0
self._min_index = min_index
self._slabs = RBTree()
def _get_previous_or_none(self, index):
@ -118,7 +118,7 @@ class CompletedKeys(object):
return random.randint(hole_start, rand_max_bound)
def yield_random_entries(batch_query, primary_key_field, batch_size, max_id):
def yield_random_entries(batch_query, primary_key_field, batch_size, max_id, min_id=0):
""" This method will yield items from random blocks in the database. We will track metadata
about which keys are available for work, and we will complete the backfill when there is no
more work to be done. The method yields tupes of (candidate, Event), and if the work was
@ -126,8 +126,9 @@ def yield_random_entries(batch_query, primary_key_field, batch_size, max_id):
an "id" field which can be inspected.
"""
min_id = max(min_id, 0)
max_id = max(max_id, 1)
allocator = CompletedKeys(max_id + 1)
allocator = CompletedKeys(min_id, max_id + 1)
try:
while True: