jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1583661 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: api/ kernel/ plugins/blob/ plugins/memory/ plugins/segment/ plugins/segment/file/ plugins/value/
Date Tue, 01 Apr 2014 13:27:28 GMT
Author: mduerig
Date: Tue Apr  1 13:27:27 2014
New Revision: 1583661

URL: http://svn.apache.org/r1583661
Log:
OAK-1489: ValueImpl should implement JackrabbitValue
Add and use Blob.getContentIdentity such that Blob implementations can optimise the way the
identifier is calculated

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBlob.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreBlob.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/AbstractBlob.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentBlob.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileBlob.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java?rev=1583661&r1=1583660&r2=1583661&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/api/Blob.java Tue
Apr  1 13:27:27 2014
@@ -67,4 +67,24 @@ public interface Blob {
     @CheckForNull
     String getReference();
 
+    /**
+     * A unique identifier of the content of this value. Usually this is a
+     * message digest of the content (a cryptographically secure one-way hash).
+     * This allows to avoid processing large binary values multiple times.
+     * <p>
+     * This method returns null if the identifier is unknown. The identifier may
+     * not always be available, for example if the value has not yet been saved
+     * or processed. Once an identifier is available, it will never change
+     * because values are immutable.
+     * <p>
+     * If two values have the same identifier, the content of the value is
+     * guaranteed to be the same. However it is not guaranteed that two values
+     * with the same content will return the same identifier.
+     * <p>
+     * The identifier is opaque, meaning it can have any format and size.
+     *
+     * @return the unique identifier or null
+     */
+    @CheckForNull
+    String getContentIdentity();
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBlob.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBlob.java?rev=1583661&r1=1583660&r2=1583661&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBlob.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelBlob.java
Tue Apr  1 13:27:27 2014
@@ -69,6 +69,11 @@ public class KernelBlob extends Abstract
         return binaryID;
     }
 
+    @Override
+    public String getContentIdentity() {
+        return binaryID;
+    }
+
     /**
      * This implementation delegates back to the underlying {@code Microkernel}
      * if other is also of type {@code KernelBlob}.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreBlob.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreBlob.java?rev=1583661&r1=1583660&r2=1583661&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreBlob.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/blob/BlobStoreBlob.java
Tue Apr  1 13:27:27 2014
@@ -65,6 +65,11 @@ public class BlobStoreBlob implements Bl
         return blobStore.getReference(blobId);
     }
 
+    @Override
+    public String getContentIdentity() {
+        return blobId;
+    }
+
     public String getBlobId() {
         return blobId;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/AbstractBlob.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/AbstractBlob.java?rev=1583661&r1=1583660&r2=1583661&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/AbstractBlob.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/AbstractBlob.java
Tue Apr  1 13:27:27 2014
@@ -117,7 +117,12 @@ public abstract class AbstractBlob imple
         return null;
     }
 
-    //------------------------------------------------------------< Object >--
+    @Override
+    public String getContentIdentity() {
+        return null;
+    }
+
+//------------------------------------------------------------< Object >--
 
     /**
      * To {@code Blob} instances are considered equal iff they have the

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=1583661&r1=1583660&r2=1583661&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
Tue Apr  1 13:27:27 2014
@@ -21,6 +21,8 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.plugins.segment.Segment.SMALL_LIMIT;
 import static org.apache.jackrabbit.oak.plugins.segment.SegmentWriter.BLOCK_SIZE;
 
+import java.io.InputStream;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
@@ -28,8 +30,6 @@ import org.apache.jackrabbit.oak.api.Blo
 import org.apache.jackrabbit.oak.plugins.memory.AbstractBlob;
 import org.apache.jackrabbit.oak.spi.blob.BlobStore;
 
-import java.io.InputStream;
-
 class SegmentBlob extends Record implements Blob {
 
     SegmentBlob(RecordId id) {
@@ -120,6 +120,12 @@ class SegmentBlob extends Record impleme
         return null;
     }
 
+
+    @Override
+    public String getContentIdentity() {
+        return getRecordId().toString();
+    }
+
     public String getBlobId() {
         Segment segment = getSegment();
         int offset = getOffset();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileBlob.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileBlob.java?rev=1583661&r1=1583660&r2=1583661&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileBlob.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileBlob.java
Tue Apr  1 13:27:27 2014
@@ -16,15 +16,15 @@
  */
 package org.apache.jackrabbit.oak.plugins.segment.file;
 
-import org.apache.jackrabbit.oak.api.Blob;
-
-import javax.annotation.Nonnull;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
+import javax.annotation.Nonnull;
+
+import org.apache.jackrabbit.oak.api.Blob;
+
 public class FileBlob implements Blob {
 
     private final String path;
@@ -38,6 +38,11 @@ public class FileBlob implements Blob {
         return path; // FIXME: should be a secure reference
     }
 
+    @Override
+    public String getContentIdentity() {
+        return null;
+    }
+
     @Nonnull
     @Override
     public InputStream getNewStream() {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueImpl.java?rev=1583661&r1=1583660&r2=1583661&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/value/ValueImpl.java
Tue Apr  1 13:27:27 2014
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.oak.plugin
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
-import static org.apache.jackrabbit.oak.plugins.memory.AbstractBlob.calculateSha256;
 
 import java.io.InputStream;
 import java.math.BigDecimal;
@@ -262,7 +261,7 @@ public class ValueImpl implements Jackra
 
     @Override
     public String getContentIdentity() {
-        return calculateSha256(getBlob()).toString();
+        return getBlob().getContentIdentity();
     }
 
     //-------------------------------------------------------------< Object >---



Mime
View raw message