aboutsummaryrefslogtreecommitdiffstats
path: root/document/src
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2022-03-08 08:48:21 +0000
committerArne H Juul <arnej@yahooinc.com>2022-03-08 08:48:27 +0000
commit4b798440baad23420c2f1cd853a47f9e2d9f8f5d (patch)
tree5a7c186aab27d4fd0e2b6adefef812061e889b3f /document/src
parentefeacc80ae83629377a7c0a58e2872927a658d4d (diff)
deprecate useless constructor
* always ignored non-null typeName * the intention was probably something else * was not used anywhere
Diffstat (limited to 'document/src')
-rw-r--r--document/src/main/java/com/yahoo/document/DataType.java1
-rw-r--r--document/src/main/java/com/yahoo/document/WeightedSetDataType.java28
2 files changed, 19 insertions, 10 deletions
diff --git a/document/src/main/java/com/yahoo/document/DataType.java b/document/src/main/java/com/yahoo/document/DataType.java
index bb1777954a3..697536a8ac0 100644
--- a/document/src/main/java/com/yahoo/document/DataType.java
+++ b/document/src/main/java/com/yahoo/document/DataType.java
@@ -52,6 +52,7 @@ public abstract class DataType extends Identifiable implements Serializable, Com
public final static DocumentType DOCUMENT = new DocumentType("document");
public final static PrimitiveDataType URI = new PrimitiveDataType("uri", 10, UriFieldValue.class, new UriFieldValue.Factory());
public final static NumericDataType BYTE = new NumericDataType("byte", 16, ByteFieldValue.class, ByteFieldValue.getFactory());
+ final static int TAG_ID = 18;
public final static PrimitiveDataType PREDICATE = new PrimitiveDataType("predicate", 20, PredicateFieldValue.class, PredicateFieldValue.getFactory());
public final static int tensorDataTypeCode = 21; // All TensorDataType instances have id=21 but carries additional type information serialized separately
// ADDITIONAL parametrized types added at runtime: map, struct, array, weighted set, annotation reference, tensor
diff --git a/document/src/main/java/com/yahoo/document/WeightedSetDataType.java b/document/src/main/java/com/yahoo/document/WeightedSetDataType.java
index 35dd13efb0b..b21f059bd7d 100644
--- a/document/src/main/java/com/yahoo/document/WeightedSetDataType.java
+++ b/document/src/main/java/com/yahoo/document/WeightedSetDataType.java
@@ -24,25 +24,33 @@ public class WeightedSetDataType extends CollectionDataType {
public WeightedSetDataType(DataType nestedType, boolean createIfNonExistent, boolean removeIfZero) {
this(nestedType, createIfNonExistent, removeIfZero, 0);
- if ((nestedType == STRING) && createIfNonExistent && removeIfZero) { // the tag type definition
- setId(18);
- } else {
- setId(getName().toLowerCase().hashCode());
- }
}
public WeightedSetDataType(DataType nestedType, boolean createIfNonExistent, boolean removeIfZero, int id) {
super(createName(nestedType, createIfNonExistent, removeIfZero), id, nestedType);
this.createIfNonExistent = createIfNonExistent;
this.removeIfZero = removeIfZero;
+ if (id == 0) {
+ if ((nestedType == STRING) && createIfNonExistent && removeIfZero) { // the tag type definition
+ setId(TAG_ID);
+ } else {
+ setId(getName().toLowerCase().hashCode());
+ }
+ }
+ int code = getId();
+ if ((code >= 0) && (code <= DataType.lastPredefinedDataTypeId()) && (code != TAG_ID)) {
+ throw new IllegalArgumentException("Cannot create a weighted set datatype with code " + code);
+ }
}
+ /*
+ * @deprecated // TODO remove on Vespa 8
+ * Do not use - use one of the constructors above.
+ * Note: ignores typeName argument.
+ */
+ @Deprecated
public WeightedSetDataType(String typeName, int code, DataType nestedType, boolean createIfNonExistent, boolean removeIfZero) {
- super(typeName != null ? createName(nestedType, createIfNonExistent, removeIfZero) : null, code, nestedType);
- if ((code >= 0) && (code <= DataType.lastPredefinedDataTypeId()) && (code != 18)) // 18 == DataType.TAG.getId() is not yet initialized
- throw new IllegalArgumentException("Cannot create a weighted set datatype with code " + code);
- this.createIfNonExistent = createIfNonExistent;
- this.removeIfZero = removeIfZero;
+ this(nestedType, createIfNonExistent, removeIfZero, code);
}
@Override