Skip to content

Commit ffd3aa7

Browse files
yeyinglanglikun
authored andcommitted
Third Step: Remove Lombok from milvus sdk-core
Signed-off-by: kun <kunyinglang@163.com>
1 parent 6ca429a commit ffd3aa7

98 files changed

Lines changed: 3849 additions & 892 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

sdk-core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
<groupId>org.projectlombok</groupId>
155155
<artifactId>lombok</artifactId>
156156
<version>${lombok.version}</version>
157-
<scope>provided</scope>
157+
<scope>test</scope>
158158
</dependency>
159159
<dependency>
160160
<groupId>com.squareup.okhttp3</groupId>
@@ -177,4 +177,4 @@
177177
<scope>provided</scope>
178178
</dependency>
179179
</dependencies>
180-
</project>
180+
</project>

sdk-core/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java

Lines changed: 71 additions & 39 deletions
Large diffs are not rendered by default.

sdk-core/src/main/java/io/milvus/client/MilvusMultiServiceClient.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import io.milvus.param.partition.*;
4242
import io.milvus.param.resourcegroup.*;
4343
import io.milvus.param.role.*;
44-
import lombok.NonNull;
4544
import org.apache.commons.collections4.CollectionUtils;
4645

4746
import java.util.List;
@@ -56,7 +55,10 @@ public class MilvusMultiServiceClient implements MilvusClient {
5655
* Sets connect param for multi milvus clusters.
5756
* @param multiConnectParam multi server connect param
5857
*/
59-
public MilvusMultiServiceClient(@NonNull MultiConnectParam multiConnectParam) {
58+
public MilvusMultiServiceClient(MultiConnectParam multiConnectParam) {
59+
if (multiConnectParam == null) {
60+
throw new IllegalArgumentException("multiConnectParam must not be null");
61+
}
6062

6163
List<ServerSetting> serverSettings = multiConnectParam.getHosts().stream()
6264
.map(host -> {
@@ -723,4 +725,3 @@ private <T> R<T> handleResponse(List<R<T>> response) {
723725
return R.failed(R.Status.Unknown, "Response is empty.");
724726
}
725727
}
726-

sdk-core/src/main/java/io/milvus/client/MilvusServiceClient.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
2626
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext;
2727
import io.grpc.stub.MetadataUtils;
28+
import io.milvus.common.utils.ExceptionUtils;
2829
import io.milvus.exception.MilvusException;
2930
import io.milvus.exception.ServerException;
3031
import io.milvus.grpc.*;
@@ -49,7 +50,6 @@
4950
import io.milvus.v2.utils.ClientUtils;
5051
import io.grpc.ProxiedSocketAddress;
5152
import io.grpc.ProxyDetector;
52-
import lombok.NonNull;
5353
import org.apache.commons.lang3.StringUtils;
5454

5555
import java.io.File;
@@ -75,7 +75,8 @@ public class MilvusServiceClient extends AbstractMilvusGrpcClient {
7575
private RetryParam retryParam = RetryParam.newBuilder().build();
7676
private String currentDatabaseName;
7777

78-
public MilvusServiceClient(@NonNull ConnectParam connectParam) {
78+
public MilvusServiceClient(ConnectParam connectParam) {
79+
ExceptionUtils.checkNotNull(connectParam, connectParam.getClass().getSimpleName());
7980
this.rpcDeadlineMs = connectParam.getRpcDeadlineMs();
8081

8182
Metadata metadata = new Metadata();
@@ -417,7 +418,8 @@ private <T> R<T> retry(Callable<R<T>> callable) {
417418
* 3. sdk language type and version
418419
* 4. the client's local time
419420
*/
420-
private R<ConnectResponse> connect(@NonNull ConnectParam connectParam) {
421+
private R<ConnectResponse> connect(ConnectParam connectParam) {
422+
ExceptionUtils.checkNotNull(connectParam, connectParam.getClass().getSimpleName());
421423
ClientInfo info = ClientInfo.newBuilder()
422424
.setSdkType("Java")
423425
.setSdkVersion(getSDKVersion())
@@ -620,12 +622,14 @@ public R<DescribeIndexResponse> describeIndex(DescribeIndexParam requestParam) {
620622
}
621623

622624
@Override
623-
public R<GetIndexStateResponse> getIndexState(@NonNull GetIndexStateParam requestParam) {
625+
public R<GetIndexStateResponse> getIndexState(GetIndexStateParam requestParam) {
626+
ExceptionUtils.checkNotNull(requestParam, requestParam.getClass().getSimpleName());
624627
return retry(()-> super.getIndexState(requestParam));
625628
}
626629

627630
@Override
628-
public R<GetIndexBuildProgressResponse> getIndexBuildProgress(@NonNull GetIndexBuildProgressParam requestParam) {
631+
public R<GetIndexBuildProgressResponse> getIndexBuildProgress(GetIndexBuildProgressParam requestParam) {
632+
ExceptionUtils.checkNotNull(requestParam, requestParam.getClass().getSimpleName());
629633
return retry(()-> super.getIndexBuildProgress(requestParam));
630634
}
631635

sdk-core/src/main/java/io/milvus/common/clientenum/ConsistencyLevelEnum.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,32 @@
1919

2020
package io.milvus.common.clientenum;
2121

22-
import lombok.Getter;
23-
2422
public enum ConsistencyLevelEnum {
2523

2624
STRONG("Strong", 0),
2725
SESSION("Session", 1),
2826
BOUNDED("Bounded", 2),
29-
EVENTUALLY("Eventually",3),
27+
EVENTUALLY("Eventually", 3),
3028
;
3129

32-
@Getter
3330
private final String name;
34-
35-
@Getter
3631
private final int code;
3732

38-
ConsistencyLevelEnum(String name, int code){
33+
ConsistencyLevelEnum(String name, int code) {
3934
this.name = name;
4035
this.code = code;
4136
}
4237

43-
private static final ConsistencyLevelEnum[] CONSISTENCY_LEVELS = new ConsistencyLevelEnum[values().length];
38+
// Getter methods to replace @Getter annotations
39+
public String getName() {
40+
return name;
41+
}
42+
43+
public int getCode() {
44+
return code;
45+
}
46+
47+
private static final ConsistencyLevelEnum[] CONSISTENCY_LEVELS = values();
4448

4549
public static ConsistencyLevelEnum getNameByCode(int code) {
4650
if (code >= 0 && code < CONSISTENCY_LEVELS.length) {

sdk-core/src/main/java/io/milvus/common/clientenum/FunctionType.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,27 @@
1919

2020
package io.milvus.common.clientenum;
2121

22-
import lombok.Getter;
23-
2422
public enum FunctionType {
2523
UNKNOWN("Unknown", 0), // in milvus-proto, the name is "Unknown"
26-
BM25(1),
24+
BM25("BM25", 1), // Added missing name parameter
2725
TEXTEMBEDDING("TextEmbedding", 2), // in milvus-proto, the name is "TextEmbedding"
28-
RERANK(3),
29-
;
26+
RERANK("RERANK", 3); // Added missing name parameter
3027

3128
private final String name;
32-
33-
@Getter
3429
private final int code;
3530

36-
FunctionType(){
37-
this.name = this.name();
38-
this.code = this.ordinal();
31+
FunctionType(String name, int code){
32+
this.name = name;
33+
this.code = code;
3934
}
4035

41-
FunctionType(int code){
42-
this.name = this.name();
43-
this.code = code;
36+
// Getter method to replace @Getter annotation
37+
public int getCode() {
38+
return code;
4439
}
4540

46-
FunctionType(String name, int code){
47-
this.name = name;
48-
this.code = code;
41+
public String getName() {
42+
return name;
4943
}
5044

5145
public static FunctionType fromName(String name) {

sdk-core/src/main/java/io/milvus/common/utils/ExceptionUtils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,10 @@ public static void handleResponseStatus(R<?> r) {
3737
throw new RuntimeException(r.getMessage());
3838
}
3939
}
40+
41+
public static void checkNotNull(Object obj, String msg) {
42+
if (obj == null) {
43+
throw new IllegalArgumentException(msg + "cannot be null");
44+
}
45+
}
4046
}

sdk-core/src/main/java/io/milvus/common/utils/URLParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
package io.milvus.utils;
20+
package io.milvus.common.utils;
2121

2222
import java.net.URI;
2323
import java.net.URISyntaxException;

sdk-core/src/main/java/io/milvus/connection/ClusterFactory.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import io.milvus.exception.ParamException;
2323
import io.milvus.param.QueryNodeSingleSearch;
2424
import io.milvus.param.ServerAddress;
25-
import lombok.NonNull;
2625
import org.apache.commons.collections4.CollectionUtils;
2726

2827
import java.util.List;
@@ -41,7 +40,10 @@ public class ClusterFactory {
4140

4241
private ServerMonitor monitor;
4342

44-
private ClusterFactory(@NonNull Builder builder) {
43+
private ClusterFactory(Builder builder) {
44+
if (builder == null) {
45+
throw new NullPointerException("builder cannot be null");
46+
}
4547
this.serverSettings = builder.serverSettings;
4648
this.master = this.getDefaultServer();
4749
this.availableServerSettings = builder.serverSettings;
@@ -114,7 +116,10 @@ private Builder() {
114116
* @param serverSettings ServerSetting
115117
* @return <code>Builder</code>
116118
*/
117-
public Builder withServerSetting(@NonNull List<ServerSetting> serverSettings) {
119+
public Builder withServerSetting(List<ServerSetting> serverSettings) {
120+
if (serverSettings == null) {
121+
throw new NullPointerException("serverSettings cannot be null");
122+
}
118123
this.serverSettings = serverSettings;
119124
return this;
120125
}

sdk-core/src/main/java/io/milvus/connection/ServerSetting.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import io.milvus.param.ConnectParam;
2525
import io.milvus.param.ParamUtils;
2626
import io.milvus.param.ServerAddress;
27-
import lombok.NonNull;
2827

2928
/**
3029
* Defined address and Milvus clients for each server.
@@ -33,7 +32,10 @@ public class ServerSetting {
3332
private final ServerAddress serverAddress;
3433
private final MilvusClient client;
3534

36-
public ServerSetting(@NonNull Builder builder) {
35+
public ServerSetting(Builder builder) {
36+
if (builder == null) {
37+
throw new IllegalArgumentException("builder cannot be null");
38+
}
3739
this.serverAddress = builder.serverAddress;
3840
this.client = builder.milvusClient;
3941
}
@@ -64,7 +66,10 @@ private Builder() {
6466
* @param serverAddress ServerAddress host,port/server
6567
* @return <code>Builder</code>
6668
*/
67-
public Builder withHost(@NonNull ServerAddress serverAddress) {
69+
public Builder withHost(ServerAddress serverAddress) {
70+
if (serverAddress == null) {
71+
throw new IllegalArgumentException("serverAddress cannot be null");
72+
}
6873
this.serverAddress = serverAddress;
6974
return this;
7075
}

0 commit comments

Comments
 (0)