From e9e0c1f3abf1bbf83ebdb933d318caa2a45c15b0 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期六, 30 三月 2024 17:14:11 +0800
Subject: [PATCH] 调整代码结构, 精简比对过程

---
 cache/shardmap/shardmap.go |   61 +++++++-----------------------
 1 files changed, 15 insertions(+), 46 deletions(-)

diff --git a/cache/shardmap/shardmap.go b/cache/shardmap/shardmap.go
index e53aa38..255f0c4 100644
--- a/cache/shardmap/shardmap.go
+++ b/cache/shardmap/shardmap.go
@@ -4,6 +4,7 @@
 
 import (
 	"basic.com/pubsub/protomsg.git"
+	"sdkCompare/db"
 	"sync"
 	//"encoding/json"
 	//"fmt"
@@ -89,7 +90,7 @@
 	value interface{}
 }
 
-func (s *ShardMap) Walk(wf wfOp, sourceFea []byte, baseScore float32, isWebComp bool, target string) (targets []*protomsg.SdkCompareEach) {
+func (s *ShardMap) Walk(wf wfOp, sourceFea []byte, baseScore float32) (targets []*protomsg.SdkCompareEach) {
 	var wg sync.WaitGroup
 	var lock sync.Mutex
 	for _, si := range s.shards {
@@ -101,57 +102,25 @@
 
 		wg.Add(1)
 
-		go func(st *shardItem, fw wfOp, sf []byte, baseSec float32, isWeb bool) {
+		go func(st *shardItem, fw wfOp, sf []byte, baseSec float32) {
 			defer wg.Done()
 			for _, feature := range st.data {
-				if eif, ok := feature.(*protomsg.Esinfo); ok {
-					if !isWeb { //涓嶄細姣斿鎶撴媿搴�,鍙瘮瀵规湁鏁堢殑浜�
-						if eif.Enable == 1 {
-							score := float32(0)
-							if target == "car" {
-								if eif.CarNo != "" {
-									score = strComp(sf, eif.CarNo)
-								} else {
-									continue
-								}
-							} else {
-								score = fw(sf, eif.FaceFeature)
-							}
-							if score > 0 && score >= baseScore {
-								lock.Lock()
-								targets = append(targets, &protomsg.SdkCompareEach{
-									Id:           eif.Id,
-									CompareScore: score,
-									Tableid:      eif.Tableid,
-								})
-								lock.Unlock()
-							}
-						}
-					} else { //鏉ユ簮鏄痺eb锛屼細姣斿鎶撴媿搴擄紝涓嶇鏄惁鏈夋晥閮介渶瑕佹瘮瀵�
-						score := float32(0)
-						if target == "car" {
-							if eif.CarNo != "" {
-								score = strComp(sf, eif.CarNo)
-							} else {
-								continue
-							}
-						} else {
-							score = fw(sf, eif.FaceFeature)
-						}
-						if score > 0 && score >= baseScore {
-							lock.Lock()
-							targets = append(targets, &protomsg.SdkCompareEach{
-								Id:           eif.Id,
-								CompareScore: score,
-								Tableid:      eif.Tableid,
-							})
-							lock.Unlock()
-						}
+				if eif, ok := feature.(*db.FeatureCacheBase); ok {
+					score := float32(0)
+					score = fw(sf, eif.FaceFeature)
+					if score > 0 && score >= baseScore {
+						lock.Lock()
+						targets = append(targets, &protomsg.SdkCompareEach{
+							Id:           eif.Id,
+							CompareScore: score,
+							Tableid:      eif.TableId,
+						})
+						lock.Unlock()
 					}
 				}
 			}
 
-		}(&tempsi, wf, sourceFea, baseScore, isWebComp)
+		}(&tempsi, wf, sourceFea, baseScore)
 	}
 
 	wg.Wait()

--
Gitblit v1.8.0