File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed
sdk-core/src/main/java/io/milvus/v2/service/collection Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change
1
+ package io .milvus .v2 .service .collection ;
2
+
3
+ import lombok .Data ;
4
+ import lombok .experimental .SuperBuilder ;
5
+
6
+ @ Data
7
+ @ SuperBuilder
8
+ public class CollectionInfo {
9
+ private String collectionName ;
10
+ private Integer shardNum ;
11
+ }
Original file line number Diff line number Diff line change @@ -183,11 +183,24 @@ public ListCollectionsResp listCollections(MilvusServiceGrpc.MilvusServiceBlocki
183
183
ShowCollectionsRequest showCollectionsRequest = ShowCollectionsRequest .newBuilder ()
184
184
.build ();
185
185
ShowCollectionsResponse response = blockingStub .showCollections (showCollectionsRequest );
186
- ListCollectionsResp listCollectionsResp = ListCollectionsResp .builder ()
186
+
187
+ List <CollectionInfo > collectionInfos = new ArrayList <>();
188
+ for (int i = 0 ; i < response .getCollectionNamesCount (); i ++) {
189
+ CollectionInfo collectionInfo = CollectionInfo .builder ()
190
+ .collectionName (response .getCollectionNames (i ))
191
+ .build ();
192
+ // Milvus version >= 2.6.1 will additionally return shardNum
193
+ List <Integer > shardsNums = response .getShardsNumList ();
194
+ if (CollectionUtils .isNotEmpty (shardsNums )) {
195
+ collectionInfo .setShardNum (response .getShardsNum (i ));
196
+ }
197
+ collectionInfos .add (collectionInfo );
198
+ }
199
+
200
+ return ListCollectionsResp .builder ()
187
201
.collectionNames (response .getCollectionNamesList ())
202
+ .collectionInfos (collectionInfos )
188
203
.build ();
189
-
190
- return listCollectionsResp ;
191
204
}
192
205
193
206
public Void dropCollection (MilvusServiceGrpc .MilvusServiceBlockingStub blockingStub , DropCollectionReq request ) {
Original file line number Diff line number Diff line change @@ -50,9 +50,9 @@ public void setCollectionNames(List<String> collectionNames) {
50
50
public boolean equals (Object obj ) {
51
51
if (this == obj ) return true ;
52
52
if (obj == null || getClass () != obj .getClass ()) return false ;
53
-
53
+
54
54
ListCollectionsResp that = (ListCollectionsResp ) obj ;
55
-
55
+
56
56
return new EqualsBuilder ()
57
57
.append (collectionNames , that .collectionNames )
58
58
.isEquals ();
You can’t perform that action at this time.
0 commit comments