[fix][chat] Fix the issue with the order of parallel execution in the map. (#1976)

This commit is contained in:
lexluo09
2024-12-25 20:52:52 +08:00
committed by GitHub
parent 6738aba19e
commit c483bb891a

View File

@@ -27,7 +27,7 @@ public abstract class BaseMatchStrategy<T extends MapResult> implements MatchStr
@Override @Override
public Map<MatchText, List<T>> match(ChatQueryContext chatQueryContext, List<S2Term> terms, public Map<MatchText, List<T>> match(ChatQueryContext chatQueryContext, List<S2Term> terms,
Set<Long> detectDataSetIds) { Set<Long> detectDataSetIds) {
String text = chatQueryContext.getRequest().getQueryText(); String text = chatQueryContext.getRequest().getQueryText();
if (Objects.isNull(terms) || StringUtils.isEmpty(text)) { if (Objects.isNull(terms) || StringUtils.isEmpty(text)) {
return null; return null;
@@ -43,7 +43,7 @@ public abstract class BaseMatchStrategy<T extends MapResult> implements MatchStr
} }
public List<T> detect(ChatQueryContext chatQueryContext, List<S2Term> terms, public List<T> detect(ChatQueryContext chatQueryContext, List<S2Term> terms,
Set<Long> detectDataSetIds) { Set<Long> detectDataSetIds) {
throw new RuntimeException("Not implemented"); throw new RuntimeException("Not implemented");
} }
@@ -73,11 +73,15 @@ public abstract class BaseMatchStrategy<T extends MapResult> implements MatchStr
protected void executeTasks(List<Callable<Void>> tasks) { protected void executeTasks(List<Callable<Void>> tasks) {
try { try {
threadPoolConfig.getMapExecutor().invokeAll(tasks); threadPoolConfig.getMapExecutor().invokeAll(tasks);
} catch (InterruptedException e) { for (Callable<Void> future : tasks) {
future.call();
}
} catch (Exception e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
throw new RuntimeException("Task execution interrupted", e); throw new RuntimeException("Task execution interrupted", e);
} }
} }
public double getThreshold(Double threshold, Double minThreshold, MapModeEnum mapModeEnum) { public double getThreshold(Double threshold, Double minThreshold, MapModeEnum mapModeEnum) {
if (MapModeEnum.STRICT.equals(mapModeEnum)) { if (MapModeEnum.STRICT.equals(mapModeEnum)) {
return 1.0d; return 1.0d;