Skip to content

Commit 55064ee

Browse files
committed
新增支持 AI 向量数据库 Milvus
1 parent f3dc785 commit 55064ee

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java

+30-7
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public abstract class AbstractSQLConfig<T extends Object> implements SQLConfig<T
195195
DATABASE_LIST.add(DATABASE_HIVE);
196196
DATABASE_LIST.add(DATABASE_PRESTO);
197197
DATABASE_LIST.add(DATABASE_TRINO);
198+
DATABASE_LIST.add(DATABASE_MILVUS);
198199
DATABASE_LIST.add(DATABASE_INFLUXDB);
199200
DATABASE_LIST.add(DATABASE_TDENGINE);
200201
DATABASE_LIST.add(DATABASE_REDIS);
@@ -1191,6 +1192,14 @@ public static boolean isPresto(String db) {
11911192
return DATABASE_PRESTO.equals(db);
11921193
}
11931194

1195+
@Override
1196+
public boolean isTrino() {
1197+
return isTrino(getSQLDatabase());
1198+
}
1199+
public static boolean isTrino(String db) {
1200+
return DATABASE_TRINO.equals(db);
1201+
}
1202+
11941203
@Override
11951204
public boolean isSnowflake() {
11961205
return isSnowflake(getSQLDatabase());
@@ -1216,11 +1225,11 @@ public static boolean isCassandra(String db) {
12161225
}
12171226

12181227
@Override
1219-
public boolean isTrino() {
1220-
return isTrino(getSQLDatabase());
1228+
public boolean isMilvus() {
1229+
return isMilvus(getSQLDatabase());
12211230
}
1222-
public static boolean isTrino(String db) {
1223-
return DATABASE_TRINO.equals(db);
1231+
public static boolean isMilvus(String db) {
1232+
return DATABASE_MILVUS.equals(db);
12241233
}
12251234

12261235
@Override
@@ -1268,15 +1277,15 @@ public boolean isMQ() {
12681277
return isMQ(getSQLDatabase());
12691278
}
12701279
public static boolean isMQ(String db) {
1271-
return isKafka(db);
1280+
return DATABASE_MQ.equals(db) || isKafka(db);
12721281
}
12731282

12741283
@Override
12751284
public String getQuote() {
12761285
if(isElasticsearch()) {
12771286
return "";
12781287
}
1279-
return isMySQL() || isMariaDB() || isTiDB() || isClickHouse() || isTDengine() ? "`" : "\"";
1288+
return isMySQL() || isMariaDB() || isTiDB() || isClickHouse() || isTDengine() || isMilvus() ? "`" : "\"";
12801289
}
12811290

12821291
public String quote(String s) {
@@ -1290,6 +1299,7 @@ public String getSchema() {
12901299
}
12911300

12921301
@NotNull
1302+
@Override
12931303
public String getSQLSchema() {
12941304
String table = getTable();
12951305
//强制,避免因为全局默认的 @schema 自动填充进来,导致这几个类的 schema 为 sys 等其它值
@@ -2596,9 +2606,22 @@ public static int getOffset(int page, int count) {
25962606
*/
25972607
@JSONField(serialize = false)
25982608
public String getLimitString() {
2599-
if (count <= 0 || RequestMethod.isHeadMethod(getMethod(), true)) {
2609+
int count = getCount();
2610+
2611+
if (isMilvus()) {
2612+
if (count == 0) {
2613+
Parser<T> parser = getParser();
2614+
count = parser == null ? AbstractParser.MAX_QUERY_COUNT : parser.getMaxQueryCount();
2615+
}
2616+
2617+
int offset = getOffset(getPage(), count);
2618+
return " LIMIT " + offset + ", " + count; // 目前 moql-transx 的限制
2619+
}
2620+
2621+
if (count <= 0 || RequestMethod.isHeadMethod(getMethod(), true)) { // TODO HEAD 真的不需要 LIMIT ?
26002622
return "";
26012623
}
2624+
26022625
return getLimitString(
26032626
getPage()
26042627
, getCount()

APIJSONORM/src/main/java/apijson/orm/SQLConfig.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public interface SQLConfig<T extends Object> {
3434
String DATABASE_SNOWFLAKE = "SNOWFLAKE"; // https://www.snowflake.com
3535
String DATABASE_DATABRICKS = "DATABRICKS"; // https://www.databricks.com
3636
String DATABASE_CASSANDRA = "CASSANDRA"; // https://cassandra.apache.org
37+
String DATABASE_MILVUS = "MILVUS"; // https://milvus.io
3738
String DATABASE_INFLUXDB = "INFLUXDB"; // https://www.influxdata.com/products/influxdb-overview
3839
String DATABASE_TDENGINE = "TDENGINE"; // https://tdengine.com
3940
String DATABASE_REDIS = "REDIS"; // https://redisql.com
@@ -79,10 +80,11 @@ public interface SQLConfig<T extends Object> {
7980
boolean isClickHouse();
8081
boolean isHive();
8182
boolean isPresto();
83+
boolean isTrino();
8284
boolean isSnowflake();
8385
boolean isDatabricks();
8486
boolean isCassandra();
85-
boolean isTrino();
87+
boolean isMilvus();
8688
boolean isInfluxDB();
8789
boolean isTDengine();
8890
boolean isRedis();
@@ -219,6 +221,7 @@ default int[] getDBVersionNums() {
219221
String getDatabase();
220222
SQLConfig setDatabase(String database);
221223

224+
String getSQLSchema();
222225
String getSchema();
223226
SQLConfig setSchema(String schema);
224227

0 commit comments

Comments
 (0)