Skip to content

Commit c98971d

Browse files
authored
[client] Improve initialization of Cluster class (#292)
1 parent 83aef68 commit c98971d

File tree

1 file changed

+2
-7
lines changed
  • fluss-common/src/main/java/com/alibaba/fluss/cluster

1 file changed

+2
-7
lines changed

fluss-common/src/main/java/com/alibaba/fluss/cluster/Cluster.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,17 @@ public Cluster(
8383
List<BucketLocation> bucketsForTable = entry.getValue();
8484
// Optimise for the common case where all buckets are available.
8585
boolean foundUnavailableBucket = false;
86+
List<BucketLocation> availableBucketsForTable = new ArrayList<>(bucketsForTable.size());
8687
for (BucketLocation bucketLocation : bucketsForTable) {
8788
if (bucketLocation.getLeader() != null) {
8889
tmpAvailableLocationByBucket.put(
8990
bucketLocation.getTableBucket(), bucketLocation);
91+
availableBucketsForTable.add(bucketLocation);
9092
} else {
9193
foundUnavailableBucket = true;
9294
}
9395
}
9496
if (foundUnavailableBucket) {
95-
List<BucketLocation> availableBucketsForTable =
96-
new ArrayList<>(bucketsForTable.size());
97-
for (BucketLocation loc : bucketsForTable) {
98-
if (loc.getLeader() != null) {
99-
availableBucketsForTable.add(loc);
100-
}
101-
}
10297
tmpAvailableLocationsByPath.put(
10398
physicalTablePath, Collections.unmodifiableList(availableBucketsForTable));
10499
} else {

0 commit comments

Comments
 (0)