Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit 2fed47e

Browse files
committed
#52 lower memory footprint in MetricTimeSeriesKey
1 parent 1c17987 commit 2fed47e

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

chronix-solr-cloud-storage/src/main/java/de/qaware/chronix/storage/solr/timeseries/metric/MetricTimeSeriesKey.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import org.apache.commons.lang3.builder.HashCodeBuilder;
2121

2222
import java.io.Serializable;
23-
import java.util.Collections;
24-
import java.util.Map;
2523

2624
/**
2725
* Represents the identity of a MetricTimeSeries.
@@ -31,20 +29,19 @@ public class MetricTimeSeriesKey implements Serializable {
3129

3230
private static final long serialVersionUID = 42L;
3331

34-
private final String metric;
35-
private final Map<String, Object> attributes;
32+
private MetricTimeSeries mts;
3633

34+
/**
35+
* Default constructor
36+
*
37+
* @param mts
38+
*/
3739
public MetricTimeSeriesKey(MetricTimeSeries mts) {
38-
this.metric = mts.getMetric();
39-
this.attributes = mts.attributes();
40+
this.mts = mts;
4041
}
4142

42-
public String getMetric() {
43-
return metric;
44-
}
45-
46-
public Map<String, Object> getAttributes() {
47-
return Collections.unmodifiableMap(attributes);
43+
private MetricTimeSeries getMetricTimeSeries() {
44+
return mts;
4845
}
4946

5047
@Override
@@ -57,9 +54,10 @@ public boolean equals(Object o) {
5754
EqualsBuilder eb = new EqualsBuilder();
5855
for (MetricDimensions dim : MetricDimensions.getIdentityDimensions()) {
5956
if (dim == MetricDimensions.METRIC) {
60-
eb.append(this.metric, that.metric);
57+
eb.append(mts.getMetric(), that.getMetricTimeSeries().getMetric());
6158
} else {
62-
eb.append(this.attributes.get(dim.getId()), that.attributes.get(dim.getId()));
59+
eb.append(mts.attributes().get(dim.getId()),
60+
that.getMetricTimeSeries().attributes().get(dim.getId()));
6361
}
6462
}
6563
return eb.isEquals();
@@ -71,9 +69,9 @@ public int hashCode() {
7169

7270
for (MetricDimensions dim : MetricDimensions.getIdentityDimensions()) {
7371
if (dim == MetricDimensions.METRIC) {
74-
hb.append(this.metric);
72+
hb.append(mts.getMetric());
7573
} else {
76-
hb.append(this.attributes.get(dim.getId()));
74+
hb.append(mts.attributes().get(dim.getId()));
7775
}
7876
}
7977

0 commit comments

Comments
 (0)