diff options
43 files changed, 201 insertions, 196 deletions
diff --git a/config-lib/src/main/java/com/yahoo/config/ChangesRequiringRestart.java b/config-lib/src/main/java/com/yahoo/config/ChangesRequiringRestart.java index b536f99490e..a21f36cdbe9 100644 --- a/config-lib/src/main/java/com/yahoo/config/ChangesRequiringRestart.java +++ b/config-lib/src/main/java/com/yahoo/config/ChangesRequiringRestart.java @@ -8,11 +8,12 @@ import java.util.Map; import static java.util.stream.Collectors.joining; /** - * @author <a href="mailto:magnarn@yahoo-inc.com">Magnar Nedland</a> - * * This class aggregates information about config changes that causes a restart to be required. + * + * @author Magnar Nedland */ public class ChangesRequiringRestart { + static class ReportLine { private String name; private final Node from; @@ -159,4 +160,5 @@ public class ChangesRequiringRestart { public boolean needsRestart() { return !report.isEmpty(); } + } diff --git a/config-lib/src/main/java/com/yahoo/config/text/StringUtilities.java b/config-lib/src/main/java/com/yahoo/config/text/StringUtilities.java index afbf722766f..4fbe55b4978 100644 --- a/config-lib/src/main/java/com/yahoo/config/text/StringUtilities.java +++ b/config-lib/src/main/java/com/yahoo/config/text/StringUtilities.java @@ -3,23 +3,26 @@ package com.yahoo.config.text; import java.nio.charset.Charset; import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; /** * Escapes strings into and out of a format where they only contain printable characters. * * Need to duplicate escape / unescape of strings as we have in C++ for java version of system states. * - * @author <a href="mailto:humbe@yahoo-inc.com">Haakon Humberset</a> + * @author Haakon Humberset */ public class StringUtilities { - private static Charset UTF8 = Charset.forName("utf8"); + + private static final Charset UTF8 = StandardCharsets.UTF_8; private static byte toHex(int val) { return (byte) (val < 10 ? '0' + val : 'a' + (val - 10)); } private static class ReplacementCharacters { - public byte needEscape[] = new byte[256]; - public byte replacement1[] = new byte[256]; - public byte replacement2[] = new byte[256]; + + public byte[] needEscape = new byte[256]; + public byte[] replacement1 = new byte[256]; + public byte[] replacement2 = new byte[256]; public ReplacementCharacters() { for (int i=0; i<256; ++i) { @@ -55,12 +58,12 @@ public class StringUtilities { /** * Escapes strings into a format with only printable ASCII characters. * - * @param source The string to escape - * @param delimiter Escape this character too, even if it is printable. - * @return The escaped string + * @param source the string to escape + * @param delimiter escape this character too, even if it is printable + * @return the escaped string */ public static String escape(String source, char delimiter) { - byte bytes[] = source.getBytes(UTF8); + byte[] bytes = source.getBytes(UTF8); ByteArrayOutputStream result = new ByteArrayOutputStream(); for (byte b : bytes) { int val = b; @@ -81,8 +84,7 @@ public class StringUtilities { result.write(replacementCharacters.replacement2[val]); } } - return new String(result.toByteArray(), UTF8); + return result.toString(UTF8); } - } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/IndexStructureValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/IndexStructureValidator.java index b09f85726e5..10385e826f2 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/IndexStructureValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/IndexStructureValidator.java @@ -10,7 +10,7 @@ import com.yahoo.vespa.indexinglanguage.expressions.Expression; import com.yahoo.vespa.indexinglanguage.expressions.OutputExpression; /** - * @author <a href="mailto:mlidal@yahoo-inc.com">Mathias M Lidal</a> + * @author Mathias M Lidal */ public class IndexStructureValidator extends Validator { @@ -37,15 +37,14 @@ public class IndexStructureValidator extends Validator { @Override protected void doVisit(Expression exp) { - if (!(exp instanceof OutputExpression)) { - return; - } + if (!(exp instanceof OutputExpression)) return; + String fieldName = ((OutputExpression)exp).getFieldName(); - if (docType.getField(fieldName) != null) { - return; - } + if (docType.getField(fieldName) != null) return; + throw new IllegalArgumentException("Indexing expression '" + this.exp + "' refers to field '" + fieldName + "' which does not exist in the index structure."); } } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/Ranking.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/Ranking.java index fb1e9ae2f3b..35f782d4334 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/Ranking.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/Ranking.java @@ -6,7 +6,7 @@ import java.io.Serializable; /** * The rank settings given in a rank clause in the search definition. * - * @author <a href="mailto:vehardh@yahoo-inc.com">Vegard Havdal</a> + * @author Vegard Havdal */ public class Ranking implements Cloneable, Serializable { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/annotation/SDAnnotationType.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/annotation/SDAnnotationType.java index cec5af7998f..adf58ee6838 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/annotation/SDAnnotationType.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/annotation/SDAnnotationType.java @@ -5,9 +5,10 @@ import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.document.annotation.AnnotationType; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class SDAnnotationType extends AnnotationType { + private SDDocumentType sdDocType; private String inherits; @@ -32,4 +33,5 @@ public class SDAnnotationType extends AnnotationType { public void inherit(String inherits) { this.inherits = inherits; } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/annotation/TemporaryAnnotationReferenceDataType.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/annotation/TemporaryAnnotationReferenceDataType.java index c41359db9ab..8ffe0fde535 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/annotation/TemporaryAnnotationReferenceDataType.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/annotation/TemporaryAnnotationReferenceDataType.java @@ -5,9 +5,10 @@ import com.yahoo.document.annotation.AnnotationReferenceDataType; import com.yahoo.document.annotation.AnnotationType; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class TemporaryAnnotationReferenceDataType extends AnnotationReferenceDataType { + private final String target; public TemporaryAnnotationReferenceDataType(String target) { @@ -23,4 +24,5 @@ public class TemporaryAnnotationReferenceDataType extends AnnotationReferenceDat super.setName("annotationreference<" + type.getName() + ">"); super.setAnnotationType(type); } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/BoldingOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/BoldingOperation.java index 3b4a1704f63..021276a9fa4 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/BoldingOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/BoldingOperation.java @@ -5,7 +5,7 @@ import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.documentmodel.SummaryField; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class BoldingOperation implements FieldOperation { @@ -21,4 +21,5 @@ public class BoldingOperation implements FieldOperation { summaryField.addDestination("default"); summaryField.setTransform(bold ? summaryField.getTransform().bold() : summaryField.getTransform().unbold()); } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/IdOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/IdOperation.java index 16c187a9ed0..53d44a59f5a 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/IdOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/IdOperation.java @@ -5,9 +5,10 @@ import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class IdOperation implements FieldOperation { + private SDDocumentType document; private int fieldId; @@ -30,4 +31,5 @@ public class IdOperation implements FieldOperation { public void apply(SDField field) { document.setFieldId(field, fieldId); } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/MatchOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/MatchOperation.java index fdb55e7bd91..5bfd2c38586 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/MatchOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/MatchOperation.java @@ -5,9 +5,10 @@ import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDField; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class MatchOperation implements FieldOperation { + private Matching.Type matchingType; private Integer gramSize; private Integer maxLength; @@ -50,4 +51,5 @@ public class MatchOperation implements FieldOperation { field.getMatching().setExactMatchTerminator(exactMatchTerminator); } } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/NormalizingOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/NormalizingOperation.java index 8fabf246712..a5a1466d1be 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/NormalizingOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/NormalizingOperation.java @@ -5,10 +5,11 @@ import com.yahoo.searchdefinition.document.NormalizeLevel; import com.yahoo.searchdefinition.document.SDField; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class NormalizingOperation implements FieldOperation { - private NormalizeLevel.Level level; + + private final NormalizeLevel.Level level; public NormalizingOperation(String setting) { if ("none".equals(setting)) { @@ -22,11 +23,12 @@ public class NormalizingOperation implements FieldOperation { } else if ("all".equals(setting)) { this.level = NormalizeLevel.Level.ACCENT; } else { - throw new IllegalArgumentException("invalid normalizing setting: "+setting); + throw new IllegalArgumentException("invalid normalizing setting: " + setting); } } public void apply(SDField field) { field.setNormalizing(new NormalizeLevel(level, true)); } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/QueryCommandOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/QueryCommandOperation.java index 83cb48ad395..f3b8f4a16f0 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/QueryCommandOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/QueryCommandOperation.java @@ -6,10 +6,11 @@ import com.yahoo.searchdefinition.document.SDField; import java.util.List; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class QueryCommandOperation implements FieldOperation { - private List<String> queryCommands = new java.util.ArrayList<>(0); + + private final List<String> queryCommands = new java.util.ArrayList<>(0); public void addQueryCommand(String name) { queryCommands.add(name); @@ -20,4 +21,5 @@ public class QueryCommandOperation implements FieldOperation { field.addQueryCommand(command); } } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/RankOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/RankOperation.java index d3be075a3f5..4f109d27a96 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/RankOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/RankOperation.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.fieldoperation; import com.yahoo.searchdefinition.document.SDField; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class RankOperation implements FieldOperation { @@ -32,4 +32,5 @@ public class RankOperation implements FieldOperation { field.getRanking().setNormal(normal); } } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/RankTypeOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/RankTypeOperation.java index 219fd869758..7f0ee984415 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/RankTypeOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/RankTypeOperation.java @@ -6,9 +6,10 @@ import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.Index; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class RankTypeOperation implements FieldOperation { + private String indexName; private RankType type; @@ -38,4 +39,5 @@ public class RankTypeOperation implements FieldOperation { index.setRankType(type); } } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/SortingOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/SortingOperation.java index 2a7b1b376a6..c556ddea99d 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/SortingOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/SortingOperation.java @@ -6,10 +6,11 @@ import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Sorting; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class SortingOperation implements FieldOperation { - private String attributeName; + + private final String attributeName; private Boolean ascending; private Boolean descending; private Sorting.Function function; @@ -88,4 +89,5 @@ public class SortingOperation implements FieldOperation { sorting.setLocale(locale); } } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/StemmingOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/StemmingOperation.java index 75a8410327b..e3cee4ece3d 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/StemmingOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/StemmingOperation.java @@ -5,9 +5,10 @@ import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class StemmingOperation implements FieldOperation { + private String setting; public String getSetting() { @@ -21,4 +22,5 @@ public class StemmingOperation implements FieldOperation { public void apply(SDField field) { field.setStemming(Stemming.get(setting)); } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/SummaryInFieldShortOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/SummaryInFieldShortOperation.java index a59252ab8a8..c1a5adb2ae7 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/SummaryInFieldShortOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/SummaryInFieldShortOperation.java @@ -5,9 +5,10 @@ import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.documentmodel.SummaryField; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class SummaryInFieldShortOperation extends SummaryInFieldOperation { + public SummaryInFieldShortOperation(String name) { super(name); } @@ -27,4 +28,5 @@ public class SummaryInFieldShortOperation extends SummaryInFieldOperation { } field.addSummaryField(ret); } + } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/docproc/DocumentProcessorModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/docproc/DocumentProcessorModelBuilder.java index 326494ee240..6f84afa2c6e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/docproc/DocumentProcessorModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/docproc/DocumentProcessorModelBuilder.java @@ -11,7 +11,7 @@ import java.util.HashMap; import java.util.Map; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class DocumentProcessorModelBuilder extends ChainedComponentModelBuilder { @@ -35,7 +35,7 @@ public class DocumentProcessorModelBuilder extends ChainedComponentModelBuilder * Parses a schemamapping element and generates a map of field mappings * * @param e a schemamapping element - * @return doctype,in-document → in-processor + * @return doctype, in-document → in-processor */ public static Map<Pair<String,String>, String> parseFieldNameSchemaMap(Element e) { Map<Pair<String, String>, String> ret = new HashMap<>(); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/TimeParser.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/TimeParser.java index e22cd0c72ea..33fb7db41ab 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/TimeParser.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/chains/search/TimeParser.java @@ -8,9 +8,10 @@ import java.util.regex.Pattern; * Utility class for parsing timeout fields. * * @author Tony Vaagenes - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> + * @author Steinar Knutsen */ public class TimeParser { + private static final Pattern timeoutPattern = Pattern.compile("(\\d+(\\.\\d*)?)\\s*(m)?s"); private static final double milliSecondsPerSecond = 1000.0d; @@ -24,7 +25,7 @@ public class TimeParser { if (matcher.group(3) != null) { value /= milliSecondsPerSecond; } - return Double.valueOf(value); + return value; } public static int asMilliSeconds(String timeout) { @@ -40,4 +41,5 @@ public class TimeParser { return (int) value; } + } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/docproc/model/DocumentProcessorModel.java b/config-model/src/main/java/com/yahoo/vespa/model/container/docproc/model/DocumentProcessorModel.java index 4798b942e5a..2825be32eb5 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/docproc/model/DocumentProcessorModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/docproc/model/DocumentProcessorModel.java @@ -11,11 +11,12 @@ import java.util.HashMap; import java.util.Map; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ @Immutable public class DocumentProcessorModel extends ChainedComponentModel { - private Map<Pair<String, String>, String> fieldNameSchemaMap = new HashMap<>(); + + private final Map<Pair<String, String>, String> fieldNameSchemaMap = new HashMap<>(); public DocumentProcessorModel(BundleInstantiationSpecification bundleInstantiationSpec, Dependencies dependencies, Map<Pair<String, String>, String> fieldNameSchemaMap) { super(bundleInstantiationSpec, dependencies); @@ -29,4 +30,5 @@ public class DocumentProcessorModel extends ChainedComponentModel { public Map<Pair<String,String>,String> fieldNameSchemaMap() { return fieldNameSchemaMap; } + } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/QrsCache.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/QrsCache.java index 78a1b01bacc..f47103b859e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/QrsCache.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/QrsCache.java @@ -4,12 +4,14 @@ package com.yahoo.vespa.model.container.search; /** * A helper class to wrap a set of QRS cache settings. * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> + * @author Steinar Knutsen */ public class QrsCache { + public final Integer size; public QrsCache(Integer size) { this.size = size; } + } diff --git a/container-disc/src/test/java/com/yahoo/container/jdisc/DisableOsgiFrameworkTest.java b/container-disc/src/test/java/com/yahoo/container/jdisc/DisableOsgiFrameworkTest.java index d784a7b1a30..875b3213c79 100644 --- a/container-disc/src/test/java/com/yahoo/container/jdisc/DisableOsgiFrameworkTest.java +++ b/container-disc/src/test/java/com/yahoo/container/jdisc/DisableOsgiFrameworkTest.java @@ -6,9 +6,9 @@ import org.osgi.framework.BundleException; /** * @author Ulf Lilleengen - * @since 5.1 */ public class DisableOsgiFrameworkTest { + @Test(expected = RuntimeException.class) public void require_that_installBundle_throws_exception() throws BundleException { new DisableOsgiFramework().installBundle("foo"); @@ -43,4 +43,5 @@ public class DisableOsgiFrameworkTest { public void require_that_stop_throws_exception() throws BundleException { new DisableOsgiFramework().stop(); } + } diff --git a/container-messagebus/src/test/java/com/yahoo/container/jdisc/messagebus/MbusClientProviderTest.java b/container-messagebus/src/test/java/com/yahoo/container/jdisc/messagebus/MbusClientProviderTest.java index 7ac05ab716b..6335cf01d8c 100644 --- a/container-messagebus/src/test/java/com/yahoo/container/jdisc/messagebus/MbusClientProviderTest.java +++ b/container-messagebus/src/test/java/com/yahoo/container/jdisc/messagebus/MbusClientProviderTest.java @@ -10,9 +10,9 @@ import static org.junit.Assert.assertNotNull; /** * @author Ulf Lilleengen - * @since 5.1 */ public class MbusClientProviderTest { + @Test public void testIntermediateClient() { SessionConfig.Builder builder = new SessionConfig.Builder(); @@ -34,4 +34,5 @@ public class MbusClientProviderTest { assertNotNull(p.get()); p.deconstruct(); } + } diff --git a/container-search/src/main/java/com/yahoo/prelude/query/ItemHelper.java b/container-search/src/main/java/com/yahoo/prelude/query/ItemHelper.java index b535ae7b8bd..cbdaa04a49f 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/ItemHelper.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/ItemHelper.java @@ -5,8 +5,9 @@ import java.util.Iterator; import java.util.List; /** - * Helper function for Item - * @author <a href="mailto:arnebef@yahoo-inc.com">Arne Bergene Fossaa</a> + * Helper functions for Item + * + * @author Arne Bergene Fossaa */ public class ItemHelper { @@ -77,5 +78,4 @@ public class ItemHelper { } } - } diff --git a/container-search/src/main/java/com/yahoo/prelude/query/SegmentingRule.java b/container-search/src/main/java/com/yahoo/prelude/query/SegmentingRule.java index 2a7089ed20e..891a7628a65 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/SegmentingRule.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/SegmentingRule.java @@ -7,9 +7,10 @@ package com.yahoo.prelude.query; * the default is creating a phrase, but for business reasons, some East Asian * languages use an AND instead. * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - * @since 5.1.28 + * @author Steinar Knutsen */ public enum SegmentingRule { + LANGUAGE_DEFAULT, PHRASE, BOOLEAN_AND; + } diff --git a/container-search/src/main/java/com/yahoo/prelude/query/SuffixItem.java b/container-search/src/main/java/com/yahoo/prelude/query/SuffixItem.java index 7baca8d60ba..cb87ca85d9a 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/SuffixItem.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/SuffixItem.java @@ -5,9 +5,8 @@ package com.yahoo.prelude.query; /** * A word that matches a suffix of words instead of a complete word. * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> + * @author Steinar Knutsen */ - public class SuffixItem extends WordItem { public SuffixItem(String suffix) { diff --git a/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java b/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java index 0e1acd66600..f344872955a 100644 --- a/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java @@ -14,16 +14,15 @@ import com.yahoo.search.statistics.TimeTracker.Activity; import com.yahoo.statistics.Statistics; import com.yahoo.statistics.Value; - /** * A searcher which is intended to be useful as a general probe for * measuring time consumption a search chain. * - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> + * @author Steinar Knutsen */ @Before("rawQuery") public class TimingSearcher extends PingableSearcher { + private Value measurements; private final boolean measurePing; private final boolean measureSearch; @@ -140,5 +139,4 @@ public class TimingSearcher extends PingableSearcher { super.deconstruct(); } - } diff --git a/container-search/src/main/java/com/yahoo/search/yql/NullItemException.java b/container-search/src/main/java/com/yahoo/search/yql/NullItemException.java index b451b9c85c5..8502af76858 100644 --- a/container-search/src/main/java/com/yahoo/search/yql/NullItemException.java +++ b/container-search/src/main/java/com/yahoo/search/yql/NullItemException.java @@ -4,11 +4,12 @@ package com.yahoo.search.yql; /** * Used to communicate a NullItem has been encountered in the query tree. * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> + * @author Steinar Knutsen */ -@SuppressWarnings("serial") public class NullItemException extends RuntimeException { + public NullItemException(String message) { super(message); } + } diff --git a/container-search/src/main/java/com/yahoo/text/interpretation/Annotations.java b/container-search/src/main/java/com/yahoo/text/interpretation/Annotations.java index 5afe51d4415..f625bedca19 100644 --- a/container-search/src/main/java/com/yahoo/text/interpretation/Annotations.java +++ b/container-search/src/main/java/com/yahoo/text/interpretation/Annotations.java @@ -8,28 +8,26 @@ import java.util.Map; /** * An annotation is a description of a an area of text, with a given class. For example, an annotation for the * - * @author <a href="mailto:arnebef@yahoo-inc.com">Arne Bergene Fossaa</a> + * @author Arne Bergene Fossaa */ public class Annotations { - - private Span span; + private final Span span; protected Map<String,Object> annotations; - /** * Adds an annotation to the the the set of annotations. */ public void put(String key,Object o) { - if(annotations == null) { + if (annotations == null) { annotations = new HashMap<>(); } annotations.put(key,o); } public Map<String,Object> getMap() { - if(annotations == null) { + if (annotations == null) { return Collections.emptyMap(); } else { return annotations; @@ -113,12 +111,11 @@ public class Annotations { */ public Boolean getBoolean(String key) { Object o = getMap().get(key); - if(o == null || !(o instanceof Boolean)) { + if ( ! (o instanceof Boolean)) { return null; } else { - return (Boolean) o; + return (Boolean)o; } } - } diff --git a/container-search/src/main/java/com/yahoo/text/interpretation/Interpretation.java b/container-search/src/main/java/com/yahoo/text/interpretation/Interpretation.java index 9a9b8e81633..f662a0a4e7e 100644 --- a/container-search/src/main/java/com/yahoo/text/interpretation/Interpretation.java +++ b/container-search/src/main/java/com/yahoo/text/interpretation/Interpretation.java @@ -21,21 +21,19 @@ import java.util.Set; * is not needed. * * @see Span - * @author <a href="mailto:arnebef@yahoo-inc.com">Arne Bergene Fossaa</a> + * @author Arne Bergene Fossaa */ public class Interpretation { - private Modification modification; + private final Modification modification; private double probability; - private Span rootSpan; + private final Span rootSpan; public final static AnnotationClass INTERPRETATION_CLASS = new AnnotationClass("interpretation"); - /** * Creates a new interpretation and a new modification from the text, * with the probability set to the default value(0.0). - */ public Interpretation(String text) { this(text,0.0); @@ -48,7 +46,6 @@ public class Interpretation { this(new Modification(text),probabilty); } - /** * Creates a new interpretation based on the modification, with the probability set to the default value(0.0). */ @@ -65,12 +62,10 @@ public class Interpretation { setProbability(probability); } - public Modification getModification() { return modification; } - /** * The probability that this interpretation is correct. * @return a value between 0.0 and 1.0 that gives the probability that this interpretation is correct @@ -98,13 +93,12 @@ public class Interpretation { /** Returns the root of the tree representation of the interpretation */ public Span root() { return rootSpan; } - // Wrapper methods for Span /** * Return the annotation with the given annotationclass (and create it if necessary). - * @param annotationClass The class of the annotation * + * @param annotationClass The class of the annotation */ public Annotations annotate(String annotationClass) { return annotate(new AnnotationClass(annotationClass)); @@ -112,8 +106,8 @@ public class Interpretation { /** * Return the annotation with the given annotationclass (and create it if necessary). - * @param annotationClass The class of the annotation * + * @param annotationClass The class of the annotation */ public Annotations annotate(AnnotationClass annotationClass) { return rootSpan.annotate(annotationClass); @@ -124,6 +118,7 @@ public class Interpretation { * exist, a new is created. * * A shortcut for annotate(annotationClass).put(key,value) + * * @param annotationClass class of the annotation * @param key key of the property to set on the annotation * @param value value of the property to set on the annotation @@ -137,6 +132,7 @@ public class Interpretation { * exist, a new is created. * * A shortcut for annotate(annotationClass).put(key,value) + * * @param annotationClass class of the annotation * @param key key of the property to set on the annotation * @param value value of the property to set on the annotation @@ -147,6 +143,7 @@ public class Interpretation { /** * Returns the annotation with the given annotationClass (and create it if necessary). + * * @param from start of the substring * @param to end of the substring * @param annotationClass class of the annotation @@ -157,6 +154,7 @@ public class Interpretation { /** * Returns the annotation with the given annotationClass (and create it if necessary). + * * @param from start of the substring * @param to end of the substring * @param annotationClass class of the annotation @@ -169,7 +167,8 @@ public class Interpretation { * Sets a key/value pair for an annotation of a substring. If an annotation of the class * does not exist, a new is created. * - * A shortcut for annotate(from, to, annotationClass, key, value + * A shortcut for annotate(from, to, annotationClass, key, value) + * * @param from start of the substring * @param to end of the substring * @param annotationClass class of the annotation @@ -184,7 +183,8 @@ public class Interpretation { * Sets a key/value pair for an annotation of a substring. If an annotation of the class * does not exist, a new is created. * - * A shortcut for annotate(from, to, annotationClass, key, value + * A shortcut for annotate(from, to, annotationClass, key, value) + * * @param from start of the substring * @param to end of the substring * @param annotationClass class of the annotation @@ -219,12 +219,7 @@ public class Interpretation { */ public List<Annotations> getAll(AnnotationClass annotationClass) { // TODO: This implementation is very inefficient because it unnecessarily collects for all classes - Map<AnnotationClass,List<Annotations>> all = getAll(); - if(all.containsKey(annotationClass)){ - return all.get(annotationClass); - } else { - return Collections.emptyList(); - } + return getAll().getOrDefault(annotationClass, List.of()); } /** @@ -256,7 +251,7 @@ public class Interpretation { /** * Gets the value of a property set on an annotation. * If the annotation or the key/value pair does not exists, null - * is returned + * is returned. */ public Object get(String annotationClass,String key) { return get(new AnnotationClass(annotationClass),key); @@ -265,7 +260,7 @@ public class Interpretation { /** * Gets the value of a property set on an annotation. * If the annotation or the key/value pair does not exists, null - * is returned + * is returned. */ public Object get(AnnotationClass annotationClass,String key) { Annotations annotations = get(annotationClass); @@ -280,7 +275,7 @@ public class Interpretation { * Equivalent to <code>get(from,to,new AnnotationClass(annotationClass))</code> */ public Annotations get(int from, int to, String annotationClass) { - return get(from,to,new AnnotationClass(annotationClass)); + return get(from, to, new AnnotationClass(annotationClass)); } /** @@ -310,7 +305,7 @@ public class Interpretation { * @return the anno */ public Annotations get(int from, int to, AnnotationClass annotationClass ) { - return rootSpan.getAnnotation(from,to,annotationClass); + return rootSpan.getAnnotation(from, to, annotationClass); } /** @@ -320,9 +315,9 @@ public class Interpretation { * is returned. * */ - public Object get(int from,int to,String annotationClass,String key) { - Annotations annotations = get(from,to,annotationClass); - if(annotations != null) { + public Object get(int from, int to, String annotationClass, String key) { + Annotations annotations = get(from, to, annotationClass); + if (annotations != null) { return annotations.get(key); } else { return null; @@ -331,7 +326,6 @@ public class Interpretation { /** * Gets all the annotationclasses that describes the text. - */ public Set<AnnotationClass> getClasses() { return rootSpan.getClasses(); @@ -399,7 +393,7 @@ public class Interpretation { } } sb.append("}"); - } } + } diff --git a/container-search/src/main/java/com/yahoo/text/interpretation/Modification.java b/container-search/src/main/java/com/yahoo/text/interpretation/Modification.java index e2fd5a5ec5c..28cf11c62b1 100644 --- a/container-search/src/main/java/com/yahoo/text/interpretation/Modification.java +++ b/container-search/src/main/java/com/yahoo/text/interpretation/Modification.java @@ -9,21 +9,14 @@ import java.util.HashMap; * This class represents a possible rewrite of an original text. Reasons for rewrite may be due to possible * spelling errors in the text or to query expansion. * - * @author <a href="mailto:arnebef@yahoo-inc.com">Arne Bergene Fossaa</a> + * @author Arne Bergene Fossaa */ public class Modification extends HashMap<String,Object>{ - /** - * - */ - private static final long serialVersionUID = -8522335044460396296L; - - public final static AnnotationClass MODIFICATION_CLASS = new AnnotationClass("modification"); - - private String text; - private Annotations annotations; + private final String text; + private final Annotations annotations; public Modification(String text) { this.text = text; diff --git a/container-search/src/main/java/com/yahoo/text/interpretation/Span.java b/container-search/src/main/java/com/yahoo/text/interpretation/Span.java index 6ade5e323e7..90cc6231d48 100644 --- a/container-search/src/main/java/com/yahoo/text/interpretation/Span.java +++ b/container-search/src/main/java/com/yahoo/text/interpretation/Span.java @@ -22,7 +22,7 @@ import java.util.Set; * <p> * A span will usually be used indirectly through Interpretation. * - * @author <a href="mailto:arnebef@yahoo-inc.com">Arne Bergene Fossaa</a> + * @author Arne Bergene Fossaa */ public class Span { @@ -33,7 +33,6 @@ public class Span { private final int from; private final int to; - /** * Creates a new root span based on the modfication */ @@ -44,7 +43,7 @@ public class Span { this.to = modification.getText().length(); } - //This constructor is private to ensure that all child spans for a span is contained inside it. + // This constructor is private to ensure that all child spans for a span is contained inside it. private Span(int from, int to, Span parent) { this.parent = parent; this.modification = parent.modification; @@ -52,8 +51,6 @@ public class Span { this.to = to; } - - /** * Returns the text that this spans is */ @@ -61,12 +58,11 @@ public class Span { return modification.getText().substring(from, to); } - + @Override public String toString() { return "SPAN: " + getText(); } - public Annotations annotate(AnnotationClass clazz) { Annotations annotations = this.annotations.get(clazz); if (!this.annotations.containsKey(clazz)) { @@ -83,7 +79,6 @@ public class Span { return addAnnotation(from, to, clazz); } - /** * Returns all annotations that are contained in either this subspan or in any of its subannotations */ @@ -124,7 +119,7 @@ public class Span { * @throws RuntimeException if (from,to) is not contained in the span */ public Annotations getAnnotation(int from, int to, AnnotationClass clazz) { - if(from < this.from || to > this.to) { + if (from < this.from || to > this.to) { throw new RuntimeException("Trying to get a range that is outside this span"); } if (this.parent != null) { @@ -140,13 +135,12 @@ public class Span { */ public Set<AnnotationClass> getClasses() { return getClasses(from, to); - } /** * Returns all AnnotationClasses that are defined for the range (from,to). * - * @throws RuntimeException if (from,to) is not contained in the span + * @throws RuntimeException if (from, to) is not contained in the span */ public Set<AnnotationClass> getClasses(int from, int to) { if(from < this.from || to > this.to) { @@ -161,8 +155,6 @@ public class Span { } } - - /** * Returns an unmodifiable list of all spans below this span that is a leaf node */ @@ -191,26 +183,25 @@ public class Span { /** hack */ public int getFrom() { return from; } + /** hack */ public int getTo() { return to; } - //Needed by addAnnotation + // Needed by addAnnotation private List<Span> getRemovableSubSpan() { return subSpans == null ? Collections.<Span>emptyList() : subSpans; } - private void addSubSpan(Span span) { - if(subSpans == null) { + if (subSpans == null) { subSpans = new ArrayList<>(); } subSpans.add(span); } - - /* + /** * How this works: * * First we check if any excisting subannotation can contain this annotation. If so, we leave it to them to add @@ -222,7 +213,7 @@ public class Span { */ private Annotations addAnnotation(int from, int to, AnnotationClass clazz) { if (equalsRange(from, to)) { - //We simply add everything from the new span to this + // We simply add everything from the new span to this if (annotations.containsKey(clazz)) { return annotations.get(clazz); } else { @@ -232,7 +223,7 @@ public class Span { } } - //We then check if any of the children intersects + // We then check if any of the children intersects for (Span subSpan : getSubSpans()) { if (subSpan.intersects(from, to)) { throw new RuntimeException("Trying to add span that intersects already excisting span"); @@ -241,14 +232,13 @@ public class Span { } } - //We now know that we have to add the new span to this span + // We now know that we have to add the new span to this span Span span = new Span(from, to, this); Annotations nAnnotations = new Annotations(span); span.annotations.put(clazz,nAnnotations); addSubSpan(span); - - //We then add any subannotation that is inside the span + // We then add any subannotation that is inside the span Iterator<Span> subIterator = getRemovableSubSpan().iterator(); while (subIterator.hasNext()) { @@ -256,7 +246,7 @@ public class Span { if (subSpan.contains(from, to)) { return subSpan.addAnnotation(from, to, clazz); } else if (subSpan.isInside(from, to)) { - //Overtake the subannotation + // Take over the subannotation subSpan.parent = span; span.addSubSpan(subSpan); subIterator.remove(); @@ -265,7 +255,6 @@ public class Span { return nAnnotations; } - private boolean contains(int from, int to) { return this.from <= from && this.to >= to; } @@ -274,12 +263,9 @@ public class Span { return this.from >= from && this.to <= to; } - private boolean intersects(int from, int to) { return (this.from < from && this.to > from && this.to < to) || (this.from < to && this.to > to && this.from > from); - - } private boolean equalsRange(int from, int to) { @@ -336,7 +322,7 @@ public class Span { if (!contains(from, to)) { return null; } - //First yourself, then the subs + // First yourself, then the subs Annotations annotations = this.annotations.get(clazz); for (Span subSpan : getSubSpans()) { Annotations subAnnotations = subSpan.getBestAnnotation(from, to, clazz); @@ -346,4 +332,5 @@ public class Span { } return annotations; } + } diff --git a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/Visitor.java b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/Visitor.java index e8b83495c69..8065f71c1f0 100644 --- a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/Visitor.java +++ b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/Visitor.java @@ -15,7 +15,7 @@ import java.util.Map; /** * Visitor for performing searches and accessing results. * - * @author <a href="mailto:ulf@yahoo-inc.com">Ulf Carlin</a> + * @author Ulf Carlin */ interface Visitor { diff --git a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VisitorFactory.java b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VisitorFactory.java index 7ce323a2f2b..421a36dbc63 100644 --- a/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VisitorFactory.java +++ b/container-search/src/main/java/com/yahoo/vespa/streamingvisitors/VisitorFactory.java @@ -7,7 +7,7 @@ import com.yahoo.search.Query; /** * A factory that creates Visitors. * - * @author <a href="mailto:ulf@yahoo-inc.com">Ulf Carlin</a> + * @author Ulf Carlin */ interface VisitorFactory { diff --git a/document/src/main/java/com/yahoo/document/CollectionDataType.java b/document/src/main/java/com/yahoo/document/CollectionDataType.java index c6420b5e71f..9088f48d827 100644 --- a/document/src/main/java/com/yahoo/document/CollectionDataType.java +++ b/document/src/main/java/com/yahoo/document/CollectionDataType.java @@ -9,9 +9,10 @@ import com.yahoo.vespa.objects.ObjectVisitor; import java.util.List; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public abstract class CollectionDataType extends DataType { + // The global class identifier shared with C++. public static int classId = registerClass(Ids.document + 53, CollectionDataType.class); @@ -23,7 +24,7 @@ public abstract class CollectionDataType extends DataType { } @Override - public abstract CollectionFieldValue createFieldValue(); + public abstract CollectionFieldValue<?> createFieldValue(); @Override public CollectionDataType clone() { @@ -56,7 +57,7 @@ public abstract class CollectionDataType extends DataType { if (!(value instanceof CollectionFieldValue)) { return false; } - CollectionFieldValue cfv = (CollectionFieldValue) value; + CollectionFieldValue<?> cfv = (CollectionFieldValue<?>) value; return equals(cfv.getDataType()); } diff --git a/document/src/main/java/com/yahoo/document/DocumentTypeId.java b/document/src/main/java/com/yahoo/document/DocumentTypeId.java index d7ecfb11c31..0b90493f4cd 100644 --- a/document/src/main/java/com/yahoo/document/DocumentTypeId.java +++ b/document/src/main/java/com/yahoo/document/DocumentTypeId.java @@ -4,10 +4,11 @@ package com.yahoo.document; /** * The id of a document type. * - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class DocumentTypeId { - private int id; + + private final int id; public DocumentTypeId(int id) { this.id = id; @@ -17,17 +18,21 @@ public class DocumentTypeId { return id; } + @Override public boolean equals(Object o) { if (!(o instanceof DocumentTypeId)) return false; DocumentTypeId other = (DocumentTypeId) o; return other.id == this.id; } + @Override public int hashCode() { return id; } + @Override public String toString() { return "" + id; } + } diff --git a/document/src/main/java/com/yahoo/document/Generated.java b/document/src/main/java/com/yahoo/document/Generated.java index 6c02bc7ee0a..b58471617fb 100644 --- a/document/src/main/java/com/yahoo/document/Generated.java +++ b/document/src/main/java/com/yahoo/document/Generated.java @@ -9,7 +9,7 @@ import java.lang.annotation.RetentionPolicy; * differs from <code>javax.annotation.Generated</code> in that the retention * policy is Runtime. * - * @author <a href="mailto:vegardh@yahoo-inc.com">Vegard Havdal</a> + * @author Vegard Havdal */ @Retention(RetentionPolicy.RUNTIME) public @interface Generated { diff --git a/document/src/main/java/com/yahoo/document/TemporaryStructuredDataType.java b/document/src/main/java/com/yahoo/document/TemporaryStructuredDataType.java index 1f99cc7bf0e..0449612da6f 100644 --- a/document/src/main/java/com/yahoo/document/TemporaryStructuredDataType.java +++ b/document/src/main/java/com/yahoo/document/TemporaryStructuredDataType.java @@ -4,7 +4,7 @@ package com.yahoo.document; /** * Internal class, DO NOT USE!! Only public because it must be used from com.yahoo.searchdefinition.parser. * - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class TemporaryStructuredDataType extends StructDataType { @@ -29,4 +29,5 @@ public class TemporaryStructuredDataType extends StructDataType { super.setName(name); setId(createId(getName())); } + } diff --git a/document/src/main/java/com/yahoo/document/annotation/AlternateSpanList.java b/document/src/main/java/com/yahoo/document/annotation/AlternateSpanList.java index bfac5c2c620..54511d6d0b9 100644 --- a/document/src/main/java/com/yahoo/document/annotation/AlternateSpanList.java +++ b/document/src/main/java/com/yahoo/document/annotation/AlternateSpanList.java @@ -14,12 +14,14 @@ import java.util.ListIterator; * A node in a {@link SpanNode} tree that can have a <strong>multiple</strong> trees of child nodes, each with its own probability. * This class has quite a few convenience methods for accessing the <strong>first</strong> subtree. * - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge * @see com.yahoo.document.annotation.SpanList */ public class AlternateSpanList extends SpanList { + public static final byte ID = 4; - private final List<Children> childTrees = new LinkedList<Children>(); + + private final List<Children> childTrees = new LinkedList<>(); private static final Comparator<Children> childComparator = new ProbabilityComparator(); /** Create a new AlternateSpanList instance, having a single subtree with probability 1.0. */ @@ -28,7 +30,7 @@ public class AlternateSpanList extends SpanList { ensureAtLeastOneSubTree(); } - /* + /** * Deep-copies another AlternateSpanList. * * @param otherSpanList the instance to deep-copy. @@ -267,7 +269,6 @@ public class AlternateSpanList extends SpanList { } } - /** * Traverses all immediate children of all subtrees of this AlternateSpanList. * The ListIterator only supports iteration forwards, and the optional operations that are implemented are @@ -334,7 +335,6 @@ public class AlternateSpanList extends SpanList { return children(i).size(); } - /** * Returns a modifiable {@link List} of child nodes of the specified subtree. * @@ -345,7 +345,6 @@ public class AlternateSpanList extends SpanList { return childTrees.get(i).children(); } - @Override void setParent(SpanNodeParent parent) { super.setParent(parent); @@ -436,7 +435,6 @@ public class AlternateSpanList extends SpanList { } } - /** * Sets the subtree at index i. * @@ -597,7 +595,6 @@ public class AlternateSpanList extends SpanList { return "AlternateSpanList, num subtrees=" + getNumSubTrees(); } - private static class ProbabilityComparator implements Comparator<Children> { @Override public int compare(Children o1, Children o2) { @@ -606,6 +603,7 @@ public class AlternateSpanList extends SpanList { } private class Children extends SpanList { + private double probability = 1.0; private Children(SpanNodeParent parent) { @@ -630,5 +628,7 @@ public class AlternateSpanList extends SpanList { public void setProbability(double probability) { this.probability = probability; } + } + } diff --git a/document/src/main/java/com/yahoo/document/annotation/Annotation.java b/document/src/main/java/com/yahoo/document/annotation/Annotation.java index 4b9452f3400..1aaaa8e1d16 100644 --- a/document/src/main/java/com/yahoo/document/annotation/Annotation.java +++ b/document/src/main/java/com/yahoo/document/annotation/Annotation.java @@ -5,21 +5,21 @@ import com.yahoo.document.DataType; import com.yahoo.document.datatypes.FieldValue; /** - * An Annotation describes some kind of information associated with - * a {@link SpanNode}. + * An Annotation describes some kind of information associated with a {@link SpanNode}. * - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> * @see com.yahoo.document.annotation.SpanNode * @see com.yahoo.document.annotation.AnnotationType + * @author Einar M R Rosenvinge */ public class Annotation implements Comparable<Annotation> { + private AnnotationType type; private SpanNode spanNode = null; private FieldValue value = null; - /** - * This scratch id is used to avoid using IdentityHashMaps as they are very costly. - */ + + /** This scratch id is used to avoid using IdentityHashMaps as they are very costly. */ private int scratchId = -1; + public void setScratchId(int id) { scratchId = id; } @@ -30,7 +30,7 @@ public class Annotation implements Comparable<Annotation> { /** - * Constructs an Annotation without a type. BEWARE! Should only be used during deserialization. + * Constructs an Annotation without a type. BEWARE! Should only be used during deserialization. */ public Annotation() { } @@ -77,7 +77,7 @@ public class Annotation implements Comparable<Annotation> { } /** - * Sets the type of this annotation. BEWARE! Should only be used during deserialization. + * Sets the type of this annotation. BEWARE! Should only be used during deserialization. * * @param type the type of this annotation */ @@ -96,9 +96,9 @@ public class Annotation implements Comparable<Annotation> { } /** - * Returns true iff. this Annotation is associated with a SpanNode and the SpanNode is valid. + * Returns true iff this Annotation is associated with a SpanNode and the SpanNode is valid. * - * @return true iff. this Annotation is associated with a SpanNode and the SpanNode is valid. + * @return true iff this Annotation is associated with a SpanNode and the SpanNode is valid. * @see com.yahoo.document.annotation.SpanNode#isValid() */ public boolean isSpanNodeValid() { @@ -129,7 +129,7 @@ public class Annotation implements Comparable<Annotation> { } /** - * WARNING! Should only be used by deserializers! Sets the span node that this annotation points to. + * WARNING! Should only be used by deserializers! Sets the span node that this annotation points to. * * @param spanNode the span node that this annotation shall point to. */ @@ -143,14 +143,14 @@ public class Annotation implements Comparable<Annotation> { throw new IllegalStateException("Span node is invalid: " + spanNode); } if (spanNode == DummySpanNode.INSTANCE) { - //internal safeguard - throw new IllegalStateException("BUG!! Annotations should never be attached to DummySpanNode."); + // internal safeguard + throw new IllegalStateException("BUG! Annotations should never be attached to DummySpanNode."); } this.spanNode = spanNode; } /** - * WARNING! Should only be used by deserializers! Sets the span node that this annotation points to. + * WARNING! Should only be used by deserializers! Sets the span node that this annotation points to. * * @param spanNode the span node that this annotation shall point to. */ @@ -247,7 +247,7 @@ public class Annotation implements Comparable<Annotation> { return comp; } - //types are equal, too, compare values + // types are equal, too, compare values if (value == null) { comp = (annotation.value == null) ? 0 : -1; } else { @@ -256,5 +256,6 @@ public class Annotation implements Comparable<Annotation> { return comp; } + } diff --git a/document/src/main/java/com/yahoo/document/annotation/AnnotationContainer.java b/document/src/main/java/com/yahoo/document/annotation/AnnotationContainer.java index 40651bdc123..e9a81f16f90 100644 --- a/document/src/main/java/com/yahoo/document/annotation/AnnotationContainer.java +++ b/document/src/main/java/com/yahoo/document/annotation/AnnotationContainer.java @@ -5,7 +5,7 @@ import java.util.Collection; import java.util.Iterator; /** - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ abstract class AnnotationContainer { @@ -46,6 +46,6 @@ abstract class AnnotationContainer { */ abstract Iterator<Annotation> iteratorRecursive(SpanNode node); + // TODO: remember equals and hashcode in subclasses! - //TODO: remember equals and hashcode in subclasses! } diff --git a/document/src/main/java/com/yahoo/document/annotation/AnnotationReference.java b/document/src/main/java/com/yahoo/document/annotation/AnnotationReference.java index be6f4955dcf..66ab895c88b 100644 --- a/document/src/main/java/com/yahoo/document/annotation/AnnotationReference.java +++ b/document/src/main/java/com/yahoo/document/annotation/AnnotationReference.java @@ -12,8 +12,8 @@ import com.yahoo.vespa.objects.Ids; /** * A FieldValue which holds a reference to an annotation of a specified type. * - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> * @see Annotation#setFieldValue(com.yahoo.document.datatypes.FieldValue) + * @author Einar M R Rosenvinge */ public class AnnotationReference extends FieldValue { @@ -123,7 +123,7 @@ public class AnnotationReference extends FieldValue { @Override public void printXml(XmlStream xml) { - //TODO: Implement AnnotationReference.printXml() + // TODO: Implement AnnotationReference.printXml() } @Override @@ -182,4 +182,5 @@ public class AnnotationReference extends FieldValue { } return comp; } + } diff --git a/document/src/main/java/com/yahoo/document/annotation/AnnotationReferenceDataType.java b/document/src/main/java/com/yahoo/document/annotation/AnnotationReferenceDataType.java index 9adf7397a52..26b8919f4b8 100644 --- a/document/src/main/java/com/yahoo/document/annotation/AnnotationReferenceDataType.java +++ b/document/src/main/java/com/yahoo/document/annotation/AnnotationReferenceDataType.java @@ -7,15 +7,16 @@ import com.yahoo.document.datatypes.FieldValue; /** * A data type describing a field value having a reference to an annotation of a given type. * - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class AnnotationReferenceDataType extends DataType { + private AnnotationType aType; /** * Creates an AnnotationReferenceDataType with a generated id. * - * @param aType the annotation type that AnnotationRefs shall refer to. + * @param aType the annotation type that AnnotationRefs shall refer to */ public AnnotationReferenceDataType(AnnotationType aType) { super("annotationreference<" + ((aType == null) ? "" : aType.getName()) + ">", 0); @@ -25,7 +26,7 @@ public class AnnotationReferenceDataType extends DataType { /** * Creates an AnnotationReferenceDataType with a given id. * - * @param aType the annotation type that AnnotationRefs shall refer to. + * @param aType the annotation type that AnnotationRefs shall refer to * @param id the id to use */ public AnnotationReferenceDataType(AnnotationType aType, int id) { @@ -34,7 +35,7 @@ public class AnnotationReferenceDataType extends DataType { } /** - * Creates an AnnotationReferenceDataType. WARNING! Do not use! + * Creates an AnnotationReferenceDataType. WARNING! Do not use! */ protected AnnotationReferenceDataType() { super("annotationreference<>", 0); @@ -77,11 +78,12 @@ public class AnnotationReferenceDataType extends DataType { } /** - * Sets the annotation type that this AnnotationReferenceDataType points to. WARNING! Do not use. + * Sets the annotation type that this AnnotationReferenceDataType points to. WARNING! Do not use. * @param type the annotation type of this AnnotationReferenceDataType. */ protected void setAnnotationType(AnnotationType type) { this.aType = type; setId(createId()); } + } diff --git a/document/src/main/java/com/yahoo/document/annotation/AnnotationType.java b/document/src/main/java/com/yahoo/document/annotation/AnnotationType.java index 15e30b1f882..c93c69b08fc 100644 --- a/document/src/main/java/com/yahoo/document/annotation/AnnotationType.java +++ b/document/src/main/java/com/yahoo/document/annotation/AnnotationType.java @@ -16,9 +16,10 @@ import java.util.Collections; * that type are allowed to have a {@link com.yahoo.document.datatypes.FieldValue} of the given * {@link com.yahoo.document.DataType} as an optional payload. * - * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + * @author Einar M R Rosenvinge */ public class AnnotationType implements Comparable<AnnotationType> { + private final int id; private final String name; private DataType dataType; @@ -60,7 +61,7 @@ public class AnnotationType implements Comparable<AnnotationType> { } /** - * Creates a new annotation type, with the specified ID. WARNING! Only to be used by configuration + * Creates a new annotation type, with the specified ID. WARNING! Only to be used by configuration * system, do not use!! * * @param name the name of the new annotation type @@ -71,26 +72,18 @@ public class AnnotationType implements Comparable<AnnotationType> { this.name = name; } - /** - * Returns the name of this annotation. - * - * @return the name of this annotation. - */ + /** Returns the name of this annotation. */ public String getName() { return name; } - /** - * Returns the data type of this annotation, if any. - * - * @return the data type of this annotation, or null. - */ + /** Returns the data type of this annotation, if any. */ public DataType getDataType() { return dataType; } /** - * Sets the data type of this annotation. WARNING! Only to be used by configuration + * Sets the data type of this annotation. WARNING! Only to be used by configuration * system, do not use!! * * @param dataType the data type of the annotation value @@ -99,11 +92,7 @@ public class AnnotationType implements Comparable<AnnotationType> { this.dataType = dataType; } - /** - * Returns the ID of this annotation. - * - * @return the ID of this annotation. - */ + /** Returns the ID of this annotation. */ public int getId() { return id; } @@ -121,13 +110,14 @@ public class AnnotationType implements Comparable<AnnotationType> { } /** - * WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code. + * WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code. * * @param type the type to inherit from */ public void inherit(AnnotationType type) { if (superType != null) { - throw new IllegalArgumentException("Already inherits type " + superType + ", multiple inheritance not currently supported."); + throw new IllegalArgumentException("Already inherits type " + superType + + ", multiple inheritance not currently supported."); } superType = type; } @@ -183,4 +173,5 @@ public class AnnotationType implements Comparable<AnnotationType> { } return 0; } + } |