diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-10-25 10:34:45 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-10-25 10:34:45 +0200 |
commit | 85c88300cdab6541fea85cb69a7b4f844bb91250 (patch) | |
tree | aac7700c98b6a62efe2b104c54bac529d6ebf486 | |
parent | 832108f7de2bd4065d79198f23fd477c83c12939 (diff) |
Update execute -> mutate with '+=', '-=' and '='
4 files changed, 33 insertions, 33 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java index 7f3b018d569..21aa5661fa4 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java @@ -674,25 +674,26 @@ public class RankProfile implements Cloneable { inputFeatures.put(ref, declaredType); } - public static class ExecuteOperation { + public static class MutateOperation { public enum Phase { onmatch, onrerank, onsummary} final Phase phase; final String attribute; final String operation; - ExecuteOperation(Phase phase, String attribute, String operation) { + MutateOperation(Phase phase, String attribute, String operation) { this.phase = phase; this.attribute = attribute; this.operation = operation; } } - private final List<ExecuteOperation> executeOperations = new ArrayList<>(); + private final List<MutateOperation> mutateOperations = new ArrayList<>(); - public void addExecuteOperation(ExecuteOperation.Phase phase, String attribute, String operation) { - executeOperations.add(new ExecuteOperation(phase, attribute, operation)); + public void addMutateOperation(MutateOperation.Phase phase, String attribute, String operation) { + mutateOperations.add(new MutateOperation(phase, attribute, operation)); + //TODO once query control of these are gone we should change these to 'vespa.mutate.' addRankProperty("vespa.execute." + phase + ".attribute", attribute); addRankProperty("vespa.execute." + phase + ".operation", operation); } - public List<ExecuteOperation> getExecuteOperations() { return executeOperations; } + public List<MutateOperation> getMutateOperations() { return mutateOperations; } public RankingExpressionFunction findFunction(String name) { RankingExpressionFunction function = functions.get(name); diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj index 0f60db40069..3f4b6ab8206 100644 --- a/config-model/src/main/javacc/SDParser.jj +++ b/config-model/src/main/javacc/SDParser.jj @@ -207,7 +207,6 @@ TOKEN : | < LOOSE: "loose" > | < STRICT: "strict" > | < DOCUMENT: "document" > -| < EXECUTE: "execute" > | < OPERATION: "operation" > | < ON_MATCH: "on-match" > | < ON_RERANK: "on-rerank" > @@ -239,6 +238,7 @@ TOKEN : | < CONSTANT: "constant"> | < ONNXMODEL: "onnx-model"> | < MODEL: "model" > +| < MUTATE: "mutate" > | < RANKPROFILE: "rank-profile" > | < RANKDEGRADATIONFREQ: "rank-degradation-frequency" > | < RANKDEGRADATION: "rank-degradation" > @@ -2066,7 +2066,7 @@ Object rankProfileItem(RankProfile profile) : { } | firstPhase(profile) | matchPhase(profile) | function(profile) - | execute(profile) + | mutate(profile) | ignoreRankFeatures(profile) | numThreadsPerSearch(profile) | minHitsPerThread(profile) @@ -2096,39 +2096,39 @@ void inheritsRankProfile(RankProfile profile) : } /** - * This rule consumes an execute statement of a rank-profile. + * This rule consumes an mutate statement of a rank-profile. * * @param profile The profile to modify. */ -void execute(RankProfile profile) : +void mutate(RankProfile profile) : { } { - <EXECUTE> lbrace() (execute_operation(profile) <NL>)+ <RBRACE> + <MUTATE> lbrace() (mutate_operation(profile) <NL>)+ <RBRACE> { } } -void execute_operation(RankProfile profile) : +void mutate_operation(RankProfile profile) : { String attribute, operation; - RankProfile.ExecuteOperation.Phase phase; + RankProfile.MutateOperation.Phase phase; } { - ( <ON_MATCH> { phase = RankProfile.ExecuteOperation.Phase.onmatch; } - | <ON_RERANK> { phase = RankProfile.ExecuteOperation.Phase.onrerank; } - | <ON_SUMMARY> { phase = RankProfile.ExecuteOperation.Phase.onsummary; } + ( <ON_MATCH> { phase = RankProfile.MutateOperation.Phase.onmatch; } + | <ON_RERANK> { phase = RankProfile.MutateOperation.Phase.onrerank; } + | <ON_SUMMARY> { phase = RankProfile.MutateOperation.Phase.onsummary; } ) - lbrace() attribute = identifier() operation = execute_expr() (<NL>)* <RBRACE> - { profile.addExecuteOperation(phase, attribute, operation); } + lbrace() attribute = identifier() operation = mutate_expr() (<NL>)* <RBRACE> + { profile.addMutateOperation(phase, attribute, operation); } } -String execute_expr() : +String mutate_expr() : { String op; Number constant = null; } { - (("++" | "--") { op = token.image; } | ("+=" | "-=" | "*=" | "/=" | "%=" | "=") { op = token.image; } constant = consumeNumber()) + (("+=" | "-=" | "=") { op = token.image; } constant = consumeNumber()) { return constant != null ? (op + constant) : op; } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java index e2ca8ac4f65..ceacd08bddc 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java @@ -78,7 +78,7 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { } } @Test - public void testRankProfileExecute() throws ParseException { + public void testRankProfileMutate() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); SearchBuilder builder = new SearchBuilder(rankProfileRegistry); builder.importString(joinLines( @@ -101,15 +101,15 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { " attribute: mutable", " }", " rank-profile a {", - " execute {", + " mutate {", " on-match {", - " synthetic_attribute_a ++", + " synthetic_attribute_a += 7", " }", " on-rerank {", " synthetic_attribute_b = 1.01", " }", " on-summary {", - " synthetic_attribute_c --", + " synthetic_attribute_c -= 1", " }", " }", " first-phase {", @@ -128,27 +128,27 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { builder.build(); Schema schema = builder.getSearch(); RankProfile a = rankProfileRegistry.get(schema, "a"); - List<RankProfile.ExecuteOperation> operations = a.getExecuteOperations(); + List<RankProfile.MutateOperation> operations = a.getMutateOperations(); assertEquals(3, operations.size()); - assertEquals(RankProfile.ExecuteOperation.Phase.onmatch, operations.get(0).phase); + assertEquals(RankProfile.MutateOperation.Phase.onmatch, operations.get(0).phase); assertEquals("synthetic_attribute_a", operations.get(0).attribute); - assertEquals("++", operations.get(0).operation); - assertEquals(RankProfile.ExecuteOperation.Phase.onrerank, operations.get(1).phase); + assertEquals("+=7", operations.get(0).operation); + assertEquals(RankProfile.MutateOperation.Phase.onrerank, operations.get(1).phase); assertEquals("synthetic_attribute_b", operations.get(1).attribute); assertEquals("=1.01", operations.get(1).operation); - assertEquals(RankProfile.ExecuteOperation.Phase.onsummary, operations.get(2).phase); + assertEquals(RankProfile.MutateOperation.Phase.onsummary, operations.get(2).phase); assertEquals("synthetic_attribute_c", operations.get(2).attribute); - assertEquals("--", operations.get(2).operation); + assertEquals("-=1", operations.get(2).operation); AttributeFields attributeFields = new AttributeFields(schema); RawRankProfile raw = new RawRankProfile(a, new LargeRankExpressions(new MockFileRegistry()), new QueryProfileRegistry(), new ImportedMlModels(), attributeFields, new TestProperties()); assertEquals(7, raw.configProperties().size()); assertEquals("(vespa.execute.onmatch.attribute, synthetic_attribute_a)", raw.configProperties().get(0).toString()); - assertEquals("(vespa.execute.onmatch.operation, ++)", raw.configProperties().get(1).toString()); + assertEquals("(vespa.execute.onmatch.operation, +=7)", raw.configProperties().get(1).toString()); assertEquals("(vespa.execute.onrerank.attribute, synthetic_attribute_b)", raw.configProperties().get(2).toString()); assertEquals("(vespa.execute.onrerank.operation, =1.01)", raw.configProperties().get(3).toString()); assertEquals("(vespa.execute.onsummary.attribute, synthetic_attribute_c)", raw.configProperties().get(4).toString()); - assertEquals("(vespa.execute.onsummary.operation, --)", raw.configProperties().get(5).toString()); + assertEquals("(vespa.execute.onsummary.operation, -=1)", raw.configProperties().get(5).toString()); assertEquals("(vespa.rank.firstphase, a)", raw.configProperties().get(6).toString()); } diff --git a/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpFeedClient.java b/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpFeedClient.java index 9c423c6fc34..eb818ba1d48 100644 --- a/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpFeedClient.java +++ b/vespa-feed-client/src/main/java/ai/vespa/feed/client/HttpFeedClient.java @@ -8,7 +8,6 @@ import com.fasterxml.jackson.core.JsonToken; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.StringJoiner; |