hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From harisan...@apache.org
Subject hive git commit: HIVE-12310: Update memory estimation login in TopNHash (Hari Subramaniyan, reviewed by Thejas Nair)
Date Fri, 06 Nov 2015 18:39:35 GMT
Repository: hive
Updated Branches:
  refs/heads/master 6ba735f0b -> 678b77b5b


HIVE-12310: Update memory estimation login in TopNHash (Hari Subramaniyan, reviewed by Thejas
Nair)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/678b77b5
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/678b77b5
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/678b77b5

Branch: refs/heads/master
Commit: 678b77b5be2e97581a49fdb47614274f1ea8a7a5
Parents: 6ba735f
Author: Hari Subramaniyan <harisankar@apache.org>
Authored: Fri Nov 6 10:39:25 2015 -0800
Committer: Hari Subramaniyan <harisankar@apache.org>
Committed: Fri Nov 6 10:39:25 2015 -0800

----------------------------------------------------------------------
 ql/src/java/org/apache/hadoop/hive/ql/exec/TopNHash.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/678b77b5/ql/src/java/org/apache/hadoop/hive/ql/exec/TopNHash.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/TopNHash.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/TopNHash.java
index 46b3510..e400368 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/TopNHash.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/TopNHash.java
@@ -103,8 +103,13 @@ public class TopNHash {
       return; // topN == 0 will cause a short-circuit, don't need any initialization
     }
 
+    // Used Memory = totalMemory() - freeMemory();
+    // Total Free Memory = maxMemory() - Used Memory;
+    long totalFreeMemory = Runtime.getRuntime().maxMemory() -
+      Runtime.getRuntime().totalMemory() + Runtime.getRuntime().freeMemory();
+
     // limit * 64 : compensation of arrays for key/value/hashcodes
-    this.threshold = (long) (memUsage * Runtime.getRuntime().freeMemory()) - topN * 64L;
+    this.threshold = (long) (memUsage * totalFreeMemory) - topN * 64L;
     if (threshold < 0) {
       return;
     }


Mime
View raw message