release branch 0.24.2

This commit is contained in:
houbb
2025-02-02 16:04:31 +08:00
parent 027898530b
commit b7757e6f3f
7 changed files with 65 additions and 45 deletions

View File

@@ -398,4 +398,11 @@
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|:---|:-----|------------|:------------------|:---------------|
| 1 | F | 删除时添加同步锁优化 | 2025-2-2 15:30:26 | 涉及到接口调整 PR-100 |
| 1 | F | 删除时添加同步锁优化 | 2025-2-2 15:30:26 | 涉及到接口调整 PR-100 |
# release_0.24.2
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|:---|:-----|---------------------|:------------------|:-------------------|
| 1 | O | findFirst 真实实现,性能优化 | 2025-2-2 15:30:26 | PR-99 |
| 2 | O | 黑白名单遍历统一优化,性能优化 | 2025-2-2 15:30:26 | PR-99 涉及到原始结果返回值调整 |

View File

@@ -58,9 +58,6 @@ v0.24.0 开始内置支持对敏感词的分类细化,不过工作量比较大
[CHANGE_LOG.md](https://github.com/houbb/sensitive-word/blob/master/CHANGE_LOG.md)
### V0.23.0
- 结果条件拓展支持 wordTags 和 chains
### V0.24.0
@@ -70,6 +67,12 @@ v0.24.0 开始内置支持对敏感词的分类细化,不过工作量比较大
- 删除时统一添加同步锁 sync
### V0.24.2
- 统一黑白名单为一次遍历,性能优化
- 实现真实的 findFirst性能优化
## 更多资料
### 敏感词控台
@@ -108,7 +111,7 @@ v0.24.0 开始内置支持对敏感词的分类细化,不过工作量比较大
<dependency>
<groupId>com.github.houbb</groupId>
<artifactId>sensitive-word</artifactId>
<version>0.24.1</version>
<version>0.24.2</version>
</dependency>
```

View File

@@ -6,7 +6,7 @@
<groupId>com.github.houbb</groupId>
<artifactId>sensitive-word</artifactId>
<version>0.24.1</version>
<version>0.24.2</version>
<properties>
<!--============================== All Plugins START ==============================-->

View File

@@ -10,7 +10,7 @@ ECHO "============================= RELEASE START..."
:: 版本号信息(需要手动指定)
:::: 旧版本名称
SET version=0.24.1
SET version=0.24.2
:::: 新版本名称
SET newVersion=0.25.0
:::: 组织名称

View File

@@ -31,6 +31,7 @@ public interface IWordCheck {
* @param context 执行上下文
* @return 敏感信息对应的长度
* @since 0.0.5
* @since 0.24.2 为了黑白名单统一,调整了对应的返回值
*/
WordCheckResult sensitiveCheck(final int beginIndex,
final InnerSensitiveWordContext context);

View File

@@ -1,32 +1,48 @@
package com.github.houbb.sensitive.word.support.result;
/**
* 说明:统一让黑白名单一次遍历,性能优化
*
* @since 0.24.2
*/
public class WordLengthResult {
private int wordAllowLen;
private int wordDenyLen;
/**
* 白名单长度
*/
private int wordAllowLen;
/**
* 黑名单长度
*/
private int wordDenyLen;
private WordLengthResult(){}
public static WordLengthResult newInstance(){
public static WordLengthResult newInstance() {
return new WordLengthResult();
}
public int wordAllowLen(){
public int wordAllowLen() {
return this.wordAllowLen;
}
public WordLengthResult wordAllowLen(int wordAllowLen){
this.wordAllowLen=wordAllowLen;
public WordLengthResult wordAllowLen(int wordAllowLen) {
this.wordAllowLen = wordAllowLen;
return this;
}
public int wordDenyLen(){
public int wordDenyLen() {
return this.wordDenyLen;
}
public WordLengthResult wordDenyLen(int wordDenyLen){
this.wordDenyLen=wordDenyLen;
public WordLengthResult wordDenyLen(int wordDenyLen) {
this.wordDenyLen = wordDenyLen;
return this;
}
@Override
public String toString() {
return "WordLengthResult{" +
"wordAllowLen=" + wordAllowLen +
", wordDenyLen=" + wordDenyLen +
'}';
}
}

View File

@@ -72,44 +72,37 @@ public class BenchmarkBasicTest {
}
/**
* * 黑白名单一次遍历 优化前300*他们在地铁口交易查10000次26183
* * 黑白名单一次遍历 优化后300*他们在地铁口交易查10000次15705
*
* 黑白名单一次遍历 优化前300*他们在地铁口交易查10000次26183
* 黑白名单一次遍历 优化后300*他们在地铁口交易查10000次15705
* @since 0.24.2
*/
@Test
public void costTimeOneTraceTest() {
StringBuilder sb=new StringBuilder();
for(int i=0;i<300;i++){
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 300; i++) {
sb.append("他们在地铁口交易").append(i);
}
String text = sb.toString();
// 1W 次
long start = System.currentTimeMillis();
SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance()
.wordDeny(new IWordDeny() {
@Override
public List<String> deny() {
return Collections.singletonList("口交");
}
})
.wordAllow(new IWordAllow() {
@Override
public List<String> allow() {
return Collections.singletonList("地铁口交易");
}
})
.enableWordCheck(true)
.enableNumCheck(false)
.enableUrlCheck(false)
.enableEmailCheck(false)
.init();
SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance().wordDeny(new IWordDeny() {
@Override
public List<String> deny() {
return Collections.singletonList("口交");
}
}).wordAllow(new IWordAllow() {
@Override
public List<String> allow() {
return Collections.singletonList("地铁口交易");
}
}).enableWordCheck(true).enableNumCheck(false).enableUrlCheck(false).enableEmailCheck(false).init();
for(int i = 0; i < 10000; i++) {
for (int i = 0; i < 10000; i++) {
sensitiveWordBs.findAll(text);
}
long end = System.currentTimeMillis();
System.out.println("------------------ COST: " + (end-start));
System.out.println("------------------ COST: " + (end - start));
}
/**