Skip to content

Commit af2c0b3

Browse files
authored
IDE suggested cleanups (#2934)
Remove unused parameters and constants.
1 parent 2728f7a commit af2c0b3

File tree

7 files changed

+21
-44
lines changed

7 files changed

+21
-44
lines changed

solr/core/src/java/org/apache/solr/handler/designer/DefaultSampleDocumentsLoader.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ public SampleDocuments parseDocsFromStream(
117117
List<SolrInputDocument> docs = null;
118118
if (stream.getSize() > 0) {
119119
if (contentType.contains(JSON_MIME)) {
120-
docs = loadJsonDocs(params, byteStream, maxDocsToLoad);
120+
docs = loadJsonDocs(byteStream, maxDocsToLoad);
121121
} else if (contentType.contains("text/xml") || contentType.contains("application/xml")) {
122-
docs = loadXmlDocs(params, byteStream, maxDocsToLoad);
122+
docs = loadXmlDocs(byteStream, maxDocsToLoad);
123123
} else if (contentType.contains("text/csv") || contentType.contains("application/csv")) {
124124
docs = loadCsvDocs(params, fileSource, uploadedBytes, charset, maxDocsToLoad);
125125
} else if (contentType.contains("text/plain")
126126
|| contentType.contains("application/octet-stream")) {
127-
docs = loadJsonLines(params, byteStream, maxDocsToLoad);
127+
docs = loadJsonLines(byteStream, maxDocsToLoad);
128128
} else {
129129
throw new SolrException(
130130
SolrException.ErrorCode.BAD_REQUEST, contentType + " not supported yet!");
@@ -157,8 +157,7 @@ protected List<SolrInputDocument> loadCsvDocs(
157157

158158
@SuppressWarnings("unchecked")
159159
protected List<SolrInputDocument> loadJsonLines(
160-
SolrParams params, ContentStreamBase.ByteArrayStream stream, final int maxDocsToLoad)
161-
throws IOException {
160+
ContentStreamBase.ByteArrayStream stream, final int maxDocsToLoad) throws IOException {
162161
List<Map<String, Object>> docs = new ArrayList<>();
163162
try (Reader r = stream.getReader()) {
164163
BufferedReader br = new BufferedReader(r);
@@ -182,8 +181,7 @@ protected List<SolrInputDocument> loadJsonLines(
182181

183182
@SuppressWarnings("unchecked")
184183
protected List<SolrInputDocument> loadJsonDocs(
185-
SolrParams params, ContentStreamBase.ByteArrayStream stream, final int maxDocsToLoad)
186-
throws IOException {
184+
ContentStreamBase.ByteArrayStream stream, final int maxDocsToLoad) throws IOException {
187185
Object json;
188186
try (Reader r = stream.getReader()) {
189187
json = ObjectBuilder.getVal(new JSONParser(r));
@@ -231,8 +229,7 @@ protected List<SolrInputDocument> loadJsonDocs(
231229
}
232230

233231
protected List<SolrInputDocument> loadXmlDocs(
234-
SolrParams params, ContentStreamBase.ByteArrayStream stream, final int maxDocsToLoad)
235-
throws IOException {
232+
ContentStreamBase.ByteArrayStream stream, final int maxDocsToLoad) throws IOException {
236233
String xmlString = new String(readAllBytes(stream), StandardCharsets.UTF_8).trim();
237234
List<SolrInputDocument> docs;
238235
if (xmlString.contains("<add>") && xmlString.contains("<doc>")) {

solr/core/src/java/org/apache/solr/handler/designer/DefaultSchemaSuggester.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public Optional<SchemaField> suggestField(
163163
Locale locale = Locale.ROOT;
164164

165165
boolean isMV = isMultiValued(sampleValues);
166-
String fieldTypeName = guessFieldType(fieldName, sampleValues, schema, isMV, locale);
166+
String fieldTypeName = guessFieldType(sampleValues, isMV, locale);
167167
FieldType fieldType = schema.getFieldTypeByName(fieldTypeName);
168168
if (fieldType == null) {
169169
// TODO: construct this field type on-the-fly ...
@@ -222,12 +222,7 @@ public Map<String, List<Object>> transposeDocs(List<SolrInputDocument> docs) {
222222
return mapByField;
223223
}
224224

225-
protected String guessFieldType(
226-
String fieldName,
227-
final List<Object> sampleValues,
228-
IndexSchema schema,
229-
boolean isMV,
230-
Locale locale) {
225+
protected String guessFieldType(final List<Object> sampleValues, boolean isMV, Locale locale) {
231226
String type = null;
232227

233228
// flatten values to a single stream for easier analysis; also remove nulls
@@ -361,7 +356,7 @@ protected String isIntOrLong(List<Object> values, Locale locale) {
361356
}
362357

363358
// if all values are less than some smallish threshold, then it's likely this field holds small
364-
// numbers but be very conservative here as it's simply an optimization and we can always fall
359+
// numbers but be very conservative here as it's simply an optimization, and we can always fall
365360
// back to long
366361
return maxLong < 10000 ? "pint" : "plong";
367362
}

solr/core/src/java/org/apache/solr/handler/designer/SampleDocuments.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
package org.apache.solr.handler.designer;
1919

20-
import static org.apache.solr.common.params.CommonParams.JSON_MIME;
21-
2220
import java.util.ArrayList;
2321
import java.util.List;
2422
import java.util.Objects;
@@ -42,15 +40,6 @@ public String getSource() {
4240
return fileSource != null ? fileSource : "paste";
4341
}
4442

45-
private boolean isTextContentType() {
46-
if (contentType == null) {
47-
return false;
48-
}
49-
return contentType.contains(JSON_MIME)
50-
|| contentType.startsWith("text/")
51-
|| contentType.contains("application/xml");
52-
}
53-
5443
public List<SolrInputDocument> appendDocs(
5544
String idFieldName, List<SolrInputDocument> add, int maxDocsToLoad) {
5645
if (add != null && !add.isEmpty()) {
@@ -65,7 +54,7 @@ public List<SolrInputDocument> appendDocs(
6554
doc -> {
6655
Object id = doc.getFieldValue(idFieldName);
6756
return id != null
68-
&& !ids.contains(id); // doc has ID and it's not already in the set
57+
&& !ids.contains(id); // doc has ID, and it's not already in the set
6958
})
7059
.collect(Collectors.toList());
7160
parsed.addAll(toAdd);

solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import static org.apache.solr.client.solrj.SolrRequest.METHOD.PUT;
2323
import static org.apache.solr.common.params.CommonParams.JSON_MIME;
2424
import static org.apache.solr.handler.admin.ConfigSetsHandler.DEFAULT_CONFIGSET_NAME;
25-
import static org.apache.solr.schema.ManagedIndexSchemaFactory.DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME;
2625
import static org.apache.solr.security.PermissionNameProvider.Name.CONFIG_EDIT_PERM;
2726
import static org.apache.solr.security.PermissionNameProvider.Name.CONFIG_READ_PERM;
2827

@@ -85,7 +84,7 @@
8584
import org.slf4j.Logger;
8685
import org.slf4j.LoggerFactory;
8786

88-
/** All V2 APIs that have a prefix of /api/schema-designer/ */
87+
/** All V2 APIs have a prefix of /api/schema-designer/ */
8988
public class SchemaDesignerAPI implements SchemaDesignerConstants {
9089

9190
private static final Set<String> excludeConfigSetNames =
@@ -103,8 +102,8 @@ public class SchemaDesignerAPI implements SchemaDesignerConstants {
103102
public SchemaDesignerAPI(CoreContainer coreContainer) {
104103
this(
105104
coreContainer,
106-
SchemaDesignerAPI.newSchemaSuggester(coreContainer),
107-
SchemaDesignerAPI.newSampleDocumentsLoader(coreContainer));
105+
SchemaDesignerAPI.newSchemaSuggester(),
106+
SchemaDesignerAPI.newSampleDocumentsLoader());
108107
}
109108

110109
SchemaDesignerAPI(
@@ -119,13 +118,13 @@ public SchemaDesignerAPI(CoreContainer coreContainer) {
119118
this.settingsDAO = new SchemaDesignerSettingsDAO(coreContainer, configSetHelper);
120119
}
121120

122-
public static SchemaSuggester newSchemaSuggester(CoreContainer coreContainer) {
121+
public static SchemaSuggester newSchemaSuggester() {
123122
DefaultSchemaSuggester suggester = new DefaultSchemaSuggester();
124123
suggester.init(new NamedList<>());
125124
return suggester;
126125
}
127126

128-
public static SampleDocumentsLoader newSampleDocumentsLoader(CoreContainer coreContainer) {
127+
public static SampleDocumentsLoader newSampleDocumentsLoader() {
129128
SampleDocumentsLoader loader = new DefaultSampleDocumentsLoader();
130129
loader.init(new NamedList<>());
131130
return loader;
@@ -520,7 +519,8 @@ public void publish(SolrQueryRequest req, SolrQueryResponse rsp)
520519
final String configSet = getRequiredParam(CONFIG_SET_PARAM, req);
521520
final String mutableId = checkMutable(configSet, req);
522521

523-
// verify the configSet we're going to apply changes to has not changed since being loaded for
522+
// verify the configSet we're going to apply changes to hasn't been changed since being loaded
523+
// for
524524
// editing by the schema designer
525525
SchemaDesignerSettings settings = settingsDAO.getSettings(mutableId);
526526
final Optional<Integer> publishedVersion = settings.getPublishedVersion();
@@ -845,7 +845,7 @@ protected SampleDocuments loadSampleDocuments(SolrQueryRequest req, String confi
845845
latestSchema.getUniqueKeyField().getName(), stored, MAX_SAMPLE_DOCS);
846846
}
847847

848-
// store in the blob store so we always have access to these docs
848+
// store in the blob store so that we always have access to these docs
849849
configSetHelper.storeSampleDocs(configSet, docs);
850850
}
851851
}
@@ -892,10 +892,6 @@ protected ManagedIndexSchema analyzeInputDocs(
892892
return schema;
893893
}
894894

895-
protected String getManagedSchemaZkPath(final String configSet) {
896-
return getConfigSetZkPath(configSet, DEFAULT_MANAGED_SCHEMA_RESOURCE_NAME);
897-
}
898-
899895
protected SchemaDesignerSettings getMutableSchemaForConfigSet(
900896
final String configSet, final int schemaVersion, String copyFrom) throws IOException {
901897
// The designer works with mutable config sets stored in a "temp" znode in ZK instead of the

solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ private boolean isMatchingLangOrNonLangFile(final String path, final Set<String>
10521052
}
10531053
}
10541054

1055-
// if we fall thru to here, then the file should be excluded
1055+
// if we fall through to here, then the file should be excluded
10561056
return false;
10571057
}
10581058

solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ public void testFieldUpdates() throws Exception {
740740

741741
String mutableId = getMutableId(configSet);
742742
SchemaDesignerConfigSetHelper configSetHelper =
743-
new SchemaDesignerConfigSetHelper(cc, SchemaDesignerAPI.newSchemaSuggester(cc));
743+
new SchemaDesignerConfigSetHelper(cc, SchemaDesignerAPI.newSchemaSuggester());
744744
ManagedIndexSchema schema = schemaDesignerAPI.loadLatestSchema(mutableId);
745745

746746
// make it required

solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerConfigSetHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void setupTest() {
7878
assertNotNull(cluster);
7979
cc = cluster.getJettySolrRunner(0).getCoreContainer();
8080
assertNotNull(cc);
81-
helper = new SchemaDesignerConfigSetHelper(cc, SchemaDesignerAPI.newSchemaSuggester(cc));
81+
helper = new SchemaDesignerConfigSetHelper(cc, SchemaDesignerAPI.newSchemaSuggester());
8282
}
8383

8484
@Test

0 commit comments

Comments
 (0)