Skip to content

Commit e8879e4

Browse files
committed
Convert MemoryAllocation to the record
1 parent d83fcc8 commit e8879e4

File tree

3 files changed

+49
-28
lines changed

3 files changed

+49
-28
lines changed

core/trino-main/src/main/java/io/trino/memory/ClusterMemoryPool.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ private List<MemoryAllocation> mergeQueryAllocations(List<MemoryAllocation> left
157157
Map<String, MemoryAllocation> mergedAllocations = new HashMap<>();
158158

159159
for (MemoryAllocation allocation : left) {
160-
mergedAllocations.put(allocation.getTag(), allocation);
160+
mergedAllocations.put(allocation.tag(), allocation);
161161
}
162162

163163
for (MemoryAllocation allocation : right) {
164164
mergedAllocations.merge(
165-
allocation.getTag(),
165+
allocation.tag(),
166166
allocation,
167-
(a, b) -> new MemoryAllocation(a.getTag(), a.getAllocation() + b.getAllocation()));
167+
(a, b) -> new MemoryAllocation(a.tag(), a.allocation() + b.allocation()));
168168
}
169169

170170
return new ArrayList<>(mergedAllocations.values());

core/trino-spi/pom.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,49 @@
326326
<old>method java.util.Map&lt;io.trino.spi.QueryId, java.lang.Long&gt; io.trino.spi.memory.MemoryPoolInfo::getQueryMemoryRevocableReservations()</old>
327327
<justification>Removed unused field</justification>
328328
</item>
329+
<item>
330+
<ignore>true</ignore>
331+
<code>java.annotation.removed</code>
332+
<old>parameter void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(===java.lang.String===, long)</old>
333+
<new>parameter void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(===java.lang.String===, long)</new>
334+
<annotation>@com.fasterxml.jackson.annotation.JsonProperty("tag")</annotation>
335+
<justification>Class converted to a record</justification>
336+
</item>
337+
<item>
338+
<ignore>true</ignore>
339+
<code>java.annotation.removed</code>
340+
<old>parameter void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(java.lang.String, ===long===)</old>
341+
<new>parameter void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(java.lang.String, ===long===)</new>
342+
<annotation>@com.fasterxml.jackson.annotation.JsonProperty("allocation")</annotation>
343+
<justification>Class converted to a record</justification>
344+
</item>
345+
<item>
346+
<ignore>true</ignore>
347+
<code>java.annotation.removed</code>
348+
<old>method void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(java.lang.String, long)</old>
349+
<new>method void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(java.lang.String, long)</new>
350+
<annotation>@com.fasterxml.jackson.annotation.JsonCreator</annotation>
351+
<justification>Class converted to a record</justification>
352+
</item>
353+
<item>
354+
<ignore>true</ignore>
355+
<code>java.method.removed</code>
356+
<old>method long io.trino.spi.memory.MemoryAllocation::getAllocation()</old>
357+
<justification>Class converted to a record</justification>
358+
</item>
359+
<item>
360+
<ignore>true</ignore>
361+
<code>java.method.removed</code>
362+
<old>method java.lang.String io.trino.spi.memory.MemoryAllocation::getTag()</old>
363+
<justification>Class converted to a record</justification>
364+
</item>
365+
<item>
366+
<ignore>true</ignore>
367+
<code>java.class.kindChanged</code>
368+
<old>class io.trino.spi.memory.MemoryAllocation</old>
369+
<new>class io.trino.spi.memory.MemoryAllocation</new>
370+
<justification>Class converted to a record</justification>
371+
</item>
329372
</differences>
330373
</revapi.differences>
331374
</analysisConfiguration>

core/trino-spi/src/main/java/io/trino/spi/memory/MemoryAllocation.java

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,12 @@
1313
*/
1414
package io.trino.spi.memory;
1515

16-
import com.fasterxml.jackson.annotation.JsonCreator;
17-
import com.fasterxml.jackson.annotation.JsonProperty;
18-
1916
import static java.util.Objects.requireNonNull;
2017

21-
public final class MemoryAllocation
18+
public record MemoryAllocation(String tag, long allocation)
2219
{
23-
private final String tag;
24-
private final long allocation;
25-
26-
@JsonCreator
27-
public MemoryAllocation(
28-
@JsonProperty("tag") String tag,
29-
@JsonProperty("allocation") long allocation)
30-
{
31-
this.tag = requireNonNull(tag, "tag is null");
32-
this.allocation = allocation;
33-
}
34-
35-
@JsonProperty
36-
public String getTag()
37-
{
38-
return tag;
39-
}
40-
41-
@JsonProperty
42-
public long getAllocation()
20+
public MemoryAllocation
4321
{
44-
return allocation;
22+
requireNonNull(tag, "tag is null");
4523
}
4624
}

0 commit comments

Comments
 (0)