runtime-split-patch-a
parent
d206529162
commit
74609e481d
@ -0,0 +1,17 @@
|
||||
package at.procon.dip.runtime.condition;
|
||||
|
||||
import at.procon.dip.runtime.config.RuntimeMode;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Conditional(RuntimeModeCondition.class)
|
||||
public @interface ConditionalOnRuntimeMode {
|
||||
RuntimeMode value();
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package at.procon.dip.runtime.condition;
|
||||
|
||||
import at.procon.dip.runtime.config.RuntimeMode;
|
||||
import java.util.Map;
|
||||
import org.springframework.context.annotation.Condition;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
|
||||
public class RuntimeModeCondition implements Condition {
|
||||
|
||||
@Override
|
||||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||
Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnRuntimeMode.class.getName());
|
||||
if (attributes == null || !attributes.containsKey("value")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RuntimeMode expected = (RuntimeMode) attributes.get("value");
|
||||
String configured = context.getEnvironment().getProperty("dip.runtime.mode", RuntimeMode.LEGACY.name());
|
||||
RuntimeMode actual;
|
||||
try {
|
||||
actual = RuntimeMode.valueOf(configured.trim().toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
actual = RuntimeMode.LEGACY;
|
||||
}
|
||||
return actual == expected;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
package at.procon.dip.runtime.config;
|
||||
|
||||
public enum RuntimeMode {
|
||||
LEGACY,
|
||||
NEW
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package at.procon.dip.runtime.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "dip.runtime")
|
||||
@Data
|
||||
public class RuntimeModeProperties {
|
||||
/**
|
||||
* Patch A defaults to LEGACY so existing runtime behaviour is preserved until
|
||||
* NEW mode is explicitly enabled.
|
||||
*/
|
||||
private RuntimeMode mode = RuntimeMode.LEGACY;
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
package at.procon.dip.search.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "dip.search")
|
||||
@Data
|
||||
public class DipSearchProperties {
|
||||
|
||||
private Lexical lexical = new Lexical();
|
||||
private Semantic semantic = new Semantic();
|
||||
private Fusion fusion = new Fusion();
|
||||
private Chunking chunking = new Chunking();
|
||||
|
||||
@Data
|
||||
public static class Lexical {
|
||||
private double trigramSimilarityThreshold = 0.12;
|
||||
private int fulltextCandidateLimit = 120;
|
||||
private int trigramCandidateLimit = 120;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Semantic {
|
||||
private double similarityThreshold = 0.7;
|
||||
private int semanticCandidateLimit = 120;
|
||||
private String defaultModelKey;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Fusion {
|
||||
private double fulltextWeight = 0.35;
|
||||
private double trigramWeight = 0.20;
|
||||
private double semanticWeight = 0.45;
|
||||
private double recencyBoostWeight = 0.05;
|
||||
private int recencyHalfLifeDays = 30;
|
||||
private int debugTopHitsPerEngine = 10;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Chunking {
|
||||
private boolean enabled = true;
|
||||
private int targetChars = 1800;
|
||||
private int overlapChars = 200;
|
||||
private int maxChunksPerDocument = 12;
|
||||
private int startupLexicalBackfillLimit = 500;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package at.procon.ted.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Patch A scaffold for the legacy runtime configuration tree.
|
||||
*
|
||||
* The legacy runtime still uses {@link TedProcessorProperties} today. This class is
|
||||
* introduced so the old configuration can be moved gradually from `ted.*` to
|
||||
* `legacy.ted.*` without blocking the runtime split.
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "legacy.ted")
|
||||
public class LegacyTedProperties extends TedProcessorProperties {
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
dip:
|
||||
runtime:
|
||||
mode: LEGACY
|
||||
@ -0,0 +1,3 @@
|
||||
dip:
|
||||
runtime:
|
||||
mode: NEW
|
||||
Loading…
Reference in New Issue