|
|
@@ -0,0 +1,30 @@
|
|
|
+package com.tzld.videoVector.config.mybatis;
|
|
|
+
|
|
|
+import org.apache.ibatis.executor.statement.StatementHandler;
|
|
|
+import org.apache.ibatis.plugin.Interceptor;
|
|
|
+import org.apache.ibatis.plugin.Intercepts;
|
|
|
+import org.apache.ibatis.plugin.Invocation;
|
|
|
+import org.apache.ibatis.plugin.Signature;
|
|
|
+
|
|
|
+import java.sql.Connection;
|
|
|
+import java.sql.Statement;
|
|
|
+
|
|
|
+@Intercepts({
|
|
|
+ @Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})
|
|
|
+})
|
|
|
+public class HnswEfSearchInterceptor implements Interceptor {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object intercept(Invocation invocation) throws Throwable {
|
|
|
+ Connection connection = (Connection) invocation.getArgs()[0];
|
|
|
+ try (Statement stmt = connection.createStatement()) {
|
|
|
+ stmt.execute("SET hnsw.ef_search = 200");
|
|
|
+ }
|
|
|
+ return invocation.proceed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object plugin(Object target) {
|
|
|
+ return org.apache.ibatis.plugin.Plugin.wrap(target, this);
|
|
|
+ }
|
|
|
+}
|