thomasmueller commented on code in PR #2108:
URL: https://github.com/apache/jackrabbit-oak/pull/2108#discussion_r1975051828
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java:
##########
@@ -887,31 +884,36 @@ public IndexingRule getApplicableIndexingRule(String
primaryNodeType) {
public IndexingRule getApplicableIndexingRule(NodeState state) {
//This method would be invoked for every node. So be as
//conservative as possible in object creation
- List<IndexingRule> rules = null;
- List<IndexingRule> r = indexRules.get(getPrimaryTypeName(state));
- if (r != null) {
- rules = new ArrayList<>(r);
+ {
+ List<IndexingRule> rules =
indexRules.get(getPrimaryTypeName(state));
+ IndexingRule rule = getApplicableIndexingRule(state, rules);
+ if (rule != null) {
+ return rule;
+ }
}
Review Comment:
```suggestion
List<IndexingRule> rules = indexRules.get(getPrimaryTypeName(state));
IndexingRule rule = getApplicableIndexingRule(state, rules);
if (rule != null) {
return rule;
}
```
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java:
##########
@@ -887,31 +884,36 @@ public IndexingRule getApplicableIndexingRule(String
primaryNodeType) {
public IndexingRule getApplicableIndexingRule(NodeState state) {
//This method would be invoked for every node. So be as
//conservative as possible in object creation
- List<IndexingRule> rules = null;
- List<IndexingRule> r = indexRules.get(getPrimaryTypeName(state));
- if (r != null) {
- rules = new ArrayList<>(r);
+ {
+ List<IndexingRule> rules =
indexRules.get(getPrimaryTypeName(state));
+ IndexingRule rule = getApplicableIndexingRule(state, rules);
+ if (rule != null) {
+ return rule;
+ }
}
for (String name : getMixinTypeNames(state)) {
- r = indexRules.get(name);
- if (r != null) {
- if (rules == null) {
- rules = new ArrayList<>();
- }
- rules.addAll(r);
+ List<IndexingRule> rules = indexRules.get(name);
+ IndexingRule rule = getApplicableIndexingRule(state, rules);
Review Comment:
```suggestion
rule = getApplicableIndexingRule(state, rules);
```
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java:
##########
@@ -1302,16 +1307,16 @@ public boolean isBasedOnNtBase() {
return JcrConstants.NT_BASE.equals(baseNodeType);
}
- private Map<String, PropertyDefinition> collectPropConfigs(NodeState
config,
-
List<NamePattern> patterns,
-
List<Aggregate.Include> propAggregate,
-
List<PropertyDefinition> nonExistentProperties,
-
List<PropertyDefinition> existentProperties,
-
List<PropertyDefinition> nodeScopeAnalyzedProps,
-
List<PropertyDefinition> functionRestrictions,
-
List<PropertyDefinition> syncProps,
-
List<PropertyDefinition> similarityProperties) {
- Map<String, PropertyDefinition> propDefns = new HashMap<>();
+ private TreeMap<String, PropertyDefinition>
collectPropConfigs(NodeState config,
+
List<NamePattern> patterns,
+
List<Aggregate.Include> propAggregate,
+
List<PropertyDefinition> nonExistentProperties,
+
List<PropertyDefinition> existentProperties,
+
List<PropertyDefinition> nodeScopeAnalyzedProps,
+
List<PropertyDefinition> functionRestrictions,
+
List<PropertyDefinition> syncProps,
+
List<PropertyDefinition> similarityProperties) {
+ TreeMap<String, PropertyDefinition> propDefns = new
TreeMap<>(String.CASE_INSENSITIVE_ORDER);
Review Comment:
I'm not sure if TreeMap with CASE_INSENSITIVE_ORDER is faster than
HashMap... I know, toLowerCase is not needed, but then, aren't most property
names already lowercase? So toLowerCase() will just return "this".
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java:
##########
@@ -1395,27 +1400,27 @@ private Map<String, PropertyDefinition>
collectPropConfigs(NodeState config,
}
}
ensureNodeTypeIndexingIsConsistent(propDefns, syncProps);
- return Map.copyOf(propDefns);
Review Comment:
Hm, we used to copy the map... I don't know why... But are you sure this is
not needed?
--
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]