feat(knowledge): implement AminusB function for multiset comparison of knowledge bases

- Added AminusB method to the knowledgeRepository, which returns IDs of knowledge in A that have no counterpart in B, comparing by file_hash as a multiset.
- This implementation addresses issues with handling duplicate entries and NULL file_hash values, ensuring accurate synchronization between knowledge bases.
- Updated the KnowledgeRepository interface to reflect the new functionality and improved documentation for clarity.
This commit is contained in:
wizardchen
2026-07-21 17:00:20 +08:00
committed by lyingbug
parent 516ef01cf2
commit 0d545c8c6a
2 changed files with 75 additions and 12 deletions
+3 -1
View File
@@ -232,7 +232,9 @@ type KnowledgeRepository interface {
kbID string,
params *types.KnowledgeCheckParams,
) (bool, *types.Knowledge, error)
// AminusB returns the difference set of A and B.
// AminusB returns the IDs of knowledge in A that have no counterpart in B,
// comparing file_hash as a multiset (so duplicate-count differences and
// NULL/empty hashes are handled correctly, letting a clone converge).
AminusB(ctx context.Context, Atenant uint64, A string, Btenant uint64, B string) ([]string, error)
UpdateKnowledgeColumn(ctx context.Context, id string, column string, value interface{}) error
// UpdateKnowledgeColumns updates multiple columns of a knowledge row in a single