db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r604818 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/store/raw/PageKey.java impl/store/raw/data/RecordId.java
Date Mon, 17 Dec 2007 10:33:13 GMT
Author: kahatlen
Date: Mon Dec 17 02:33:11 2007
New Revision: 604818

URL: http://svn.apache.org/viewvc?rev=604818&view=rev
Log:
DERBY-3280: Poor distribution of hash values from RecordId.hashCode()

Auto-generated RecordId.hashCode() and PageKey.hashCode() with
NetBeans so that they return values distributed (more) evenly over the
whole 32-bit range.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/PageKey.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RecordId.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/PageKey.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/PageKey.java?rev=604818&r1=604817&r2=604818&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/PageKey.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/PageKey.java Mon Dec 17
02:33:11 2007
@@ -92,8 +92,10 @@
 
 
 	public int hashCode() {
-
-		return (int) (pageNumber ^ container.hashCode());
+        int hash = 7;
+        hash = 79 * hash + container.hashCode();
+        hash = 79 * hash + (int) (pageNumber ^ (pageNumber >>> 32));
+        return hash;
 	}
 
 	public String toString() {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RecordId.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RecordId.java?rev=604818&r1=604817&r2=604818&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RecordId.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/RecordId.java Mon
Dec 17 02:33:11 2007
@@ -248,8 +248,10 @@
 		MT - thread safe
 	*/
 	public int hashCode() {
-
-		return (int) recordId ^ pageId.hashCode();
+        int hash = 7;
+        hash = 89 * hash + pageId.hashCode();
+        hash = 89 * hash + recordId;
+        return hash;
 	}
 
     public String toString()



Mime
View raw message