You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (Jira)" <ji...@apache.org> on 2021/07/28 08:58:00 UTC

[jira] [Assigned] (SPARK-36326) Use Map.computeIfAbsent to simplify the process of HeapMemoryAllocator.bufferPoolsBySize init new item

     [ https://issues.apache.org/jira/browse/SPARK-36326?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Apache Spark reassigned SPARK-36326:
------------------------------------

    Assignee:     (was: Apache Spark)

> Use Map.computeIfAbsent to simplify the process of HeapMemoryAllocator.bufferPoolsBySize init new item
> ------------------------------------------------------------------------------------------------------
>
>                 Key: SPARK-36326
>                 URL: https://issues.apache.org/jira/browse/SPARK-36326
>             Project: Spark
>          Issue Type: Improvement
>          Components: Spark Core
>    Affects Versions: 3.3.0
>            Reporter: Yang Jie
>            Priority: Trivial
>
> HeapMemoryAllocator initializes the new element ofbufferPoolsBySizein the following way:
> {code:java}
> synchronized (this) {
>   LinkedList<WeakReference<long[]>> pool = bufferPoolsBySize.get(alignedSize);
>   if (pool == null) {
>     pool = new LinkedList<>();
>     bufferPoolsBySize.put(alignedSize, pool);
>   }
>   pool.add(new WeakReference<>(array));
> }
> {code}
> The codes can be simplified by Map.computeIfAbsent
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org