hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1457994 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java
Date Mon, 18 Mar 2013 21:05:07 GMT
Author: tedyu
Date: Mon Mar 18 21:05:06 2013
New Revision: 1457994

URL: http://svn.apache.org/r1457994
Log:
HBASE-8014 Backport HBASE-6915 to 0.94 (Jean-Marc)


Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java?rev=1457994&r1=1457993&r2=1457994&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java Mon Mar
18 21:05:06 2013
@@ -97,6 +97,20 @@ public class ClassSize {
   /** Overhead for CopyOnWriteArrayList */
   public static final int COPYONWRITE_ARRAYLIST;
 
+  /* Are we running on jdk7? */
+  private static final boolean JDK7;
+  static {
+    final String version = System.getProperty("java.version");
+    // Verify String looks like this: 1.6.0_29
+    if (!version.matches("\\d\\.\\d\\..*")) {
+      throw new RuntimeException("Unexpected version format: " + version);
+    }
+    // Convert char to int
+    int major = (int) (version.charAt(0) - '0');
+    int minor = (int) (version.charAt(2) - '0');
+    JDK7 = major == 1 && minor == 7;
+  }
+
   /**
    * Method for reading the arc settings and setting overheads according
    * to 32-bit or 64-bit architecture.
@@ -127,9 +141,9 @@ public class ClassSize {
 
     TREEMAP = align(OBJECT + (2 * Bytes.SIZEOF_INT) + align(7 * REFERENCE));
 
-    STRING = align(OBJECT + ARRAY + REFERENCE + 3 * Bytes.SIZEOF_INT);
+    STRING = align(OBJECT + ARRAY + REFERENCE + ((JDK7? 2: 3) * Bytes.SIZEOF_INT));
 
-    CONCURRENT_HASHMAP = align((2 * Bytes.SIZEOF_INT) + ARRAY +
+    CONCURRENT_HASHMAP = align(((JDK7? 3: 2) * Bytes.SIZEOF_INT) + ARRAY +
         (6 * REFERENCE) + OBJECT);
 
     CONCURRENT_HASHMAP_ENTRY = align(REFERENCE + OBJECT + (3 * REFERENCE) +



Mime
View raw message