aboutsummaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-02-21 14:41:50 +0100
committerJon Bratseth <bratseth@gmail.com>2021-02-21 14:41:50 +0100
commite5852de9c3fcfd5714aa20512014e1524338c844 (patch)
tree9b09189f6258bec37174ea90b0ef97930232d014 /document
parentafe876252b56b5a30735865047d7392958835f6a (diff)
Non-functional changes only
Diffstat (limited to 'document')
-rw-r--r--document/src/main/java/com/yahoo/document/CollectionDataType.java7
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentTypeId.java9
-rw-r--r--document/src/main/java/com/yahoo/document/Generated.java2
-rw-r--r--document/src/main/java/com/yahoo/document/TemporaryStructuredDataType.java3
-rw-r--r--document/src/main/java/com/yahoo/document/annotation/AlternateSpanList.java16
-rw-r--r--document/src/main/java/com/yahoo/document/annotation/Annotation.java31
-rw-r--r--document/src/main/java/com/yahoo/document/annotation/AnnotationContainer.java4
-rw-r--r--document/src/main/java/com/yahoo/document/annotation/AnnotationReference.java5
-rw-r--r--document/src/main/java/com/yahoo/document/annotation/AnnotationReferenceDataType.java12
-rw-r--r--document/src/main/java/com/yahoo/document/annotation/AnnotationType.java31
10 files changed, 61 insertions, 59 deletions
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!!&nbsp;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.&nbsp;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.&nbsp;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.&nbsp;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.&nbsp;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!&nbsp;Should only be used by deserializers!&nbsp;Sets the span node that this annotation points to.
+ * WARNING! Should only be used by deserializers!&nbsp;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!&nbsp;Should only be used by deserializers!&nbsp;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.&nbsp;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.&nbsp;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.&nbsp;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.&nbsp;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!&nbsp;Only to be used by the configuration system and in unit tests.&nbsp;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;
}
+
}