You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by si...@apache.org on 2018/06/25 17:14:37 UTC
[arrow] branch master updated: ARROW-2725: [Java] make
Accountant.AllocationOutcome publicly visible (#2149)
This is an automated email from the ASF dual-hosted git repository.
siddteotia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new ac0e521 ARROW-2725: [Java] make Accountant.AllocationOutcome publicly visible (#2149)
ac0e521 is described below
commit ac0e521903a3b3028590bd90bd33360618126c46
Author: Vanco Buca <va...@dremio.com>
AuthorDate: Mon Jun 25 10:14:34 2018 -0700
ARROW-2725: [Java] make Accountant.AllocationOutcome publicly visible (#2149)
---
.../java/org/apache/arrow/memory/Accountant.java | 37 +--------------
.../apache/arrow/memory/AllocationListener.java | 4 +-
.../org/apache/arrow/memory/AllocationOutcome.java | 55 ++++++++++++++++++++++
.../org/apache/arrow/memory/TestAccountant.java | 1 -
.../org/apache/arrow/memory/TestBaseAllocator.java | 2 +-
5 files changed, 59 insertions(+), 40 deletions(-)
diff --git a/java/memory/src/main/java/org/apache/arrow/memory/Accountant.java b/java/memory/src/main/java/org/apache/arrow/memory/Accountant.java
index 5bd6b9f..7a2531e 100644
--- a/java/memory/src/main/java/org/apache/arrow/memory/Accountant.java
+++ b/java/memory/src/main/java/org/apache/arrow/memory/Accountant.java
@@ -170,7 +170,7 @@ class Accountant implements AutoCloseable {
}
final AllocationOutcome finalOutcome = beyondLimit ? AllocationOutcome.FAILED_LOCAL :
- parentOutcome.ok ? AllocationOutcome.SUCCESS : AllocationOutcome.FAILED_PARENT;
+ parentOutcome.isOk() ? AllocationOutcome.SUCCESS : AllocationOutcome.FAILED_PARENT;
if (updatePeak) {
updatePeak();
@@ -258,39 +258,4 @@ class Accountant implements AutoCloseable {
return Math.min(localHeadroom, parent.getHeadroom());
}
- /**
- * Describes the type of outcome that occurred when trying to account for allocation of memory.
- */
- public static enum AllocationOutcome {
-
- /**
- * Allocation succeeded.
- */
- SUCCESS(true),
-
- /**
- * Allocation succeeded but only because the allocator was forced to move beyond a limit.
- */
- FORCED_SUCCESS(true),
-
- /**
- * Allocation failed because the local allocator's limits were exceeded.
- */
- FAILED_LOCAL(false),
-
- /**
- * Allocation failed because a parent allocator's limits were exceeded.
- */
- FAILED_PARENT(false);
-
- private final boolean ok;
-
- AllocationOutcome(boolean ok) {
- this.ok = ok;
- }
-
- public boolean isOk() {
- return ok;
- }
- }
}
diff --git a/java/memory/src/main/java/org/apache/arrow/memory/AllocationListener.java b/java/memory/src/main/java/org/apache/arrow/memory/AllocationListener.java
index de181df..67a7b9c 100644
--- a/java/memory/src/main/java/org/apache/arrow/memory/AllocationListener.java
+++ b/java/memory/src/main/java/org/apache/arrow/memory/AllocationListener.java
@@ -32,7 +32,7 @@ public interface AllocationListener {
}
@Override
- public boolean onFailedAllocation(long size, Accountant.AllocationOutcome outcome) {
+ public boolean onFailedAllocation(long size, AllocationOutcome outcome) {
return false;
}
};
@@ -53,6 +53,6 @@ public interface AllocationListener {
* @param outcome the outcome of the failed allocation. Carries information of what failed
* @return true, if the allocation can be retried; false if the allocation should fail
*/
- boolean onFailedAllocation(long size, Accountant.AllocationOutcome outcome);
+ boolean onFailedAllocation(long size, AllocationOutcome outcome);
}
diff --git a/java/memory/src/main/java/org/apache/arrow/memory/AllocationOutcome.java b/java/memory/src/main/java/org/apache/arrow/memory/AllocationOutcome.java
new file mode 100644
index 0000000..9f2daa7
--- /dev/null
+++ b/java/memory/src/main/java/org/apache/arrow/memory/AllocationOutcome.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.arrow.memory;
+
+/**
+ * Describes the type of outcome that occurred when trying to account for allocation of memory.
+ */
+public enum AllocationOutcome {
+
+ /**
+ * Allocation succeeded.
+ */
+ SUCCESS(true),
+
+ /**
+ * Allocation succeeded but only because the allocator was forced to move beyond a limit.
+ */
+ FORCED_SUCCESS(true),
+
+ /**
+ * Allocation failed because the local allocator's limits were exceeded.
+ */
+ FAILED_LOCAL(false),
+
+ /**
+ * Allocation failed because a parent allocator's limits were exceeded.
+ */
+ FAILED_PARENT(false);
+
+ private final boolean ok;
+
+ AllocationOutcome(boolean ok) {
+ this.ok = ok;
+ }
+
+ public boolean isOk() {
+ return ok;
+ }
+}
diff --git a/java/memory/src/test/java/org/apache/arrow/memory/TestAccountant.java b/java/memory/src/test/java/org/apache/arrow/memory/TestAccountant.java
index 100be06..a45de48 100644
--- a/java/memory/src/test/java/org/apache/arrow/memory/TestAccountant.java
+++ b/java/memory/src/test/java/org/apache/arrow/memory/TestAccountant.java
@@ -20,7 +20,6 @@ package org.apache.arrow.memory;
import static org.junit.Assert.assertEquals;
-import org.apache.arrow.memory.Accountant.AllocationOutcome;
import org.junit.Assert;
import org.junit.Test;
diff --git a/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java b/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java
index 62b0046..b826d16 100644
--- a/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java
+++ b/java/memory/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java
@@ -247,7 +247,7 @@ public class TestBaseAllocator {
}
@Override
- public boolean onFailedAllocation(long size, Accountant.AllocationOutcome outcome) {
+ public boolean onFailedAllocation(long size, AllocationOutcome outcome) {
if (expandOnFail) {
expandAlloc.setLimit(expandLimit);
return true;