Skip to content

Commit a22a5a2

Browse files
yhmoyeyinglang
andauthored
Remove Lombok from milvus sdk-core (#1653) (#1656)
* first step: remove lombok at io.milvus.v2.service.resourcegroup (#1500) * Second Step: Remove Lombok from io.milvus.v2 * Third Step: Remove Lombok from milvus sdk-core * Remove Lombok from milvus sdk-core --------- Signed-off-by: kun <[email protected]> Co-authored-by: kun <[email protected]>
1 parent e5bb495 commit a22a5a2

File tree

269 files changed

+22128
-2655
lines changed

Some content is hidden

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

269 files changed

+22128
-2655
lines changed

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/resourcegroup/NodeInfo.java

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,100 @@
1919

2020
package io.milvus.common.resourcegroup;
2121

22-
import lombok.Data;
23-
import lombok.experimental.SuperBuilder;
22+
import org.apache.commons.lang3.builder.EqualsBuilder;
2423

25-
@Data
26-
@SuperBuilder
2724
public class NodeInfo {
2825
private Long nodeId;
2926
private String address;
3027
private String hostname;
28+
29+
private NodeInfo(Builder builder) {
30+
this.nodeId = builder.nodeId;
31+
this.address = builder.address;
32+
this.hostname = builder.hostname;
33+
}
34+
35+
public Long getNodeId() {
36+
return nodeId;
37+
}
38+
39+
public void setNodeId(Long nodeId) {
40+
this.nodeId = nodeId;
41+
}
42+
43+
public String getAddress() {
44+
return address;
45+
}
46+
47+
public void setAddress(String address) {
48+
this.address = address;
49+
}
50+
51+
public String getHostname() {
52+
return hostname;
53+
}
54+
55+
public void setHostname(String hostname) {
56+
this.hostname = hostname;
57+
}
58+
59+
@Override
60+
public boolean equals(Object obj) {
61+
if (this == obj) return true;
62+
if (obj == null || getClass() != obj.getClass()) return false;
63+
NodeInfo nodeInfo = (NodeInfo) obj;
64+
return new EqualsBuilder()
65+
.append(nodeId, nodeInfo.nodeId)
66+
.append(address, nodeInfo.address)
67+
.append(hostname, nodeInfo.hostname)
68+
.isEquals();
69+
}
70+
71+
@Override
72+
public int hashCode() {
73+
int result = nodeId != null ? nodeId.hashCode() : 0;
74+
result = 31 * result + (address != null ? address.hashCode() : 0);
75+
result = 31 * result + (hostname != null ? hostname.hashCode() : 0);
76+
return result;
77+
}
78+
79+
@Override
80+
public String toString() {
81+
return "NodeInfo{" +
82+
"nodeId=" + nodeId +
83+
", address='" + address + '\'' +
84+
", hostname='" + hostname + '\'' +
85+
'}';
86+
}
87+
88+
public static Builder builder() {
89+
return new Builder();
90+
}
91+
92+
public static class Builder {
93+
private Long nodeId;
94+
private String address;
95+
private String hostname;
96+
97+
private Builder() {}
98+
99+
public Builder nodeId(Long nodeId) {
100+
this.nodeId = nodeId;
101+
return this;
102+
}
103+
104+
public Builder address(String address) {
105+
this.address = address;
106+
return this;
107+
}
108+
109+
public Builder hostname(String hostname) {
110+
this.hostname = hostname;
111+
return this;
112+
}
113+
114+
public NodeInfo build() {
115+
return new NodeInfo(this);
116+
}
117+
}
31118
}

0 commit comments

Comments
 (0)