Skip to content

Commit eaae15b

Browse files
committed
remove counterNames array
1 parent b60fcc8 commit eaae15b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

modules/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageOperationsStats.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ final class GoogleCloudStorageOperationsStats {
2121
private static final int OPERATION_PURPOSE_NUM = OperationPurpose.values().length;
2222
private static final int OPERATION_NUM = Operation.values().length;
2323
private final OperationCounters[] counters;
24-
private final String[] counterNames;
2524
private final String bucketName;
2625

2726
GoogleCloudStorageOperationsStats(String bucketName) {
2827
this.bucketName = bucketName;
2928
counters = new OperationCounters[OPERATION_PURPOSE_NUM * OPERATION_NUM];
30-
counterNames = new String[counters.length];
3129
for (int counterIndex = 0; counterIndex < counters.length; counterIndex++) {
32-
counterNames[counterIndex] = counterName(counterIndex);
33-
counters[counterIndex] = new OperationCounters(new LongAdder(), new LongAdder());
30+
counters[counterIndex] = new OperationCounters(counterName(counterIndex), new LongAdder(), new LongAdder());
3431
}
3532
}
3633

@@ -59,12 +56,11 @@ String bucketName() {
5956
}
6057

6158
Map<String, BlobStoreActionStats> toMap() {
62-
var results = new HashMap<String, BlobStoreActionStats>(counterNames.length);
63-
for (var counterIndex = 0; counterIndex < counterNames.length; counterIndex++) {
64-
var stats = counters[counterIndex];
59+
var results = new HashMap<String, BlobStoreActionStats>(counters.length);
60+
for (var stats : counters) {
6561
var operations = stats.operations.sum();
6662
var requests = stats.requests.sum();
67-
results.put(counterNames[counterIndex], new BlobStoreActionStats(operations, requests));
63+
results.put(stats.nane, new BlobStoreActionStats(operations, requests));
6864
}
6965
return results;
7066
}
@@ -82,5 +78,5 @@ public enum Operation {
8278
}
8379
}
8480

85-
record OperationCounters(LongAdder operations, LongAdder requests) {}
81+
record OperationCounters(String nane, LongAdder operations, LongAdder requests) {}
8682
}

0 commit comments

Comments
 (0)