jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1444981 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBlob.java
Date Mon, 11 Feb 2013 22:22:22 GMT
Author: jukka
Date: Mon Feb 11 22:22:21 2013
New Revision: 1444981

URL: http://svn.apache.org/r1444981
Log:
OAK-593: Segment-based MK

Improved blob handling

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBlob.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBlob.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBlob.java?rev=1444981&r1=1444980&r2=1444981&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBlob.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBlob.java
Mon Feb 11 22:22:21 2013
@@ -24,8 +24,9 @@ import java.security.NoSuchAlgorithmExce
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.plugins.memory.AbstractBlob;
 
-public class SegmentBlob implements Blob {
+public class SegmentBlob extends AbstractBlob {
 
     private final SegmentReader reader;
 
@@ -52,27 +53,25 @@ public class SegmentBlob implements Blob
     }
 
     @Override
-    public byte[] sha256() {
-        SegmentStream stream = getNewStream();
-        try {
-            MessageDigest digest = MessageDigest.getInstance("SHA-256");
-
-            byte[] buffer = new byte[1024];
-            for (int n = stream.read(buffer); n != -1; n = stream.read(buffer)) {
-                digest.update(buffer, 0, n);
+    public int compareTo(Blob blob) {
+        if (blob instanceof SegmentBlob) {
+            SegmentBlob that = (SegmentBlob) blob;
+            if (recordId.equals(that.recordId)) {
+                return 0;
             }
-
-            return digest.digest();
-        } catch (NoSuchAlgorithmException e) {
-            throw new UnsupportedOperationException("SHA256 not supported", e);
-        } finally {
-            stream.close();
         }
+        return super.compareTo(blob);
     }
 
     @Override
-    public int compareTo(Blob that) {
-        throw new UnsupportedOperationException();
+    public boolean equals(Object object) {
+        if (object instanceof SegmentBlob) {
+            SegmentBlob that = (SegmentBlob) object;
+            if (recordId.equals(that.recordId)) {
+                return true;
+            }
+        }
+        return super.equals(object);
     }
 
 }



Mime
View raw message