File tree Expand file tree Collapse file tree
sdk-core/src/main/java/io/milvus/v2/service/collection Expand file tree Collapse file tree 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
183183 ShowCollectionsRequest showCollectionsRequest = ShowCollectionsRequest .newBuilder ()
184184 .build ();
185185 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 ()
187201 .collectionNames (response .getCollectionNamesList ())
202+ .collectionInfos (collectionInfos )
188203 .build ();
189-
190- return listCollectionsResp ;
191204 }
192205
193206 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) {
5050 public boolean equals (Object obj ) {
5151 if (this == obj ) return true ;
5252 if (obj == null || getClass () != obj .getClass ()) return false ;
53-
53+
5454 ListCollectionsResp that = (ListCollectionsResp ) obj ;
55-
55+
5656 return new EqualsBuilder ()
5757 .append (collectionNames , that .collectionNames )
5858 .isEquals ();
You can’t perform that action at this time.
0 commit comments