ErickErickson commented on a change in pull request #706: URL: https://github.com/apache/solr/pull/706#discussion_r815320067
########## File path: solr/solrj/src/java/org/apache/solr/common/params/AnalysisParams.java ########## @@ -19,41 +19,31 @@ /** * Defines the request parameters used by all analysis request handlers. * - * * @since solr 1.4 */ public interface AnalysisParams { - /** - * The prefix for all parameters. - */ + /** The prefix for all parameters. */ static final String PREFIX = "analysis"; - /** - * Holds the query to be analyzed. - */ + /** Holds the query to be analyzed. */ static final String QUERY = PREFIX + ".query"; /** - * Set to {@code true} to indicate that the index tokens that match query tokens should be marked as "matched". + * Set to {@code true} to indicate that the index tokens that match query tokens should be marked + * as "matched". */ static final String SHOW_MATCH = PREFIX + ".showmatch"; + // ===================================== FieldAnalysisRequestHandler Params Review comment: don't break? ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java ########## @@ -264,9 +282,10 @@ public void setStreamContext(StreamContext context) { } /** - * Opens the CloudSolrStream - * - ***/ + * Opens the CloudSolrStream + * + * <p>* Review comment: delete <p> and extra lines. ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/comp/FieldComparator.java ########## @@ -180,13 +194,14 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; FieldComparator that = (FieldComparator) o; - return leftFieldName.equals(that.leftFieldName) && - rightFieldName.equals(that.rightFieldName) && - order == that.order; // comparator is based on the other fields so is not needed in this compare + return leftFieldName.equals(that.leftFieldName) + && rightFieldName.equals(that.rightFieldName) + && order == that.order; // comparator is based on the other fields so is not needed in this + // compare Review comment: somehow don't break comment. ########## File path: solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientTest.java ########## @@ -16,33 +16,36 @@ */ package org.apache.solr.client.solrj.impl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.io.IOException; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.solr.client.solrj.ResponseParser; import org.apache.solr.common.params.ModifiableSolrParams; import org.junit.Test; -import java.io.IOException; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -/** - * Test the LBHttpSolrClient. - */ +/** Test the LBHttpSolrClient. */ public class LBHttpSolrClientTest { - + /** * Test method for {@link LBHttpSolrClient.Builder}. - * - * Validate that the parser passed in is used in the <code>HttpSolrClient</code> instances created. + * + * <p>Validate that the parser passed in is used in the <code>HttpSolrClient</code> instances + * created. */ @Test - // commented out on: 17-Feb-2019 @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // added 20-Sep-2018 + // commented out on: 17-Feb-2019 + // @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // added Review comment: Should we take the whole comment out? I noticed other places you removed all the BadApple stuff, I don't know whether we're paying any attention to them any more. I fact, I did a grep of this checkout and these files contain commented-out BadApple annotations, remove them all? ./src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExplanationTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExplanationTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpessionTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionToExpessionTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java: ./src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java: I'm sure I missed some before I thought to make the first comment about removing them, so here they are. ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/cloud/ShardTerms.java ########## @@ -100,15 +103,16 @@ public ShardTerms increaseTerms(String leader, Set<String> replicasNeedingRecove String key = entry.getKey(); if (replicasNeedingRecovery.contains(key)) foundReplicasInLowerTerms = true; if (Objects.equals(entry.getValue(), leaderTerm)) { - if(skipIncreaseTermOf(key, replicasNeedingRecovery)) { + if (skipIncreaseTermOf(key, replicasNeedingRecovery)) { saveChanges = true; // if we don't skip anybody, then there's no reason to increment } else { entry.setValue(leaderTerm + 1); } } } - // We should skip the optimization if there are no replicasNeedingRecovery present in local terms, + // We should skip the optimization if there are no replicasNeedingRecovery present in local + // terms, Review comment: tighten ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TextLogitStream.java ########## @@ -318,7 +364,8 @@ public void setStreamContext(StreamContext context) { /** * Opens the CloudSolrStream * - ***/ + * <p>* Review comment: delete <p> ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/UpdateStream.java ########## @@ -293,56 +330,64 @@ private void setCloudSolrClient() { this.cloudSolrClient.connect(); } } - + private SolrInputDocument convertTupleToSolrDocument(Tuple tuple) { SolrInputDocument doc = new SolrInputDocument(); for (String field : tuple.getFields().keySet()) { - if (! (field.equals(CommonParams.VERSION_FIELD) && pruneVersionField)) { + if (!(field.equals(CommonParams.VERSION_FIELD) && pruneVersionField)) { Object value = tuple.get(field); if (value instanceof List) { - addMultivaluedField(doc, field, (List<?>)value); + addMultivaluedField(doc, field, (List<?>) value); } else { doc.addField(field, value); } } } log.debug("Tuple [{}] was converted into SolrInputDocument [{}].", tuple, doc); - + return doc; } - + private void addMultivaluedField(SolrInputDocument doc, String fieldName, List<?> values) { for (Object value : values) { doc.addField(fieldName, value); } } - + /** - * This method will be called on every batch of tuples comsumed, after converting each tuple - * in that batch to a Solr Input Document. + * This method will be called on every batch of tuples comsumed, after converting each tuple in + * that batch to a Solr Input Document. */ protected void uploadBatchToCollection(List<SolrInputDocument> documentBatch) throws IOException { if (documentBatch.size() == 0) { return; } - + try { cloudSolrClient.add(collection, documentBatch); } catch (SolrServerException | IOException e) { // TODO: it would be nice if there was an option to "skipFailedBatches" - // TODO: and just record the batch failure info in the summary tuple for that batch and continue + // TODO: and just record the batch failure info in the summary tuple for that batch and + // continue // - // TODO: The summary batches (and/or stream error) should also pay attention to the error metadata + // TODO: The summary batches (and/or stream error) should also pay attention to the error + // metadata Review comment: tighten up. ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ParallelMetricsRollup.java ########## @@ -121,7 +130,8 @@ if (count != null) { nextRollup = new WeightedSumMetric(next.getIdentifier(), count.getIdentifier()); } else { - return Optional.empty(); // can't properly rollup mean metrics w/o a count (reqd by WeightedSumMetric) + return Optional.empty(); // can't properly rollup mean metrics w/o a count (reqd by Review comment: awkward breakup ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java ########## @@ -720,19 +749,21 @@ protected RouteException getRouteException(SolrException.ErrorCode serverError, NamedList<Object> cheader = new NamedList<>(); cheader.add("status", status); cheader.add("QTime", timeMillis); - if (rf != null) - cheader.add(UpdateRequest.REPFACT, rf); + if (rf != null) cheader.add(UpdateRequest.REPFACT, rf); if (null != toleratedErrors) { cheader.add("maxErrors", ToleratedUpdateError.getUserFriendlyMaxErrors(maxToleratedErrors)); cheader.add("errors", toleratedErrors); if (maxToleratedErrors < toleratedErrors.size()) { // cumulative errors are too high, we need to throw a client exception w/correct metadata - // NOTE: it shouldn't be possible for 1 == toleratedErrors.size(), because if that were the case + // NOTE: it shouldn't be possible for 1 == toleratedErrors.size(), because if that were the + // case Review comment: Tighten up? ########## File path: solr/solrj/src/java/org/apache/solr/common/MapWriter.java ########## @@ -17,63 +17,64 @@ package org.apache.solr.common; - import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; import java.util.function.BiPredicate; - import org.apache.solr.common.util.Utils; /** - * Use this class to push all entries of a Map into an output. - * This avoids creating map instances and is supposed to be memory efficient. - * If the entries are primitives, unnecessary boxing is also avoided. + * Use this class to push all entries of a Map into an output. This avoids creating map instances + * and is supposed to be memory efficient. If the entries are primitives, unnecessary boxing is also + * avoided. */ -public interface MapWriter extends MapSerializable , NavigableObject { +public interface MapWriter extends MapSerializable, NavigableObject { - default String jsonStr(){ + default String jsonStr() { return Utils.toJSONString(this); } @Override @SuppressWarnings({"unchecked", "rawtypes"}) - default Map<String,Object> toMap(Map<String, Object> map) { + default Map<String, Object> toMap(Map<String, Object> map) { try { - writeMap(new EntryWriter() { - @Override - public EntryWriter put(CharSequence k, Object v) { - if (v instanceof MapWriter) v = ((MapWriter) v).toMap(new LinkedHashMap<>()); - if (v instanceof IteratorWriter) v = ((IteratorWriter) v).toList(new ArrayList<>()); - if (v instanceof Iterable) { - List lst = new ArrayList(); - for (Object vv : (Iterable)v) { - if (vv instanceof MapWriter) vv = ((MapWriter) vv).toMap(new LinkedHashMap<>()); - if (vv instanceof IteratorWriter) vv = ((IteratorWriter) vv).toList(new ArrayList<>()); - lst.add(vv); - } - v = lst; - } - if (v instanceof Map) { - Map map = new LinkedHashMap(); - for (Map.Entry<?, ?> entry : ((Map<?, ?>)v).entrySet()) { - Object vv = entry.getValue(); - if (vv instanceof MapWriter) vv = ((MapWriter) vv).toMap(new LinkedHashMap<>()); - if (vv instanceof IteratorWriter) vv = ((IteratorWriter) vv).toList(new ArrayList<>()); - map.put(entry.getKey(), vv); + writeMap( + new EntryWriter() { + @Override + public EntryWriter put(CharSequence k, Object v) { + if (v instanceof MapWriter) v = ((MapWriter) v).toMap(new LinkedHashMap<>()); + if (v instanceof IteratorWriter) v = ((IteratorWriter) v).toList(new ArrayList<>()); + if (v instanceof Iterable) { + List lst = new ArrayList(); + for (Object vv : (Iterable) v) { + if (vv instanceof MapWriter) vv = ((MapWriter) vv).toMap(new LinkedHashMap<>()); + if (vv instanceof IteratorWriter) + vv = ((IteratorWriter) vv).toList(new ArrayList<>()); + lst.add(vv); + } + v = lst; + } + if (v instanceof Map) { + Map map = new LinkedHashMap(); + for (Map.Entry<?, ?> entry : ((Map<?, ?>) v).entrySet()) { + Object vv = entry.getValue(); + if (vv instanceof MapWriter) vv = ((MapWriter) vv).toMap(new LinkedHashMap<>()); + if (vv instanceof IteratorWriter) + vv = ((IteratorWriter) vv).toList(new ArrayList<>()); + map.put(entry.getKey(), vv); + } + v = map; + } + map.put(k == null ? null : k.toString(), v); + // note: It'd be nice to assert that there is no previous value at 'k' but it's + // possible the passed in Review comment: awkward breakup ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java ########## @@ -225,13 +225,15 @@ void sendUpdateStream() throws Exception { } InputStreamResponseListener responseListener = null; - try (Http2SolrClient.OutStream out = client.initOutStream(basePath, update.getRequest(), - update.getCollection())) { + try (Http2SolrClient.OutStream out = + client.initOutStream(basePath, update.getRequest(), update.getCollection())) { Update upd = update; while (upd != null) { UpdateRequest req = upd.getRequest(); if (!out.belongToThisStream(req, upd.getCollection())) { - queue.add(upd); // Request has different params or destination core/collection, return to queue + queue.add( + upd); // Request has different params or destination core/collection, return Review comment: move comment up rather than break it ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/response/AnalysisResponseBase.java ########## @@ -122,15 +122,16 @@ protected TokenInfo buildTokenInfo(NamedList<?> tokenNL) { int end = (Integer) tokenNL.get("end"); int position = (Integer) tokenNL.get("position"); Boolean match = (Boolean) tokenNL.get("match"); - return new TokenInfo(text, rawText, type, start, end, position, (match == null ? false : match)); + return new TokenInfo( + text, rawText, type, start, end, position, (match == null ? false : match)); } - - //================================================= Inner Classes ================================================== + // ================================================= Inner Classes Review comment: don't break ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RecursiveEvaluator.java ########## @@ -41,160 +40,151 @@ public abstract class RecursiveEvaluator implements StreamEvaluator, ValueWorker { protected static final long serialVersionUID = 1L; protected StreamContext streamContext; - + protected UUID nodeId = UUID.randomUUID(); - + protected StreamFactory constructingFactory; - + protected List<StreamEvaluator> containedEvaluators = new ArrayList<StreamEvaluator>(); - - public RecursiveEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{ + + public RecursiveEvaluator(StreamExpression expression, StreamFactory factory) throws IOException { this(expression, factory, new ArrayList<>()); } - - protected Object normalizeInputType(Object value){ - if(null == value){ + + protected Object normalizeInputType(Object value) { + if (null == value) { return null; } else if (value instanceof VectorFunction) { return value; - } - else if(value instanceof Double){ - if(Double.isNaN((Double)value)){ + } else if (value instanceof Double) { + if (Double.isNaN((Double) value)) { return null; } return new BigDecimal(value.toString()); - } - else if(value instanceof BigDecimal){ - return (BigDecimal)value; - } - else if(value instanceof Number){ + } else if (value instanceof BigDecimal) { + return (BigDecimal) value; + } else if (value instanceof Number) { return new BigDecimal(value.toString()); - } - else if(value instanceof Collection){ - //Let's first check to see if we have a List of Strings. - //If we do let's try and convert to a list of doubles and see what happens + } else if (value instanceof Collection) { + // Let's first check to see if we have a List of Strings. + // If we do let's try and convert to a list of doubles and see what happens try { List<Number> vector = new ArrayList<>(); boolean allDoubles = true; - for(Object o : (Collection)value) { - if(o instanceof String) { + for (Object o : (Collection) value) { + if (o instanceof String) { Double d = Double.parseDouble(o.toString()); vector.add(d); } else { allDoubles = false; break; } } - if(allDoubles) { + if (allDoubles) { return vector; } - } catch(Exception e) { + } catch (Exception e) { } - return ((Collection<?>)value).stream().map(innerValue -> normalizeInputType(innerValue)).collect(Collectors.toList()); - } - else if(value.getClass().isArray()){ + return ((Collection<?>) value) + .stream().map(innerValue -> normalizeInputType(innerValue)).collect(Collectors.toList()); + } else if (value.getClass().isArray()) { Stream<?> stream = Stream.empty(); - if(value instanceof double[]){ - stream = Arrays.stream((double[])value).boxed(); - } - else if(value instanceof int[]){ - stream = Arrays.stream((int[])value).boxed(); - } - else if(value instanceof long[]){ - stream = Arrays.stream((long[])value).boxed(); + if (value instanceof double[]) { + stream = Arrays.stream((double[]) value).boxed(); + } else if (value instanceof int[]) { + stream = Arrays.stream((int[]) value).boxed(); + } else if (value instanceof long[]) { + stream = Arrays.stream((long[]) value).boxed(); + } else if (value instanceof String[]) { + stream = Arrays.stream((String[]) value); } - else if(value instanceof String[]){ - stream = Arrays.stream((String[])value); - } return stream.map(innerValue -> normalizeInputType(innerValue)).collect(Collectors.toList()); - } - else{ + } else { // anything else can just be returned as is return value; } - } - + protected Object normalizeOutputType(Object value) { - if(null == value){ + if (null == value) { return null; } else if (value instanceof VectorFunction) { return value; - } else if(value instanceof BigDecimal){ - BigDecimal bd = (BigDecimal)value; + } else if (value instanceof BigDecimal) { + BigDecimal bd = (BigDecimal) value; return bd.doubleValue(); - } - else if(value instanceof Long || value instanceof Integer) { + } else if (value instanceof Long || value instanceof Integer) { return ((Number) value).longValue(); - } - else if(value instanceof Double){ + } else if (value instanceof Double) { return value; - } - else if(value instanceof Number){ + } else if (value instanceof Number) { return ((Number) value).doubleValue(); - } - else if(value instanceof List){ + } else if (value instanceof List) { // normalize each value in the list - return ((List<?>)value).stream().map(innerValue -> normalizeOutputType(innerValue)).collect(Collectors.toList()); - } else if(value instanceof Tuple && value.getClass().getEnclosingClass() == null) { - //If its a tuple and not a inner class that has extended tuple, which is done in a number of cases so that mathematical models - //can be contained within a tuple. + return ((List<?>) value) + .stream().map(innerValue -> normalizeOutputType(innerValue)).collect(Collectors.toList()); + } else if (value instanceof Tuple && value.getClass().getEnclosingClass() == null) { + // If its a tuple and not a inner class that has extended tuple, which is done in a number of + // cases so that mathematical models Review comment: awkward break ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/request/beans/RejoinLeaderElectionPayload.java ########## @@ -22,23 +22,18 @@ public class RejoinLeaderElectionPayload implements ReflectMapWriter { - // TODO It seems like most of these properties should be required, but it's hard to tell which ones are meant to be - // required without that being specified on the v1 API or elsewhere - @JsonProperty - public String collection; + // TODO It seems like most of these properties should be required, but it's hard to tell which + // ones are meant to be + // required without that being specified on the v1 API or elsewhere Review comment: awkward break ########## File path: solr/solrj/src/test/org/apache/solr/client/solrj/TestSolrJErrorHandling.java ########## @@ -129,43 +128,49 @@ public boolean hasNext() { @Override public SolrInputDocument next() { int id = base + count++; - if (count == 1) { // first doc is legit, and will increment a counter - return sdoc("id","test", "count_i", map("inc",1)); + if (count == 1) { // first doc is legit, and will increment a counter + return sdoc("id", "test", "count_i", map("inc", 1)); } - // include "ignore_exception" so the log doesn't fill up with known exceptions, and change the values for each doc + // include "ignore_exception" so the log doesn't fill up with known exceptions, and change + // the values for each doc // so binary format won't compress too much - return sdoc("id",Integer.toString(id),"ignore_exception_field_does_not_exist_"+id,"fieldval"+id); + return sdoc( Review comment: tighten up ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java ########## @@ -407,142 +482,172 @@ public String getCollection() { } } - if(buff.length() > 0) { + if (buff.length() > 0) { sorts.add(buff.toString()); } return sorts.toArray(new String[sorts.size()]); } - - private void init(String collection, SolrParams params, Bucket[] buckets, FieldComparator[] bucketSorts, Metric[] metrics, int rows, int offset, int bucketSizeLimit, boolean refine, String method, boolean serializeBucketSizeLimit, int overfetch, String zkHost) throws IOException { - this.zkHost = zkHost; + private void init( + String collection, + SolrParams params, + Bucket[] buckets, + FieldComparator[] bucketSorts, + Metric[] metrics, + int rows, + int offset, + int bucketSizeLimit, + boolean refine, + String method, + boolean serializeBucketSizeLimit, + int overfetch, + String zkHost) + throws IOException { + this.zkHost = zkHost; this.params = new ModifiableSolrParams(params); this.buckets = buckets; this.metrics = metrics; this.rows = rows; this.offset = offset; this.refine = refine; - this.bucketSizeLimit = bucketSizeLimit; + this.bucketSizeLimit = bucketSizeLimit; this.collection = collection; this.bucketSorts = bucketSorts; this.method = method; this.serializeBucketSizeLimit = serializeBucketSizeLimit; this.overfetch = overfetch; - + // In a facet world it only makes sense to have the same field name in all of the sorters // Because FieldComparator allows for left and right field names we will need to validate // that they are the same - for(FieldComparator sort : bucketSorts){ - if(sort.hasDifferentFieldNames()){ - throw new IOException("Invalid FacetStream - all sorts must be constructed with a single field name."); + for (FieldComparator sort : bucketSorts) { + if (sort.hasDifferentFieldNames()) { + throw new IOException( + "Invalid FacetStream - all sorts must be constructed with a single field name."); } } } - + @Override - public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException { + public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException { // function name StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass())); - + // collection - if(collection.indexOf(',') > -1) { - expression.addParameter("\""+collection+"\""); + if (collection.indexOf(',') > -1) { + expression.addParameter("\"" + collection + "\""); } else { expression.addParameter(collection); } - + // parameters for (Entry<String, String[]> param : params.getMap().entrySet()) { for (String val : param.getValue()) { expression.addParameter(new StreamExpressionNamedParameter(param.getKey(), val)); } } - + // buckets { StringBuilder builder = new StringBuilder(); - for(Bucket bucket : buckets){ - if(0 != builder.length()){ builder.append(","); } + for (Bucket bucket : buckets) { + if (0 != builder.length()) { + builder.append(","); + } builder.append(bucket.toString()); } expression.addParameter(new StreamExpressionNamedParameter("buckets", builder.toString())); } - + // bucketSorts { StringBuilder builder = new StringBuilder(); - for(FieldComparator sort : bucketSorts){ - if(0 != builder.length()){ builder.append(","); } + for (FieldComparator sort : bucketSorts) { + if (0 != builder.length()) { + builder.append(","); + } builder.append(sort.toExpression(factory)); } - expression.addParameter(new StreamExpressionNamedParameter("bucketSorts", builder.toString())); + expression.addParameter( + new StreamExpressionNamedParameter("bucketSorts", builder.toString())); } - + // metrics - for(Metric metric : metrics){ + for (Metric metric : metrics) { expression.addParameter(metric.toExpression(factory)); } - - if(serializeBucketSizeLimit) { - if(bucketSizeLimit == Integer.MAX_VALUE) { - expression.addParameter(new StreamExpressionNamedParameter("bucketSizeLimit", Integer.toString(-1))); + + if (serializeBucketSizeLimit) { + if (bucketSizeLimit == Integer.MAX_VALUE) { + expression.addParameter( + new StreamExpressionNamedParameter("bucketSizeLimit", Integer.toString(-1))); } else { - expression.addParameter(new StreamExpressionNamedParameter("bucketSizeLimit", Integer.toString(bucketSizeLimit))); + expression.addParameter( + new StreamExpressionNamedParameter( + "bucketSizeLimit", Integer.toString(bucketSizeLimit))); } } else { if (rows == Integer.MAX_VALUE) { expression.addParameter(new StreamExpressionNamedParameter("rows", Integer.toString(-1))); - } else{ + } else { expression.addParameter(new StreamExpressionNamedParameter("rows", Integer.toString(rows))); } - expression.addParameter(new StreamExpressionNamedParameter("offset", Integer.toString(offset))); + expression.addParameter( + new StreamExpressionNamedParameter("offset", Integer.toString(offset))); - if(overfetch == Integer.MAX_VALUE) { - expression.addParameter(new StreamExpressionNamedParameter("overfetch", Integer.toString(-1))); + if (overfetch == Integer.MAX_VALUE) { + expression.addParameter( + new StreamExpressionNamedParameter("overfetch", Integer.toString(-1))); } else { - expression.addParameter(new StreamExpressionNamedParameter("overfetch", Integer.toString(overfetch))); + expression.addParameter( + new StreamExpressionNamedParameter("overfetch", Integer.toString(overfetch))); } } - if(method != null) { + if (method != null) { expression.addParameter(new StreamExpressionNamedParameter("method", this.method)); } - + // zkHost expression.addParameter(new StreamExpressionNamedParameter("zkHost", zkHost)); - - return expression; + + return expression; } @Override public Explanation toExplanation(StreamFactory factory) throws IOException { StreamExplanation explanation = new StreamExplanation(getStreamNodeId().toString()); - + explanation.setFunctionName(factory.getFunctionName(this.getClass())); explanation.setImplementingClass(this.getClass().getName()); explanation.setExpressionType(ExpressionType.STREAM_SOURCE); explanation.setExpression(toExpression(factory).toString()); - + // child is a datastore so add it at this point StreamExplanation child = new StreamExplanation(getStreamNodeId() + "-datastore"); - child.setFunctionName(String.format(Locale.ROOT, "solr (%s)", collection)); - // TODO: fix this so we know the # of workers - check with Joel about a Topic's ability to be in a + child.setFunctionName(String.format(Locale.ROOT, "solr (%s)", collection)); + // TODO: fix this so we know the # of workers - check with Joel about a Topic's ability to be in + // a Review comment: tighten up ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FeaturesSelectionStream.java ########## @@ -238,7 +262,8 @@ public void setStreamContext(StreamContext context) { /** * Opens the CloudSolrStream * - ***/ + * <p>* Review comment: remove <p> ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TimeSeriesStream.java ########## @@ -294,13 +319,18 @@ public Explanation toExplanation(StreamFactory factory) throws IOException { // child is a datastore so add it at this point StreamExplanation child = new StreamExplanation(getStreamNodeId() + "-datastore"); child.setFunctionName(String.format(Locale.ROOT, "solr (%s)", collection)); - // TODO: fix this so we know the # of workers - check with Joel about a Topic's ability to be in a + // TODO: fix this so we know the # of workers - check with Joel about a Topic's ability to be in + // a Review comment: tighten ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SearchFacadeStream.java ########## @@ -120,7 +121,8 @@ public void setStreamContext(StreamContext context) { /** * Opens the CloudSolrStream * - ***/ + * <p>* Review comment: tighten up ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/StatsStream.java ########## @@ -222,18 +226,21 @@ public void setStreamContext(StreamContext context) { public void open() throws IOException { @SuppressWarnings({"unchecked"}) - Map<String, List<String>> shardsMap = (Map<String, List<String>>)context.get("shards"); + Map<String, List<String>> shardsMap = (Map<String, List<String>>) context.get("shards"); // Parallelize the stats stream across multiple collections for an alias using plist if possible if (shardsMap == null && params.getBool(TIERED_PARAM, defaultTieredEnabled)) { - ClusterStateProvider clusterStateProvider = cache.getCloudSolrClient(zkHost).getClusterStateProvider(); - final List<String> resolved = clusterStateProvider != null ? clusterStateProvider.resolveAlias(collection) : null; + ClusterStateProvider clusterStateProvider = + cache.getCloudSolrClient(zkHost).getClusterStateProvider(); + final List<String> resolved = + clusterStateProvider != null ? clusterStateProvider.resolveAlias(collection) : null; if (resolved != null && resolved.size() > 1) { Optional<TupleStream> maybeParallelize = openParallelStream(context, resolved, metrics); if (maybeParallelize.isPresent()) { this.parallelizedStream = maybeParallelize.get(); return; // we're using a plist to parallelize the facet operation - } // else, there's a metric that we can't rollup over the plist results safely ... no plist for you! + } // else, there's a metric that we can't rollup over the plist results safely ... no plist + // for you! Review comment: awkward ########## File path: solr/solrj/src/java/org/noggit/JSONParser.java ########## @@ -414,7 +398,8 @@ protected boolean matchBareWord(char[] arr) throws IOException { } } - // if we don't allow bare strings, we don't need to check that the string actually terminates... just + // if we don't allow bare strings, we don't need to check that the string actually terminates... Review comment: awkward comment split ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java ########## @@ -553,87 +658,98 @@ public void setStreamContext(StreamContext context) { } public void open() throws IOException { - if(cache != null) { + if (cache != null) { cloudSolrClient = cache.getCloudSolrClient(zkHost); } else { final List<String> hosts = new ArrayList<>(); hosts.add(zkHost); - cloudSolrClient = new Builder(hosts, Optional.empty()).withSocketTimeout(30000).withConnectionTimeout(15000).build(); + cloudSolrClient = + new Builder(hosts, Optional.empty()) + .withSocketTimeout(30000) + .withConnectionTimeout(15000) + .build(); } - // Parallelize the facet expression across multiple collections for an alias using plist if possible + // Parallelize the facet expression across multiple collections for an alias using plist if + // possible if (params.getBool(TIERED_PARAM, defaultTieredEnabled)) { ClusterStateProvider clusterStateProvider = cloudSolrClient.getClusterStateProvider(); - final List<String> resolved = clusterStateProvider != null ? clusterStateProvider.resolveAlias(collection) : null; + final List<String> resolved = + clusterStateProvider != null ? clusterStateProvider.resolveAlias(collection) : null; if (resolved != null && resolved.size() > 1) { Optional<TupleStream> maybeParallelize = openParallelStream(context, resolved, metrics); if (maybeParallelize.isPresent()) { this.parallelizedStream = maybeParallelize.get(); return; // we're using a plist to parallelize the facet operation - } // else, there's a metric that we can't rollup over the plist results safely ... no plist for you! + } // else, there's a metric that we can't rollup over the plist results safely ... no plist Review comment: reword or somehow not break ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java ########## @@ -412,73 +412,74 @@ public void waitForState(String collection, long wait, TimeUnit unit, Predicate< * Register a CollectionStateWatcher to be called when the cluster state for a collection changes * <em>or</em> the set of live nodes changes. * - * <p> - * The Watcher will automatically be removed when it's - * <code>onStateChanged</code> returns <code>true</code> - * </p> + * <p>The Watcher will automatically be removed when it's <code>onStateChanged</code> returns + * <code>true</code> * - * <p> - * This implementation utilizes {@link ZkStateReader#registerCollectionStateWatcher} internally. - * Callers that don't care about liveNodes are encouraged to use a {@link DocCollectionWatcher} - * instead - * </p> + * <p>This implementation utilizes {@link ZkStateReader#registerCollectionStateWatcher} + * internally. Callers that don't care about liveNodes are encouraged to use a {@link + * DocCollectionWatcher} instead * * @see #registerDocCollectionWatcher(String, DocCollectionWatcher) * @see ZkStateReader#registerCollectionStateWatcher * @param collection the collection to watch - * @param watcher a watcher that will be called when the state changes + * @param watcher a watcher that will be called when the state changes */ public void registerCollectionStateWatcher(String collection, CollectionStateWatcher watcher) { getClusterStateProvider().connect(); assertZKStateProvider().zkStateReader.registerCollectionStateWatcher(collection, watcher); } - + /** * Register a DocCollectionWatcher to be called when the cluster state for a collection changes. * - * <p> - * The Watcher will automatically be removed when it's - * <code>onStateChanged</code> returns <code>true</code> - * </p> + * <p>The Watcher will automatically be removed when it's <code>onStateChanged</code> returns + * <code>true</code> * * @see ZkStateReader#registerDocCollectionWatcher * @param collection the collection to watch - * @param watcher a watcher that will be called when the state changes + * @param watcher a watcher that will be called when the state changes */ public void registerDocCollectionWatcher(String collection, DocCollectionWatcher watcher) { getClusterStateProvider().connect(); assertZKStateProvider().zkStateReader.registerDocCollectionWatcher(collection, watcher); } @SuppressWarnings({"unchecked"}) - private NamedList<Object> directUpdate(AbstractUpdateRequest request, String collection) throws SolrServerException { + private NamedList<Object> directUpdate(AbstractUpdateRequest request, String collection) + throws SolrServerException { UpdateRequest updateRequest = (UpdateRequest) request; SolrParams params = request.getParams(); ModifiableSolrParams routableParams = new ModifiableSolrParams(); ModifiableSolrParams nonRoutableParams = new ModifiableSolrParams(); - if(params != null) { + if (params != null) { nonRoutableParams.add(params); routableParams.add(params); - for(String param : NON_ROUTABLE_PARAMS) { + for (String param : NON_ROUTABLE_PARAMS) { routableParams.remove(param); } } else { params = new ModifiableSolrParams(); } if (collection == null) { - throw new SolrServerException("No collection param specified on request and no default collection has been set."); + throw new SolrServerException( + "No collection param specified on request and no default collection has been set."); } - //Check to see if the collection is an alias. Updates to multi-collection aliases are ok as long + // Check to see if the collection is an alias. Updates to multi-collection aliases are ok as Review comment: tighten ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/JDBCStream.java ########## @@ -455,78 +543,88 @@ public String getColumnName() { final int scale = metadata.getScale(columnNumber); if (Number.class.isAssignableFrom(clazz)) { if (scale > 0) { - valueSelector = new ResultSetValueSelector() { - @Override - public Object selectValue(ResultSet resultSet) throws SQLException { - BigDecimal bd = resultSet.getBigDecimal(columnNumber); - return resultSet.wasNull() ? null : bd.doubleValue(); - } - @Override - public String getColumnName() { - return columnName; - } - }; + valueSelector = + new ResultSetValueSelector() { + @Override + public Object selectValue(ResultSet resultSet) throws SQLException { + BigDecimal bd = resultSet.getBigDecimal(columnNumber); + return resultSet.wasNull() ? null : bd.doubleValue(); + } + + @Override + public String getColumnName() { + return columnName; + } + }; } else { - valueSelector = new ResultSetValueSelector() { - @Override - public Object selectValue(ResultSet resultSet) throws SQLException { - BigDecimal bd = resultSet.getBigDecimal(columnNumber); - return resultSet.wasNull() ? null : bd.longValue(); - } - @Override - public String getColumnName() { - return columnName; - } - }; - } + valueSelector = + new ResultSetValueSelector() { + @Override + public Object selectValue(ResultSet resultSet) throws SQLException { + BigDecimal bd = resultSet.getBigDecimal(columnNumber); + return resultSet.wasNull() ? null : bd.longValue(); + } + + @Override + public String getColumnName() { + return columnName; + } + }; + } } else if (Clob.class.isAssignableFrom(clazz)) { - valueSelector = new ResultSetValueSelector() { - @Override - public Object selectValue(ResultSet resultSet) throws SQLException { - Clob c = resultSet.getClob(columnNumber); - if (resultSet.wasNull()) { - return null; - } - long length = c.length(); - int lengthInt = (int) length; - if (length != lengthInt) { - throw new SQLException(String.format(Locale.ROOT, - "Encountered a clob of length #%l in column '%s' (col #%d). Max supported length is #%i.", - length, columnName, columnNumber, Integer.MAX_VALUE)); - } - return c.getSubString(1, lengthInt); - } - @Override - public String getColumnName() { - return columnName; - } - }; - } + valueSelector = + new ResultSetValueSelector() { + @Override + public Object selectValue(ResultSet resultSet) throws SQLException { + Clob c = resultSet.getClob(columnNumber); + if (resultSet.wasNull()) { + return null; + } + long length = c.length(); + int lengthInt = (int) length; + if (length != lengthInt) { + throw new SQLException( + String.format( + Locale.ROOT, + "Encountered a clob of length #%l in column '%s' (col #%d). Max supported length is #%i.", + length, + columnName, + columnNumber, + Integer.MAX_VALUE)); + } + return c.getSubString(1, lengthInt); + } + + @Override + public String getColumnName() { + return columnName; + } + }; + } } return valueSelector; } - - /** - * Closes the JDBCStream - **/ + + /** Closes the JDBCStream */ public void close() throws IOException { - try{ - if(null != resultSet){ // it's not required in JDBC that ResultSet implements the isClosed() function + try { + if (null != resultSet) { // it's not required in JDBC that ResultSet implements the isClosed() Review comment: awkward comment split ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/StatsStream.java ########## @@ -197,13 +196,18 @@ public Explanation toExplanation(StreamFactory factory) throws IOException { // child is a datastore so add it at this point StreamExplanation child = new StreamExplanation(getStreamNodeId() + "-datastore"); child.setFunctionName(String.format(Locale.ROOT, "solr (%s)", collection)); - // TODO: fix this so we know the # of workers - check with Joel about a Topic's ability to be in a + // TODO: fix this so we know the # of workers - check with Joel about a Topic's ability to be in + // a Review comment: tighten this up? ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/JDBCStream.java ########## @@ -130,320 +127,411 @@ // types will require some level of conversion (short -> long, etc...) // We'll use a static constructor to load this set. private static final HashSet<String> directSupportedTypes = new HashSet<>(); + static { - directSupportedTypes.add(String.class.getName()); - directSupportedTypes.add(Double.class.getName()); - directSupportedTypes.add(Long.class.getName()); - directSupportedTypes.add(Boolean.class.getName()); + directSupportedTypes.add(String.class.getName()); + directSupportedTypes.add(Double.class.getName()); + directSupportedTypes.add(Long.class.getName()); + directSupportedTypes.add(Boolean.class.getName()); } - + // Provided as input private String driverClassName; private String connectionUrl; private String sqlQuery; private StreamComparator definedSort; private int fetchSize; - + // Internal private Connection connection; private Properties connectionProperties; private Statement statement; private ResultSetValueSelector[] valueSelectors; protected ResultSet resultSet; protected transient StreamContext streamContext; - protected String sep = Character.toString((char)31); + protected String sep = Character.toString((char) 31); - public JDBCStream(String connectionUrl, String sqlQuery, StreamComparator definedSort) throws IOException { + public JDBCStream(String connectionUrl, String sqlQuery, StreamComparator definedSort) + throws IOException { this(connectionUrl, sqlQuery, definedSort, null, null); } - - public JDBCStream(String connectionUrl, String sqlQuery, StreamComparator definedSort, Properties connectionProperties, String driverClassName) throws IOException { + + public JDBCStream( + String connectionUrl, + String sqlQuery, + StreamComparator definedSort, + Properties connectionProperties, + String driverClassName) + throws IOException { init(connectionUrl, sqlQuery, definedSort, connectionProperties, driverClassName, 5000); } - - public JDBCStream(StreamExpression expression, StreamFactory factory) throws IOException{ + + public JDBCStream(StreamExpression expression, StreamFactory factory) throws IOException { // grab all parameters out List<StreamExpressionNamedParameter> namedParams = factory.getNamedOperands(expression); - StreamExpressionNamedParameter connectionUrlExpression = factory.getNamedOperand(expression, "connection"); + StreamExpressionNamedParameter connectionUrlExpression = + factory.getNamedOperand(expression, "connection"); StreamExpressionNamedParameter sqlQueryExpression = factory.getNamedOperand(expression, "sql"); - StreamExpressionNamedParameter definedSortExpression = factory.getNamedOperand(expression, SORT); - StreamExpressionNamedParameter driverClassNameExpression = factory.getNamedOperand(expression, "driver"); - StreamExpressionNamedParameter fetchSizeExpression = factory.getNamedOperand(expression, "fetchSize"); - + StreamExpressionNamedParameter definedSortExpression = + factory.getNamedOperand(expression, SORT); + StreamExpressionNamedParameter driverClassNameExpression = + factory.getNamedOperand(expression, "driver"); + StreamExpressionNamedParameter fetchSizeExpression = + factory.getNamedOperand(expression, "fetchSize"); - // Validate there are no unknown parameters - zkHost and alias are namedParameter so we don't need to count it twice - if(expression.getParameters().size() != namedParams.size()){ - throw new IOException(String.format(Locale.ROOT,"invalid expression %s - unknown operands found", expression)); + // Validate there are no unknown parameters - zkHost and alias are namedParameter so we don't + // need to count it twice + if (expression.getParameters().size() != namedParams.size()) { + throw new IOException( + String.format(Locale.ROOT, "invalid expression %s - unknown operands found", expression)); } - + // All named params we don't care about will be passed to the driver on connection Properties connectionProperties = new Properties(); - for(StreamExpressionNamedParameter namedParam : namedParams){ - if(!namedParam.getName().equals("driver") && !namedParam.getName().equals("connection") && !namedParam.getName().equals("sql") && !namedParam.getName().equals(SORT)){ + for (StreamExpressionNamedParameter namedParam : namedParams) { + if (!namedParam.getName().equals("driver") + && !namedParam.getName().equals("connection") + && !namedParam.getName().equals("sql") + && !namedParam.getName().equals(SORT)) { connectionProperties.put(namedParam.getName(), namedParam.getParameter().toString().trim()); } } int fetchSize = 5000; - if(null != fetchSizeExpression && fetchSizeExpression.getParameter() instanceof StreamExpressionValue){ - String fetchSizeString = ((StreamExpressionValue)fetchSizeExpression.getParameter()).getValue(); + if (null != fetchSizeExpression + && fetchSizeExpression.getParameter() instanceof StreamExpressionValue) { + String fetchSizeString = + ((StreamExpressionValue) fetchSizeExpression.getParameter()).getValue(); fetchSize = Integer.parseInt(fetchSizeString); } // connectionUrl, required String connectionUrl = null; - if(null != connectionUrlExpression && connectionUrlExpression.getParameter() instanceof StreamExpressionValue){ - connectionUrl = ((StreamExpressionValue)connectionUrlExpression.getParameter()).getValue(); + if (null != connectionUrlExpression + && connectionUrlExpression.getParameter() instanceof StreamExpressionValue) { + connectionUrl = ((StreamExpressionValue) connectionUrlExpression.getParameter()).getValue(); } - if(null == connectionUrl){ - throw new IOException(String.format(Locale.ROOT,"invalid expression %s - connection not found", connectionUrlExpression)); + if (null == connectionUrl) { + throw new IOException( + String.format( + Locale.ROOT, + "invalid expression %s - connection not found", + connectionUrlExpression)); } - + // sql, required String sqlQuery = null; - if(null != sqlQueryExpression && sqlQueryExpression.getParameter() instanceof StreamExpressionValue){ - sqlQuery = ((StreamExpressionValue)sqlQueryExpression.getParameter()).getValue(); + if (null != sqlQueryExpression + && sqlQueryExpression.getParameter() instanceof StreamExpressionValue) { + sqlQuery = ((StreamExpressionValue) sqlQueryExpression.getParameter()).getValue(); } - if(null == sqlQuery){ - throw new IOException(String.format(Locale.ROOT,"invalid expression %s - sql not found", sqlQueryExpression)); + if (null == sqlQuery) { + throw new IOException( + String.format(Locale.ROOT, "invalid expression %s - sql not found", sqlQueryExpression)); } - + // definedSort, required StreamComparator definedSort = null; - if(null != definedSortExpression && definedSortExpression.getParameter() instanceof StreamExpressionValue){ - definedSort = factory.constructComparator(((StreamExpressionValue)definedSortExpression.getParameter()).getValue(), FieldComparator.class); + if (null != definedSortExpression + && definedSortExpression.getParameter() instanceof StreamExpressionValue) { + definedSort = + factory.constructComparator( + ((StreamExpressionValue) definedSortExpression.getParameter()).getValue(), + FieldComparator.class); } - if(null == definedSort){ - throw new IOException(String.format(Locale.ROOT,"invalid expression %s - sort not found", definedSortExpression)); + if (null == definedSort) { + throw new IOException( + String.format( + Locale.ROOT, "invalid expression %s - sort not found", definedSortExpression)); } - + // driverClass, optional String driverClass = null; - if(null != driverClassNameExpression && driverClassNameExpression.getParameter() instanceof StreamExpressionValue){ - driverClass = ((StreamExpressionValue)driverClassNameExpression.getParameter()).getValue(); + if (null != driverClassNameExpression + && driverClassNameExpression.getParameter() instanceof StreamExpressionValue) { + driverClass = ((StreamExpressionValue) driverClassNameExpression.getParameter()).getValue(); } // We've got all the required items init(connectionUrl, sqlQuery, definedSort, connectionProperties, driverClass, fetchSize); } - - private void init(String connectionUrl, String sqlQuery, StreamComparator definedSort, Properties connectionProperties, String driverClassName, int fetchSize) { + + private void init( + String connectionUrl, + String sqlQuery, + StreamComparator definedSort, + Properties connectionProperties, + String driverClassName, + int fetchSize) { this.connectionUrl = connectionUrl; this.sqlQuery = sqlQuery; this.definedSort = definedSort; this.connectionProperties = connectionProperties; this.driverClassName = driverClassName; this.fetchSize = fetchSize; } - + public void setStreamContext(StreamContext context) { this.streamContext = context; } /** - * Opens the JDBCStream - * - ***/ + * Opens the JDBCStream + * + * <p>* Review comment: delete <p> ########## File path: solr/solrj/src/java/org/apache/solr/common/ToleratedUpdateError.java ########## @@ -16,122 +16,135 @@ */ package org.apache.solr.common; +import static org.apache.solr.common.params.CommonParams.ID; + import java.util.ArrayList; import java.util.List; - import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.util.SimpleOrderedMap; -import static org.apache.solr.common.params.CommonParams.ID; - /** - * Models the basic information related to a single "tolerated" error that occurred during updates. - * This class is only useful when the <code>TolerantUpdateProcessorFactory</code> is used in an update - * processor chain + * Models the basic information related to a single "tolerated" error that occurred during updates. + * This class is only useful when the <code>TolerantUpdateProcessorFactory</code> is used in an + * update processor chain */ public final class ToleratedUpdateError { - - private final static String META_PRE = ToleratedUpdateError.class.getName() + "--"; - private final static int META_PRE_LEN = META_PRE.length(); + + private static final String META_PRE = ToleratedUpdateError.class.getName() + "--"; + private static final int META_PRE_LEN = META_PRE.length(); /** - * Given a 'maxErrors' value such that<code>-1 <= maxErrors <= {@link Integer#MAX_VALUE}</code> - * this method returns the original input unless it is <code>-1</code> in which case the effective value of - * {@link Integer#MAX_VALUE} is returned. - * Input of <code>maxErrors < -1</code> will trip an assertion and otherwise have undefined behavior. + * Given a 'maxErrors' value such that<code>-1 <= maxErrors <= {@link Integer#MAX_VALUE} + * </code> this method returns the original input unless it is <code>-1</code> in which case the + * effective value of {@link Integer#MAX_VALUE} is returned. Input of <code>maxErrors < -1 + * </code> will trip an assertion and otherwise have undefined behavior. + * * @see #getUserFriendlyMaxErrors */ public static int getEffectiveMaxErrors(int maxErrors) { assert -1 <= maxErrors; return -1 == maxErrors ? Integer.MAX_VALUE : maxErrors; } - + /** - * Given a 'maxErrors' value such that<code>-1 <= maxErrors <= {@link Integer#MAX_VALUE}</code> - * this method returns the original input unless it is {@link Integer#MAX_VALUE} in which case - * <code>-1</code> is returned for user convinience. - * Input of <code>maxErrors < -1</code> will trip an assertion and otherwise have undefined behavior. + * Given a 'maxErrors' value such that<code>-1 <= maxErrors <= {@link Integer#MAX_VALUE} + * </code> this method returns the original input unless it is {@link Integer#MAX_VALUE} in which + * case <code>-1</code> is returned for user convinience. Input of <code>maxErrors < -1</code> + * will trip an assertion and otherwise have undefined behavior. + * * @see #getEffectiveMaxErrors */ public static int getUserFriendlyMaxErrors(int maxErrors) { assert -1 <= maxErrors; return Integer.MAX_VALUE == maxErrors ? -1 : maxErrors; } - - /** - * returns a list of maps of simple objects suitable for putting in a SolrQueryResponse header + + /** + * returns a list of maps of simple objects suitable for putting in a SolrQueryResponse header + * * @see #getSimpleMap * @see #parseMap */ - public static List<SimpleOrderedMap<String>> formatForResponseHeader(List<ToleratedUpdateError> errs) { + public static List<SimpleOrderedMap<String>> formatForResponseHeader( + List<ToleratedUpdateError> errs) { List<SimpleOrderedMap<String>> result = new ArrayList<>(errs.size()); for (ToleratedUpdateError e : errs) { result.add(e.getSimpleMap()); } return result; } - - /** - * returns a ToleratedUpdateError instance from the data in this Map + + /** + * returns a ToleratedUpdateError instance from the data in this Map + * * @see #getSimpleMap */ public static ToleratedUpdateError parseMap(SimpleOrderedMap<String> data) { final String id = data.get(ID); final String message = data.get("message"); final String t = data.get("type"); if (null == t || null == id || null == message) { - throw new SolrException(ErrorCode.SERVER_ERROR, "Map does not represent a ToleratedUpdateError, must contain 'type', 'id', and 'message'"); + throw new SolrException( + ErrorCode.SERVER_ERROR, + "Map does not represent a ToleratedUpdateError, must contain 'type', 'id', and 'message'"); } try { return new ToleratedUpdateError(CmdType.valueOf(t), id, message); } catch (IllegalArgumentException iae) { - throw new SolrException(ErrorCode.SERVER_ERROR, "Invalid type for ToleratedUpdateError: " + t, iae); + throw new SolrException( + ErrorCode.SERVER_ERROR, "Invalid type for ToleratedUpdateError: " + t, iae); } } - - /** - * returns a ToleratedUpdateError instance if this metadataKey is one we care about, else null + + /** + * returns a ToleratedUpdateError instance if this metadataKey is one we care about, else null + * * @see #getMetadataKey * @see #getMetadataValue */ - public static ToleratedUpdateError parseMetadataIfToleratedUpdateError(String metadataKey, - String metadataVal) { - if (! metadataKey.startsWith(META_PRE)) { + public static ToleratedUpdateError parseMetadataIfToleratedUpdateError( + String metadataKey, String metadataVal) { + if (!metadataKey.startsWith(META_PRE)) { return null; // not a key we care about } final int typeEnd = metadataKey.indexOf(':', META_PRE_LEN); if (typeEnd < 0) { - return null; // has our prefix, but not our format -- must not be a key we (actually) care about + return null; // has our prefix, but not our format -- must not be a key we (actually) care + // about Review comment: awkward ########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TopicStream.java ########## @@ -226,54 +242,67 @@ public StreamExpression toExpression(StreamFactory factory) throws IOException { // zkHost expression.addParameter(new StreamExpressionNamedParameter("zkHost", zkHost)); expression.addParameter(new StreamExpressionNamedParameter(ID, id)); - if(initialCheckpoint > -1) { - expression.addParameter(new StreamExpressionNamedParameter("initialCheckpoint", Long.toString(initialCheckpoint))); + if (initialCheckpoint > -1) { + expression.addParameter( + new StreamExpressionNamedParameter( + "initialCheckpoint", Long.toString(initialCheckpoint))); } - expression.addParameter(new StreamExpressionNamedParameter("checkpointEvery", Long.toString(checkpointEvery))); + expression.addParameter( + new StreamExpressionNamedParameter("checkpointEvery", Long.toString(checkpointEvery))); return expression; } - + @Override public Explanation toExplanation(StreamFactory factory) throws IOException { StreamExplanation explanation = new StreamExplanation(getStreamNodeId().toString()); - + explanation.setFunctionName(factory.getFunctionName(this.getClass())); explanation.setImplementingClass(this.getClass().getName()); explanation.setExpressionType(ExpressionType.STREAM_SOURCE); explanation.setExpression(toExpression(factory).toString()); - + { // child 1 is a datastore so add it at this point StreamExplanation child = new StreamExplanation(getStreamNodeId() + "-datastore"); - child.setFunctionName(String.format(Locale.ROOT, "solr (%s)", collection)); - // TODO: fix this so we know the # of workers - check with Joel about a Topic's ability to be in a - // parallel stream. - + child.setFunctionName(String.format(Locale.ROOT, "solr (%s)", collection)); + // TODO: fix this so we know the # of workers - check with Joel about a Topic's ability to be + // in a Review comment: awkward -- 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: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org