You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 10:09:07 UTC
[lucene] 10/23: javadocs and other review comments
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch jira/solr14827
in repository https://gitbox.apache.org/repos/asf/lucene.git
commit 504740f1551591f35f690b6cb96c4b684e085a7a
Author: noble <no...@apache.org>
AuthorDate: Sat Oct 10 17:36:31 2020 +1100
javadocs and other review comments
---
.../src/java/org/apache/solr/schema/IndexSchema.java | 6 +++---
.../src/java/org/apache/solr/util/DataConfigNode.java | 4 ++--
.../src/java/org/apache/solr/common/ConfigNode.java | 18 ++++++++++++++++--
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
index 20281e3..97d786b 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -561,16 +561,16 @@ public class IndexSchema {
if (node != null) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Setting defaultSearchField in schema not supported since Solr 7");
}
- node = rootNode.child("solrQueryParser");
- // /schema/solrQueryParser/@defaultOperator
+ ///schema/solrQueryParser/@defaultOperator
// expression = stepsToPath(SCHEMA, "solrQueryParser", AT + "defaultOperator");
// node = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
+ node = rootNode.child(it -> it.attributes().get("defaultOperator") != null, "solrQueryParser");
if (node != null) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Setting default operator in schema (solrQueryParser/@defaultOperator) not supported");
}
- // /schema/uniqueKey/text()
+ // /schema/uniqueKey/text()
// expression = stepsToPath(SCHEMA, UNIQUE_KEY, TEXT_FUNCTION);
// node = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
node = rootNode.child(UNIQUE_KEY);
diff --git a/solr/core/src/java/org/apache/solr/util/DataConfigNode.java b/solr/core/src/java/org/apache/solr/util/DataConfigNode.java
index 9c825e8..29afd67 100644
--- a/solr/core/src/java/org/apache/solr/util/DataConfigNode.java
+++ b/solr/core/src/java/org/apache/solr/util/DataConfigNode.java
@@ -105,9 +105,9 @@ public class DataConfigNode implements ConfigNode {
}
@Override
- public List<ConfigNode> children(Predicate<ConfigNode> test, Set<String> set) {
+ public List<ConfigNode> children(Predicate<ConfigNode> test, Set<String> matchNames) {
List<ConfigNode> result = new ArrayList<>();
- for (String s : set) {
+ for (String s : matchNames) {
List<ConfigNode> vals = kids.get(s);
if (vals != null) {
vals.forEach(it -> {
diff --git a/solr/solrj/src/java/org/apache/solr/common/ConfigNode.java b/solr/solrj/src/java/org/apache/solr/common/ConfigNode.java
index 0f6a813..44ac4ff 100644
--- a/solr/solrj/src/java/org/apache/solr/common/ConfigNode.java
+++ b/solr/solrj/src/java/org/apache/solr/common/ConfigNode.java
@@ -53,6 +53,8 @@ public interface ConfigNode {
return child(null, name);
}
+ /**Iterate through child nodes with the name and return the first child that matches
+ */
default ConfigNode child(Predicate<ConfigNode> test, String name) {
ConfigNode[] result = new ConfigNode[1];
forEachChild(it -> {
@@ -66,14 +68,22 @@ public interface ConfigNode {
return result[0];
}
+ /**Iterate through child nodes with the names and return all the matching children
+ * @param nodeNames names of tags to be returned
+ * @param test check for the nodes to be returned
+ */
default List<ConfigNode> children(Predicate<ConfigNode> test, String... nodeNames) {
return children(test, nodeNames == null ? Collections.emptySet() : Set.of(nodeNames));
}
- default List<ConfigNode> children(Predicate<ConfigNode> test, Set<String> set) {
+ /**Iterate through child nodes with the names and return all the matching children
+ * @param matchNames names of tags to be returned
+ * @param test check for the nodes to be returned
+ */
+ default List<ConfigNode> children(Predicate<ConfigNode> test, Set<String> matchNames) {
List<ConfigNode> result = new ArrayList<>();
forEachChild(it -> {
- if (set != null && !set.isEmpty() && !set.contains(it.name())) return Boolean.TRUE;
+ if (matchNames != null && !matchNames.isEmpty() && !matchNames.contains(it.name())) return Boolean.TRUE;
if (test == null || test.test(it)) result.add(it);
return Boolean.TRUE;
});
@@ -84,6 +94,10 @@ public interface ConfigNode {
return children(null, Collections.singleton(name));
}
+ /** abortable iterate through child
+ *
+ * @param fun consume the node and return true to continue or false to abort
+ */
void forEachChild(Function<ConfigNode, Boolean> fun);