feat(publish): 实体键唯一索引,保证一个实体一行
This commit is contained in:
@ -93,9 +93,16 @@ func TestDedupNearDuplicate(t *testing.T) {
|
||||
t.Fatalf("汉明距离 1 的近重复应被命中")
|
||||
}
|
||||
|
||||
// 全 0 向量:与全 1 向量汉明距离 = 64,远超阈值,不应命中。
|
||||
_, found2, _ := repo.FindNearDuplicateImage(ctx, tables, phash.ToVectorBits(0), phash.DefaultThreshold)
|
||||
if found2 {
|
||||
t.Fatalf("汉明距离 64 的图不应被误判为近重复")
|
||||
// 全 1 向量(与库中那条距离 0)的取反不是合法探针(会有空串问题),
|
||||
// 这里改用与库中那条完全相同的全 1 探针(非空、合法)并先断言查询本身不报错。
|
||||
probeSame, foundSame, errSame := repo.FindNearDuplicateImage(ctx, tables, phash.ToVectorBits(^uint64(0)), phash.DefaultThreshold)
|
||||
if errSame != nil {
|
||||
t.Fatalf("去重查询不应报错: %v", errSame)
|
||||
}
|
||||
if !foundSame {
|
||||
t.Fatalf("与库中那条完全相同的 phash 应命中")
|
||||
}
|
||||
if probeSame == 0 {
|
||||
t.Fatalf("命中的行 id 不应为 0")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user