summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne H Juul <arnej27959@users.noreply.github.com>2022-03-08 18:09:08 +0100
committerGitHub <noreply@github.com>2022-03-08 18:09:08 +0100
commit8048ece519673f4da655160a53d9e40b01800779 (patch)
tree642de2500eabeb1a386af20a13e9342e638834db
parent13ab9df084ddc55c1deb4c012fd7b96c937fb318 (diff)
parent4b798440baad23420c2f1cd853a47f9e2d9f8f5d (diff)
Merge pull request #21594 from vespa-engine/arnej/regular-type-query-commands
Arnej/regular type query commands
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java5
-rw-r--r--config-model/src/test/derived/types/index-info.cfg4
-rw-r--r--document/src/main/java/com/yahoo/document/DataType.java1
-rw-r--r--document/src/main/java/com/yahoo/document/WeightedSetDataType.java28
4 files changed, 26 insertions, 12 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
index d9bdf5dc917..0d1222e737b 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java
@@ -9,6 +9,7 @@ import com.yahoo.document.MapDataType;
import com.yahoo.document.StructDataType;
import com.yahoo.document.TemporaryStructuredDataType;
import com.yahoo.document.TensorDataType;
+import com.yahoo.document.WeightedSetDataType;
import com.yahoo.language.Linguistics;
import com.yahoo.language.process.Embedder;
import com.yahoo.language.simple.SimpleLinguistics;
@@ -186,6 +187,10 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
": Dense tensor dimensions must have a size");
addQueryCommand("type " + type);
}
+ else if (dataType instanceof WeightedSetDataType) {
+ var nested = ((WeightedSetDataType) dataType).getNestedType().getName();
+ addQueryCommand("type WeightedSet<" + nested + ">");
+ }
else {
addQueryCommand("type " + dataType.getName());
}
diff --git a/config-model/src/test/derived/types/index-info.cfg b/config-model/src/test/derived/types/index-info.cfg
index 2db4ead180b..7f43cd67a6b 100644
--- a/config-model/src/test/derived/types/index-info.cfg
+++ b/config-model/src/test/derived/types/index-info.cfg
@@ -96,7 +96,7 @@ indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "tagfield"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "tagfield"
-indexinfo[].command[].command "type tag"
+indexinfo[].command[].command "type WeightedSet<string>"
indexinfo[].command[].indexname "structfield.s1"
indexinfo[].command[].command "index"
indexinfo[].command[].indexname "structfield.s1"
@@ -704,4 +704,4 @@ indexinfo[].command[].command "index"
indexinfo[].command[].indexname "pst_sta_boldingoff_nomatch_tag_01"
indexinfo[].command[].command "multivalue"
indexinfo[].command[].indexname "pst_sta_boldingoff_nomatch_tag_01"
-indexinfo[].command[].command "type tag"
+indexinfo[].command[].command "type WeightedSet<string>"
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