Skip to content

Commit d1e15cb

Browse files
author
colorknight
committed
添加对milvus数据库的支持
1 parent b2e06f1 commit d1e15cb

File tree

20 files changed

+1353
-0
lines changed

20 files changed

+1353
-0
lines changed

moql-querier-milvus/pom.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<parent>
7+
<artifactId>moql-parent</artifactId>
8+
<groupId>org.datayoo.moql</groupId>
9+
<version>1.1.0</version>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>moql-querier-milvus</artifactId>
14+
15+
<name>moql-querier-milvus</name>
16+
17+
<properties>
18+
</properties>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>junit</groupId>
23+
<artifactId>junit</artifactId>
24+
<version>4.13.1</version>
25+
<scope>test</scope>
26+
</dependency>
27+
<dependency>
28+
<groupId>io.milvus</groupId>
29+
<artifactId>milvus-sdk-java</artifactId>
30+
<version>2.2.2</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.datayoo.moql</groupId>
34+
<artifactId>moql-querier</artifactId>
35+
<version>1.2.1</version>
36+
<scope>compile</scope>
37+
</dependency>
38+
</dependencies>
39+
40+
<build>
41+
</build>
42+
</project>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package org.datayoo.moql.querier.milvus;
2+
3+
import io.milvus.param.ConnectParam;
4+
import org.apache.commons.lang3.Validate;
5+
6+
import java.util.Properties;
7+
import java.util.concurrent.TimeUnit;
8+
9+
/**
10+
* @author tangtadin
11+
* @version 1.0
12+
* @description: TODO
13+
* @date 2023/2/23 12:40
14+
*/
15+
public abstract class ConnectionBuilderHelper {
16+
17+
public static final String PROP_PORT = "milvus.connection.port";
18+
public static final String PROP_URI = "milvus.connection.uri";
19+
public static final String PROP_IDLE_TIMEOUT = "milvus.connection.idleTimeout";
20+
21+
public static final String PROP_CONNECTION_TIMEOUT = "milvus.connection.connectionTimeout";
22+
23+
public static final String PROP_KEEPALIVE_TIMEOUT = "milvus.connection.keepaliveTimeout";
24+
25+
public static final String PROP_USER = "milvus.connection.user";
26+
27+
public static final String PROP_PASSWORD = "milvus.connection.password";
28+
29+
public static ConnectParam.Builder createConnectionBuilder(String host,
30+
Properties properties) {
31+
ConnectParam.Builder builder = ConnectParam.newBuilder();
32+
if (properties != null && properties.size() > 0) {
33+
String uri = properties.getProperty(PROP_URI);
34+
if (uri == null) {
35+
Validate.notEmpty(host, "host is empty!");
36+
builder.withHost(host);
37+
String port = properties.getProperty(PROP_PORT);
38+
if (port != null) {
39+
builder.withPort(Integer.valueOf(port));
40+
}
41+
} else {
42+
builder.withUri(uri);
43+
}
44+
fillProps(builder, properties);
45+
} else {
46+
Validate.notEmpty(host, "host is empty!");
47+
builder.withHost(host);
48+
}
49+
return builder;
50+
}
51+
52+
protected static void fillProps(ConnectParam.Builder builder,
53+
Properties properties) {
54+
String v = properties.getProperty(PROP_USER);
55+
if (v != null) {
56+
builder.withAuthorization(v, properties.getProperty(PROP_PASSWORD));
57+
}
58+
v = properties.getProperty(PROP_IDLE_TIMEOUT);
59+
if (v != null) {
60+
builder.withIdleTimeout(Long.valueOf(v), TimeUnit.SECONDS);
61+
}
62+
v = properties.getProperty(PROP_CONNECTION_TIMEOUT);
63+
if (v != null) {
64+
builder.withConnectTimeout(Long.valueOf(v), TimeUnit.SECONDS);
65+
}
66+
v = properties.getProperty(PROP_KEEPALIVE_TIMEOUT);
67+
if (v != null) {
68+
builder.withKeepAliveTimeout(Long.valueOf(v), TimeUnit.SECONDS);
69+
}
70+
}
71+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.datayoo.moql.querier.milvus;
19+
20+
import io.milvus.common.clientenum.ConsistencyLevelEnum;
21+
import org.datayoo.moql.EntityMap;
22+
import org.datayoo.moql.Operand;
23+
import org.datayoo.moql.operand.function.AbstractFunction;
24+
25+
import java.util.List;
26+
27+
/**
28+
* @author Tang Tadin
29+
*/
30+
public class ConsistencyLevel extends AbstractFunction {
31+
32+
public static final String FUNCTION_NAME = "consistencyLevel";
33+
34+
protected ConsistencyLevelEnum consistencyLevel;
35+
36+
public ConsistencyLevel(List<Operand> parameters) {
37+
super(FUNCTION_NAME, 1, parameters);
38+
String v = (String) parameters.get(0).operate((EntityMap) null);
39+
consistencyLevel = ConsistencyLevelEnum.valueOf(v.toUpperCase());
40+
}
41+
42+
/* (non-Javadoc)
43+
* @see org.moql.operand.function.AbstractFunction#innerOperate(org.moql.data.EntityMap)
44+
*/
45+
@Override
46+
protected Object innerOperate(EntityMap entityMap) {
47+
throw new UnsupportedOperationException();
48+
}
49+
50+
@Override
51+
protected Object innerOperate(Object[] entityArray) {
52+
throw new UnsupportedOperationException();
53+
}
54+
55+
public ConsistencyLevelEnum getConsistencyLevel() {
56+
return consistencyLevel;
57+
}
58+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.datayoo.moql.querier.milvus;
19+
20+
import org.datayoo.moql.EntityMap;
21+
import org.datayoo.moql.Operand;
22+
import org.datayoo.moql.operand.function.AbstractFunction;
23+
24+
import java.util.List;
25+
26+
/**
27+
* @author Tang Tadin
28+
*/
29+
public class Ef extends AbstractFunction {
30+
31+
public static final String FUNCTION_NAME = "ef";
32+
33+
protected Long ef;
34+
35+
public Ef(List<Operand> parameters) {
36+
super(FUNCTION_NAME, 1, parameters);
37+
ef = (Long) parameters.get(0).operate((EntityMap) null);
38+
}
39+
40+
/* (non-Javadoc)
41+
* @see org.moql.operand.function.AbstractFunction#innerOperate(org.moql.data.EntityMap)
42+
*/
43+
@Override
44+
protected Object innerOperate(EntityMap entityMap) {
45+
throw new UnsupportedOperationException();
46+
}
47+
48+
@Override
49+
protected Object innerOperate(Object[] entityArray) {
50+
throw new UnsupportedOperationException();
51+
}
52+
53+
public Long getEf() {
54+
return ef;
55+
}
56+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.datayoo.moql.querier.milvus;
19+
20+
import io.milvus.common.clientenum.ConsistencyLevelEnum;
21+
import org.datayoo.moql.EntityMap;
22+
import org.datayoo.moql.Operand;
23+
import org.datayoo.moql.operand.function.AbstractFunction;
24+
25+
import java.util.List;
26+
27+
/**
28+
* @author Tang Tadin
29+
*/
30+
public class GracefulTime extends AbstractFunction {
31+
32+
public static final String FUNCTION_NAME = "gracefulTime";
33+
34+
protected Long gracefulTime;
35+
36+
public GracefulTime(List<Operand> parameters) {
37+
super(FUNCTION_NAME, 1, parameters);
38+
gracefulTime = (Long) parameters.get(0).operate((EntityMap) null);
39+
}
40+
41+
/* (non-Javadoc)
42+
* @see org.moql.operand.function.AbstractFunction#innerOperate(org.moql.data.EntityMap)
43+
*/
44+
@Override
45+
protected Object innerOperate(EntityMap entityMap) {
46+
throw new UnsupportedOperationException();
47+
}
48+
49+
@Override
50+
protected Object innerOperate(Object[] entityArray) {
51+
throw new UnsupportedOperationException();
52+
}
53+
54+
public Long getGracefulTime() {
55+
return gracefulTime;
56+
}
57+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
* <p>
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
* <p>
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.datayoo.moql.querier.milvus;
19+
20+
import org.datayoo.moql.EntityMap;
21+
import org.datayoo.moql.Operand;
22+
import org.datayoo.moql.operand.function.AbstractFunction;
23+
24+
import java.util.List;
25+
26+
/**
27+
* @author Tang Tadin
28+
*/
29+
public class GuaranteeTimestamp extends AbstractFunction {
30+
31+
public static final String FUNCTION_NAME = "guaranteeTimestamp";
32+
33+
protected Long guaranteeTimestamp;
34+
35+
public GuaranteeTimestamp(List<Operand> parameters) {
36+
super(FUNCTION_NAME, 1, parameters);
37+
guaranteeTimestamp = (Long) parameters.get(0).operate((EntityMap) null);
38+
}
39+
40+
/* (non-Javadoc)
41+
* @see org.moql.operand.function.AbstractFunction#innerOperate(org.moql.data.EntityMap)
42+
*/
43+
@Override
44+
protected Object innerOperate(EntityMap entityMap) {
45+
throw new UnsupportedOperationException();
46+
}
47+
48+
@Override
49+
protected Object innerOperate(Object[] entityArray) {
50+
throw new UnsupportedOperationException();
51+
}
52+
53+
public Long getGuaranteeTimestamp() {
54+
return guaranteeTimestamp;
55+
}
56+
}

0 commit comments

Comments
 (0)