cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r901806 - in /cocoon/cocoon3/trunk/cocoon-pipeline/src: main/java/org/apache/cocoon/pipeline/caching/ main/java/org/apache/cocoon/pipeline/util/ test/java/org/apache/cocoon/pipeline/util/
Date Thu, 21 Jan 2010 18:05:03 GMT
Author: reinhard
Date: Thu Jan 21 18:05:02 2010
New Revision: 901806

URL: http://svn.apache.org/viewvc?rev=901806&view=rev
Log:
add the timestamp value to the TimestampCacheKey hashcode

Modified:
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java
    cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/MurmurHashCodeBuilder.java
    cocoon/cocoon3/trunk/cocoon-pipeline/src/test/java/org/apache/cocoon/pipeline/util/MurmurHashCodeBuilderTest.java

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java?rev=901806&r1=901805&r2=901806&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/caching/TimestampCacheKey.java
Thu Jan 21 18:05:02 2010
@@ -58,7 +58,7 @@
 
     @Override
     public int hashCode() {
-        return new MurmurHashCodeBuilder().append(this.url.toExternalForm()).toHashCode();
+        return new MurmurHashCodeBuilder().append(this.url.toExternalForm()).append(this.timestamp).toHashCode();
     }
 
     public boolean isValid(CacheKey cacheKey) {

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/MurmurHashCodeBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/MurmurHashCodeBuilder.java?rev=901806&r1=901805&r2=901806&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/MurmurHashCodeBuilder.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/main/java/org/apache/cocoon/pipeline/util/MurmurHashCodeBuilder.java
Thu Jan 21 18:05:02 2010
@@ -40,7 +40,13 @@
     }
 
     public MurmurHashCodeBuilder append(int value) {
-        return this.append(new byte[] { (byte) (value >>> 24), (byte) (value >>>
16), (byte) (value >>> 8), (byte) value });
+        return this.append(new byte[] { (byte) (value >>> 24), (byte) (value >>>
16), (byte) (value >>> 8),
+                (byte) value });
+    }
+
+    public MurmurHashCodeBuilder append(long v) {
+        return this.append(new byte[] { (byte) (v >>> 56), (byte) (v >>>
48), (byte) (v >>> 40), (byte) (v >>> 32),
+                (byte) (v >>> 24), (byte) (v >>> 16), (byte) (v >>>
8), (byte) (v >>> 0) });
     }
 
     public MurmurHashCodeBuilder append(String value) {

Modified: cocoon/cocoon3/trunk/cocoon-pipeline/src/test/java/org/apache/cocoon/pipeline/util/MurmurHashCodeBuilderTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-pipeline/src/test/java/org/apache/cocoon/pipeline/util/MurmurHashCodeBuilderTest.java?rev=901806&r1=901805&r2=901806&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-pipeline/src/test/java/org/apache/cocoon/pipeline/util/MurmurHashCodeBuilderTest.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-pipeline/src/test/java/org/apache/cocoon/pipeline/util/MurmurHashCodeBuilderTest.java
Thu Jan 21 18:05:02 2010
@@ -23,12 +23,24 @@
 public class MurmurHashCodeBuilderTest {
 
     @Test
+    public void addBytes() {
+        byte[] bytes = new MurmurHashCodeBuilder().append("a".getBytes()).append("b".getBytes()).getBytes();
+        assertEquals("ab", new String(bytes));
+    }
+
+    @Test
     public void addInteger() {
         byte[] bytes = new MurmurHashCodeBuilder().append(2).getBytes();
         assertEquals(2, byteArrayToInt(bytes));
     }
 
     @Test
+    public void addLong() {
+        byte[] bytes = new MurmurHashCodeBuilder().append(2l).getBytes();
+        assertEquals(2l, byteArrayToLong(bytes));
+    }
+
+    @Test
     public void addMaxInteger() {
         byte[] bytes = new MurmurHashCodeBuilder().append(Integer.MAX_VALUE).getBytes();
         assertEquals(Integer.MAX_VALUE, byteArrayToInt(bytes));
@@ -47,15 +59,15 @@
     }
 
     @Test
-    public void addBytes() {
-        byte[] bytes = new MurmurHashCodeBuilder().append("a".getBytes()).append("b".getBytes()).getBytes();
+    public void addString() {
+        byte[] bytes = new MurmurHashCodeBuilder().append("a").append("b").getBytes();
         assertEquals("ab", new String(bytes));
     }
 
     @Test
-    public void addString() {
-        byte[] bytes = new MurmurHashCodeBuilder().append("a").append("b").getBytes();
-        assertEquals("ab", new String(bytes));
+    public void nullInputToHashCode() {
+        int hashCode = new MurmurHashCodeBuilder().toHashCode();
+        assertEquals(1540447798, hashCode);
     }
 
     @Test
@@ -64,13 +76,13 @@
         assertEquals(-419373624, hashCode);
     }
 
-    @Test
-    public void nullInputToHashCode() {
-        int hashCode = new MurmurHashCodeBuilder().toHashCode();
-        assertEquals(1540447798, hashCode);
-    }
-
     private static final int byteArrayToInt(byte[] b) {
         return (b[0] << 24) + ((b[1] & 0xFF) << 16) + ((b[2] & 0xFF)
<< 8) + (b[3] & 0xFF);
     }
+
+    private static Object byteArrayToLong(byte[] b) {
+        return ((long) b[0] << 56) + ((long) (b[1] & 255) << 48) + ((long)
(b[2] & 255) << 40)
+                + ((long) (b[3] & 255) << 32) + ((long) (b[4] & 255) <<
24) + ((b[5] & 255) << 16)
+                + ((b[6] & 255) << 8) + ((b[7] & 255) << 0);
+    }
 }



Mime
View raw message