2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-02-08 05:58:45 +00:00

remove poor algorithm

This commit is contained in:
2026-01-29 23:07:34 +00:00
parent 1b7798e2fc
commit 5152802c6b

View File

@@ -540,44 +540,6 @@ class LoadingSurvex:
return topo_sorted_list return topo_sorted_list
def get_generational_chunks(sorted_blocks):
"""
Splits a topologically sorted list into chunks where no child
exists in the same chunk as its parent.
"""
chunks = []
# Track which IDs are already "saved" (in a previous chunk)
saved_ids = set()
# current_batch will hold blocks for the current "generation"
current_batch = []
for block in sorted_blocks:
parent_id = getattr(block.parent, '_blockid', block.parent)
# If the parent is not yet 'saved', this block MUST
# go into a future batch.
if parent_id and parent_id not in saved_ids:
# Finish the current chunk and start a new one
if current_batch:
chunks.append(current_batch)
# Mark everything in the finished batch as 'saved'
saved_ids.update(b._blockid for b in current_batch)
current_batch = []
current_batch.append(block)
# Safety: Even if there are no dependencies, respect the BATCH_SIZE
if len(current_batch) >= BATCH_SIZE:
chunks.append(current_batch)
saved_ids.update(b._blockid for b in current_batch)
current_batch = []
# Add the final trailing batch
if current_batch:
chunks.append(current_batch)
return chunks
def get_generational_chunks_optimized(blocks): def get_generational_chunks_optimized(blocks):
""" """
Splits a topologically sorted list into chunks where no child Splits a topologically sorted list into chunks where no child