浏览代码

Determine the size of the array

Avoid expansion or memory waste
dwq 4 年之前
父节点
当前提交
d4747df3fd
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      examples/src/main/java/MilvusClientExample.java

+ 1 - 1
examples/src/main/java/MilvusClientExample.java

@@ -36,7 +36,7 @@ public class MilvusClientExample {
   // Helper function that generates random vectors
   static List<List<Float>> generateVectors(long vectorCount, long dimension) {
     SplittableRandom splitcollectionRandom = new SplittableRandom();
-    List<List<Float>> vectors = new ArrayList<>();
+    List<List<Float>> vectors = new ArrayList<>(vectorCount);
     for (long i = 0; i < vectorCount; ++i) {
       splitcollectionRandom = splitcollectionRandom.split();
       DoubleStream doubleStream = splitcollectionRandom.doubles(dimension);