You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/08/12 15:51:37 UTC
[lucene-solr] branch reference_impl_dev updated: @534 Little
IndexSchema opti.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/reference_impl_dev by this push:
new a7bbb0f @534 Little IndexSchema opti.
a7bbb0f is described below
commit a7bbb0f22fd37191529814a7c1544e0a900cdc16
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Wed Aug 12 10:51:10 2020 -0500
@534 Little IndexSchema opti.
---
.../java/org/apache/solr/schema/IndexSchema.java | 32 ++++++++++------------
1 file changed, 15 insertions(+), 17 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 74aeac1..0f77aa3 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -23,6 +23,7 @@ import org.apache.lucene.queries.payloads.PayloadDecoder;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.util.Version;
import org.apache.solr.common.MapSerializable;
+import org.apache.solr.common.ParWork;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
@@ -145,7 +146,7 @@ public class IndexSchema {
public DynamicField[] getDynamicFields() { return dynamicFields; }
- protected Cache<String, SchemaField> dynamicFieldCache = new ConcurrentLRUCache(10000, 8000, 9000,100, false,false, null);
+ protected final Cache<String, SchemaField> dynamicFieldCache = new ConcurrentLRUCache(10000, 8000, 9000,100, false,false, null);
private Analyzer indexAnalyzer;
private Analyzer queryAnalyzer;
@@ -181,7 +182,6 @@ public class IndexSchema {
this.resourceName = Objects.requireNonNull(name);
try {
readSchema(is);
- // nocommit
loader.inform(loader);
} catch (IOException e) {
throw new RuntimeException(e);
@@ -634,8 +634,13 @@ public class IndexSchema {
protected void postReadInform() {
//Run the callbacks on SchemaAware now that everything else is done
- for (SchemaAware aware : schemaAware) {
- aware.inform(this);
+ try (ParWork work = new ParWork(this)) {
+ for (SchemaAware aware : schemaAware) {
+ work.collect(() -> {
+ aware.inform(this);
+ });
+ }
+ work.addCollect("postReadInform");
}
}
@@ -714,6 +719,8 @@ public class IndexSchema {
requiredFields.addAll(fieldsWithDefaultValue);
dynamicFields = dynamicFieldListToSortedArray(dFields);
+
+ fields = Collections.unmodifiableMap(fields);
return explicitRequiredProp;
}
@@ -826,10 +833,10 @@ public class IndexSchema {
* Register one or more new Dynamic Fields with the Schema.
* @param fields The sequence of {@link org.apache.solr.schema.SchemaField}
*/
- public void registerDynamicFields(SchemaField... fields) {
- List<DynamicField> dynFields = Collections.synchronizedList(new ArrayList<>(asList(dynamicFields)));
+ public synchronized void registerDynamicFields(SchemaField... fields) {
+ List<DynamicField> dynFields = new ArrayList<>(asList(dynamicFields));
for (SchemaField field : fields) {
- if (isDuplicateDynField(dynFields, field)) { Collections.synchronizedList(new ArrayList<>(asList(dynamicFields)));
+ if (isDuplicateDynField(dynFields, field)) { new ArrayList<>(asList(dynamicFields));
if (log.isDebugEnabled()) {
log.debug("dynamic field already exists: dynamic field: [{}]", field.getName());
}
@@ -859,16 +866,7 @@ public class IndexSchema {
registerCopyField(source, dest, CopyField.UNLIMITED);
}
- /**
- * <p>
- * NOTE: this function is not thread safe. However, it is safe to use within the standard
- * <code>inform( SolrCore core )</code> function for <code>SolrCoreAware</code> classes.
- * Outside <code>inform</code>, this could potentially throw a ConcurrentModificationException
- * </p>
- *
- * @see SolrCoreAware
- */
- public void registerCopyField(String source, String dest, int maxChars) {
+ public synchronized void registerCopyField(String source, String dest, int maxChars) {
log.debug("{} {}='{}' {}='{}' {}='{}'", COPY_FIELD, SOURCE, source, DESTINATION, dest
,MAX_CHARS, maxChars);