diff options
author | Arne H Juul <arnej@yahooinc.com> | 2022-04-27 09:58:33 +0000 |
---|---|---|
committer | Arne H Juul <arnej@yahooinc.com> | 2022-04-27 09:58:33 +0000 |
commit | de28c02fe270ac13725f5de0d94374ce612c1f98 (patch) | |
tree | 1e0cc79d141c3d03334868334fc82e05834f2446 /config-model | |
parent | e45cd30a0cf9e99be02af029dbb5c8517ba8ce4b (diff) |
validate nested type for weighted sets
* prepare to be more strict in Vespa 8
Diffstat (limited to 'config-model')
10 files changed, 35 insertions, 119 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedType.java b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedType.java index a5f00b1ce45..bcf8d8c9172 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedType.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedType.java @@ -153,6 +153,32 @@ class ParsedType { } static ParsedType wsetOf(ParsedType vt) { assert(vt != null); + if (vt.getVariant() != Variant.BUILTIN) { + throw new IllegalArgumentException("weightedset of complex type '" + vt + "' is not supported"); + } + switch (vt.name()) { + // allowed types: + case "bool": + case "byte": + case "int": + case "long": + case "string": + case "uri": + break; + case "predicate": + case "raw": + case "tag": + throw new IllegalArgumentException("weightedset of complex type '" + vt + "' is not supported"); + case "float16": + case "float": + case "double": + /* TODO Vespa 8: + throw new IllegalArgumentException("weightedset of inexact type '" + vt + "' is not supported"); + */ + break; + default: + throw new IllegalArgumentException("weightedset of unknown type '" + vt + "' is not supported"); + } return new ParsedType("weightedset<" + vt.name() + ">", Variant.WSET, vt); } static ParsedType documentRef(ParsedType docType) { diff --git a/config-model/src/test/derived/attributeprefetch/attributeprefetch.sd b/config-model/src/test/derived/attributeprefetch/attributeprefetch.sd index e778c590aac..296a1fd828d 100644 --- a/config-model/src/test/derived/attributeprefetch/attributeprefetch.sd +++ b/config-model/src/test/derived/attributeprefetch/attributeprefetch.sd @@ -34,18 +34,12 @@ search prefetch { field multifloat type array<float> { indexing: attribute } - field wsfloat type weightedset<float> { - indexing: attribute - } field singledouble type double { indexing: attribute } field multidouble type array<double> { indexing: attribute } - field wsdouble type weightedset<double> { - indexing: attribute - } field singlestring type string { indexing: attribute match { diff --git a/config-model/src/test/derived/attributeprefetch/attributes.cfg b/config-model/src/test/derived/attributeprefetch/attributes.cfg index b6f37a216a7..8b49dc1dc23 100644 --- a/config-model/src/test/derived/attributeprefetch/attributes.cfg +++ b/config-model/src/test/derived/attributeprefetch/attributes.cfg @@ -350,38 +350,6 @@ attribute[].index.hnsw.maxlinkspernode 16 attribute[].index.hnsw.neighborstoexploreatinsert 200 attribute[].index.hnsw.distancemetric EUCLIDEAN attribute[].index.hnsw.multithreadedindexing true -attribute[].name "wsfloat" -attribute[].datatype FLOAT -attribute[].collectiontype WEIGHTEDSET -attribute[].dictionary.type BTREE -attribute[].dictionary.match UNCASED -attribute[].match UNCASED -attribute[].removeifzero false -attribute[].createifnonexistent false -attribute[].fastsearch false -attribute[].huge false -attribute[].paged false -attribute[].ismutable false -attribute[].sortascending true -attribute[].sortfunction UCA -attribute[].sortstrength PRIMARY -attribute[].sortlocale "" -attribute[].enablebitvectors false -attribute[].enableonlybitvector false -attribute[].fastaccess false -attribute[].arity 8 -attribute[].lowerbound -9223372036854775808 -attribute[].upperbound 9223372036854775807 -attribute[].densepostinglistthreshold 0.4 -attribute[].tensortype "" -attribute[].imported false -attribute[].maxuncommittedmemory 77777 -attribute[].distancemetric EUCLIDEAN -attribute[].index.hnsw.enabled false -attribute[].index.hnsw.maxlinkspernode 16 -attribute[].index.hnsw.neighborstoexploreatinsert 200 -attribute[].index.hnsw.distancemetric EUCLIDEAN -attribute[].index.hnsw.multithreadedindexing true attribute[].name "singledouble" attribute[].datatype DOUBLE attribute[].collectiontype SINGLE @@ -446,38 +414,6 @@ attribute[].index.hnsw.maxlinkspernode 16 attribute[].index.hnsw.neighborstoexploreatinsert 200 attribute[].index.hnsw.distancemetric EUCLIDEAN attribute[].index.hnsw.multithreadedindexing true -attribute[].name "wsdouble" -attribute[].datatype DOUBLE -attribute[].collectiontype WEIGHTEDSET -attribute[].dictionary.type BTREE -attribute[].dictionary.match UNCASED -attribute[].match UNCASED -attribute[].removeifzero false -attribute[].createifnonexistent false -attribute[].fastsearch false -attribute[].huge false -attribute[].paged false -attribute[].ismutable false -attribute[].sortascending true -attribute[].sortfunction UCA -attribute[].sortstrength PRIMARY -attribute[].sortlocale "" -attribute[].enablebitvectors false -attribute[].enableonlybitvector false -attribute[].fastaccess false -attribute[].arity 8 -attribute[].lowerbound -9223372036854775808 -attribute[].upperbound 9223372036854775807 -attribute[].densepostinglistthreshold 0.4 -attribute[].tensortype "" -attribute[].imported false -attribute[].maxuncommittedmemory 77777 -attribute[].distancemetric EUCLIDEAN -attribute[].index.hnsw.enabled false -attribute[].index.hnsw.maxlinkspernode 16 -attribute[].index.hnsw.neighborstoexploreatinsert 200 -attribute[].index.hnsw.distancemetric EUCLIDEAN -attribute[].index.hnsw.multithreadedindexing true attribute[].name "singlestring" attribute[].datatype STRING attribute[].collectiontype SINGLE diff --git a/config-model/src/test/derived/attributeprefetch/documentmanager.cfg b/config-model/src/test/derived/attributeprefetch/documentmanager.cfg index 373e0211253..9d91ad3f5ab 100644 --- a/config-model/src/test/derived/attributeprefetch/documentmanager.cfg +++ b/config-model/src/test/derived/attributeprefetch/documentmanager.cfg @@ -56,8 +56,6 @@ doctype[].fieldsets{[document]}.fields[] "singleint" doctype[].fieldsets{[document]}.fields[] "singlelong" doctype[].fieldsets{[document]}.fields[] "singlestring" doctype[].fieldsets{[document]}.fields[] "wsbyte" -doctype[].fieldsets{[document]}.fields[] "wsdouble" -doctype[].fieldsets{[document]}.fields[] "wsfloat" doctype[].fieldsets{[document]}.fields[] "wsint" doctype[].fieldsets{[document]}.fields[] "wslong" doctype[].fieldsets{[document]}.fields[] "wsstring" @@ -69,9 +67,9 @@ doctype[].arraytype[].idx 10021 doctype[].arraytype[].elementtype 10008 doctype[].arraytype[].idx 10023 doctype[].arraytype[].elementtype 10005 -doctype[].arraytype[].idx 10025 +doctype[].arraytype[].idx 10024 doctype[].arraytype[].elementtype 10004 -doctype[].arraytype[].idx 10027 +doctype[].arraytype[].idx 10025 doctype[].arraytype[].elementtype 10012 doctype[].wsettype[].idx 10018 doctype[].wsettype[].elementtype 10003 @@ -85,15 +83,7 @@ doctype[].wsettype[].idx 10022 doctype[].wsettype[].elementtype 10008 doctype[].wsettype[].createifnonexistent false doctype[].wsettype[].removeifzero false -doctype[].wsettype[].idx 10024 -doctype[].wsettype[].elementtype 10005 -doctype[].wsettype[].createifnonexistent false -doctype[].wsettype[].removeifzero false doctype[].wsettype[].idx 10026 -doctype[].wsettype[].elementtype 10004 -doctype[].wsettype[].createifnonexistent false -doctype[].wsettype[].removeifzero false -doctype[].wsettype[].idx 10028 doctype[].wsettype[].elementtype 10012 doctype[].wsettype[].createifnonexistent false doctype[].wsettype[].removeifzero false @@ -132,24 +122,18 @@ doctype[].structtype[].field[].type 10005 doctype[].structtype[].field[].name "multifloat" doctype[].structtype[].field[].internalid 1028626753 doctype[].structtype[].field[].type 10023 -doctype[].structtype[].field[].name "wsfloat" -doctype[].structtype[].field[].internalid 2087992058 -doctype[].structtype[].field[].type 10024 doctype[].structtype[].field[].name "singledouble" doctype[].structtype[].field[].internalid 1982688634 doctype[].structtype[].field[].type 10004 doctype[].structtype[].field[].name "multidouble" doctype[].structtype[].field[].internalid 1316159002 -doctype[].structtype[].field[].type 10025 -doctype[].structtype[].field[].name "wsdouble" -doctype[].structtype[].field[].internalid 995331392 -doctype[].structtype[].field[].type 10026 +doctype[].structtype[].field[].type 10024 doctype[].structtype[].field[].name "singlestring" doctype[].structtype[].field[].internalid 289408547 doctype[].structtype[].field[].type 10012 doctype[].structtype[].field[].name "multistring" doctype[].structtype[].field[].internalid 862051908 -doctype[].structtype[].field[].type 10027 +doctype[].structtype[].field[].type 10025 doctype[].structtype[].field[].name "wsstring" doctype[].structtype[].field[].internalid 447961272 -doctype[].structtype[].field[].type 10028 +doctype[].structtype[].field[].type 10026 diff --git a/config-model/src/test/derived/attributeprefetch/ilscripts.cfg b/config-model/src/test/derived/attributeprefetch/ilscripts.cfg index 61f4cde6e66..771a54359b9 100644 --- a/config-model/src/test/derived/attributeprefetch/ilscripts.cfg +++ b/config-model/src/test/derived/attributeprefetch/ilscripts.cfg @@ -12,10 +12,8 @@ ilscript[].docfield[] "multilong" ilscript[].docfield[] "wslong" ilscript[].docfield[] "singlefloat" ilscript[].docfield[] "multifloat" -ilscript[].docfield[] "wsfloat" ilscript[].docfield[] "singledouble" ilscript[].docfield[] "multidouble" -ilscript[].docfield[] "wsdouble" ilscript[].docfield[] "singlestring" ilscript[].docfield[] "multistring" ilscript[].docfield[] "wsstring" @@ -30,10 +28,8 @@ ilscript[].content[] "clear_state | guard { input multilong | attribute multilon ilscript[].content[] "clear_state | guard { input wslong | attribute wslong; }" ilscript[].content[] "clear_state | guard { input singlefloat | attribute singlefloat; }" ilscript[].content[] "clear_state | guard { input multifloat | attribute multifloat; }" -ilscript[].content[] "clear_state | guard { input wsfloat | attribute wsfloat; }" ilscript[].content[] "clear_state | guard { input singledouble | attribute singledouble; }" ilscript[].content[] "clear_state | guard { input multidouble | attribute multidouble; }" -ilscript[].content[] "clear_state | guard { input wsdouble | attribute wsdouble; }" ilscript[].content[] "clear_state | guard { input singlestring | attribute singlestring; }" ilscript[].content[] "clear_state | guard { input multistring | attribute multistring; }" ilscript[].content[] "clear_state | guard { input wsstring | attribute wsstring; }" diff --git a/config-model/src/test/derived/attributeprefetch/index-info.cfg b/config-model/src/test/derived/attributeprefetch/index-info.cfg index e1b20b33e17..28e669d3571 100644 --- a/config-model/src/test/derived/attributeprefetch/index-info.cfg +++ b/config-model/src/test/derived/attributeprefetch/index-info.cfg @@ -105,16 +105,6 @@ indexinfo[].command[].indexname "multifloat" indexinfo[].command[].command "numerical" indexinfo[].command[].indexname "multifloat" indexinfo[].command[].command "type Array<float>" -indexinfo[].command[].indexname "wsfloat" -indexinfo[].command[].command "index" -indexinfo[].command[].indexname "wsfloat" -indexinfo[].command[].command "multivalue" -indexinfo[].command[].indexname "wsfloat" -indexinfo[].command[].command "attribute" -indexinfo[].command[].indexname "wsfloat" -indexinfo[].command[].command "numerical" -indexinfo[].command[].indexname "wsfloat" -indexinfo[].command[].command "type WeightedSet<float>" indexinfo[].command[].indexname "singledouble" indexinfo[].command[].command "index" indexinfo[].command[].indexname "singledouble" @@ -133,16 +123,6 @@ indexinfo[].command[].indexname "multidouble" indexinfo[].command[].command "numerical" indexinfo[].command[].indexname "multidouble" indexinfo[].command[].command "type Array<double>" -indexinfo[].command[].indexname "wsdouble" -indexinfo[].command[].command "index" -indexinfo[].command[].indexname "wsdouble" -indexinfo[].command[].command "multivalue" -indexinfo[].command[].indexname "wsdouble" -indexinfo[].command[].command "attribute" -indexinfo[].command[].indexname "wsdouble" -indexinfo[].command[].command "numerical" -indexinfo[].command[].indexname "wsdouble" -indexinfo[].command[].command "type WeightedSet<double>" indexinfo[].command[].indexname "singlestring" indexinfo[].command[].command "index" indexinfo[].command[].indexname "singlestring" diff --git a/config-model/src/test/derived/attributes/attributes.cfg b/config-model/src/test/derived/attributes/attributes.cfg index cbc3280f213..cf473ad4854 100644 --- a/config-model/src/test/derived/attributes/attributes.cfg +++ b/config-model/src/test/derived/attributes/attributes.cfg @@ -351,7 +351,7 @@ attribute[].index.hnsw.neighborstoexploreatinsert 200 attribute[].index.hnsw.distancemetric EUCLIDEAN attribute[].index.hnsw.multithreadedindexing true attribute[].name "b7" -attribute[].datatype DOUBLE +attribute[].datatype INT32 attribute[].collectiontype WEIGHTEDSET attribute[].dictionary.type BTREE attribute[].dictionary.match UNCASED diff --git a/config-model/src/test/derived/attributes/attributes.sd b/config-model/src/test/derived/attributes/attributes.sd index f38087fbc6f..df647c833f4 100644 --- a/config-model/src/test/derived/attributes/attributes.sd +++ b/config-model/src/test/derived/attributes/attributes.sd @@ -74,7 +74,7 @@ search attributes { field b6 type array<long> { indexing: summary | attribute } - field b7 type weightedset<double> { + field b7 type weightedset<int> { indexing: summary | attribute } diff --git a/config-model/src/test/derived/attributes/index-info.cfg b/config-model/src/test/derived/attributes/index-info.cfg index 9aeb79a7e2d..560da741ad9 100644 --- a/config-model/src/test/derived/attributes/index-info.cfg +++ b/config-model/src/test/derived/attributes/index-info.cfg @@ -132,7 +132,7 @@ indexinfo[].command[].command "attribute" indexinfo[].command[].indexname "b7" indexinfo[].command[].command "numerical" indexinfo[].command[].indexname "b7" -indexinfo[].command[].command "type WeightedSet<double>" +indexinfo[].command[].command "type WeightedSet<int>" indexinfo[].command[].indexname "a9" indexinfo[].command[].command "index" indexinfo[].command[].indexname "a9" diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java index c71fd3dd489..e3ac5da8955 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java @@ -150,7 +150,7 @@ public class TensorTransformTestCase extends AbstractSchemaTestCase { " field double_array_field type array<double> { \n" + " indexing: summary | attribute \n" + " }\n" + - " field weightedset_field type weightedset<double> { \n" + + " field weightedset_field type weightedset<int> { \n" + " indexing: summary | attribute \n" + " }\n" + " field tensor_field_1 type tensor(x{}) { \n" + |