From cf14979ed2766f05bd2f131b93d33996aa6662e3 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Thu, 29 Sep 2022 11:19:52 +0200 Subject: Use consistent terminology --- .../java/com/yahoo/application/Application.java | 20 ++++----- .../java/com/yahoo/schema/ApplicationBuilder.java | 2 +- .../java/com/yahoo/schema/ImmutableSchema.java | 2 +- .../com/yahoo/schema/LargeRankExpressions.java | 51 --------------------- .../com/yahoo/schema/LargeRankingExpressions.java | 52 ++++++++++++++++++++++ .../java/com/yahoo/schema/RankExpressionBody.java | 32 ------------- .../com/yahoo/schema/RankingExpressionBody.java | 32 +++++++++++++ .../src/main/java/com/yahoo/schema/Schema.java | 8 ++-- .../com/yahoo/schema/derived/RankProfileList.java | 18 ++++---- .../com/yahoo/schema/derived/RawRankProfile.java | 16 +++---- .../java/com/yahoo/vespa/model/VespaModel.java | 4 +- .../application/validation/RankSetupValidator.java | 4 +- .../java/com/yahoo/schema/RankProfileTestCase.java | 8 ++-- .../com/yahoo/schema/RankPropertiesTestCase.java | 6 +-- .../schema/RankingExpressionConstantsTestCase.java | 2 +- .../schema/RankingExpressionShadowingTestCase.java | 2 +- .../processing/RankingExpressionsTestCase.java | 12 ++--- .../schema/processing/TensorTransformTestCase.java | 4 +- .../java/ai/vespa/models/evaluation/Model.java | 6 +-- .../features/rankingexpressionfeature.cpp | 6 +-- 20 files changed, 144 insertions(+), 143 deletions(-) delete mode 100644 config-model/src/main/java/com/yahoo/schema/LargeRankExpressions.java create mode 100644 config-model/src/main/java/com/yahoo/schema/LargeRankingExpressions.java delete mode 100644 config-model/src/main/java/com/yahoo/schema/RankExpressionBody.java create mode 100644 config-model/src/main/java/com/yahoo/schema/RankingExpressionBody.java diff --git a/application/src/main/java/com/yahoo/application/Application.java b/application/src/main/java/com/yahoo/application/Application.java index 5d8123de48f..b4857d18459 100644 --- a/application/src/main/java/com/yahoo/application/Application.java +++ b/application/src/main/java/com/yahoo/application/Application.java @@ -279,35 +279,35 @@ public final class Application implements AutoCloseable { /** * @param name name of document type (search definition) - * @param searchDefinition add this search definition to the application + * @param schema add this search definition to the application * @throws java.io.IOException e.g.if file not found */ - public Builder documentType(String name, String searchDefinition) throws IOException { + public Builder documentType(String name, String schema) throws IOException { Path path = nestedResource(ApplicationPackage.SCHEMAS_DIR, name, ApplicationPackage.SD_NAME_SUFFIX); - createFile(path, searchDefinition); + createFile(path, schema); return this; } - public Builder expressionInclude(String name, String searchDefinition) throws IOException { + public Builder expressionInclude(String name, String schema) throws IOException { Path path = nestedResource(ApplicationPackage.SCHEMAS_DIR, name, ApplicationPackage.RANKEXPRESSION_NAME_SUFFIX); - createFile(path, searchDefinition); + createFile(path, schema); return this; } /** - * @param name name of rank expression - * @param rankExpressionContent add this rank expression to the application + * @param name name of ranking expression + * @param rankingExpressionContent add this ranking expression to the application * @throws java.io.IOException e.g.if file not found */ - public Builder rankExpression(String name, String rankExpressionContent) throws IOException { + public Builder rankExpression(String name, String rankingExpressionContent) throws IOException { Path path = nestedResource(ApplicationPackage.SCHEMAS_DIR, name, ApplicationPackage.RANKEXPRESSION_NAME_SUFFIX); - createFile(path, rankExpressionContent); + createFile(path, rankingExpressionContent); return this; } /** * @param name name of query profile - * @param queryProfile add this queyr profile to the application + * @param queryProfile add this query profile to the application * @return builder * @throws java.io.IOException e.g.if file not found */ diff --git a/config-model/src/main/java/com/yahoo/schema/ApplicationBuilder.java b/config-model/src/main/java/com/yahoo/schema/ApplicationBuilder.java index 894415091e4..f002676f05d 100644 --- a/config-model/src/main/java/com/yahoo/schema/ApplicationBuilder.java +++ b/config-model/src/main/java/com/yahoo/schema/ApplicationBuilder.java @@ -34,7 +34,7 @@ import java.util.Set; /** * Application builder. Usage: * 1) Add all schemas, using the addXXX() methods, - * 2) provide the available rank types and rank expressions, using the setRankXXX() methods, + * 2) provide the available rank types and ranking expressions, using the setRankXXX() methods, * 3) invoke the {@link #build} method * * @author bratseth diff --git a/config-model/src/main/java/com/yahoo/schema/ImmutableSchema.java b/config-model/src/main/java/com/yahoo/schema/ImmutableSchema.java index c352d9c417f..82583addb9b 100644 --- a/config-model/src/main/java/com/yahoo/schema/ImmutableSchema.java +++ b/config-model/src/main/java/com/yahoo/schema/ImmutableSchema.java @@ -36,7 +36,7 @@ public interface ImmutableSchema { DeployLogger getDeployLogger(); ModelContext.Properties getDeployProperties(); Map constants(); - LargeRankExpressions rankExpressionFiles(); + LargeRankingExpressions rankExpressionFiles(); Map onnxModels(); Stream allImportedFields(); SDDocumentType getDocument(); diff --git a/config-model/src/main/java/com/yahoo/schema/LargeRankExpressions.java b/config-model/src/main/java/com/yahoo/schema/LargeRankExpressions.java deleted file mode 100644 index cfdd4729b97..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/LargeRankExpressions.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema; - -import com.yahoo.config.application.api.FileRegistry; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; - -public class LargeRankExpressions { - private final Map expressions = new ConcurrentHashMap<>(); - private final FileRegistry fileRegistry; - private final int limit; - - public LargeRankExpressions(FileRegistry fileRegistry) { - this(fileRegistry, 8192); - } - public LargeRankExpressions(FileRegistry fileRegistry, int limit) { - this.fileRegistry = fileRegistry; - this.limit = limit; - } - - public void add(RankExpressionBody expression) { - String name = expression.getName(); - RankExpressionBody prev = expressions.putIfAbsent(name, expression); - if (prev == null) { - expression.validate(); - expression.register(fileRegistry); - } else { - if ( ! prev.getBlob().equals(expression.getBlob())) { - throw new IllegalArgumentException("Rank expression '" + name + - "' defined twice. Previous blob with " + prev.getBlob().remaining() + - " bytes, while current has " + expression.getBlob().remaining() + " bytes"); - } - } - } - public int limit() { return limit; } - - /** Returns a read-only list of ranking constants ordered by name */ - public Collection expressions() { - return expressions.values().stream().sorted().collect(Collectors.toUnmodifiableList()); - } - - // Note: Use by integration tests in internal repo - /** Returns a read-only map of the ranking constants in this indexed by name */ - public Map asMap() { - return Collections.unmodifiableMap(expressions); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/LargeRankingExpressions.java b/config-model/src/main/java/com/yahoo/schema/LargeRankingExpressions.java new file mode 100644 index 00000000000..2ae9041b1a2 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/schema/LargeRankingExpressions.java @@ -0,0 +1,52 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.schema; + +import com.yahoo.config.application.api.FileRegistry; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; + +public class LargeRankingExpressions { + + private final Map expressions = new ConcurrentHashMap<>(); + private final FileRegistry fileRegistry; + private final int limit; + + public LargeRankingExpressions(FileRegistry fileRegistry) { + this(fileRegistry, 8192); + } + public LargeRankingExpressions(FileRegistry fileRegistry, int limit) { + this.fileRegistry = fileRegistry; + this.limit = limit; + } + + public void add(RankingExpressionBody expression) { + String name = expression.getName(); + RankingExpressionBody prev = expressions.putIfAbsent(name, expression); + if (prev == null) { + expression.validate(); + expression.register(fileRegistry); + } else { + if ( ! prev.getBlob().equals(expression.getBlob())) { + throw new IllegalArgumentException("Ranking expression '" + name + + "' defined twice. Previous blob with " + prev.getBlob().remaining() + + " bytes, while current has " + expression.getBlob().remaining() + " bytes"); + } + } + } + public int limit() { return limit; } + + /** Returns a read-only list of ranking constants ordered by name */ + public Collection expressions() { + return expressions.values().stream().sorted().collect(Collectors.toUnmodifiableList()); + } + + // Note: Use by integration tests in internal repo + /** Returns a read-only map of the ranking constants in this indexed by name */ + public Map asMap() { + return Collections.unmodifiableMap(expressions); + } + +} diff --git a/config-model/src/main/java/com/yahoo/schema/RankExpressionBody.java b/config-model/src/main/java/com/yahoo/schema/RankExpressionBody.java deleted file mode 100644 index d383a25aecb..00000000000 --- a/config-model/src/main/java/com/yahoo/schema/RankExpressionBody.java +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.schema; - -import com.yahoo.config.application.api.FileRegistry; - -import java.nio.ByteBuffer; - -import static java.util.Objects.requireNonNull; - -public class RankExpressionBody extends DistributableResource { - - private final ByteBuffer blob; - - public RankExpressionBody(String name, ByteBuffer blob) { - super(name, name + ".lz4", PathType.BLOB); - this.blob = requireNonNull(blob, "Blob cannot be null"); - } - - public ByteBuffer getBlob() { return blob; } - - public void validate() { - // Remove once pathType is final - if (getPathType() != PathType.BLOB) { - throw new IllegalArgumentException("PathType must be BLOB."); - } - } - - public void register(FileRegistry fileRegistry) { - register(fileRegistry, blob); - } - -} diff --git a/config-model/src/main/java/com/yahoo/schema/RankingExpressionBody.java b/config-model/src/main/java/com/yahoo/schema/RankingExpressionBody.java new file mode 100644 index 00000000000..89fad690ca2 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/schema/RankingExpressionBody.java @@ -0,0 +1,32 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.schema; + +import com.yahoo.config.application.api.FileRegistry; + +import java.nio.ByteBuffer; + +import static java.util.Objects.requireNonNull; + +public class RankingExpressionBody extends DistributableResource { + + private final ByteBuffer blob; + + public RankingExpressionBody(String name, ByteBuffer blob) { + super(name, name + ".lz4", PathType.BLOB); + this.blob = requireNonNull(blob, "Blob cannot be null"); + } + + public ByteBuffer getBlob() { return blob; } + + public void validate() { + // Remove once pathType is final + if (getPathType() != PathType.BLOB) { + throw new IllegalArgumentException("PathType must be BLOB."); + } + } + + public void register(FileRegistry fileRegistry) { + register(fileRegistry, blob); + } + +} diff --git a/config-model/src/main/java/com/yahoo/schema/Schema.java b/config-model/src/main/java/com/yahoo/schema/Schema.java index c1556bcfccc..180c8e6012f 100644 --- a/config-model/src/main/java/com/yahoo/schema/Schema.java +++ b/config-model/src/main/java/com/yahoo/schema/Schema.java @@ -83,8 +83,8 @@ public class Schema implements ImmutableSchema { /** The explicitly defined summaries of this schema. _Must_ preserve order. */ private final Map summaries = new LinkedHashMap<>(); - /** External rank expression files of this */ - private final LargeRankExpressions largeRankExpressions; + /** External ranking expression files of this */ + private final LargeRankingExpressions largeRankingExpressions; /** Constants that will be available in all rank profiles. */ // TODO: Remove on Vespa 9: Should always be in a rank profile @@ -150,7 +150,7 @@ public class Schema implements ImmutableSchema { this.deployLogger = deployLogger; this.properties = properties; this.documentsOnly = documentsOnly; - largeRankExpressions = new LargeRankExpressions(fileRegistry); + largeRankingExpressions = new LargeRankingExpressions(fileRegistry); } /** @@ -223,7 +223,7 @@ public class Schema implements ImmutableSchema { } @Override - public LargeRankExpressions rankExpressionFiles() { return largeRankExpressions; } + public LargeRankingExpressions rankExpressionFiles() { return largeRankingExpressions; } public void add(RankProfile.Constant constant) { constants.put(constant.name(), constant); diff --git a/config-model/src/main/java/com/yahoo/schema/derived/RankProfileList.java b/config-model/src/main/java/com/yahoo/schema/derived/RankProfileList.java index c549f9af7ce..27e6d6e57a6 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/RankProfileList.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/RankProfileList.java @@ -5,7 +5,7 @@ import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels; import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.search.query.profile.QueryProfileRegistry; -import com.yahoo.schema.LargeRankExpressions; +import com.yahoo.schema.LargeRankingExpressions; import com.yahoo.schema.OnnxModel; import com.yahoo.schema.RankProfileRegistry; import com.yahoo.searchlib.rankingexpression.Reference; @@ -36,14 +36,14 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ private final Map rankProfiles; private final FileDistributedConstants constants; - private final LargeRankExpressions largeRankExpressions; + private final LargeRankingExpressions largeRankingExpressions; private final FileDistributedOnnxModels onnxModels; public static final RankProfileList empty = new RankProfileList(); private RankProfileList() { constants = new FileDistributedConstants(null, List.of()); - largeRankExpressions = new LargeRankExpressions(null); + largeRankingExpressions = new LargeRankingExpressions(null); onnxModels = new FileDistributedOnnxModels(null, List.of()); rankProfiles = Map.of(); } @@ -55,11 +55,11 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ * @param attributeFields the attribute fields to create a ranking for */ public RankProfileList(Schema schema, - LargeRankExpressions largeRankExpressions, + LargeRankingExpressions largeRankingExpressions, AttributeFields attributeFields, DeployState deployState) { setName(schema == null ? "default" : schema.getName()); - this.largeRankExpressions = largeRankExpressions; + this.largeRankingExpressions = largeRankingExpressions; this.rankProfiles = deriveRankProfiles(schema, attributeFields, deployState); this.constants = deriveFileDistributedConstants(schema, rankProfiles.values(), deployState); this.onnxModels = deriveFileDistributedOnnxModels(schema, rankProfiles.values(), deployState); @@ -77,7 +77,7 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ Map rawRankProfiles = new LinkedHashMap<>(); if (schema != null) { // profiles belonging to a schema have a default profile RawRankProfile rawRank = new RawRankProfile(deployState.rankProfileRegistry().get(schema, "default"), - largeRankExpressions, + largeRankingExpressions, deployState.getQueryProfiles().getRegistry(), deployState.getImportedModels(), attributeFields, @@ -113,8 +113,8 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ ExecutorService executor) { Map> futureRawRankProfiles = new LinkedHashMap<>(); for (RankProfile profile : profiles) { - futureRawRankProfiles.put(profile.name(), executor.submit(() -> new RawRankProfile(profile, largeRankExpressions, queryProfiles, importedModels, - attributeFields, deployProperties))); + futureRawRankProfiles.put(profile.name(), executor.submit(() -> new RawRankProfile(profile, largeRankingExpressions, queryProfiles, importedModels, + attributeFields, deployProperties))); } try { Map rawRankProfiles = new LinkedHashMap<>(); @@ -196,7 +196,7 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ } public void getConfig(RankingExpressionsConfig.Builder builder) { - largeRankExpressions.expressions().forEach((expr) -> builder.expression.add(new RankingExpressionsConfig.Expression.Builder().name(expr.getName()).fileref(expr.getFileReference()))); + largeRankingExpressions.expressions().forEach((expr) -> builder.expression.add(new RankingExpressionsConfig.Expression.Builder().name(expr.getName()).fileref(expr.getFileReference()))); } public void getConfig(RankingConstantsConfig.Builder builder) { diff --git a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java index 11af3b0bf78..59f4035f34f 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java @@ -9,8 +9,8 @@ import com.yahoo.config.model.api.ModelContext; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.schema.FeatureNames; import com.yahoo.schema.OnnxModel; -import com.yahoo.schema.LargeRankExpressions; -import com.yahoo.schema.RankExpressionBody; +import com.yahoo.schema.LargeRankingExpressions; +import com.yahoo.schema.RankingExpressionBody; import com.yahoo.schema.document.RankType; import com.yahoo.schema.RankProfile; import com.yahoo.schema.expressiontransforms.OnnxModelTransformer; @@ -60,7 +60,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer { private final Collection onnxModels; /** Creates a raw rank profile from the given rank profile. */ - public RawRankProfile(RankProfile rankProfile, LargeRankExpressions largeExpressions, + public RawRankProfile(RankProfile rankProfile, LargeRankingExpressions largeExpressions, QueryProfileRegistry queryProfiles, ImportedMlModels importedModels, AttributeFields attributeFields, ModelContext.Properties deployProperties) { this.name = rankProfile.name(); @@ -344,7 +344,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer { } /** Derives the properties this produces */ - public List> derive(LargeRankExpressions largeRankExpressions) { + public List> derive(LargeRankingExpressions largeRankingExpressions) { List> properties = new ArrayList<>(); for (RankProfile.RankProperty property : rankProperties) { if (RankingExpression.propertyName(RankProfile.FIRST_PHASE).equals(property.getName())) { @@ -453,20 +453,20 @@ public class RawRankProfile implements RankProfilesConfig.Producer { } } if (properties.size() >= 1000000) throw new IllegalArgumentException("Too many rank properties"); - distributeLargeExpressionsAsFiles(properties, largeRankExpressions); + distributeLargeExpressionsAsFiles(properties, largeRankingExpressions); return properties; } - private void distributeLargeExpressionsAsFiles(List> properties, LargeRankExpressions largeRankExpressions) { + private void distributeLargeExpressionsAsFiles(List> properties, LargeRankingExpressions largeRankingExpressions) { for (ListIterator> iter = properties.listIterator(); iter.hasNext();) { Pair property = iter.next(); String expression = property.getSecond(); - if (expression.length() > largeRankExpressions.limit()) { + if (expression.length() > largeRankingExpressions.limit()) { String propertyName = property.getFirst(); String functionName = RankingExpression.extractScriptName(propertyName); if (functionName != null) { String mangledName = rankprofileName + "." + functionName; - largeRankExpressions.add(new RankExpressionBody(mangledName, ByteBuffer.wrap(expression.getBytes(StandardCharsets.UTF_8)))); + largeRankingExpressions.add(new RankingExpressionBody(mangledName, ByteBuffer.wrap(expression.getBytes(StandardCharsets.UTF_8)))); iter.set(new Pair<>(RankingExpression.propertyExpressionName(functionName), mangledName)); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java index 9bb03d3f07c..c9b462ce30b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java @@ -26,7 +26,7 @@ import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.container.QrConfig; import com.yahoo.path.Path; -import com.yahoo.schema.LargeRankExpressions; +import com.yahoo.schema.LargeRankingExpressions; import com.yahoo.schema.OnnxModel; import com.yahoo.schema.RankProfile; import com.yahoo.schema.RankProfileRegistry; @@ -164,7 +164,7 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Mode createGlobalRankProfiles(deployState); rankProfileList = new RankProfileList(null, // null search -> global - new LargeRankExpressions(deployState.getFileRegistry()), + new LargeRankingExpressions(deployState.getFileRegistry()), AttributeFields.empty, deployState); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java index 5c531d28a8e..276092e61f4 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java @@ -64,7 +64,7 @@ public class RankSetupValidator extends Validator { ".") .toFile(); for (SearchCluster cluster : model.getSearchClusters()) { - // Skipping rank expression checking for streaming clusters, not implemented yet + // Skipping rannking expression checking for streaming clusters, not implemented yet if (cluster.isStreaming()) continue; IndexedSearchCluster sc = (IndexedSearchCluster) cluster; @@ -188,7 +188,7 @@ public class RankSetupValidator extends Validator { private void validateWarn(Exception e, DeployLogger deployLogger) { String msg = "Unable to execute '" + binaryName + - "', validation of rank expressions will only take place when you start Vespa: " + + "', validation of ranking expressions will only take place when you start Vespa: " + Exceptions.toMessageString(e); deployLogger.logApplicationPackage(Level.WARNING, msg); } diff --git a/config-model/src/test/java/com/yahoo/schema/RankProfileTestCase.java b/config-model/src/test/java/com/yahoo/schema/RankProfileTestCase.java index ddca13a2984..51d19283b1e 100644 --- a/config-model/src/test/java/com/yahoo/schema/RankProfileTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/RankProfileTestCase.java @@ -258,7 +258,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { assertEquals(8, rankProfile.getNumThreadsPerSearch()); assertEquals(70, rankProfile.getMinHitsPerThread()); assertEquals(1200, rankProfile.getNumSearchPartitions()); - RawRankProfile rawRankProfile = new RawRankProfile(rankProfile, new LargeRankExpressions(new MockFileRegistry()), new QueryProfileRegistry(), + RawRankProfile rawRankProfile = new RawRankProfile(rankProfile, new LargeRankingExpressions(new MockFileRegistry()), new QueryProfileRegistry(), new ImportedMlModels(), attributeFields, deployProperties); if (expectedTermwiseLimit != null) { assertTrue(findProperty(rawRankProfile.configProperties(), "vespa.matching.termwise_limit").isPresent()); @@ -317,7 +317,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { } private static RawRankProfile createRawRankProfile(RankProfile profile, Schema schema) { - return new RawRankProfile(profile, new LargeRankExpressions(new MockFileRegistry()), new QueryProfileRegistry(), new ImportedMlModels(), new AttributeFields(schema), new TestProperties()); + return new RawRankProfile(profile, new LargeRankingExpressions(new MockFileRegistry()), new QueryProfileRegistry(), new ImportedMlModels(), new AttributeFields(schema), new TestProperties()); } private static void assertAttributeTypeSettings(RankProfile profile, Schema schema) { @@ -398,8 +398,8 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { var schema = builder.getSchema(); var rankProfile = rankProfileRegistry.get(schema, "my_profile"); - var rawRankProfile = new RawRankProfile(rankProfile, new LargeRankExpressions(new MockFileRegistry()), queryProfileRegistry, - new ImportedMlModels(), new AttributeFields(schema), props); + var rawRankProfile = new RawRankProfile(rankProfile, new LargeRankingExpressions(new MockFileRegistry()), queryProfileRegistry, + new ImportedMlModels(), new AttributeFields(schema), props); if (postFilterThreshold != null) { assertEquals((double)postFilterThreshold, rankProfile.getPostFilterThreshold().getAsDouble(), 0.000001); diff --git a/config-model/src/test/java/com/yahoo/schema/RankPropertiesTestCase.java b/config-model/src/test/java/com/yahoo/schema/RankPropertiesTestCase.java index b538d834df9..a19918d83d2 100644 --- a/config-model/src/test/java/com/yahoo/schema/RankPropertiesTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/RankPropertiesTestCase.java @@ -58,7 +58,7 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { assertEquals("query(a) = 1500", parent.getRankProperties().get(0).toString()); // Check derived model - RawRankProfile rawParent = new RawRankProfile(parent, new LargeRankExpressions(new MockFileRegistry()), new QueryProfileRegistry(), new ImportedMlModels(), attributeFields, new TestProperties()); + RawRankProfile rawParent = new RawRankProfile(parent, new LargeRankingExpressions(new MockFileRegistry()), new QueryProfileRegistry(), new ImportedMlModels(), attributeFields, new TestProperties()); assertEquals("(query(a), 1500)", rawParent.configProperties().get(0).toString()); } @@ -69,7 +69,7 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { // Check derived model RawRankProfile rawChild = new RawRankProfile(rankProfileRegistry.get(schema, "child"), - new LargeRankExpressions(new MockFileRegistry()), + new LargeRankingExpressions(new MockFileRegistry()), new QueryProfileRegistry(), new ImportedMlModels(), attributeFields, @@ -185,7 +185,7 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { assertEquals("-=1", operations.get(3).operation); AttributeFields attributeFields = new AttributeFields(schema); - RawRankProfile raw = new RawRankProfile(a, new LargeRankExpressions(new MockFileRegistry()), new QueryProfileRegistry(), new ImportedMlModels(), attributeFields, new TestProperties()); + RawRankProfile raw = new RawRankProfile(a, new LargeRankingExpressions(new MockFileRegistry()), new QueryProfileRegistry(), new ImportedMlModels(), attributeFields, new TestProperties()); assertEquals(9, raw.configProperties().size()); assertEquals("(vespa.mutate.on_match.attribute, synthetic_attribute_a)", raw.configProperties().get(0).toString()); assertEquals("(vespa.mutate.on_match.operation, +=7)", raw.configProperties().get(1).toString()); diff --git a/config-model/src/test/java/com/yahoo/schema/RankingExpressionConstantsTestCase.java b/config-model/src/test/java/com/yahoo/schema/RankingExpressionConstantsTestCase.java index c915a85a4cf..cbacfb502c9 100644 --- a/config-model/src/test/java/com/yahoo/schema/RankingExpressionConstantsTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/RankingExpressionConstantsTestCase.java @@ -80,7 +80,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { assertEquals("16.6", child2.getFirstPhaseRanking().getRoot().toString()); assertEquals("foo: 14.0", child2.getFunctions().get("foo").function().getBody().toString()); List> rankProperties = new RawRankProfile(child2, - new LargeRankExpressions(new MockFileRegistry()), + new LargeRankingExpressions(new MockFileRegistry()), queryProfileRegistry, new ImportedMlModels(), new AttributeFields(s), diff --git a/config-model/src/test/java/com/yahoo/schema/RankingExpressionShadowingTestCase.java b/config-model/src/test/java/com/yahoo/schema/RankingExpressionShadowingTestCase.java index 33bbdb2fd6f..d420772bc74 100644 --- a/config-model/src/test/java/com/yahoo/schema/RankingExpressionShadowingTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/RankingExpressionShadowingTestCase.java @@ -215,7 +215,7 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { private static RawRankProfile createRawRankProfile(RankProfile profile, QueryProfileRegistry queryProfiles, Schema schema) { return new RawRankProfile(profile, - new LargeRankExpressions(new MockFileRegistry()), + new LargeRankingExpressions(new MockFileRegistry()), queryProfiles, new ImportedMlModels(), new AttributeFields(schema), diff --git a/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionsTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionsTestCase.java index 526576c9e0b..e5d27a55c9c 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionsTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionsTestCase.java @@ -6,7 +6,7 @@ import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.search.query.profile.QueryProfileRegistry; -import com.yahoo.schema.LargeRankExpressions; +import com.yahoo.schema.LargeRankingExpressions; import com.yahoo.schema.RankProfile; import com.yahoo.schema.RankProfileRegistry; import com.yahoo.schema.Schema; @@ -50,8 +50,8 @@ public class RankingExpressionsTestCase extends AbstractSchemaTestCase { functions.get("artistmatch").function().getBody().getRoot().toString()); assertEquals(0, functions.get("artistmatch").function().arguments().size()); - RawRankProfile rawRankProfile = new RawRankProfile(functionsRankProfile, new LargeRankExpressions(new MockFileRegistry()), new QueryProfileRegistry(), - new ImportedMlModels(), new AttributeFields(schema), deployProperties); + RawRankProfile rawRankProfile = new RawRankProfile(functionsRankProfile, new LargeRankingExpressions(new MockFileRegistry()), new QueryProfileRegistry(), + new ImportedMlModels(), new AttributeFields(schema), deployProperties); List> rankProperties = rawRankProfile.configProperties(); assertEquals(6, rankProperties.size()); @@ -81,7 +81,7 @@ public class RankingExpressionsTestCase extends AbstractSchemaTestCase { } private void verifyProfile(RankProfile profile, List expectedFunctions, List> rankProperties, - LargeRankExpressions largeExpressions, QueryProfileRegistry queryProfiles, ImportedMlModels models, + LargeRankingExpressions largeExpressions, QueryProfileRegistry queryProfiles, ImportedMlModels models, AttributeFields attributes, ModelContext.Properties properties) { var functions = profile.getFunctions(); assertEquals(expectedFunctions.size(), functions.size()); @@ -97,7 +97,7 @@ public class RankingExpressionsTestCase extends AbstractSchemaTestCase { } } - private void verifySearch(Schema schema, RankProfileRegistry rankProfileRegistry, LargeRankExpressions largeExpressions, + private void verifySearch(Schema schema, RankProfileRegistry rankProfileRegistry, LargeRankingExpressions largeExpressions, QueryProfileRegistry queryProfiles, ImportedMlModels models, ModelContext.Properties properties) { AttributeFields attributes = new AttributeFields(schema); @@ -118,7 +118,7 @@ public class RankingExpressionsTestCase extends AbstractSchemaTestCase { void testLargeInheritedFunctions() throws IOException, ParseException { ModelContext.Properties properties = new TestProperties(); RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - LargeRankExpressions largeExpressions = new LargeRankExpressions(new MockFileRegistry(), 50); + LargeRankingExpressions largeExpressions = new LargeRankingExpressions(new MockFileRegistry(), 50); QueryProfileRegistry queryProfiles = new QueryProfileRegistry(); ImportedMlModels models = new ImportedMlModels(); Schema schema = createSearch("src/test/examples/largerankingexpressions", properties, rankProfileRegistry); diff --git a/config-model/src/test/java/com/yahoo/schema/processing/TensorTransformTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/TensorTransformTestCase.java index 028ad5dea86..aefcea95713 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/TensorTransformTestCase.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/TensorTransformTestCase.java @@ -10,7 +10,7 @@ import com.yahoo.search.query.profile.types.FieldDescription; import com.yahoo.search.query.profile.types.FieldType; import com.yahoo.search.query.profile.types.QueryProfileType; import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry; -import com.yahoo.schema.LargeRankExpressions; +import com.yahoo.schema.LargeRankingExpressions; import com.yahoo.schema.RankProfile; import com.yahoo.schema.RankProfileRegistry; import com.yahoo.schema.Schema; @@ -197,7 +197,7 @@ public class TensorTransformTestCase extends AbstractSchemaTestCase { Schema s = builder.getSchema(); RankProfile test = rankProfileRegistry.get(s, "test").compile(queryProfiles, new ImportedMlModels()); List> testRankProperties = new RawRankProfile(test, - new LargeRankExpressions(new MockFileRegistry()), + new LargeRankingExpressions(new MockFileRegistry()), queryProfiles, new ImportedMlModels(), new AttributeFields(s), new TestProperties()).configProperties(); diff --git a/model-evaluation/src/main/java/ai/vespa/models/evaluation/Model.java b/model-evaluation/src/main/java/ai/vespa/models/evaluation/Model.java index 8e7918bae9b..65515deee51 100644 --- a/model-evaluation/src/main/java/ai/vespa/models/evaluation/Model.java +++ b/model-evaluation/src/main/java/ai/vespa/models/evaluation/Model.java @@ -194,7 +194,7 @@ public class Model { // Check if the name is a signature List functionsStartingByName = - functions.stream().filter(f -> f.getName().startsWith(name + ".")).collect(Collectors.toList()); + functions.stream().filter(f -> f.getName().startsWith(name + ".")).toList(); if (functionsStartingByName.size() == 1) return evaluatorOf(functionsStartingByName.get(0)); if (functionsStartingByName.size() > 1) @@ -202,7 +202,7 @@ public class Model { // Check if the name is unambiguous as an output List functionsEndingByName = - functions.stream().filter(f -> f.getName().endsWith("." + name)).collect(Collectors.toList()); + functions.stream().filter(f -> f.getName().endsWith("." + name)).toList(); if (functionsEndingByName.size() == 1) return evaluatorOf(functionsEndingByName.get(0)); if (functionsEndingByName.size() > 1) @@ -213,7 +213,7 @@ public class Model { return evaluatorOf("default" + name.substring("serving_default".length())); } - // To handle backward compatibility with ONNX conversion to native Vespa rank expressions + // To handle backward compatibility with ONNX conversion to native Vespa ranking expressions if (name.startsWith("default.")) { return evaluatorOf(name.substring("default.".length())); } diff --git a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp index ff68c75a362..ffae4377196 100644 --- a/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/rankingexpressionfeature.cpp @@ -332,18 +332,18 @@ RankingExpressionBlueprint::setup(const fef::IIndexEnvironment &env, for (const auto &type_error: node_types.errors()) { LOG(warning, "type error: %s", type_error.c_str()); } - return fail("rank expression contains type errors: %s", script.c_str()); + return fail("ranking expression contains type errors: %s", script.c_str()); } auto compile_issues = CompiledFunction::detect_issues(*rank_function); auto interpret_issues = InterpretedFunction::detect_issues(*rank_function); if (do_compile && compile_issues && !interpret_issues) { - LOG(warning, "rank expression compilation disabled: %s\n%s", + LOG(warning, "ranking expression compilation disabled: %s\n%s", script.c_str(), list_issues(compile_issues.list).c_str()); do_compile = false; } const auto &issues = do_compile ? compile_issues : interpret_issues; if (issues) { - return fail("rank expression cannot be evaluated: %s\n%s", + return fail("ranking expression cannot be evaluated: %s\n%s", script.c_str(), list_issues(issues.list).c_str()); } // avoid costly compilation when only verifying setup -- cgit v1.2.3