Skip to content

Commit babc0f8

Browse files
committed
Convert MemoryAllocation to the record
1 parent cf98b6d commit babc0f8

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
@@ -298,6 +298,49 @@
298298
<old>method java.util.Map&lt;io.trino.spi.QueryId, java.lang.Long&gt; io.trino.spi.memory.MemoryPoolInfo::getQueryMemoryRevocableReservations()</old>
299299
<justification>Removed unused field</justification>
300300
</item>
301+
<item>
302+
<ignore>true</ignore>
303+
<code>java.annotation.removed</code>
304+
<old>parameter void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(===java.lang.String===, long)</old>
305+
<new>parameter void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(===java.lang.String===, long)</new>
306+
<annotation>@com.fasterxml.jackson.annotation.JsonProperty("tag")</annotation>
307+
<justification>Class converted to a record</justification>
308+
</item>
309+
<item>
310+
<ignore>true</ignore>
311+
<code>java.annotation.removed</code>
312+
<old>parameter void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(java.lang.String, ===long===)</old>
313+
<new>parameter void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(java.lang.String, ===long===)</new>
314+
<annotation>@com.fasterxml.jackson.annotation.JsonProperty("allocation")</annotation>
315+
<justification>Class converted to a record</justification>
316+
</item>
317+
<item>
318+
<ignore>true</ignore>
319+
<code>java.annotation.removed</code>
320+
<old>method void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(java.lang.String, long)</old>
321+
<new>method void io.trino.spi.memory.MemoryAllocation::&lt;init&gt;(java.lang.String, long)</new>
322+
<annotation>@com.fasterxml.jackson.annotation.JsonCreator</annotation>
323+
<justification>Class converted to a record</justification>
324+
</item>
325+
<item>
326+
<ignore>true</ignore>
327+
<code>java.method.removed</code>
328+
<old>method long io.trino.spi.memory.MemoryAllocation::getAllocation()</old>
329+
<justification>Class converted to a record</justification>
330+
</item>
331+
<item>
332+
<ignore>true</ignore>
333+
<code>java.method.removed</code>
334+
<old>method java.lang.String io.trino.spi.memory.MemoryAllocation::getTag()</old>
335+
<justification>Class converted to a record</justification>
336+
</item>
337+
<item>
338+
<ignore>true</ignore>
339+
<code>java.class.kindChanged</code>
340+
<old>class io.trino.spi.memory.MemoryAllocation</old>
341+
<new>class io.trino.spi.memory.MemoryAllocation</new>
342+
<justification>Class converted to a record</justification>
343+
</item>
301344
</differences>
302345
</revapi.differences>
303346
</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)