Ivan Provalov created SOLR-9730:
-----------------------------------

             Summary: IndexSchema Dynamic Field Definition Caching
                 Key: SOLR-9730
                 URL: https://issues.apache.org/jira/browse/SOLR-9730
             Project: Solr
          Issue Type: Improvement
      Security Level: Public (Default Security Level. Issues are Public)
          Components: Schema and Analysis
    Affects Versions: 6.2.1, 5.5.2
            Reporter: Ivan Provalov
            Priority: Minor


A small optimization suggestion for IndexSchema class, cache the definitions of 
the dynamic fields:

{code}
private Map<String, SchemaField> cachedDynamicFields = new HashMap<>();

@Override
        public SchemaField getFieldOrNull(String fieldName)
        {
                SchemaField f = fields.get(fieldName);
                if (f != null) return f;

                f = cachedDynamicFields.get(fieldName);
                if (f != null) return f;

                for (DynamicField df : dynamicFields) {
                        if (df.matches(fieldName)) {
                                f = df.makeSchemaField(fieldName);
                                cachedDynamicFields.put(fieldName, f);
                                return f;
                        }
                }
                return f;
        }
{code}

Are there any reasons not to do this?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to