Selaa lähdekoodia

Use Collections.emptyList()

Use Collections.emptyList() instead of new ArrayList<>()
dwq 4 vuotta sitten
vanhempi
commit
b0d9f097f7
1 muutettua tiedostoa jossa 18 lisäystä ja 17 poistoa
  1. 18 17
      src/main/java/io/milvus/client/MilvusGrpcClient.java

+ 18 - 17
src/main/java/io/milvus/client/MilvusGrpcClient.java

@@ -32,6 +32,7 @@ import io.milvus.grpc.*;
 import java.nio.Buffer;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
@@ -397,7 +398,7 @@ public class MilvusGrpcClient implements MilvusClient {
     if (!channelIsReadyOrIdle()) {
       logWarning("You are not connected to Milvus server");
       return new ListPartitionsResponse(
-          new Response(Response.Status.CLIENT_NOT_CONNECTED), new ArrayList<>());
+          new Response(Response.Status.CLIENT_NOT_CONNECTED), Collections.emptyList());
     }
 
     CollectionName request = CollectionName.newBuilder().setCollectionName(collectionName).build();
@@ -419,12 +420,12 @@ public class MilvusGrpcClient implements MilvusClient {
             new Response(
                 Response.Status.valueOf(response.getStatus().getErrorCodeValue()),
                 response.getStatus().getReason()),
-            new ArrayList<>());
+            Collections.emptyList());
       }
     } catch (StatusRuntimeException e) {
       logError("listPartitions RPC failed:\n{}", e.getStatus().toString());
       return new ListPartitionsResponse(
-          new Response(Response.Status.RPC_ERROR, e.toString()), new ArrayList<>());
+          new Response(Response.Status.RPC_ERROR, e.toString()), Collections.emptyList());
     }
   }
 
@@ -467,7 +468,7 @@ public class MilvusGrpcClient implements MilvusClient {
     if (!channelIsReadyOrIdle()) {
       logWarning("You are not connected to Milvus server");
       return new InsertResponse(
-          new Response(Response.Status.CLIENT_NOT_CONNECTED), new ArrayList<>());
+          new Response(Response.Status.CLIENT_NOT_CONNECTED), Collections.emptyList());
     }
 
     List<RowRecord> rowRecordList =
@@ -498,12 +499,12 @@ public class MilvusGrpcClient implements MilvusClient {
             new Response(
                 Response.Status.valueOf(response.getStatus().getErrorCodeValue()),
                 response.getStatus().getReason()),
-            new ArrayList<>());
+            Collections.emptyList());
       }
     } catch (StatusRuntimeException e) {
       logError("insert RPC failed:\n{}", e.getStatus().toString());
       return new InsertResponse(
-          new Response(Response.Status.RPC_ERROR, e.toString()), new ArrayList<>());
+          new Response(Response.Status.RPC_ERROR, e.toString()), Collections.emptyList());
     }
   }
 
@@ -514,7 +515,7 @@ public class MilvusGrpcClient implements MilvusClient {
       logWarning("You are not connected to Milvus server");
       return Futures.immediateFuture(
           new InsertResponse(
-              new Response(Response.Status.CLIENT_NOT_CONNECTED), new ArrayList<>()));
+              new Response(Response.Status.CLIENT_NOT_CONNECTED), Collections.emptyList()));
     }
 
     List<RowRecord> rowRecordList =
@@ -564,7 +565,7 @@ public class MilvusGrpcClient implements MilvusClient {
                 new Response(
                     Response.Status.valueOf(vectorIds.getStatus().getErrorCodeValue()),
                     vectorIds.getStatus().getReason()),
-                new ArrayList<>());
+                Collections.emptyList());
           }
         };
 
@@ -748,7 +749,7 @@ public class MilvusGrpcClient implements MilvusClient {
     if (!channelIsReadyOrIdle()) {
       logWarning("You are not connected to Milvus server");
       return new ListCollectionsResponse(
-          new Response(Response.Status.CLIENT_NOT_CONNECTED), new ArrayList<>());
+          new Response(Response.Status.CLIENT_NOT_CONNECTED), Collections.emptyList());
     }
 
     Command request = Command.newBuilder().setCmd("").build();
@@ -767,12 +768,12 @@ public class MilvusGrpcClient implements MilvusClient {
             new Response(
                 Response.Status.valueOf(response.getStatus().getErrorCodeValue()),
                 response.getStatus().getReason()),
-            new ArrayList<>());
+            Collections.emptyList());
       }
     } catch (StatusRuntimeException e) {
       logError("listCollections RPC failed:\n{}", e.getStatus().toString());
       return new ListCollectionsResponse(
-          new Response(Response.Status.RPC_ERROR, e.toString()), new ArrayList<>());
+          new Response(Response.Status.RPC_ERROR, e.toString()), Collections.emptyList());
     }
   }
 
@@ -987,7 +988,7 @@ public class MilvusGrpcClient implements MilvusClient {
     if (!channelIsReadyOrIdle()) {
       logWarning("You are not connected to Milvus server");
       return new GetEntityByIDResponse(
-          new Response(Response.Status.CLIENT_NOT_CONNECTED), new ArrayList<>(), null);
+          new Response(Response.Status.CLIENT_NOT_CONNECTED), Collections.emptyList(), null);
     }
 
     VectorsIdentity request =
@@ -1019,13 +1020,13 @@ public class MilvusGrpcClient implements MilvusClient {
             new Response(
                 Response.Status.valueOf(response.getStatus().getErrorCodeValue()),
                 response.getStatus().getReason()),
-            new ArrayList<>(),
+            Collections.emptyList(),
             null);
       }
     } catch (StatusRuntimeException e) {
       logError("getEntityByID RPC failed:\n{}", e.getStatus().toString());
       return new GetEntityByIDResponse(
-          new Response(Response.Status.RPC_ERROR, e.toString()), new ArrayList<>(), null);
+          new Response(Response.Status.RPC_ERROR, e.toString()), Collections.emptyList(), null);
     }
   }
 
@@ -1034,7 +1035,7 @@ public class MilvusGrpcClient implements MilvusClient {
     if (!channelIsReadyOrIdle()) {
       logWarning("You are not connected to Milvus server");
       return new ListIDInSegmentResponse(
-          new Response(Response.Status.CLIENT_NOT_CONNECTED), new ArrayList<>());
+          new Response(Response.Status.CLIENT_NOT_CONNECTED), Collections.emptyList());
     }
 
     GetVectorIDsParam request =
@@ -1065,12 +1066,12 @@ public class MilvusGrpcClient implements MilvusClient {
             new Response(
                 Response.Status.valueOf(response.getStatus().getErrorCodeValue()),
                 response.getStatus().getReason()),
-            new ArrayList<>());
+            Collections.emptyList());
       }
     } catch (StatusRuntimeException e) {
       logError("listIDInSegment RPC failed:\n{}", e.getStatus().toString());
       return new ListIDInSegmentResponse(
-          new Response(Response.Status.RPC_ERROR, e.toString()), new ArrayList<>());
+          new Response(Response.Status.RPC_ERROR, e.toString()), Collections.emptyList());
     }
   }