MCPcopy Create free account
hub / github.com/53AI/53AIHub / cleanupVectorDataAsync

Function cleanupVectorDataAsync

api/model/file.go:1222–1255  ·  view source on GitHub ↗

cleanupVectorDataAsync 异步清理向量数据

(eid int64, fileID int64, vectorIDs []string)

Source from the content-addressed store, hash-verified

1220
1221// cleanupVectorDataAsync 异步清理向量数据
1222func cleanupVectorDataAsync(eid int64, fileID int64, vectorIDs []string) {
1223 log.Printf("开始异步清理向量数据 - EID: %d, FileID: %d, 向量数量: %d", eid, fileID, len(vectorIDs))
1224
1225 // 使用defer确保错误也会被记录
1226 defer func() {
1227 if r := recover(); r != nil {
1228 log.Printf("向量数据清理过程中发生panic - EID: %d, FileID: %d, Error: %v", eid, fileID, r)
1229 }
1230 }()
1231
1232 if len(vectorIDs) == 0 {
1233 log.Printf("文件没有向量数据需要清理 - EID: %d, FileID: %d", eid, fileID)
1234 return
1235 }
1236
1237 log.Printf("开始清理 %d 个向量 - EID: %d, FileID: %d", len(vectorIDs), eid, fileID)
1238
1239 // 1. 从向量数据库中删除向量
1240 err := deleteVectorsFromDB(eid, fileID, vectorIDs)
1241 if err != nil {
1242 log.Printf("从向量数据库删除向量失败 - EID: %d, FileID: %d, Error: %v", eid, fileID, err)
1243 // 即使删除失败,也继续执行后续清理步骤
1244 } else {
1245 log.Printf("成功从向量数据库删除 %d 个向量 - EID: %d, FileID: %d", len(vectorIDs), eid, fileID)
1246 }
1247
1248 // 2. 记录清理操作日志
1249 err = recordVectorCleanupLog(eid, fileID, len(vectorIDs))
1250 if err != nil {
1251 log.Printf("记录向量清理日志失败 - EID: %d, FileID: %d, Error: %v", eid, fileID, err)
1252 }
1253
1254 log.Printf("向量数据清理完成 - EID: %d, FileID: %d, 清理向量数: %d", eid, fileID, len(vectorIDs))
1255}
1256
1257func GetChildrenByPathPrefix(eid int64, pathPrefix string) ([]File, error) {
1258 var files []File

Callers 2

cascadeDeleteFileDataFunction · 0.85
CleanupVectorDataForFileFunction · 0.85

Calls 3

deleteVectorsFromDBFunction · 0.85
recordVectorCleanupLogFunction · 0.85
PrintfMethod · 0.80

Tested by

no test coverage detected