expose min_id in allocator.py
This commit is contained in:
parent
8b61c69dad
commit
c8d825c232
1 changed files with 5 additions and 4 deletions
|
@ -14,9 +14,9 @@ class NoAvailableKeysError(ValueError):
|
||||||
|
|
||||||
|
|
||||||
class CompletedKeys(object):
|
class CompletedKeys(object):
|
||||||
def __init__(self, max_index):
|
def __init__(self, min_index, max_index):
|
||||||
self._max_index = max_index
|
self._max_index = max_index
|
||||||
self._min_index = 0
|
self._min_index = min_index
|
||||||
self._slabs = RBTree()
|
self._slabs = RBTree()
|
||||||
|
|
||||||
def _get_previous_or_none(self, index):
|
def _get_previous_or_none(self, index):
|
||||||
|
@ -118,7 +118,7 @@ class CompletedKeys(object):
|
||||||
return random.randint(hole_start, rand_max_bound)
|
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
|
""" 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
|
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
|
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.
|
an "id" field which can be inspected.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
min_id = max(min_id, 0)
|
||||||
max_id = max(max_id, 1)
|
max_id = max(max_id, 1)
|
||||||
allocator = CompletedKeys(max_id + 1)
|
allocator = CompletedKeys(min_id, max_id + 1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
|
Reference in a new issue