thomasmueller commented on code in PR #1066:
URL: https://github.com/apache/jackrabbit-oak/pull/1066#discussion_r1309908376
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/IndexName.java:
##########
@@ -231,26 +231,37 @@ public String nextCustomizedName() {
}
public static boolean isIndexActive(String indexPath, NodeState rootState)
{
+ return isIndexActive(indexPath, rootState, 0);
+ }
+
+ private static boolean isIndexActive(String indexPath, NodeState
rootState, int recursionDepth) {
// An index is active if it has a hidden child node that starts with
":oak:mount-",
// OR if it is an active merged index
- try {
- NodeState indexNode = rootState;
- for (String e : PathUtils.elements(indexPath)) {
- indexNode = indexNode.getChildNode(e);
+ if (recursionDepth > 50) {
+ LOG.warn("Fail to check index activeness for {} due to high
recursion depth", indexPath);
Review Comment:
Logging the recursion depths seems only needed if we make it configurable.
But OK, it doesn't hurt.
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/IndexName.java:
##########
@@ -231,26 +231,37 @@ public String nextCustomizedName() {
}
public static boolean isIndexActive(String indexPath, NodeState rootState)
{
+ return isIndexActive(indexPath, rootState, 0);
+ }
+
+ private static boolean isIndexActive(String indexPath, NodeState
rootState, int recursionDepth) {
// An index is active if it has a hidden child node that starts with
":oak:mount-",
// OR if it is an active merged index
- try {
- NodeState indexNode = rootState;
- for (String e : PathUtils.elements(indexPath)) {
- indexNode = indexNode.getChildNode(e);
+ if (recursionDepth > 50) {
Review Comment:
I'm not quite sure what the added indirection would help in this case: we
only use the setting once. But OK, I'll add a constant.
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/IndexName.java:
##########
@@ -231,26 +231,37 @@ public String nextCustomizedName() {
}
public static boolean isIndexActive(String indexPath, NodeState rootState)
{
+ return isIndexActive(indexPath, rootState, 0);
+ }
+
+ private static boolean isIndexActive(String indexPath, NodeState
rootState, int recursionDepth) {
// An index is active if it has a hidden child node that starts with
":oak:mount-",
// OR if it is an active merged index
- try {
- NodeState indexNode = rootState;
- for (String e : PathUtils.elements(indexPath)) {
- indexNode = indexNode.getChildNode(e);
+ if (recursionDepth > 50) {
+ LOG.warn("Fail to check index activeness for {} due to high
recursion depth", indexPath);
+ return true;
+ }
+ NodeState indexNode = rootState;
+ for (String e : PathUtils.elements(indexPath)) {
+ indexNode = indexNode.getChildNode(e);
+ }
+ for (String c : indexNode.getChildNodeNames()) {
+ if (c.startsWith(":oak:mount-")) {
+ return true;
}
- for (String c : indexNode.getChildNodeNames()) {
- if (c.startsWith(":oak:mount-")) {
- return true;
- }
+ }
+ if (recursionDepth >= 2) {
Review Comment:
Level 1 (the direct children) will still need to check.
> Is there a test for this case?
Yes: CustomizedIndexTest and IndexNameTest are in the patch. The test
coverage of the changes is 100% as far as I see.
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/IndexName.java:
##########
@@ -231,26 +231,37 @@ public String nextCustomizedName() {
}
public static boolean isIndexActive(String indexPath, NodeState rootState)
{
+ return isIndexActive(indexPath, rootState, 0);
+ }
+
+ private static boolean isIndexActive(String indexPath, NodeState
rootState, int recursionDepth) {
// An index is active if it has a hidden child node that starts with
":oak:mount-",
// OR if it is an active merged index
- try {
- NodeState indexNode = rootState;
- for (String e : PathUtils.elements(indexPath)) {
- indexNode = indexNode.getChildNode(e);
+ if (recursionDepth > 50) {
+ LOG.warn("Fail to check index activeness for {} due to high
recursion depth", indexPath);
+ return true;
+ }
+ NodeState indexNode = rootState;
+ for (String e : PathUtils.elements(indexPath)) {
+ indexNode = indexNode.getChildNode(e);
+ }
Review Comment:
This is a _loop_ over all the entries in the path, to go down to the
respective node. This code is not changed.
--
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]