Skip to content

Commit

Permalink
Address review comments, rd 4
Browse files Browse the repository at this point in the history
  • Loading branch information
gerlowskija committed May 6, 2024
1 parent 32a8e4f commit 86e3166
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Update request processor created by {@link NumFieldLimitingUpdateRequestProcessorFactory} */
public class NumFieldLimitingUpdateRequestProcessor extends UpdateRequestProcessor {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

Expand All @@ -46,6 +47,7 @@ public NumFieldLimitingUpdateRequestProcessor(
this.warnOnly = warnOnly;
}

@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
if (coreExceedsFieldLimit()) {
throwExceptionOrLog(cmd.getPrintableId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ public class NumFieldLimitingUpdateRequestProcessorFactory extends UpdateRequest

@Override
public void inform(final SolrCore core) {
// register a commit callback for monitoring the number of fields in the schema
numFieldsMonitor = new NumFieldsMonitor(core);
core.getUpdateHandler().registerCommitCallback(numFieldsMonitor);
core.registerFirstSearcherListener(numFieldsMonitor);
core.registerNewSearcherListener(numFieldsMonitor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.solr.update.processor;

import java.io.IOException;
import org.apache.solr.core.AbstractSolrEventListener;
import org.apache.solr.core.SolrCore;
import org.apache.solr.search.SolrIndexSearcher;
Expand All @@ -27,13 +26,7 @@ public class NumFieldsMonitor extends AbstractSolrEventListener {

public NumFieldsMonitor(SolrCore core) {
super(core);

try {
core.withSearcher(s -> this.numFields = s.getFieldInfos().size());
} catch (IOException e) {
// Should not happen, but required by the signature of withSearcher above
this.numFields = -1;
}
this.numFields = -1;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,10 @@
</lst>
</requestHandler>

<updateProcessor class="solr.NumFieldLimitingUpdateRequestProcessorFactory" name="max-fields">
<int name="maxFields">${solr.test.maxFields:1234}</int>
</updateProcessor>
<updateProcessor class="solr.AddSchemaFieldsUpdateProcessorFactory" name="add-schema-fields">
<lst name="typeMapping">
<str name="valueClass">java.lang.String</str>
<str name="fieldType">text_general</str>
<lst name="copyField">
<str name="dest">*_str</str>
<int name="maxChars">256</int>
</lst>
<!-- Use as default mapping instead of defaultFieldType -->
<bool name="default">true</bool>
</lst>
</updateProcessor>
<updateRequestProcessorChain name="add-unknown-fields-to-the-schema" default="true"
processor="max-fields">
<updateRequestProcessorChain name="add-unknown-fields-to-the-schema" default="true">
<processor class="solr.NumFieldLimitingUpdateRequestProcessorFactory" name="max-fields">
<int name="maxFields">${solr.test.maxFields:1234}</int>
</processor>
<processor class="solr.LogUpdateProcessorFactory"/>
<processor class="solr.DistributedUpdateProcessorFactory"/>
<processor class="solr.RunUpdateProcessorFactory"/>
Expand Down

0 comments on commit 86e3166

Please sign in to comment.