增量更新骨架
增量更新骨架
changed = detect_changes(source, last_sync_ts)
for doc in changed:
old_ids = index.find_by_doc(doc.id)
new_chunks = split(parse(doc))
index.upsert(embed(new_chunks))
index.delete([i for i in old_ids if i not in {c.uid for c in new_chunks}])删除旧块与写入新块要在一个幂等任务里完成,避免中途失败留下半新半旧。