diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-06-28 06:13:15 -0500 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-06-28 06:13:15 -0500 |
commit | 77fa90c39e927df2e3f18afaf359e3882f1b822b (patch) | |
tree | a097460583e4cf8d285c48c5c8ec2a74d1382592 | |
parent | 835688ddc6f02b256dfe12a31b57d761ce66c234 (diff) |
Nonfunctional changes only
30 files changed, 213 insertions, 230 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/hitfield/AnnotateStringFieldPart.java b/container-search/src/main/java/com/yahoo/prelude/hitfield/AnnotateStringFieldPart.java index f1b91ab5b72..e61d2ad8af5 100644 --- a/container-search/src/main/java/com/yahoo/prelude/hitfield/AnnotateStringFieldPart.java +++ b/container-search/src/main/java/com/yahoo/prelude/hitfield/AnnotateStringFieldPart.java @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.prelude.hitfield; -/** TODO: Class header! */ public class AnnotateStringFieldPart implements FieldPart { public static final char RAW_ANNOTATE_BEGIN_CHAR = '\uFFF9'; diff --git a/container-search/src/main/java/com/yahoo/prelude/hitfield/HitField.java b/container-search/src/main/java/com/yahoo/prelude/hitfield/HitField.java index fd8648b758a..e81a6653b08 100644 --- a/container-search/src/main/java/com/yahoo/prelude/hitfield/HitField.java +++ b/container-search/src/main/java/com/yahoo/prelude/hitfield/HitField.java @@ -29,65 +29,48 @@ public class HitField { private Object original; - /** - * @param f The field name - * @param c The field content - */ - public HitField(String f, String c) { - this(f, c, c.indexOf(JuniperSearcher.RAW_HIGHLIGHT_CHAR) > -1); + public HitField(String fieldName, String content) { + this(fieldName, content, content.indexOf(JuniperSearcher.RAW_HIGHLIGHT_CHAR) > -1); } - /** - * @param f The field name - * @param c The field content - */ - public HitField(String f, XMLString c) { - this(f, c, c.toString().indexOf(JuniperSearcher.RAW_HIGHLIGHT_CHAR) > -1); + public HitField(String fieldName, XMLString content) { + this(fieldName, content, content.toString().indexOf(JuniperSearcher.RAW_HIGHLIGHT_CHAR) > -1); } - /** - * @param f The field name - * @param c The field content - * @param cjk true if the content is CJK text - */ - public HitField(String f, String c, boolean cjk) { - this(f, c, cjk, false); + public HitField(String fieldName, String content, boolean cjk) { + this(fieldName, content, cjk, false); } /** - * @param f The field name - * @param c The field content + * Creates a hit field + * * @param cjk true if the content is CJK text */ - public HitField(String f, XMLString c, boolean cjk) { - this(f, c.toString(), cjk, true); + public HitField(String fieldName, XMLString content, boolean cjk) { + this(fieldName, content.toString(), cjk, true); } /** - * @param f The field name - * @param c The field content + * Creates a hit field + * + * @param fieldname The field name + * @param content The field content * @param cjk true if the content is CJK text * @param xmlProperty true if this should not quote XML syntax */ - public HitField(String f, String c, boolean cjk, boolean xmlProperty) { - name = f; - rawContent = c; - content = null; + public HitField(String fieldname, String content, boolean cjk, boolean xmlProperty) { + name = fieldname; + rawContent = content; + this.content = null; isCJK = cjk; this.xmlProperty = xmlProperty; } - /** - * @return the name of this field - */ public String getName() { return name; } - /** - * @return the raw/original content of this field - */ public String getRawContent() { return rawContent; } @@ -243,18 +226,13 @@ public class HitField { } return tokenizedContent; } - /** - * Return an iterator for the tokens, delimiters and markup elements - * of the field. - */ + /** Return an iterator for the tokens, delimiters and markup elements of the field. */ public ListIterator<FieldPart> listIterator() { return new FieldIterator(ensureTokenized(), this); } - /** - * Return an iterator for the tokens in the field - */ + /** Return an iterator over the tokens of this field */ public ListIterator<FieldPart> tokenIterator() { return new TokenFieldIterator(ensureTokenized(), this); diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java index 1923fdbc50d..8297a566a72 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java @@ -94,10 +94,10 @@ public abstract class AbstractParser implements CustomParser { } /** - * <p>Creates a new instance of this class, storing the given {@link ParserEnvironment} for parse-time access to the - * environment.</p> + * Creates a new instance of this class, storing the given {@link ParserEnvironment} for parse-time access to the + * environment. * - * @param environment The environment settings to attach to the Parser. + * @param environment the environment settings to attach to the Parser */ protected AbstractParser(ParserEnvironment environment) { this.environment = ParserEnvironment.fromParserEnvironment(environment); diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/AdvancedParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/AdvancedParser.java index 244d895f357..e3d1b280a5a 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/parser/AdvancedParser.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/AdvancedParser.java @@ -11,7 +11,7 @@ import static com.yahoo.prelude.query.parser.Token.Kind.NUMBER; * Parser for queries of type advanced. * * @author Steinar Knutsen - * @deprecated since 5.11, YQL+ should be used for formal queries + * @deprecated YQL should be used for formal queries */ @Deprecated // DO NOT REMOVE (we'll keep this around longer) public class AdvancedParser extends StructuredParser { diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java index 72ee4ae2c12..d9b969757c2 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java @@ -1,7 +1,15 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.prelude.query.parser; -import com.yahoo.prelude.query.*; +import com.yahoo.prelude.query.AndItem; +import com.yahoo.prelude.query.IntItem; +import com.yahoo.prelude.query.Item; +import com.yahoo.prelude.query.NotItem; +import com.yahoo.prelude.query.NullItem; +import com.yahoo.prelude.query.OrItem; +import com.yahoo.prelude.query.PhraseItem; +import com.yahoo.prelude.query.QueryCanonicalizer; +import com.yahoo.prelude.query.RankItem; import com.yahoo.search.query.QueryTree; import com.yahoo.search.query.parser.ParserEnvironment; @@ -86,14 +94,14 @@ public class AllParser extends SimpleParser { return and; } - protected OrItem addOr(Item item,OrItem or) { + protected OrItem addOr(Item item, OrItem or) { if (or == null) or = new OrItem(); or.addItem(item); return or; } - protected NotItem addNot(Item item,NotItem not) { + protected NotItem addNot(Item item, NotItem not) { if (not == null) not = new NotItem(); not.addNegativeItem(item); @@ -129,9 +137,9 @@ public class AllParser extends SimpleParser { // Interpret -N as a positive item matching a negative number (by backtracking out of this) // but not if there is an explicit index (such as -a:b) // but interpret --N as a negative item matching a negative number - if ( item instanceof IntItem && - ((IntItem)item).getIndexName().isEmpty() && - ! ((IntItem)item).getNumber().startsWith(("-"))) + if (item instanceof IntItem && + ((IntItem)item).getIndexName().isEmpty() && + ! ((IntItem)item).getNumber().startsWith(("-"))) item = null; return item; diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/AnyParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/AnyParser.java index 9cb9f36b8a6..2bde507fcd1 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/parser/AnyParser.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/AnyParser.java @@ -3,7 +3,6 @@ package com.yahoo.prelude.query.parser; import com.yahoo.language.Language; import com.yahoo.prelude.IndexFacts; -import com.yahoo.prelude.query.*; import com.yahoo.search.query.parser.ParserEnvironment; import java.util.Collections; diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/CustomParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/CustomParser.java index e57e06f6b12..91ccb4a5cca 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/parser/CustomParser.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/CustomParser.java @@ -12,7 +12,6 @@ import java.util.Set; /** * @author Simon Thoresen Hult - * @since 5.1.4 */ public interface CustomParser extends Parser { diff --git a/container-search/src/main/java/com/yahoo/prelude/query/textualrepresentation/TextualQueryRepresentation.java b/container-search/src/main/java/com/yahoo/prelude/query/textualrepresentation/TextualQueryRepresentation.java index e299ccb5674..858a85aeaf4 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/textualrepresentation/TextualQueryRepresentation.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/textualrepresentation/TextualQueryRepresentation.java @@ -4,7 +4,13 @@ package com.yahoo.prelude.query.textualrepresentation; import com.yahoo.prelude.query.Item; import java.lang.reflect.Array; -import java.util.*; +import java.util.ArrayList; +import java.util.IdentityHashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; import java.util.regex.Pattern; /** @@ -21,6 +27,7 @@ public class TextualQueryRepresentation { /** Creates the textual representation for a single Item. */ private class ItemDiscloser implements Discloser { + private final Item item; final Map<String, Object> properties = new TreeMap<>(); @@ -57,7 +64,7 @@ public class TextualQueryRepresentation { StringBuilder builder = new StringBuilder(); builder.append(name); - if (!properties.isEmpty() || itemReferences.get(item) != null) { + if ( ! properties.isEmpty() || itemReferences.get(item) != null) { builder.append('['); addPropertiesString(builder); builder.append(']'); diff --git a/docproc/src/main/java/com/yahoo/docproc/AbstractConcreteDocumentFactory.java b/docproc/src/main/java/com/yahoo/docproc/AbstractConcreteDocumentFactory.java index 8f771418959..e9a821c66ac 100644 --- a/docproc/src/main/java/com/yahoo/docproc/AbstractConcreteDocumentFactory.java +++ b/docproc/src/main/java/com/yahoo/docproc/AbstractConcreteDocumentFactory.java @@ -1,15 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.docproc; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.util.Map; import com.yahoo.document.Document; -import com.yahoo.document.DocumentId; import com.yahoo.document.annotation.Annotation; import com.yahoo.document.datatypes.Struct; -import com.yahoo.document.datatypes.StructuredFieldValue; -import com.yahoo.yolean.Exceptions; /** * Subtyped by factory classes for concrete document types. The factory classes are auto-generated @@ -26,7 +21,10 @@ public abstract class AbstractConcreteDocumentFactory extends com.yahoo.componen /** * Used by the docproc framework to get an instance of a concrete document type without resorting to reflection in a bundle * - * @return A concrete document instance + * @return a concrete document instance */ - public abstract com.yahoo.document.Document getDocumentCopy(java.lang.String type, com.yahoo.document.datatypes.StructuredFieldValue src, com.yahoo.document.DocumentId id); + public abstract com.yahoo.document.Document getDocumentCopy(java.lang.String type, + com.yahoo.document.datatypes.StructuredFieldValue src, + com.yahoo.document.DocumentId id); + } diff --git a/docproc/src/main/java/com/yahoo/docproc/Accesses.java b/docproc/src/main/java/com/yahoo/docproc/Accesses.java index 4c19784ea37..747b129679b 100644 --- a/docproc/src/main/java/com/yahoo/docproc/Accesses.java +++ b/docproc/src/main/java/com/yahoo/docproc/Accesses.java @@ -20,13 +20,14 @@ public @interface Accesses { /** * Describes the annotations produced and consumed on one field in a document - * @author vegardh * + * @author vegardh */ @Documented @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) - public @interface Field { + @interface Field { + /** The name of the document field */ String name(); /** The datatype of the field */ @@ -37,13 +38,13 @@ public @interface Accesses { /** * Describes the annotations produced and consumed in one tree on a field - * @author vegardh * + * @author vegardh */ @Documented @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) - public @interface Tree { + @interface Tree { /** The name of the tree */ String name() default ""; /** The annotation types that this docproc writes in this tree */ diff --git a/docproc/src/main/java/com/yahoo/docproc/Call.java b/docproc/src/main/java/com/yahoo/docproc/Call.java index edde89cd01a..a46e74c0f5f 100644 --- a/docproc/src/main/java/com/yahoo/docproc/Call.java +++ b/docproc/src/main/java/com/yahoo/docproc/Call.java @@ -91,10 +91,10 @@ public class Call implements Cloneable { * if schema mapping or @Accesses is in effect. * * <p> - * public for testing + * Public for testing */ public DocumentPut configDoc(DocumentProcessor docProc, DocumentPut documentPut) { - if (!docProc.getFieldMap().isEmpty() || docProc.hasAnnotations()) { + if ( ! docProc.getFieldMap().isEmpty() || docProc.hasAnnotations()) { Document document = documentPut.getDocument(); document = new ProxyDocument(docProc, document, docProc.getDocMap(document.getDataType().getName())); diff --git a/docproc/src/main/java/com/yahoo/docproc/CallStack.java b/docproc/src/main/java/com/yahoo/docproc/CallStack.java index 1e7bf4fba8e..2a09de1fdd5 100644 --- a/docproc/src/main/java/com/yahoo/docproc/CallStack.java +++ b/docproc/src/main/java/com/yahoo/docproc/CallStack.java @@ -12,18 +12,18 @@ import java.util.List; import java.util.ListIterator; /** - * <p>A stack of the processors to call next in this processing. To push which + * A stack of the processors to call next in this processing. To push which * processor to call next, call addNext, to get and remove the next processor, - * call pop.</p> + * call pop. * - * <p>This is not thread safe.</p> + * This is not thread safe. * * @author bratseth */ public class CallStack { /** The name of this stack, or null if it is not named */ - private String name = null; + private String name; /** The Call objects of this stack */ private final List<Call> elements = new java.util.LinkedList<>(); @@ -51,7 +51,7 @@ public class CallStack { } /** Creates an empty stack with a name */ - public CallStack(final String name, Statistics manager, Metric metric) { + public CallStack(String name, Statistics manager, Metric metric) { this.name = name; this.statistics = manager; this.metric = metric; @@ -61,10 +61,10 @@ public class CallStack { * Creates a stack from another stack (starting at the next of the given * callstack) This does a deep copy of the stack. */ - public CallStack(final CallStack stackToCopy) { + public CallStack(CallStack stackToCopy) { name = stackToCopy.name; - for (final Iterator<Call> i = stackToCopy.iterator(); i.hasNext();) { - final Call callToCopy = i.next(); + for (Iterator<Call> i = stackToCopy.iterator(); i.hasNext();) { + Call callToCopy = i.next(); elements.add((Call) callToCopy.clone()); } this.statistics = stackToCopy.statistics; @@ -78,7 +78,7 @@ public class CallStack { * @param name the name of the stack * @param docprocs the document processors to call */ - public CallStack(final String name, Collection<DocumentProcessor> docprocs, Statistics manager, Metric metric) { + public CallStack(String name, Collection<DocumentProcessor> docprocs, Statistics manager, Metric metric) { this(name, manager, metric); for (DocumentProcessor docproc : docprocs) { addLast(docproc); @@ -91,7 +91,7 @@ public class CallStack { } /** Sets the name of this stack */ - public void setName(final String name) { + public void setName(String name) { this.name = name; } @@ -100,7 +100,7 @@ public class CallStack { * * @return this for convenience */ - public CallStack addNext(final Call call) { + public CallStack addNext(Call call) { elements.add(0, call); return this; } @@ -110,7 +110,7 @@ public class CallStack { * * @return this for convenience */ - public CallStack addNext(final DocumentProcessor processor) { + public CallStack addNext(DocumentProcessor processor) { return addNext(new Call(processor, name, statistics, metric)); } @@ -119,7 +119,7 @@ public class CallStack { * * @return this for convenience */ - public CallStack addNext(final CallStack callStack) { + public CallStack addNext(CallStack callStack) { elements.addAll(0, callStack.elements); return this; } @@ -129,7 +129,7 @@ public class CallStack { * * @return this for convenience */ - public CallStack addLast(final Call call) { + public CallStack addLast(Call call) { elements.add(call); return this; } @@ -139,7 +139,7 @@ public class CallStack { * * @return this for convenience */ - public CallStack addLast(final DocumentProcessor processor) { + public CallStack addLast(DocumentProcessor processor) { return addLast(new Call(processor, name, statistics, metric)); } @@ -148,7 +148,7 @@ public class CallStack { * * @return this for convenience */ - public CallStack addLast(final CallStack callStack) { + public CallStack addLast(CallStack callStack) { elements.addAll(callStack.elements); return this; } @@ -164,8 +164,8 @@ public class CallStack { * @param call the call to add * @return this for convenience */ - public CallStack addBefore(final Call before, final Call call) { - final int insertPosition = elements.indexOf(before); + public CallStack addBefore(Call before, Call call) { + int insertPosition = elements.indexOf(before); if (insertPosition < 0) { addLast(call); } else { @@ -185,7 +185,7 @@ public class CallStack { * @param processor the processor to add * @return this for convenience */ - public CallStack addBefore(final Call before, DocumentProcessor processor) { + public CallStack addBefore(Call before, DocumentProcessor processor) { return addBefore(before, new Call(processor, name, statistics, metric)); } @@ -193,16 +193,13 @@ public class CallStack { * Adds multiple elements just before the first occurence of some element on * the stack. This can not be called during an iteration. * - * @param before - * the call to add this before. If this call is not present (the - * same object instance), the new processor is added as the last - * element - * @param callStack - * the calls to add + * @param before the call to add this before. If this call is not present (the + * same object instance), the new processor is added as the last element + * @param callStack the calls to add * @return this for convenience */ - public CallStack addBefore(final Call before, final CallStack callStack) { - final int insertPosition = elements.indexOf(before); + public CallStack addBefore(Call before, CallStack callStack) { + int insertPosition = elements.indexOf(before); if (insertPosition < 0) { addLast(callStack); } else { @@ -223,8 +220,8 @@ public class CallStack { * the call to add * @return this for convenience */ - public CallStack addAfter(final Call after, final Call call) { - final int insertPosition = elements.indexOf(after); + public CallStack addAfter(Call after, Call call) { + int insertPosition = elements.indexOf(after); if (insertPosition < 0) { addLast(call); } else { @@ -237,15 +234,12 @@ public class CallStack { * Adds an element just after the first occurence of some other element on * the stack. This can not be called during an iteration. * - * @param after - * the call to add this after. If this call is not present, (the - * same object instance), the new processor is added as the last - * element - * @param processor - * the processor to add + * @param after the call to add this after. If this call is not present, (the + * same object instance), the new processor is added as the last element + * @param processor the processor to add * @return this for convenience */ - public CallStack addAfter(final Call after, final DocumentProcessor processor) { + public CallStack addAfter(Call after, DocumentProcessor processor) { return addAfter(after, new Call(processor, name, statistics, metric)); } @@ -253,16 +247,13 @@ public class CallStack { * Adds multiple elements just after another given element on the stack. * This can not be called during an iteration. * - * @param after - * the call to add this before. If this call is not present, (the - * same object instance), the new processor is added as the last - * element - * @param callStack - * the calls to add + * @param after the call to add this before. If this call is not present, (the + * same object instance), the new processor is added as the last element + * @param callStack the calls to add * @return this for convenience */ - public CallStack addAfter(final Call after, final CallStack callStack) { - final int insertPosition = elements.indexOf(after); + public CallStack addAfter(Call after, CallStack callStack) { + int insertPosition = elements.indexOf(after); if (insertPosition < 0) { addLast(callStack); } else { @@ -278,9 +269,9 @@ public class CallStack { * the call to remove * @return this for convenience */ - public CallStack remove(final Call call) { - for (final ListIterator<Call> i = iterator(); i.hasNext();) { - final Call current = i.next(); + public CallStack remove(Call call) { + for (ListIterator<Call> i = iterator(); i.hasNext();) { + Call current = i.next(); if (current == call) { i.remove(); } @@ -295,9 +286,9 @@ public class CallStack { * the call to check * @return true if the call is present, false otherwise */ - public boolean contains(final Call call) { - for (final ListIterator<Call> i = iterator(); i.hasNext();) { - final Call current = i.next(); + public boolean contains(Call call) { + for (ListIterator<Call> i = iterator(); i.hasNext();) { + Call current = i.next(); if (current == call) { return true; } @@ -306,12 +297,11 @@ public class CallStack { } /** - * Returns the next call to this processor id, or null if no such calls are - * left + * Returns the next call to this processor id, or null if no such calls are left */ - public Call findCall(final ComponentId processorId) { - for (final Iterator<Call> i = iterator(); i.hasNext();) { - final Call call = i.next(); + public Call findCall(ComponentId processorId) { + for (Iterator<Call> i = iterator(); i.hasNext();) { + Call call = i.next(); if (call.getDocumentProcessorId().equals(processorId)) { return call; } @@ -323,7 +313,7 @@ public class CallStack { * Returns the next call to this processor, or null if no such calls are * left */ - public Call findCall(final DocumentProcessor processor) { + public Call findCall(DocumentProcessor processor) { return findCall(processor.getId()); } @@ -365,15 +355,14 @@ public class CallStack { return elements.listIterator(); } - /** Returns the number of remainnig elements in this stack */ + /** Returns the number of remaining elements in this stack */ public int size() { return elements.size(); } @Override public String toString() { - StringBuilder b = new StringBuilder(); - b.append("callstack"); + StringBuilder b = new StringBuilder("callstack"); if (name != null) { b.append(" "); b.append(name); diff --git a/docproc/src/main/java/com/yahoo/docproc/SimpleDocumentProcessor.java b/docproc/src/main/java/com/yahoo/docproc/SimpleDocumentProcessor.java index bb9ef8ff636..89985b54fb1 100644 --- a/docproc/src/main/java/com/yahoo/docproc/SimpleDocumentProcessor.java +++ b/docproc/src/main/java/com/yahoo/docproc/SimpleDocumentProcessor.java @@ -19,7 +19,7 @@ import com.yahoo.log.LogLevel; * it is not possible to return a {@link DocumentProcessor.LaterProgress} from any of the process() methods that SimpleDocumentProcessor * provides - since their return type is void.</p> * - * <p>SimpleDocumentProcessor is for the <em>simple</em> cases. For complete control over document processing, + * <p></p>SimpleDocumentProcessor is for the <em>simple</em> cases. For complete control over document processing, * like returning instances of {@link DocumentProcessor.LaterProgress}, subclass {@link DocumentProcessor} instead.</p> * * @author Einar M R Rosenvinge @@ -86,7 +86,7 @@ public class SimpleDocumentProcessor extends DocumentProcessor { */ @Override public final Progress process(Processing processing) { - final int initialSize = processing.getDocumentOperations().size(); + int initialSize = processing.getDocumentOperations().size(); for (DocumentOperation op : processing.getDocumentOperations()) { try { if (op instanceof DocumentPut) { diff --git a/docproc/src/main/java/com/yahoo/docproc/TransientFailureException.java b/docproc/src/main/java/com/yahoo/docproc/TransientFailureException.java index cda196f309c..235e2561066 100644 --- a/docproc/src/main/java/com/yahoo/docproc/TransientFailureException.java +++ b/docproc/src/main/java/com/yahoo/docproc/TransientFailureException.java @@ -2,8 +2,8 @@ package com.yahoo.docproc; /** - * Exception to be thrown by a document processor on transient failures. Caller - * is welcome to try the call again later. + * Exception to be thrown by a document processor on transient failures. + * Caller is welcome to try the call again later. * * @author Einar M R Rosenvinge */ diff --git a/docproc/src/main/java/com/yahoo/docproc/jdisc/RequestContext.java b/docproc/src/main/java/com/yahoo/docproc/jdisc/RequestContext.java index 5d04eb9fe6f..8f021546ac8 100644 --- a/docproc/src/main/java/com/yahoo/docproc/jdisc/RequestContext.java +++ b/docproc/src/main/java/com/yahoo/docproc/jdisc/RequestContext.java @@ -9,37 +9,35 @@ import java.net.URI; import java.util.List; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public interface RequestContext { - public List<Processing> getProcessings(); + List<Processing> getProcessings(); - public String getServiceName(); + String getServiceName(); - public URI getUri(); + URI getUri(); - public boolean isProcessable(); + boolean isProcessable(); - public int getApproxSize(); + int getApproxSize(); - public int getPriority(); + int getPriority(); - public void processingDone(List<Processing> processing); + void processingDone(List<Processing> processing); - public void processingFailed(ErrorCode error, String msg); + void processingFailed(ErrorCode error, String msg); - public void processingFailed(Exception exception); + void processingFailed(Exception exception); - /** - * Will check if the given timeout has expired - * @return true if the timeout has expired. - */ - public default boolean hasExpired() { return false;} + /** Returns whether this request has timed out */ + default boolean hasExpired() { return false;} - public void skip(); + void skip(); + + enum ErrorCode { - public enum ErrorCode { //transient: ERROR_ABORTED(Response.Status.TEMPORARY_REDIRECT, DocumentProtocol.ERROR_ABORTED), ERROR_BUSY(Response.Status.TEMPORARY_REDIRECT, DocumentProtocol.ERROR_BUSY), @@ -50,7 +48,7 @@ public interface RequestContext { private int discStatus; private int documentProtocolStatus; - private ErrorCode(int discStatus, int documentProtocolStatus) { + ErrorCode(int discStatus, int documentProtocolStatus) { this.discStatus = discStatus; this.documentProtocolStatus = documentProtocolStatus; } @@ -63,4 +61,5 @@ public interface RequestContext { return documentProtocolStatus; } } + } diff --git a/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/MessageFactory.java b/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/MessageFactory.java index 89f3782da52..702343acd1c 100644 --- a/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/MessageFactory.java +++ b/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/MessageFactory.java @@ -2,16 +2,24 @@ package com.yahoo.docproc.jdisc.messagebus; import com.yahoo.docproc.Processing; -import com.yahoo.document.*; +import com.yahoo.document.DocumentOperation; +import com.yahoo.document.DocumentPut; +import com.yahoo.document.DocumentRemove; +import com.yahoo.document.DocumentUpdate; import com.yahoo.documentapi.messagebus.loadtypes.LoadType; -import com.yahoo.documentapi.messagebus.protocol.*; +import com.yahoo.documentapi.messagebus.protocol.DocumentMessage; +import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol; +import com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage; +import com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage; +import com.yahoo.documentapi.messagebus.protocol.TestAndSetMessage; +import com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage; import com.yahoo.log.LogLevel; import com.yahoo.messagebus.Message; import java.util.logging.Logger; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ class MessageFactory { @@ -27,26 +35,26 @@ class MessageFactory { } public DocumentMessage fromDocumentOperation(Processing processing, DocumentOperation documentOperation) { - DocumentMessage msg = newMessage(documentOperation); - msg.setLoadType(loadType); - msg.setPriority(priority); - msg.setRoute(requestMsg.getRoute()); - msg.setTimeReceivedNow(); - msg.setTimeRemaining(requestMsg.getTimeRemainingNow()); - msg.getTrace().setLevel(requestMsg.getTrace().getLevel()); + DocumentMessage message = newMessage(documentOperation); + message.setLoadType(loadType); + message.setPriority(priority); + message.setRoute(requestMsg.getRoute()); + message.setTimeReceivedNow(); + message.setTimeRemaining(requestMsg.getTimeRemainingNow()); + message.getTrace().setLevel(requestMsg.getTrace().getLevel()); if (log.isLoggable(LogLevel.DEBUG)) { - log.log(LogLevel.DEBUG, "Created '" + msg.getClass().getName() + - "', route = '" + msg.getRoute() + - "', priority = '" + msg.getPriority().name() + - "', load type = '" + msg.getLoadType() + - "', trace level = '" + msg.getTrace().getLevel() + - "', time remaining = '" + msg.getTimeRemaining() + "'."); + log.log(LogLevel.DEBUG, "Created '" + message.getClass().getName() + + "', route = '" + message.getRoute() + + "', priority = '" + message.getPriority().name() + + "', load type = '" + message.getLoadType() + + "', trace level = '" + message.getTrace().getLevel() + + "', time remaining = '" + message.getTimeRemaining() + "'."); } - return msg; + return message; } private static DocumentMessage newMessage(DocumentOperation documentOperation) { - final TestAndSetMessage message; + TestAndSetMessage message; if (documentOperation instanceof DocumentPut) { message = new PutDocumentMessage(((DocumentPut)documentOperation)); diff --git a/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/ProcessingFactory.java b/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/ProcessingFactory.java index 49a6020d633..4696c627fe3 100644 --- a/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/ProcessingFactory.java +++ b/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/ProcessingFactory.java @@ -74,9 +74,8 @@ class ProcessingFactory { Document document = msg.getDocumentPut().getDocument(); String typeName = document.getDataType().getName(); ContainerDocumentConfig.Doctype typeConfig = getDocumentConfig(typeName); - if (typeConfig == null) { - return document; - } + if (typeConfig == null) return document; + return createConcreteDocument(document, typeConfig); } diff --git a/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/ResponseMerger.java b/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/ResponseMerger.java index 5a5e43c3cf8..d5aee5b5ff3 100644 --- a/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/ResponseMerger.java +++ b/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/ResponseMerger.java @@ -9,7 +9,6 @@ import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.messagebus.Message; import com.yahoo.messagebus.Reply; import com.yahoo.messagebus.TraceNode; -import com.yahoo.messagebus.jdisc.MbusClient; import com.yahoo.messagebus.jdisc.MbusResponse; import com.yahoo.messagebus.jdisc.StatusCodes; @@ -17,7 +16,7 @@ import java.util.ArrayList; import java.util.List; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ class ResponseMerger implements ResponseHandler { diff --git a/docproc/src/main/java/com/yahoo/docproc/jdisc/metric/NullMetric.java b/docproc/src/main/java/com/yahoo/docproc/jdisc/metric/NullMetric.java index fe204686d6c..9e88af4abd7 100644 --- a/docproc/src/main/java/com/yahoo/docproc/jdisc/metric/NullMetric.java +++ b/docproc/src/main/java/com/yahoo/docproc/jdisc/metric/NullMetric.java @@ -6,9 +6,10 @@ import com.yahoo.jdisc.Metric; import java.util.Map; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class NullMetric implements Metric { + @Override public void set(String key, Number val, Context ctx) { } @@ -25,4 +26,5 @@ public class NullMetric implements Metric { private static class NullContext implements Context { private static final NullContext INSTANCE = new NullContext(); } + } diff --git a/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocument.java b/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocument.java index b540f1c204d..e825db4e21d 100644 --- a/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocument.java +++ b/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocument.java @@ -32,15 +32,18 @@ import java.util.Map.Entry; import java.util.Set; /** - * This is a facade to a Document, with multiple purposes: <ul> <li>Getters and setters for field data takes possibly - * into account a schema map of field names. <li>We support mapping into struct fields of arbitrary depth using - * from→mystruct.mystruct.myfield </ul> We also enforce the @Accesses annotation(s) of the doc proc which uses this. + * This is a facade to a Document, with two purposes: + * <ul> + * <li>Getters and setters for field data may take into account a schema map of field names. + * <li>Mapping into struct fields of arbitrary depth using from→mystruct.mystruct.myfield + * </ul> + * + * This also enforces the @Accesses annotation(s) of the doc proc which uses this. * * @author Vegard Havdal */ public class ProxyDocument extends Document implements DocumentOperationWrapper { - private static final long serialVersionUID = 1L; private final Map<String, String> fieldMap; private final Set<String> fieldsAllowed = new HashSet<>(); private final String docProcName; @@ -72,7 +75,7 @@ public class ProxyDocument extends Document implements DocumentOperationWrapper * directly, but may refer to a field in a struct contained in it, * in which case the returned Field is only useful for obtaining * the field type; it can't be used for get() and set(). - **/ + */ @Override public Field getField(String fieldName) { if (fieldMap != null && fieldMap.containsKey(fieldName)) { diff --git a/docproc/src/main/java/com/yahoo/docproc/util/JoinerDocumentProcessor.java b/docproc/src/main/java/com/yahoo/docproc/util/JoinerDocumentProcessor.java index 6242be25f86..448d5213e6d 100644 --- a/docproc/src/main/java/com/yahoo/docproc/util/JoinerDocumentProcessor.java +++ b/docproc/src/main/java/com/yahoo/docproc/util/JoinerDocumentProcessor.java @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.docproc.util; -import com.yahoo.component.ComponentId; import com.yahoo.document.DocumentOperation; import com.yahoo.document.DocumentPut; import com.yahoo.document.config.DocumentmanagerConfig; diff --git a/docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java b/docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java index 4905f3d9dad..dd894390ac2 100644 --- a/docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java +++ b/docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java @@ -107,4 +107,5 @@ public class DocumentScript { } } } + } diff --git a/docprocs/src/main/java/com/yahoo/docprocs/indexing/FastLogger.java b/docprocs/src/main/java/com/yahoo/docprocs/indexing/FastLogger.java index 3ce2a2f1df4..ba1d5e17a78 100644 --- a/docprocs/src/main/java/com/yahoo/docprocs/indexing/FastLogger.java +++ b/docprocs/src/main/java/com/yahoo/docprocs/indexing/FastLogger.java @@ -29,4 +29,5 @@ class FastLogger { public static FastLogger getLogger(String name) { return new FastLogger(Logger.getLogger(name)); } + } diff --git a/docprocs/src/main/java/com/yahoo/docprocs/indexing/IndexingProcessor.java b/docprocs/src/main/java/com/yahoo/docprocs/indexing/IndexingProcessor.java index 761661710d4..aa66f6c7c3c 100644 --- a/docprocs/src/main/java/com/yahoo/docprocs/indexing/IndexingProcessor.java +++ b/docprocs/src/main/java/com/yahoo/docprocs/indexing/IndexingProcessor.java @@ -9,7 +9,14 @@ import com.yahoo.component.chain.dependencies.Before; import com.yahoo.component.chain.dependencies.Provides; import com.yahoo.docproc.DocumentProcessor; import com.yahoo.docproc.Processing; -import com.yahoo.document.*; +import com.yahoo.document.Document; +import com.yahoo.document.DocumentOperation; +import com.yahoo.document.DocumentPut; +import com.yahoo.document.DocumentRemove; +import com.yahoo.document.DocumentType; +import com.yahoo.document.DocumentTypeManager; +import com.yahoo.document.DocumentTypeManagerConfigurer; +import com.yahoo.document.DocumentUpdate; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.language.Linguistics; import com.yahoo.log.LogLevel; diff --git a/document/src/main/java/com/yahoo/document/datatypes/Struct.java b/document/src/main/java/com/yahoo/document/datatypes/Struct.java index fc75870bb94..db9349f22cf 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/Struct.java +++ b/document/src/main/java/com/yahoo/document/datatypes/Struct.java @@ -2,14 +2,24 @@ package com.yahoo.document.datatypes; import com.yahoo.collections.Hashlet; -import com.yahoo.document.*; +import com.yahoo.document.DataType; +import com.yahoo.document.Document; +import com.yahoo.document.Field; +import com.yahoo.document.PositionDataType; +import com.yahoo.document.StructDataType; import com.yahoo.document.serialization.FieldReader; import com.yahoo.document.serialization.FieldWriter; import com.yahoo.document.serialization.XmlSerializationHelper; import com.yahoo.document.serialization.XmlStream; import com.yahoo.vespa.objects.Ids; -import java.util.*; +import java.util.AbstractSet; +import java.util.Arrays; +import java.util.Iterator; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; + /** * @author Håkon Humberset diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/PutDocumentMessage.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/PutDocumentMessage.java index ec24798f7f2..b2bf26d3b05 100755 --- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/PutDocumentMessage.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/PutDocumentMessage.java @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.documentapi.messagebus.protocol; -import com.yahoo.document.Document; import com.yahoo.document.DocumentPut; import com.yahoo.document.TestAndSetCondition; import com.yahoo.document.serialization.DocumentDeserializer; @@ -28,7 +27,8 @@ public class PutDocumentMessage extends TestAndSetMessage { /** * Constructs a new message from a byte buffer. - * @param decoder The decoder to use for deserialization. + * + * @param decoder The decoder to use for deserialization. * @param buffer A byte buffer that contains a serialized message. */ public PutDocumentMessage(LazyDecoder decoder, DocumentDeserializer buffer) { @@ -36,11 +36,7 @@ public class PutDocumentMessage extends TestAndSetMessage { this.buffer = buffer; } - /** - * Constructs a new document put message. - * - * @param put Document put operation - */ + /** Constructs a new document put message */ public PutDocumentMessage(DocumentPut put) { this.put = put; } @@ -64,40 +60,26 @@ public class PutDocumentMessage extends TestAndSetMessage { } } - /** - * Returns the document put operation - */ + /** Returns the document put operation */ public DocumentPut getDocumentPut() { deserialize(); return put; } - /** - * Sets the document to put. - * - * @param put Put document operation - */ + /** Sets the document to put */ public void setDocumentPut(DocumentPut put) { buffer = null; decoder = null; this.put = put; } - /** - * Returns the timestamp of the document to put. - * - * @return The document timestamp. - */ + /** Returns the timestamp of the document to put */ public long getTimestamp() { deserialize(); return time; } - /** - * Sets the timestamp of the document to put. - * - * @param time The timestamp to set. - */ + /** Sets the timestamp of the document to put */ public void setTimestamp(long time) { buffer = null; decoder = null; @@ -108,7 +90,7 @@ public class PutDocumentMessage extends TestAndSetMessage { * Returns the raw serialized buffer. This buffer is stored as the message is received from accross the network, and * deserialized from as soon as a member is requested. This method will return null if the buffer has been decoded. * - * @return The buffer containing the serialized data for this message, or null. + * @return the buffer containing the serialized data for this message, or null */ ByteBuffer getSerializedBuffer() { return buffer != null ? buffer.getBuf().getByteBuffer() : null; // TODO: very dirty. Must make interface. @@ -153,4 +135,5 @@ public class PutDocumentMessage extends TestAndSetMessage { public void setCondition(TestAndSetCondition condition) { put.setCondition(condition); } + } diff --git a/documentgen-test/src/main/java/com/yahoo/vespa/document/NodeImpl.java b/documentgen-test/src/main/java/com/yahoo/vespa/document/NodeImpl.java index 58b63835539..45da1e85795 100644 --- a/documentgen-test/src/main/java/com/yahoo/vespa/document/NodeImpl.java +++ b/documentgen-test/src/main/java/com/yahoo/vespa/document/NodeImpl.java @@ -7,7 +7,6 @@ import com.yahoo.document.annotation.Annotation; * Example of user provided annotation subtype that vespa-documentgen-plugin supports * * @author vegardh - * */ public class NodeImpl extends Annotation { diff --git a/documentgen-test/src/main/java/com/yahoo/vespa/document/dom/DocumentImpl.java b/documentgen-test/src/main/java/com/yahoo/vespa/document/dom/DocumentImpl.java index fd9b8b46711..1a1548b93d5 100644 --- a/documentgen-test/src/main/java/com/yahoo/vespa/document/dom/DocumentImpl.java +++ b/documentgen-test/src/main/java/com/yahoo/vespa/document/dom/DocumentImpl.java @@ -7,7 +7,6 @@ import com.yahoo.document.annotation.Annotation; * Example of user provided annotation subtype that vespa-documentgen-plugin supports * * @author vegardh - * */ public class DocumentImpl extends Annotation { diff --git a/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java b/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java index e772a3138da..0cb365d421f 100644 --- a/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java +++ b/documentgen-test/src/test/java/com/yahoo/vespa/config/DocumentGenPluginTest.java @@ -82,15 +82,16 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertThat; - /** - * Testcases for vespa-documentgen-plugin + * Tests vespa-documentgen-plugin * * @author vegardh */ @SuppressWarnings({"unchecked", "rawtypes"}) public class DocumentGenPluginTest { + // NOTE: Most assertEquals in this use the wrong argument order + private static final int NUM_BOOKS = 10000; @Test @@ -186,7 +187,7 @@ public class DocumentGenPluginTest { } @Test - public void testremoveFieldValue() { + public void testRemoveFieldValue() { Book book = getBook(); book.setAuthor(null); Field a = new Field("author", DataType.STRING); @@ -229,9 +230,13 @@ public class DocumentGenPluginTest { @Test public void testStructs() { Book book = getBook(); + assertBook(book); + } + + private void assertBook(Book book) { assertTrue(Struct.class.isInstance(book.getMystruct())); - assertEquals(book.getMystruct().getSs01().getD0(), -238472634.78, 0); - assertEquals(book.getMystruct().getI1(), (Integer)999); + assertEquals(-238472634.78, book.getMystruct().getSs01().getD0(), 0); + assertEquals((Integer)999, book.getMystruct().getI1()); assertEquals(book.getAuthor(), "Herman Melville"); book.getMystruct().getSs01().setD0(4d); assertEquals(book.getMystruct().getSs01().getD0(), 4.0, 1E-6); diff --git a/messagebus/src/main/java/com/yahoo/messagebus/IntermediateSession.java b/messagebus/src/main/java/com/yahoo/messagebus/IntermediateSession.java index 8286404aa23..309316b450a 100644 --- a/messagebus/src/main/java/com/yahoo/messagebus/IntermediateSession.java +++ b/messagebus/src/main/java/com/yahoo/messagebus/IntermediateSession.java @@ -36,7 +36,7 @@ public final class IntermediateSession implements MessageHandler, ReplyHandler { * Sets the destroyed flag to true. The very first time this method is called, it cleans up all its dependencies. * Even if you retain a reference to this object, all of its content is allowed to be garbage collected. * - * @return True if content existed and was destroyed. + * @return true if content existed and was destroyed */ public boolean destroy() { if (!destroyed.getAndSet(true)) { @@ -73,11 +73,7 @@ public final class IntermediateSession implements MessageHandler, ReplyHandler { } } - /** - * Returns the message handler of this session. - * - * @return The message handler. - */ + /** Returns the message handler of this session */ public MessageHandler getMessageHandler() { return msgHandler; } @@ -94,18 +90,12 @@ public final class IntermediateSession implements MessageHandler, ReplyHandler { /** * Returns the connection spec string for this session. This returns a combination of the owning message bus' own * spec string and the name of this session. - * - * @return The connection string. */ public String getConnectionSpec() { return mbus.getConnectionSpec() + "/" + name; } - /** - * Returns the name of this session. - * - * @return The session name. - */ + /** Returns the name of this session */ public String getName() { return name; } @@ -123,4 +113,5 @@ public final class IntermediateSession implements MessageHandler, ReplyHandler { replyHandler.handleReply(reply); } } + } |