fix(impression): correct impression update behavior

This commit is contained in:
2026-05-23 23:22:15 +08:00
parent 047d1b56fe
commit 26ef5d875d

View File

@@ -33,15 +33,19 @@ class Entity @JvmOverloads constructor(
): IndexableData = impressionLock.withLock {
if (newImpression == null) {
impressions.computeIfAbsent(impression) { IndexableData(confidence) }
.also { it.confidence = confidence }
.also {
it.confidence = confidence
if (it.confidence >= 0.9) {
featureLock.withLock { features[impression] = it }
}
}
} else {
impressions.remove(impression)
IndexableData(confidence).also {
impressions[newImpression] = it
}
}.also {
if (it.confidence >= 0.9) {
featureLock.withLock { features[impression] = it }
featureLock.withLock { features[newImpression] = it }
}
}
}
}