Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/9127#discussion_r42894526
--- Diff: core/src/main/java/org/apache/spark/memory/TaskMemoryManager.java
---
@@ -103,16 +107,38 @@
private final boolean inHeap;
/**
- * Construct a new MemoryManager.
+ * Construct a new TaskMemoryManager.
+ */
+ public TaskMemoryManager(MemoryManager memoryManager, long
taskAttemptId) {
+ this.inHeap = memoryManager.tungstenMemoryIsAllocatedInHeap();
+ this.memoryManager = memoryManager;
+ this.taskAttemptId = taskAttemptId;
+ }
+
+ /**
+ * Acquire N bytes of memory for execution, evicting cached blocks if
necessary.
+ * @return number of bytes successfully granted (<= N).
*/
- public TaskMemoryManager(ExecutorMemoryManager executorMemoryManager) {
- this.inHeap = executorMemoryManager.inHeap;
- this.executorMemoryManager = executorMemoryManager;
+ public long acquireExecutionMemory(long size) {
+ return memoryManager.acquireExecutionMemory(size, taskAttemptId);
+ }
+
+ /**
+ * Release N bytes of execution memory.
+ */
+ public void releaseExecutionMemory(long size) {
+ memoryManager.releaseExecutionMemory(size, taskAttemptId);
+ }
+
+ public long pageSizeBytes() {
+ return memoryManager.pageSizeBytes();
}
/**
* Allocate a block of memory that will be tracked in the
MemoryManager's page table; this is
* intended for allocating large blocks of memory that will be shared
between operators.
+ *
+ * Returns `null` if there was not enough memory to allocate the page.
--- End diff --
nit `@return`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]