reschke commented on code in PR #2810:
URL: https://github.com/apache/jackrabbit-oak/pull/2810#discussion_r3016029577


##########
oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/cli/MigrationFactory.java:
##########
@@ -125,4 +125,91 @@ private List<CommitHook> loadCommitHooks() {
         return 
Collections.unmodifiableList(ListUtils.toList(loader.iterator()));
     }
 
+    /**
+     * Wraps An Oak BlobStore around a Jackrabbit Datastore
+     */
+    private static class ToJackrabbitDataStoreDelegatingBlobStore implements 
BlobStore {
+
+        private org.apache.jackrabbit.core.data.DataStore delegate;
+
+        public ToJackrabbitDataStoreDelegatingBlobStore(
+                org.apache.jackrabbit.core.data.DataStore delegate) {
+            this.delegate = delegate;
+        }
+
+        @Override
+        public String writeBlob(InputStream inputStream) throws IOException {
+            try {
+                org.apache.jackrabbit.core.data.DataRecord record = 
delegate.addRecord(inputStream);
+                return record.getIdentifier().toString();
+            } catch (org.apache.jackrabbit.core.data.DataStoreException ex) {
+                throw new IOException("Failed to write blob", ex);
+            }
+        }
+
+        @Override
+        public String writeBlob(InputStream inputStream, BlobOptions options) 
throws IOException {
+            try {
+                org.apache.jackrabbit.core.data.DataRecord record = 
delegate.addRecord(inputStream);
+                return record.getIdentifier().toString();
+            } catch (org.apache.jackrabbit.core.data.DataStoreException ex) {
+                throw new IOException("Failed to write blob", ex);
+            }
+        }
+
+        @Override
+        public int readBlob(String blobId, long pos, byte[] buff, int off, int 
length)
+                throws IOException {
+
+            try (InputStream is = getInputStream(blobId)) {
+
+                if (pos > 0) {
+                    long skipped = is.skip(pos);
+                    if (skipped < pos) {
+                        return -1;
+                    }
+                }
+
+                return is.read(buff, off, length);

Review Comment:
   ok, writing a test that exercises just the skipping method is simple, but it 
would only prove that `skipNBytes` works, which we should assume.
   
   The only other thing that actually would be interesting would be a real IT.
   
   Given the fact that this is "almost dead" code anyway, I'd prefer not to do 
it.
   
   Instead, we should remove the "upgrade" code path (JR->OAK) and just leave 
the "sidegrade" functionality in. Should I open a separate ticket for that? (cc 
@mbaedke )



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to