This is an automated email from the ASF dual-hosted git repository.
adulceanu pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 21b542d2e8 OAK-10311 - Optimize SegmentBlob#equals for segment blobs
that origin… (#1150)
21b542d2e8 is described below
commit 21b542d2e87c6e3351f23310e928f0dfbea33575
Author: Andrei Dulceanu <[email protected]>
AuthorDate: Wed Nov 15 18:24:35 2023 +0200
OAK-10311 - Optimize SegmentBlob#equals for segment blobs that origin…
(#1150)
* OAK-10311 - Optimize SegmentBlob#equals for segment blobs that originate
from the same blob store
* OAK-10311 - Optimize SegmentBlob#equals for segment blobs that originate
from the same blob store
Switched from content identity to blob id in comparison
---
.../java/org/apache/jackrabbit/oak/segment/SegmentBlob.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git
a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentBlob.java
b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentBlob.java
index 3bc438bcbb..9ab2ffea8d 100644
---
a/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentBlob.java
+++
b/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentBlob.java
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Set;
import org.apache.jackrabbit.oak.api.Blob;
+import org.apache.jackrabbit.oak.commons.properties.SystemPropertySupplier;
import org.apache.jackrabbit.oak.plugins.blob.BlobStoreBlob;
import org.apache.jackrabbit.oak.plugins.blob.datastore.InMemoryDataRecord;
import org.apache.jackrabbit.oak.plugins.memory.AbstractBlob;
@@ -41,6 +42,10 @@ import org.jetbrains.annotations.Nullable;
* A BLOB (stream of bytes). This is a record of type "VALUE".
*/
public class SegmentBlob extends Record implements Blob {
+ private static final boolean FAST_EQUALS_SAME_BLOBSTORE =
SystemPropertySupplier
+ .create("oak.segment.blob.fastEquals.same.blobstore", false)
+ .formatSetMessage( (name, value) -> String.format("%s set to: %s",
name, value) )
+ .get();
@Nullable
private final BlobStore blobStore;
@@ -192,6 +197,14 @@ public class SegmentBlob extends Record implements Blob {
}
}
+ if (FAST_EQUALS_SAME_BLOBSTORE) {
+ if (blobStore != null && this.blobStore.equals(that.blobStore)
&& this.isExternal() && that.isExternal()) {
+ if (this.getBlobId() != null && that.getBlobId() != null) {
+ return this.getBlobId().equals(that.getBlobId());
+ }
+ }
+ }
+
if (this.length() != that.length()) {
return false;
}