MCPcopy
hub / github.com/HKUDS/LightRAG / merge_source_ids

Function merge_source_ids

lightrag/utils.py:4462–4480  ·  view source on GitHub ↗

Merge two iterables of source IDs while preserving order and removing duplicates.

(
    existing_ids: Iterable[str] | None, new_ids: Iterable[str] | None
)

Source from the content-addressed store, hash-verified

4460
4461
4462def merge_source_ids(
4463 existing_ids: Iterable[str] | None, new_ids: Iterable[str] | None
4464) -> list[str]:
4465 """Merge two iterables of source IDs while preserving order and removing duplicates."""
4466
4467 merged: list[str] = []
4468 seen: set[str] = set()
4469
4470 for sequence in (existing_ids, new_ids):
4471 if not sequence:
4472 continue
4473 for source_id in sequence:
4474 if not source_id:
4475 continue
4476 if source_id not in seen:
4477 seen.add(source_id)
4478 merged.append(source_id)
4479
4480 return merged
4481
4482
4483def apply_source_ids_limit(

Callers 4

_merge_nodes_then_upsertFunction · 0.90
_merge_edges_then_upsertFunction · 0.90
_merge_edge_payloadsFunction · 0.85
_dedupe_legacy_edgesMethod · 0.85

Calls 3

setFunction · 0.85
addMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected