Hi, The DocumentStore doesn't really know the path, it only knows the key, and if the key is hashed you can't calculate the path.
There are some options: (a) Each document that has a hashed path as the key also has a "path" property (with the real path). You could use that (cache it, read it if needed, possibly from all backends). (b) Change the DocumentStore API: add the path in addition to the key. This is quite some work, and errors could be introduced here (the wrong path is passed and so on). Regards, Thomas On 21/08/15 11:57, "Bertrand Delacretaz" <[email protected]> wrote: >Hi, > >Continuing to play with Robert's MultiplexingDocumentStore [1] I got a >failure in the oak-jcr module's LongPathTest. > >That's due to the conversion of long paths to their hashed variants - >those cannot be used to locate the appropriate DocumentStore when >multiplexed, as that decision is based on the real path. In some cases >like UpdateOp the real path is saved alongside the hashed one, but not >always. > >Removing the path hashing as shown in the below patch removes that >problem, and all oak-core tests pass with this change. > >Is that hashing still needed, or was that created due to backend >limitations which are gone now? > >If still needed, could it be made configurable so that users can make >their own tradeoff (MultiplexingDocumentStore vs. supporting backends >that require that), or are there other constraints? > >-Bertrand > >[1] https://github.com/bdelacretaz/jackrabbit-oak/tree/bertrand-multiplex > > > >diff --git >a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/U >tils.java >b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/U >tils.java >index 4577c4b..d97ae76 100644 >--- >a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/U >tils.java >+++ >b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/U >tils.java >@@ -254,6 +254,7 @@ public class Utils { > } > > public static String getIdFromPath(String path) { >+ /* > if (isLongPath(path)) { > MessageDigest digest; > try { >@@ -267,6 +268,7 @@ public class Utils { > String name = PathUtils.getName(path); > return depth + ":h" + Hex.encodeHexString(hash) + "/" + name; > } >+ */ > int depth = Utils.pathDepth(path); > return depth + ":" + path; > } >diff --git >a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/U >tilsTest.java >b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/U >tilsTest.java >index b9f619e..5ed1a95 100644 >--- >a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/U >tilsTest.java >+++ >b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/U >tilsTest.java >@@ -32,6 +32,7 @@ import org.junit.Test; > > import static org.junit.Assert.assertEquals; > import static org.junit.Assert.assertNull; >+import static org.junit.Assert.assertNotNull; > import static org.junit.Assert.assertSame; > import static org.junit.Assert.assertTrue; > >@@ -62,7 +63,8 @@ public class UtilsTest { > String longPath = PathUtils.concat("/"+Strings.repeat("p", >Utils.PATH_LONG + 1), "foo"); > assertTrue(Utils.isLongPath(longPath)); > >- assertNull(Utils.getParentId(Utils.getIdFromPath(longPath))); >+ // updated to match the changes to Utils.getIdFromPath >+ assertNotNull(Utils.getParentId(Utils.getIdFromPath(longPath))); > > assertNull(Utils.getParentId(Utils.getIdFromPath("/"))); > assertEquals("1:/foo",Utils.getParentId("2:/foo/bar"));
