Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
kwin commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1991940097
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,45 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given item is an ancestor of the filter's root path.
* @param path path of the item to check
* @return {@code true} if the given item is an ancestor
*/
public boolean isAncestor(@NotNull String path) {
-return path.equals(root) || root.startsWith(path + "/") ||
"/".equals(path);
+boolean isAncestor = path.equals(root) || path.equals("/") ||
root.startsWith(path + "/");
+log.debug("isAncestor(root={}, path={}) -> {}", root, path,
isAncestor);
+return isAncestor;
+}
+
+/**
+ * Matches the given path with this filter's root. If it is an ancestor,
returns the name of the first
+ * path segment of the remaining filter root "below" path.
+ *
+ * @param path Path to check
+ * @return first path segment of non-matched path, or {@code null} when
path not ancestor
+ */
+public @Nullable String getDirectChildNameTowardsFilterRoot(@NotNull
String path) {
+String result = null;
+
+String rootMatch = appendSlashIfNeeded(root);
+String pathMatch = appendSlashIfNeeded(path);
+
+if (rootMatch.startsWith(pathMatch)) {
+// get filter root after matching path (will exclude leading "/"
+String rel = rootMatch.substring(pathMatch.length());
+
+// truncate before first "/"
+int slashPos = rel.indexOf('/');
+if (slashPos >= 0) {
+rel = rel.substring(0, slashPos);
+}
+
+result = rel.isEmpty() ? null : rel;
+}
+
+log.debug("getChildNameBelowRoot(root={}, path={}) -> {}", rootMatch,
pathMatch, result);
Review Comment:
This is inconsistent with the current name of the method.
##
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/ManySiblingsIT.java:
##
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.vault.packaging.integration;
+
+import org.apache.jackrabbit.oak.commons.junit.LogCustomizer;
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.impl.AggregateImpl;
+import org.apache.jackrabbit.vault.packaging.ExportOptions;
+import org.apache.jackrabbit.vault.packaging.VaultPackage;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.event.Level;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+public class ManySiblingsIT extends IntegrationTestBase {
+
+@BeforeClass
+public static void initRepository() throws RepositoryException,
IOException {
+initRepository(true, false); // always use BlobStore with Oak
+}
+
+// JCRVLT-789
+@Test
+public void testManySiblings() throws RepositoryException, IOException {
Review Comment:
I think some more tests with filters above or outside the path with the many
children should be added (or this one being extended).
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,45 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given item is an ancestor of the filter's root path.
Review Comment:
I think what was meant was rather
`Checks if the given path is an ancestor of the fi
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke merged PR #362: URL: https://github.com/apache/jackrabbit-filevault/pull/362 -- 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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
kwin commented on PR #362: URL: https://github.com/apache/jackrabbit-filevault/pull/362#issuecomment-2724811915 Hopefully fixed by https://github.com/apache/jackrabbit-filevault/commit/a5a62070cc93151bf12d08d579bad2cf4c474b00. -- 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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
kwin commented on PR #362: URL: https://github.com/apache/jackrabbit-filevault/pull/362#issuecomment-2724707496 Looks good now, but ASF Jenkins crashes when executing ITs. Now sure it is related to the one you added. -- 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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1995358075
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,68 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given path is an ancestor of the filter's root path.
* @param path path of the item to check
* @return {@code true} if the given item is an ancestor
*/
public boolean isAncestor(@NotNull String path) {
-return path.equals(root) || root.startsWith(path + "/") ||
"/".equals(path);
+boolean isAncestor = path.equals(root) || path.equals("/") ||
root.startsWith(path + "/");
+log.debug("isAncestor(root={}, path={}) -> {}", root, path,
isAncestor);
+return isAncestor;
+}
+
+/**
+ * Matches the given path with this filter's root. If it is an ancestor,
returns the name of the first
+ * path segment of the remaining filter root "below" path. If it's
unrelated, return an empty string
+ * (indicating that no child node will ever math). Otherwise return {@code
null).}
+ *
+ * @param path Path to check
+ * @return first path segment of non-matched path, or {@code null} when
path not ancestor
+ */
+public @Nullable String getDirectChildNameTowardsFilterRoot(@NotNull
String path) {
Review Comment:
See
https://github.com/apache/jackrabbit-filevault/pull/362/commits/788f046f872005736806c458a43954edc18cd597
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362: URL: https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1995265847 ## vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/SiblingIterationIT.java: ## @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.vault.packaging.integration; + +import org.apache.jackrabbit.oak.commons.junit.LogCustomizer; +import org.apache.jackrabbit.vault.fs.api.PathFilterSet; +import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter; +import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf; +import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter; +import org.apache.jackrabbit.vault.fs.impl.AggregateImpl; +import org.apache.jackrabbit.vault.packaging.ExportOptions; +import org.apache.jackrabbit.vault.packaging.VaultPackage; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.event.Level; + +import javax.jcr.Node; +import javax.jcr.RepositoryException; +import javax.jcr.nodetype.NodeType; +import java.io.File; +import java.io.IOException; +import java.util.Properties; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +/** + * Tests checking whether siblings Review Comment: Indeed. -- 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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1994823556
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,68 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given path is an ancestor of the filter's root path.
* @param path path of the item to check
* @return {@code true} if the given item is an ancestor
*/
public boolean isAncestor(@NotNull String path) {
-return path.equals(root) || root.startsWith(path + "/") ||
"/".equals(path);
+boolean isAncestor = path.equals(root) || path.equals("/") ||
root.startsWith(path + "/");
+log.debug("isAncestor(root={}, path={}) -> {}", root, path,
isAncestor);
+return isAncestor;
+}
+
+/**
+ * Matches the given path with this filter's root. If it is an ancestor,
returns the name of the first
+ * path segment of the remaining filter root "below" path. If it's
unrelated, return an empty string
+ * (indicating that no child node will ever math). Otherwise return {@code
null).}
+ *
+ * @param path Path to check
+ * @return first path segment of non-matched path, or {@code null} when
path not ancestor
+ */
+public @Nullable String getDirectChildNameTowardsFilterRoot(@NotNull
String path) {
Review Comment:
In the unit tests, I assume?
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on PR #362: URL: https://github.com/apache/jackrabbit-filevault/pull/362#issuecomment-2720844116 If have now refactored tests, added coverage for more combinations, and added a case "we know no children are covered". I *believe* the "null" case is gone now, but would like to get feedback before I kill it. @cc @kwin and @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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
kwin commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1993744775
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,68 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given path is an ancestor of the filter's root path.
* @param path path of the item to check
* @return {@code true} if the given item is an ancestor
*/
public boolean isAncestor(@NotNull String path) {
-return path.equals(root) || root.startsWith(path + "/") ||
"/".equals(path);
+boolean isAncestor = path.equals(root) || path.equals("/") ||
root.startsWith(path + "/");
+log.debug("isAncestor(root={}, path={}) -> {}", root, path,
isAncestor);
+return isAncestor;
+}
+
+/**
+ * Matches the given path with this filter's root. If it is an ancestor,
returns the name of the first
+ * path segment of the remaining filter root "below" path. If it's
unrelated, return an empty string
+ * (indicating that no child node will ever math). Otherwise return {@code
null).}
+ *
+ * @param path Path to check
+ * @return first path segment of non-matched path, or {@code null} when
path not ancestor
+ */
+public @Nullable String getDirectChildNameTowardsFilterRoot(@NotNull
String path) {
Review Comment:
A Unit test would be nice for this.
##
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/SiblingIterationIT.java:
##
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.packaging.integration;
+
+import org.apache.jackrabbit.oak.commons.junit.LogCustomizer;
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.impl.AggregateImpl;
+import org.apache.jackrabbit.vault.packaging.ExportOptions;
+import org.apache.jackrabbit.vault.packaging.VaultPackage;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.event.Level;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests checking whether siblings
Review Comment:
this sentence should have a verb :-)
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1992928596
##
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/ManySiblingsIT.java:
##
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.vault.packaging.integration;
+
+import org.apache.jackrabbit.oak.commons.junit.LogCustomizer;
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.impl.AggregateImpl;
+import org.apache.jackrabbit.vault.packaging.ExportOptions;
+import org.apache.jackrabbit.vault.packaging.VaultPackage;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.event.Level;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+public class ManySiblingsIT extends IntegrationTestBase {
+
+@BeforeClass
+public static void initRepository() throws RepositoryException,
IOException {
+initRepository(true, false); // always use BlobStore with Oak
+}
+
+// JCRVLT-789
+@Test
+public void testManySiblings() throws RepositoryException, IOException {
Review Comment:
I have now added a test for case 2, as expected the outcome is unnessary
iteration.
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1992037094
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,45 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given item is an ancestor of the filter's root path.
Review Comment:
Yes. What I meant was: this is consistent with the Javadoc for other methods
here - such as `covers()`. Should I use the opportunity to fix those as well?
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1992105659
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,45 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given item is an ancestor of the filter's root path.
* @param path path of the item to check
* @return {@code true} if the given item is an ancestor
*/
public boolean isAncestor(@NotNull String path) {
-return path.equals(root) || root.startsWith(path + "/") ||
"/".equals(path);
+boolean isAncestor = path.equals(root) || path.equals("/") ||
root.startsWith(path + "/");
+log.debug("isAncestor(root={}, path={}) -> {}", root, path,
isAncestor);
+return isAncestor;
+}
+
+/**
+ * Matches the given path with this filter's root. If it is an ancestor,
returns the name of the first
+ * path segment of the remaining filter root "below" path.
+ *
+ * @param path Path to check
+ * @return first path segment of non-matched path, or {@code null} when
path not ancestor
+ */
+public @Nullable String getDirectChildNameTowardsFilterRoot(@NotNull
String path) {
+String result = null;
+
+String rootMatch = appendSlashIfNeeded(root);
+String pathMatch = appendSlashIfNeeded(path);
+
+if (rootMatch.startsWith(pathMatch)) {
Review Comment:
Well, we can avoid those for the comparison (which internally normalizes),
but we'd need it anyway for the string operations below.
It would be nice to have something like "getDescendantRelativeTo", but right
now it's not there (could be inspired by nio Path
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#relativize-java.nio.file.Path-.
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,45 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given item is an ancestor of the filter's root path.
* @param path path of the item to check
* @return {@code true} if the given item is an ancestor
*/
public boolean isAncestor(@NotNull String path) {
-return path.equals(root) || root.startsWith(path + "/") ||
"/".equals(path);
+boolean isAncestor = path.equals(root) || path.equals("/") ||
root.startsWith(path + "/");
+log.debug("isAncestor(root={}, path={}) -> {}", root, path,
isAncestor);
+return isAncestor;
+}
+
+/**
+ * Matches the given path with this filter's root. If it is an ancestor,
returns the name of the first
+ * path segment of the remaining filter root "below" path.
+ *
+ * @param path Path to check
+ * @return first path segment of non-matched path, or {@code null} when
path not ancestor
+ */
+public @Nullable String getDirectChildNameTowardsFilterRoot(@NotNull
String path) {
+String result = null;
+
+String rootMatch = appendSlashIfNeeded(root);
+String pathMatch = appendSlashIfNeeded(path);
+
+if (rootMatch.startsWith(pathMatch)) {
Review Comment:
Well, we can avoid those for the comparison (which internally normalizes),
but we'd need it anyway for the string operations below.
It would be nice to have something like "getDescendantRelativeTo", but right
now it's not there (could be inspired by nio Path
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#relativize-java.nio.file.Path-).
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1992037476
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,45 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given item is an ancestor of the filter's root path.
* @param path path of the item to check
* @return {@code true} if the given item is an ancestor
*/
public boolean isAncestor(@NotNull String path) {
-return path.equals(root) || root.startsWith(path + "/") ||
"/".equals(path);
+boolean isAncestor = path.equals(root) || path.equals("/") ||
root.startsWith(path + "/");
+log.debug("isAncestor(root={}, path={}) -> {}", root, path,
isAncestor);
+return isAncestor;
+}
+
+/**
+ * Matches the given path with this filter's root. If it is an ancestor,
returns the name of the first
+ * path segment of the remaining filter root "below" path.
+ *
+ * @param path Path to check
+ * @return first path segment of non-matched path, or {@code null} when
path not ancestor
+ */
+public @Nullable String getDirectChildNameTowardsFilterRoot(@NotNull
String path) {
+String result = null;
+
+String rootMatch = appendSlashIfNeeded(root);
+String pathMatch = appendSlashIfNeeded(path);
+
+if (rootMatch.startsWith(pathMatch)) {
+// get filter root after matching path (will exclude leading "/"
+String rel = rootMatch.substring(pathMatch.length());
+
+// truncate before first "/"
+int slashPos = rel.indexOf('/');
+if (slashPos >= 0) {
+rel = rel.substring(0, slashPos);
+}
+
+result = rel.isEmpty() ? null : rel;
+}
+
+log.debug("getChildNameBelowRoot(root={}, path={}) -> {}", rootMatch,
pathMatch, result);
Review Comment:
ack
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1992037094
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,45 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given item is an ancestor of the filter's root path.
Review Comment:
Yes. What I meant was: this is consistent with the Javadoc for other methods
here. Should I use the opportunity to fix those as well?
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1992034954
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java:
##
@@ -102,6 +103,19 @@ public interface WorkspaceFilter extends Dumpable {
*/
boolean isAncestor(@NotNull String path);
+/**
+ * Matches the given path with all filter roots. For each, if it is an
ancestor,
+ * add the name of the first path segment of the remaining filter root
"below" path
+ * to the result set.
+ *
+ * @param path Path to check
+ * @return first path segments of non-matched paths, or {@code null} when
result set
Review Comment:
Well - `null` is the safe approach, because it means doing exactly what we
did before.
And no, I'm not sure. I'm trying to improve one specific use case (for which
I happen to have an integration test to verify). We probably can improve more
cases, but my personal preference would be to do that when we figure out that
it's needed - for instance when the current improvement can't be applied
because there is a second completely unrelated filter.
Does this make sense?
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1991351820
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,45 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given item is an ancestor of the filter's root path.
Review Comment:
it's consistent with the method above; should I change both?
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
mbaedke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1991238323
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,45 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given item is an ancestor of the filter's root path.
Review Comment:
s/given item/given path
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1990696015
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java:
##
@@ -102,6 +103,19 @@ public interface WorkspaceFilter extends Dumpable {
*/
boolean isAncestor(@NotNull String path);
+/**
+ * Matches the given path with all filter roots. For each, if it is an
ancestor,
+ * add the name of the first path segment of the remaining filter root
"below" path
+ * to the result set.
+ *
+ * @param path Path to check
+ * @return first path segments of non-matched paths, or {@code null} when
result set
Review Comment:
Attempted to clarify, please check.
(Note that there may be room for improvements here, but for now the change
is sufficient for my use case)
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1990696015
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java:
##
@@ -102,6 +103,19 @@ public interface WorkspaceFilter extends Dumpable {
*/
boolean isAncestor(@NotNull String path);
+/**
+ * Matches the given path with all filter roots. For each, if it is an
ancestor,
+ * add the name of the first path segment of the remaining filter root
"below" path
+ * to the result set.
+ *
+ * @param path Path to check
+ * @return first path segments of non-matched paths, or {@code null} when
result set
Review Comment:
Attempted to clariffy, please check.
(Note that there may be room for improvements here, but for now the change
is sufficient for my use case)
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1990188179
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java:
##
@@ -102,6 +103,19 @@ public interface WorkspaceFilter extends Dumpable {
*/
boolean isAncestor(@NotNull String path);
+/**
+ * Matches the given path with all filter roots. For each, if it is an
ancestor,
+ * add the name of the first path segment of the remaining filter root
"below" path
+ * to the result set.
+ *
+ * @param path Path to check
+ * @return first path segments of non-matched paths, or {@code null} when
result set
Review Comment:
It would return null, because in that case we can't optimize? So clarify the
docs?
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
kwin commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1989918936
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java:
##
@@ -102,6 +103,19 @@ public interface WorkspaceFilter extends Dumpable {
*/
boolean isAncestor(@NotNull String path);
+/**
+ * Matches the given path with all filter roots. For each, if it is an
ancestor,
+ * add the name of the first path segment of the remaining filter root
"below" path
+ * to the result set.
+ *
+ * @param path Path to check
+ * @return first path segments of non-matched paths, or {@code null} when
result set
Review Comment:
The condition when null is returned is not really clear. What if only some
roots are no offsprings of the given path?
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1989825433
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,45 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given item is an ancestor of the filter's root path.
* @param path path of the item to check
* @return {@code true} if the given item is an ancestor
*/
public boolean isAncestor(@NotNull String path) {
-return path.equals(root) || root.startsWith(path + "/") ||
"/".equals(path);
+boolean isAncestor = path.equals(root) || path.equals("/") ||
root.startsWith(path + "/");
+log.debug("isAncestor(root={}, path={}) -> {}", root, path,
isAncestor);
+return isAncestor;
+}
+
+/**
+ * Matches the given path with this filter's root. If it is an ancestor,
returns the name of the first
+ * path segment of the remaining filter root "below" path.
+ *
+ * @param path Path to check
+ * @return first path segment of non-matched path, or {@code null} when
path not ancestor
+ */
+public @Nullable String getChildNameBelowFilterRoot(@NotNull String path) {
Review Comment:
ack
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
kwin commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1989797974
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/FilterSet.java:
##
@@ -239,12 +243,45 @@ public boolean covers(@NotNull String path) {
}
/**
- * Checks if the given item is an ancestor of the root node.
+ * Checks if the given item is an ancestor of the filter's root path.
* @param path path of the item to check
* @return {@code true} if the given item is an ancestor
*/
public boolean isAncestor(@NotNull String path) {
-return path.equals(root) || root.startsWith(path + "/") ||
"/".equals(path);
+boolean isAncestor = path.equals(root) || path.equals("/") ||
root.startsWith(path + "/");
+log.debug("isAncestor(root={}, path={}) -> {}", root, path,
isAncestor);
+return isAncestor;
+}
+
+/**
+ * Matches the given path with this filter's root. If it is an ancestor,
returns the name of the first
+ * path segment of the remaining filter root "below" path.
+ *
+ * @param path Path to check
+ * @return first path segment of non-matched path, or {@code null} when
path not ancestor
+ */
+public @Nullable String getChildNameBelowFilterRoot(@NotNull String path) {
Review Comment:
likewise `getDirectChildNameTowardsFilterRoot`
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
reschke commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1989765982
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java:
##
@@ -102,6 +103,19 @@ public interface WorkspaceFilter extends Dumpable {
*/
boolean isAncestor(@NotNull String path);
+/**
+ * Matches the given path with all filter roots. For each, if it is an
ancestor,
+ * add the name of the first path segment of the remaining filter root
"below" path
+ * to the result set.
+ *
+ * @param path Path to check
+ * @return first path segments of non-matched paths, or {@code null} when
result set
+ * cam not be computed.
+ */
+default @Nullable Set getFirstChildNamesOfRootsBelowPath(@NotNull
String path) {
Review Comment:
yes, sounds good
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
kwin commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1989757415
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java:
##
@@ -102,6 +103,19 @@ public interface WorkspaceFilter extends Dumpable {
*/
boolean isAncestor(@NotNull String path);
+/**
+ * Matches the given path with all filter roots. For each, if it is an
ancestor,
+ * add the name of the first path segment of the remaining filter root
"below" path
+ * to the result set.
+ *
+ * @param path Path to check
+ * @return first path segments of non-matched paths, or {@code null} when
result set
+ * cam not be computed.
+ */
+default @Nullable Set getFirstChildNamesOfRootsBelowPath(@NotNull
String path) {
Review Comment:
maybe `getDirectChildNamesTowardsFilterRoots`?
--
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]
Re: [PR] JCRVLT-789: AggregateImpl - avoid iterating over sibling nodes [jackrabbit-filevault]
kwin commented on code in PR #362:
URL:
https://github.com/apache/jackrabbit-filevault/pull/362#discussion_r1989757415
##
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/api/WorkspaceFilter.java:
##
@@ -102,6 +103,19 @@ public interface WorkspaceFilter extends Dumpable {
*/
boolean isAncestor(@NotNull String path);
+/**
+ * Matches the given path with all filter roots. For each, if it is an
ancestor,
+ * add the name of the first path segment of the remaining filter root
"below" path
+ * to the result set.
+ *
+ * @param path Path to check
+ * @return first path segments of non-matched paths, or {@code null} when
result set
+ * cam not be computed.
+ */
+default @Nullable Set getFirstChildNamesOfRootsBelowPath(@NotNull
String path) {
Review Comment:
maybe `getDirectChildNamesTowardFilterRoots`?
--
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]
