Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Use fewer batches when updating URLs

Daoud Clarke09ffee046d6e
diff --git a/mwmbl/indexer/index_batches.py b/mwmbl/indexer/index_batches.py
index 740643e..55397b9 100644
--- a/mwmbl/indexer/index_batches.py
+++ b/mwmbl/indexer/index_batches.py
@@ -36,7 +36,7 @@ def run(batch_cache: BatchCache, index_path: str):
index_batches(batches, index_path, url_db)
logger.info("Indexed pages")
- process_batch.run(batch_cache, BatchStatus.URLS_UPDATED, BatchStatus.INDEXED, process)
+ process_batch.run(batch_cache, BatchStatus.URLS_UPDATED, BatchStatus.INDEXED, process, 10000)
def index_batches(batch_data: Collection[HashedBatch], index_path: str, url_db: URLDatabase):
diff --git a/mwmbl/indexer/process_batch.py b/mwmbl/indexer/process_batch.py
index 0b3dd1d..cd9df6b 100644
--- a/mwmbl/indexer/process_batch.py
+++ b/mwmbl/indexer/process_batch.py
@@ -10,13 +10,13 @@ logger = getLogger(__name__)
def run(batch_cache: BatchCache, start_status: BatchStatus, end_status: BatchStatus,
- process: Callable[[Collection[HashedBatch], ...], None], *args):
+ process: Callable[[Collection[HashedBatch], ...], None], num_batches, *args):
with Database() as db:
index_db = IndexDatabase(db.connection)
logger.info(f"Getting batches with status {start_status}")
- batches = index_db.get_batches_by_status(start_status, 10000)
+ batches = index_db.get_batches_by_status(start_status, num_batches)
logger.info(f"Got {len(batches)} batch urls")
if len(batches) == 0:
return
diff --git a/mwmbl/indexer/update_urls.py b/mwmbl/indexer/update_urls.py
index da67351..b887993 100644
--- a/mwmbl/indexer/update_urls.py
+++ b/mwmbl/indexer/update_urls.py
@@ -35,7 +35,7 @@ def update_urls_continuously(data_path: str, new_item_queue: Queue):
def run(batch_cache: BatchCache, new_item_queue: Queue):
- process_batch.run(batch_cache, BatchStatus.LOCAL, BatchStatus.URLS_UPDATED, record_urls_in_database, new_item_queue)
+ process_batch.run(batch_cache, BatchStatus.LOCAL, BatchStatus.URLS_UPDATED, record_urls_in_database, new_item_queue, 100)
def record_urls_in_database(batches: Collection[HashedBatch], new_item_queue: Queue):