diff options
Diffstat (limited to 'config-model/src')
3 files changed, 54 insertions, 13 deletions
diff --git a/config-model/src/main/javacc/IntermediateParser.jj b/config-model/src/main/javacc/IntermediateParser.jj index d2d27a7a2d4..ebaf8337ff9 100644 --- a/config-model/src/main/javacc/IntermediateParser.jj +++ b/config-model/src/main/javacc/IntermediateParser.jj @@ -303,6 +303,7 @@ TOKEN : | < ENABLE_BM25: "enable-bm25" > | < HNSW: "hnsw" > | < MAXLINKSPERNODE: "max-links-per-node" > +| < DOUBLE_KEYWORD: "double" > | < DISTANCEMETRIC: "distance-metric" > | < NEIGHBORSTOEXPLOREATINSERT: "neighbors-to-explore-at-insert" > | < MULTITHREADEDINDEXING: "multi-threaded-indexing" > @@ -2067,10 +2068,24 @@ void inputs(ParsedRankProfile profile) : } { <INPUTS> <LBRACE> (<NL>)* - ( reference = queryFeature() type = tensorType("Type of " + reference) { profile.addInput(reference, type); } (<NL>)*) * + ( reference = queryFeature() type = inputType(reference) { profile.addInput(reference, type); } (<NL>)*) * <RBRACE> } +TensorType inputType(Reference reference) : +{ + TensorType type; + +} +{ + ( + ( type = tensorType("Type of " + reference) ) + | + ( <DOUBLE_KEYWORD> { type = TensorType.empty; } ) + ) + { return type; } +} + Reference queryFeature() : { String argument; @@ -2276,10 +2291,13 @@ void rankProperty(ParsedRankProfile profile) : */ String rankPropertyItem() : { - String image, ret = ""; + String image = null; + String ret = ""; + Token dToken = null; } { - ( ( image = identifierWithDash() { ret += image; } + ( ( image = identifierWithDash() { ret += image; } + | dToken = <DOUBLE> { ret += dToken.image; } | image = quotedString() { ret += image; } | ( "(" | ")" | <DOT> | <COMMA> ) { ret += token.image; } )+ ) { return ret; } @@ -2408,10 +2426,10 @@ void constants(ParsedRankProfile profile) : void constantValue(ParsedRankProfile profile, String name) : { - String value; + Token value; } { - <COLON> value = identifier() { profile.addConstant(name, Value.parse(value)); } + <COLON> ( value = <DOUBLE> | value = <INTEGER> | value = <IDENTIFIER> ) { profile.addConstant(name, Value.parse(value.image)); } } void constantTensor(ParsedRankProfile profile, String name) : @@ -2555,7 +2573,7 @@ String identifier() : { } | <DIRECT> | <DOCUMENT> | <DOCUMENTSUMMARY> - | <DOUBLE> + | <DOUBLE_KEYWORD> | <DYNAMIC> | <ENABLEBITVECTORS> | <ENABLEONLYBITVECTOR> diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj index 0ff9513885f..d498cb5dac2 100644 --- a/config-model/src/main/javacc/SDParser.jj +++ b/config-model/src/main/javacc/SDParser.jj @@ -202,6 +202,7 @@ TOKEN : | < INDEXING: "indexing" > | < SUMMARYTO: "summary-to" > | < DOCUMENTSUMMARY: "document-summary" > +| <DOUBLE_KEYWORD: "double" > | < RANKTYPE: "rank-type" > | < WEIGHT: "weight" > | < TYPE: "type" > @@ -2203,10 +2204,23 @@ void inputs(RankProfile profile) : } { <INPUTS> <LBRACE> (<NL>)* - ( reference = queryFeature() type = tensorType("Type of " + reference) { profile.addInput(reference, type); } (<NL>)*) * + ( reference = queryFeature() type = inputType(reference) { profile.addInput(reference, type); } (<NL>)*) * <RBRACE> } +TensorType inputType(Reference reference) : +{ + TensorType type; +} +{ + ( + ( type = tensorType("Type of " + reference) ) + | + ( <DOUBLE_KEYWORD> { type = TensorType.empty; } ) + ) + { return type; } +} + Reference queryFeature() : { String argument; @@ -2408,10 +2422,13 @@ void rankProperty(RankProfile profile) : */ String rankPropertyItem() : { - String image, ret = ""; + String image; + String ret = ""; + Token dToken; } { - ( ( image = identifierWithDash() { ret += image; } + ( ( image = identifierWithDash() { ret += image; } + | dToken = <DOUBLE> { ret += dToken.image; } | image = quotedString() { ret += image; } | ( "(" | ")" | <DOT> | <COMMA> ) { ret += token.image; } )+ ) { return ret; } @@ -2542,10 +2559,10 @@ void constants(RankProfile profile) : void constantValue(RankProfile profile, String name) : { - String value; + Token value; } { - <COLON> value = identifier() { profile.addConstant(name, Value.parse(value)); } + <COLON> ( value = <DOUBLE> | value = <INTEGER> | value = <IDENTIFIER> ) { profile.addConstant(name, Value.parse(value.image)); } } void constantTensor(RankProfile profile, String name) : @@ -2693,7 +2710,7 @@ String identifier() : { } | <DIRECT> | <DOCUMENT> | <DOCUMENTSUMMARY> - | <DOUBLE> + | <DOUBLE_KEYWORD> | <DYNAMIC> | <ENABLEBITVECTORS> | <ENABLEONLYBITVECTOR> diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java index d92561f3123..53a949ff92d 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaInfoTestCase.java @@ -19,6 +19,8 @@ public class SchemaInfoTestCase { " inputs {" + " query(foo) tensor<float>(x[10])" + " query(bar) tensor(key{},x[1000])" + + " query(myDouble1) double" + + " query(myDouble2) double" + " }" + " }"; List<String> schemas = List.of("type1", "type2"); @@ -46,11 +48,15 @@ public class SchemaInfoTestCase { tester.assertRankProfile(schema, 5, "rankfeatures", false, true); var inputs = tester.assertRankProfile(schema, 6, "inputs", false, false); - assertEquals(2, inputs.input().size()); + assertEquals(4, inputs.input().size()); assertEquals("query(foo)", inputs.input(0).name()); assertEquals("tensor<float>(x[10])", inputs.input(0).type()); assertEquals("query(bar)", inputs.input(1).name()); assertEquals("tensor(key{},x[1000])", inputs.input(1).type()); + assertEquals("query(myDouble1)", inputs.input(2).name()); + assertEquals("tensor()", inputs.input(2).type()); + assertEquals("query(myDouble2)", inputs.input(3).name()); + assertEquals("tensor()", inputs.input(3).type()); assertEquals(2, schema.summaryclass().size()); assertEquals("default", schema.summaryclass(0).name()); |