diff options
22 files changed, 98 insertions, 108 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java b/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java index cf6d90db7fa..cec4296196d 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/MapEvaluationTypeContext.java @@ -54,6 +54,7 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement @Override public TensorType getType(Reference reference) { + // A reference to a macro argument? Optional<String> binding = boundIdentifier(reference); if (binding.isPresent()) { try { @@ -66,6 +67,7 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement } } + // A reference to an attribute, query or constant feature? if (isSimpleFeature(reference)) { // The argument may be a local identifier bound to the actual value String argument = simpleArgument(reference.arguments()).get(); @@ -73,11 +75,18 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement return featureTypes.getOrDefault(reference, defaultTypeOf(reference)); } + // A reference to a function? Optional<ExpressionFunction> function = functionInvocation(reference); if (function.isPresent()) { return function.get().getBody().type(this.withBindings(bind(function.get().arguments(), reference.arguments()))); } + // A reference to a feature which returns a tensor? + Optional<TensorType> featureTensorType = tensorFeatureType(reference); + if (featureTensorType.isPresent()) { + return featureTensorType.get(); + } + // We do not know what this is - since we do not have complete knowledge abut the match features // in Java we must assume this is a match feature and return the double type - which is the type of all // all match features @@ -110,7 +119,8 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement * ("attribute(name)", "constant(name)" or "query(name)"). * We disregard the output because all outputs under a simple feature have the same type. */ - private boolean isSimpleFeature(Reference reference) { + // TODO: Move simpleness without knowing the names to Reference, move the name-knowing to FeatureNames + public static boolean isSimpleFeature(Reference reference) { Optional<String> argument = simpleArgument(reference.arguments()); if ( ! argument.isPresent()) return false; return reference.name().equals("attribute") || @@ -122,16 +132,23 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement * If these arguments contains one simple argument string, it is returned. * Otherwise null is returned. */ - private Optional<String> simpleArgument(Arguments arguments) { + private static Optional<String> simpleArgument(Arguments arguments) { if (arguments.expressions().size() != 1) return Optional.empty(); ExpressionNode argument = arguments.expressions().get(0); - if ( ! (argument instanceof ReferenceNode)) return Optional.empty(); - ReferenceNode refArgument = (ReferenceNode)argument; + if (argument instanceof ReferenceNode) { + ReferenceNode refArgument = (ReferenceNode) argument; - if ( ! refArgument.reference().isIdentifier()) return Optional.empty(); + if ( ! refArgument.reference().isIdentifier()) return Optional.empty(); - return Optional.of(refArgument.getName()); + return Optional.of(refArgument.getName()); + } + else if (argument instanceof NameNode) { + return Optional.of(((NameNode) argument).getValue()); + } + else { + return Optional.empty(); + } } private Optional<ExpressionFunction> functionInvocation(Reference reference) { @@ -142,6 +159,38 @@ public class MapEvaluationTypeContext extends FunctionReferenceContext implement return Optional.of(function); } + /** + * There are two features which returns the (non-empty) tensor type: tensorFromLabels and tensorFromWeightedSet. + * This returns the type of those features if this is a reference to either of them, or empty otherwise. + */ + private Optional<TensorType> tensorFeatureType(Reference reference) { + if ( ! reference.name().equals("tensorFromLabels") && ! reference.name().equals("tensorFromWeightedSet")) + return Optional.empty(); + + if (reference.arguments().size() != 1 && reference.arguments().size() != 2) + throw new IllegalArgumentException(reference.name() + " must have one or two arguments"); + + ExpressionNode arg0 = reference.arguments().expressions().get(0); + if ( ! ( arg0 instanceof ReferenceNode) || ! isSimpleFeature(((ReferenceNode)arg0).reference())) + throw new IllegalArgumentException("The first argument of " + reference.name() + + " must be a simple feature, not " + arg0); + + String dimension; + if (reference.arguments().size() > 1) { + ExpressionNode arg1 = reference.arguments().expressions().get(1); + if ( ( ! (arg1 instanceof ReferenceNode) || ! (((ReferenceNode)arg1).reference().isIdentifier())) + && + ( ! (arg1 instanceof NameNode))) + throw new IllegalArgumentException("The second argument of " + reference.name() + + " must be a dimension name, not " + arg1); + dimension = reference.arguments().expressions().get(1).toString(); + } + else { // default + dimension = ((ReferenceNode)arg0).reference().arguments().expressions().get(0).toString(); + } + return Optional.of(new TensorType.Builder().mapped(dimension).build()); + } + /** Binds the given list of formal arguments to their actual values */ private Map<String, String> bind(List<String> formalArguments, Arguments invocationArguments) { 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 064897de8dc..2005f49213e 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java @@ -750,7 +750,7 @@ public class RankProfile implements Serializable, Cloneable { * Creates a context containing the type information of all constants, attributes and query profiles * referable from this rank profile. */ - public TypeContext typeContext(QueryProfileRegistry queryProfiles) { + public TypeContext<Reference> typeContext(QueryProfileRegistry queryProfiles) { MapEvaluationTypeContext context = new MapEvaluationTypeContext(getMacros().values().stream() .map(Macro::asExpressionFunction) .collect(Collectors.toList())); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConstantTensorTransformer.java b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConstantTensorTransformer.java index 843248961c2..2eb778c4b10 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConstantTensorTransformer.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/ConstantTensorTransformer.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.expressiontransforms; +import com.yahoo.searchdefinition.MapEvaluationTypeContext; import com.yahoo.searchlib.rankingexpression.evaluation.TensorValue; import com.yahoo.searchlib.rankingexpression.evaluation.Value; import com.yahoo.searchlib.rankingexpression.rule.CompositeNode; @@ -34,7 +35,7 @@ public class ConstantTensorTransformer extends ExpressionTransformer<RankProfile } private ExpressionNode transformFeature(ReferenceNode node, RankProfileTransformContext context) { - if ( ! node.getArguments().isEmpty()) { + if ( ! node.getArguments().isEmpty() && ! MapEvaluationTypeContext.isSimpleFeature(node.reference())) { return transformArguments(node, context); } else { return transformConstantReference(node, context); @@ -60,7 +61,9 @@ public class ConstantTensorTransformer extends ExpressionTransformer<RankProfile String tensorType = tensorValue.asTensor().type().toString(); context.rankPropertiesOutput().put(featureName + ".value", tensorValue.toString()); context.rankPropertiesOutput().put(featureName + ".type", tensorType); - return new ReferenceNode("constant", Arrays.asList(new NameNode(node.getName())), null); + System.out.println("==== turning " + node + " into " + new ReferenceNode(CONSTANT, Arrays.asList(new NameNode(node.getName())), null)); // TODO: Remove + // TODO: This allows us to reference constant "a" as "a" instead of "constant(a)", but we shouldn't allow that + return new ReferenceNode(CONSTANT, Arrays.asList(new NameNode(node.getName())), null); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/TensorTransformer.java b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/TensorTransformer.java index 0334012e8d9..fd2a5fcf2e4 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/TensorTransformer.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/TensorTransformer.java @@ -18,6 +18,7 @@ import com.yahoo.searchlib.rankingexpression.rule.TensorFunctionNode; import com.yahoo.searchlib.rankingexpression.transform.ExpressionTransformer; import com.yahoo.tensor.Tensor; import com.yahoo.tensor.TensorType; +import com.yahoo.tensor.evaluation.TypeContext; import com.yahoo.tensor.functions.Reduce; import java.util.List; @@ -40,51 +41,35 @@ public class TensorTransformer extends ExpressionTransformer<RankProfileTransfor node = transformChildren((CompositeNode) node, context); } if (node instanceof FunctionNode) { - node = transformFunctionNode((FunctionNode) node, context.rankProfile()); + node = transformFunctionNode((FunctionNode) node, context); } return node; } - private ExpressionNode transformFunctionNode(FunctionNode node, RankProfile profile) { + private ExpressionNode transformFunctionNode(FunctionNode node, RankProfileTransformContext context) { switch (node.getFunction()) { case min: case max: - return transformMaxAndMinFunctionNode(node, profile); + return transformMaxAndMinFunctionNode(node, context); } return node; } /** - * Transforms max and min functions if it can be proven that the first - * argument resolves to a tensor and the second argument is a valid - * dimension in the tensor. If these do not hold, the node will not - * be transformed. - * - * The test for whether or not the first argument resolves to a tensor - * is to evaluate that expression. All values used in the expression - * is bound to a context with dummy values with enough information to - * deduce tensor types. - * - * There is currently no guarantee that all cases will be found. For - * instance, if-statements are problematic. + * Transforms max and min functions if the first + * argument returns a tensor type and the second argument is a valid + * dimension in the tensor. */ - private ExpressionNode transformMaxAndMinFunctionNode(FunctionNode node, RankProfile profile) { + private ExpressionNode transformMaxAndMinFunctionNode(FunctionNode node, RankProfileTransformContext context) { if (node.children().size() != 2) { return node; } ExpressionNode arg1 = node.children().get(0); Optional<String> dimension = dimensionName(node.children().get(1)); if (dimension.isPresent()) { - try { - Context context = buildContext(arg1, profile); - Value value = arg1.evaluate(context); - if (isTensorWithDimension(value, dimension.get())) { - return replaceMaxAndMinFunction(node); - } - } catch (IllegalArgumentException e) { - // Thrown from evaluate if some variables are not bound, for - // instance for a backend rank feature. Means we don't have - // enough information to replace expression. + TensorType type = arg1.type(context.rankProfile().typeContext(context.queryProfiles())); + if (type.dimension(dimension.get()).isPresent()) { + return replaceMaxAndMinFunction(node); } } return node; @@ -97,13 +82,6 @@ public class TensorTransformer extends ExpressionTransformer<RankProfileTransfor return Optional.empty(); } - private boolean isTensorWithDimension(Value value, String dimension) { - if (value instanceof TensorValue) - return value.asTensor().type().dimensionNames().contains(dimension); - else - return false; - } - private ExpressionNode replaceMaxAndMinFunction(FunctionNode node) { ExpressionNode arg1 = node.children().get(0); ExpressionNode arg2 = node.children().get(1); diff --git a/config-model/src/test/derived/tensor/rank-profiles.cfg b/config-model/src/test/derived/tensor/rank-profiles.cfg index b6ad5372c05..9070e34458e 100644 --- a/config-model/src/test/derived/tensor/rank-profiles.cfg +++ b/config-model/src/test/derived/tensor/rank-profiles.cfg @@ -24,7 +24,7 @@ rankprofile[2].name "profile1" rankprofile[2].fef.property[0].name "vespa.rank.firstphase" rankprofile[2].fef.property[0].value "rankingExpression(firstphase)" rankprofile[2].fef.property[1].name "rankingExpression(firstphase).rankingScript" -rankprofile[2].fef.property[1].value "map(attribute(f4), f(x)(x * x)) + reduce(tensor(x[2],y[3])(random), count) * rename(attribute(f4), (x, y), (y, x))" +rankprofile[2].fef.property[1].value "reduce(map(attribute(f4), f(x)(x * x)) + reduce(tensor(x[2],y[3])(random), count) * rename(attribute(f4), (x, y), (y, x)), sum)" rankprofile[2].fef.property[2].name "vespa.type.attribute.f2" rankprofile[2].fef.property[2].value "tensor(x[2],y[])" rankprofile[2].fef.property[3].name "vespa.type.attribute.f3" @@ -46,7 +46,7 @@ rankprofile[4].name "profile3" rankprofile[4].fef.property[0].name "vespa.rank.firstphase" rankprofile[4].fef.property[0].value "rankingExpression(firstphase)" rankprofile[4].fef.property[1].name "rankingExpression(firstphase).rankingScript" -rankprofile[4].fef.property[1].value "tensor(i[10])(i) * attribute(f4)" +rankprofile[4].fef.property[1].value "reduce(tensor(i[10])(i) * attribute(f4), sum)" rankprofile[4].fef.property[2].name "vespa.type.attribute.f2" rankprofile[4].fef.property[2].value "tensor(x[2],y[])" rankprofile[4].fef.property[3].name "vespa.type.attribute.f3" diff --git a/config-model/src/test/derived/tensor/tensor.sd b/config-model/src/test/derived/tensor/tensor.sd index 3d64f6b807e..5792a7997f8 100644 --- a/config-model/src/test/derived/tensor/tensor.sd +++ b/config-model/src/test/derived/tensor/tensor.sd @@ -20,7 +20,7 @@ search tensor { rank-profile profile1 { first-phase { - expression: map(attribute(f4),f(x)(x*x)) + reduce(random(x[2],y[3]), count) * rename(attribute(f4), (x, y), (y, x)) + expression: sum(map(attribute(f4),f(x)(x*x)) + reduce(random(x[2],y[3]), count) * rename(attribute(f4), (x, y), (y, x))) } } @@ -36,7 +36,7 @@ search tensor { rank-profile profile3 { first-phase { - expression: tensor(i[10])(i) * attribute(f4) + expression: sum(tensor(i[10])(i) * attribute(f4)) } } diff --git a/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java b/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java index c89544fc4b8..390017e8588 100644 --- a/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/ApplicationDeployTest.java @@ -96,7 +96,6 @@ public class ApplicationDeployTest { Map<String, Bundle.DefEntry> defEntriesByName = defEntries2map(components.get(0).getDefEntries()); assertEquals(5, defEntriesByName.size()); - System.out.println(defEntriesByName); Bundle.DefEntry def1 = defEntriesByName.get("test-namespace"); assertNotNull(def1); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java index 973a8edd86d..6999518e706 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileRegistryTest.java @@ -15,8 +15,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; /** - * @author lulf - * @since 5.20 + * @author Ulf Lilleengen */ public class RankProfileRegistryTest { private static final String TESTDIR = "src/test/cfg/search/data/v2/inherited_rankprofiles"; @@ -26,10 +25,7 @@ public class RankProfileRegistryTest { TestRoot root = new TestDriver().buildModel(FilesApplicationPackage.fromFile(new File(TESTDIR))); RankProfilesConfig left = root.getConfig(RankProfilesConfig.class, "inherit/search/cluster.inherit/left"); RankProfilesConfig right = root.getConfig(RankProfilesConfig.class, "inherit/search/cluster.inherit/right"); - System.out.println(left); assertThat(left.rankprofile().size(), is(3)); - System.out.println("\n\n"); - System.out.println(right); assertThat(right.rankprofile().size(), is(2)); } @@ -37,7 +33,7 @@ public class RankProfileRegistryTest { public void testRankProfileDuplicateNameIsIllegal() { Search search = new Search("foo", null); RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search); - final RankProfile barRankProfile = new RankProfile("bar", search, rankProfileRegistry); + RankProfile barRankProfile = new RankProfile("bar", search, rankProfileRegistry); rankProfileRegistry.addRankProfile(barRankProfile); rankProfileRegistry.addRankProfile(barRankProfile); } @@ -49,10 +45,11 @@ public class RankProfileRegistryTest { for (String rankProfileName : RankProfileRegistry.overridableRankProfileNames) { assertNull(rankProfileRegistry.getRankProfile(search, rankProfileName).getMacros().get("foo")); - final RankProfile rankProfileWithAddedMacro = new RankProfile(rankProfileName, search, rankProfileRegistry); + RankProfile rankProfileWithAddedMacro = new RankProfile(rankProfileName, search, rankProfileRegistry); rankProfileWithAddedMacro.addMacro("foo", true); rankProfileRegistry.addRankProfile(rankProfileWithAddedMacro); assertNotNull(rankProfileRegistry.getRankProfile(search, rankProfileName).getMacros().get("foo")); } } + } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SearchDefinitionsParsingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SearchDefinitionsParsingTestCase.java index a883359fc5e..278471cb37a 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SearchDefinitionsParsingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SearchDefinitionsParsingTestCase.java @@ -32,8 +32,7 @@ public class SearchDefinitionsParsingTestCase extends SearchDefinitionTestCase { try { SearchBuilder.buildFromFile("src/test/examples/invalid_sd_construct.sd"); } catch (ParseException e) { - System.out.println(e.getMessage()); - if (!e.getMessage().contains("at line 5, column 36.")) { + if ( ! e.getMessage().contains("at line 5, column 36.")) { throw e; } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorFlowTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorFlowTestCase.java index 1e376824b7b..19d37c5fb44 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorFlowTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorFlowTestCase.java @@ -112,7 +112,7 @@ public class RankingExpressionWithTensorFlowTestCase { StoringApplicationPackage application = new StoringApplicationPackage(applicationDir, queryProfile, queryProfileType); - RankProfileSearchFixture search = fixtureWith("query(mytensor) * attribute(mytensor) * constant(mytensor)", + RankProfileSearchFixture search = fixtureWith("sum(query(mytensor) * attribute(mytensor) * constant(mytensor),d2)", "tensorflow('mnist_softmax/saved')", "constant mytensor { file: ignored\ntype: tensor(d0[7],d1[784]) }", "field mytensor type tensor(d0[],d1[784]) { indexing: attribute }", @@ -327,7 +327,7 @@ public class RankingExpressionWithTensorFlowTestCase { new StoringApplicationPackage(applicationDir)); } - private RankProfileSearchFixture fixtureWith(String placeholderExpression, + private RankProfileSearchFixture fixtureWith(String macroExpression, String firstPhaseExpression, String constant, String field, @@ -339,7 +339,7 @@ public class RankingExpressionWithTensorFlowTestCase { application.getQueryProfiles(), " rank-profile my_profile {\n" + " macro " + macroName + "() {\n" + - " expression: " + placeholderExpression + + " expression: " + macroExpression + " }\n" + " first-phase {\n" + " expression: " + firstPhaseExpression + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocumentTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocumentTest.java index 90618ab0117..de37695bd0b 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocumentTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocumentTest.java @@ -20,7 +20,6 @@ public class SearchMustHaveDocumentTest { SearchBuilder.buildFromFile("src/test/examples/invalid_sd_missing_document.sd"); fail("SD without document"); } catch (IllegalArgumentException e) { - System.out.println(e.getMessage()); if (!e.getMessage() .contains("For search 'imageconfig': A search specification must have an equally named document inside of it.")) { throw e; 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 054c9220225..098594dd06e 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 @@ -112,7 +112,7 @@ public class TensorTransformTestCase extends SearchDefinitionTestCase { } @Test - public void requireThatMaxAndMinWithTensoresReturnedFromMacrosAreReplaced() throws ParseException { + public void requireThatMaxAndMinWithTensorsReturnedFromMacrosAreReplaced() throws ParseException { assertTransformedExpression("reduce(rankingExpression(returns_tensor),max,x)", "max(returns_tensor,x)"); assertTransformedExpression("reduce(rankingExpression(wraps_returns_tensor),max,x)", @@ -123,17 +123,16 @@ public class TensorTransformTestCase extends SearchDefinitionTestCase { "max(returns_tensor_with_arg(attribute(tensor_field_1)),x)"); } - private void assertTransformedExpression(String expected, String original) throws ParseException { for (Pair<String, String> rankPropertyExpression : buildSearch(original)) { String rankProperty = rankPropertyExpression.getFirst(); - if (rankProperty.equals("rankingExpression(firstphase).rankingScript")) { + if (rankProperty.equals("rankingExpression(testexpression).rankingScript")) { String rankExpression = censorBindingHash(rankPropertyExpression.getSecond().replace(" ","")); assertEquals(expected, rankExpression); return; } } - fail("No 'rankingExpression(firstphase).rankingScript' property produced"); + fail("No 'rankingExpression(testexpression).rankingScript' property produced"); } private List<Pair<String, String>> buildSearch(String expression) throws ParseException { @@ -193,7 +192,7 @@ public class TensorTransformTestCase extends SearchDefinitionTestCase { " macro tensor_inheriting() {\n" + " expression: base_tensor\n" + " }\n" + - " first-phase {\n" + + " macro testexpression() {\n" + " expression: " + expression + "\n" + " }\n" + " }\n" + diff --git a/config-model/src/test/java/com/yahoo/vespa/model/RecentLogFilterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/RecentLogFilterTest.java index c992d8da380..a1c98a156a5 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/RecentLogFilterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/RecentLogFilterTest.java @@ -14,7 +14,6 @@ import static junit.framework.TestCase.assertTrue; /** * @author hmusum - * @since 5.1 */ public class RecentLogFilterTest { @@ -32,11 +31,10 @@ public class RecentLogFilterTest { for (int i = 1; i < RecentLogFilter.maxMessages + 1; i++) { assertTrue(rlf.isLoggable(logRecords.get(i))); } - System.out.println(logRecords.size()); - System.out.println(logRecords); // Should have filled up maxMessages slots with records 1-maxMessages // and pushed the first one out, so the below should return true assertTrue(rlf.isLoggable(logRecords.get(0))); } + } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java b/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java index 9a507827d17..b5934da3178 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/VespaModelFactoryTest.java @@ -41,7 +41,7 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** - * @author lulf + * @author Ulf Lilleengen */ public class VespaModelFactoryTest { @@ -143,7 +143,6 @@ public class VespaModelFactoryTest { assertThat(hostInfo.getHostname(), is(hostName)); assertTrue("Routing service should run on host " + hostName, hostInfo.getServices().stream() - .peek(s -> System.out.println(s.getConfigId())) .map(ServiceInfo::getConfigId) .anyMatch(configId -> configId.contains(routingClusterName))); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java index ad35eff6467..62638b7c08e 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/AdminTestCase.java @@ -220,7 +220,6 @@ public class AdminTestCase { StatisticsComponent stat = null; for (Component component : qrCluster.getAllComponents()) { - System.out.println(component.getClassId().getName()); if (component.getClassId().getName().contains("com.yahoo.statistics.StatisticsImpl")) { stat = (StatisticsComponent) component; break; diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilderTest.java index 77cc881e0d9..4bdb809f546 100755 --- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilderTest.java @@ -116,10 +116,9 @@ public class VespaDomBuilderTest { } @Test - public void testHostSystem() throws IOException, SAXException { + public void testHostSystem() { VespaModel model = createModel(hosts, services); HostSystem hostSystem = model.getHostSystem(); - System.out.println(hostSystem); assertThat(hostSystem.getHosts().size(), is(1)); HostResource host = hostSystem.getHosts().get(0); assertThat(host, is(hostSystem.getHostByHostname(host.getHostname()))); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/routing/test/RoutingTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/routing/test/RoutingTestCase.java index c8648514ca7..2cd0f906a30 100755 --- a/config-model/src/test/java/com/yahoo/vespa/model/routing/test/RoutingTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/routing/test/RoutingTestCase.java @@ -21,7 +21,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** - * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen</a> + * @author Simon Thoresen */ public class RoutingTestCase { @@ -61,12 +61,10 @@ public class RoutingTestCase { * application directory containing the necessary setup files, and call this method with a TRUE create flag. * * @param application The application directory. - * @throws IOException */ private static void assertApplication(File application) throws IOException { assertTrue(application.isDirectory()); String applicationName = application.getName(); - System.out.println("Testing route configuration from application '" + applicationName + "'.."); Map<String, File> files = new HashMap<>(); for (File file : application.listFiles(new ContentFilter())) { files.put(file.getName(), file); @@ -105,7 +103,6 @@ public class RoutingTestCase { } assertFileContains(application, files, "errors.txt", msg.toString()); } - System.out.println("\tDone."); } /** @@ -125,7 +122,6 @@ public class RoutingTestCase { fail("Expected file '" + fileName + "' not found.\nExpected content: " + expectedContent); return; } - System.out.println("\tVerifying content of '" + fileName + "'."); StringBuilder content = new StringBuilder(); try { @@ -155,7 +151,7 @@ public class RoutingTestCase { */ private static void assertConfigFileContains(File application, Map<String, File> files, String fileName, ConfigInstance config) throws IOException { - final String configString = config.toString(); + String configString = config.toString(); if (WRITE_FILES) { files.put(fileName, writeFile(application, fileName, configString.trim() + "\n")); } @@ -163,7 +159,6 @@ public class RoutingTestCase { fail("Expected file '" + fileName + "' not found."); return; } - System.out.println("\tVerifying content of '" + fileName + "'."); assertSerializedConfigEquals(IOUtils.readFile(files.get(fileName)), configString); } @@ -200,4 +195,5 @@ public class RoutingTestCase { return !name.equals(".git") && !name.equals(".svn"); } } + } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchClusterTest.java index d2341babc2c..de45eaa4d1a 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SearchClusterTest.java @@ -136,7 +136,6 @@ public class SearchClusterTest { QrSearchersConfig.Builder builder = new QrSearchersConfig.Builder(); cluster1.getConfig(builder); QrSearchersConfig config = new QrSearchersConfig(builder); - System.out.println(config); assertThat(config.searchcluster().size(), is(2)); int normalId = 0; @@ -147,14 +146,12 @@ public class SearchClusterTest { ClusterConfig.Builder clusterConfigBuilder = new ClusterConfig.Builder(); model.getConfig(clusterConfigBuilder, "j1/searchchains/chain/normal/component/com.yahoo.prelude.cluster.ClusterSearcher"); ClusterConfig clusterConfig = new ClusterConfig(clusterConfigBuilder); - System.out.println(clusterConfig); assertThat(clusterConfig.clusterId(), is(normalId)); assertThat(clusterConfig.clusterName(), is("normal")); ClusterConfig.Builder clusterConfigBuilder2 = new ClusterConfig.Builder(); model.getConfig(clusterConfigBuilder2, "j2/searchchains/chain/xbulk/component/com.yahoo.prelude.cluster.ClusterSearcher"); ClusterConfig clusterConfig2 = new ClusterConfig(clusterConfigBuilder2); - System.out.println(clusterConfig2); assertThat(clusterConfig2.clusterId(), is(bulkId)); assertThat(clusterConfig2.clusterName(), is("xbulk")); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/ModelAmendingTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/test/ModelAmendingTestCase.java index 06e06493845..ca1f0454a94 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/test/ModelAmendingTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/test/ModelAmendingTestCase.java @@ -108,7 +108,6 @@ public class ModelAmendingTestCase { } private void amend(AdminModel adminModel) { - System.out.println("Amending admin model. " + adminModel.getAdmin().getHostSystem().getHosts().size() + " hosts"); for (HostResource host : adminModel.getAdmin().getHostSystem().getHosts()) { if ( ! host.getHost().getChildrenByTypeRecursive(AmendedService.class).isEmpty()) continue; // already amended adminModel.getAdmin().addAndInitializeService(host, new AmendedService(host.getHost())); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java index 96137652e22..57bcbeda942 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java @@ -249,7 +249,6 @@ public class VespaModelTestCase { DeployState deployState = builder.deployLogger(logger).applicationPackage(app).build(); VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState); Validation.validate(model, true, deployState); - System.out.println(logger.msgs); assertFalse(logger.msgs.isEmpty()); } diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/ReferenceNode.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/ReferenceNode.java index 78f53b1593d..822d6055815 100755 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/ReferenceNode.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/rule/ReferenceNode.java @@ -16,7 +16,6 @@ import java.util.List; /** * A node referring either to a value in the context or to a named ranking expression (function aka macro). * - * @author simon * @author bratseth */ public final class ReferenceNode extends CompositeNode { @@ -64,11 +63,13 @@ public final class ReferenceNode extends CompositeNode { @Override public String toString(SerializationContext context, Deque<String> path, CompositeNode parent) { + // A reference to a macro argument? if (reference.isIdentifier() && context.getBinding(getName()) != null) { // a bound identifier: replace by the value it is bound to return context.getBinding(getName()); } + // A reference to a function? ExpressionFunction function = context.getFunction(getName()); if (function != null && function.arguments().size() == getArguments().size() && getOutput() == null) { // a function reference: replace by the referenced function wrapped in rankingExpression @@ -84,7 +85,7 @@ public final class ReferenceNode extends CompositeNode { return "rankingExpression(" + instance.getName() + ")"; } - // not resolved in this context: output as-is + // Not resolved in this context: output as-is return reference.toString(context, path, parent); } diff --git a/vespajlib/src/main/java/com/yahoo/tensor/functions/Join.java b/vespajlib/src/main/java/com/yahoo/tensor/functions/Join.java index 50b0e706a43..54568401adb 100644 --- a/vespajlib/src/main/java/com/yahoo/tensor/functions/Join.java +++ b/vespajlib/src/main/java/com/yahoo/tensor/functions/Join.java @@ -48,28 +48,8 @@ public class Join extends PrimitiveTensorFunction { } /** Returns the type resulting from applying Join to the two given types */ - // TODO: Replace implementation by new TensorType.Builder(a.type(), b.type()).build(); public static TensorType outputType(TensorType a, TensorType b) { - TensorType.Builder typeBuilder = new TensorType.Builder(); - for (int i = 0; i < a.dimensions().size(); ++i) { - TensorType.Dimension aDim = a.dimensions().get(i); - for (int j = 0; j < b.dimensions().size(); ++j) { - TensorType.Dimension bDim = b.dimensions().get(j); - if (aDim.name().equals(bDim.name())) { // include - if (aDim.isIndexed() && bDim.isIndexed()) { - if (aDim.size().isPresent() || bDim.size().isPresent()) - typeBuilder.indexed(aDim.name(), Math.min(aDim.size().orElse(Long.MAX_VALUE), - bDim.size().orElse(Long.MAX_VALUE))); - else - typeBuilder.indexed(aDim.name()); - } - else { - typeBuilder.mapped(aDim.name()); - } - } - } - } - return typeBuilder.build(); + return new TensorType.Builder(a, b).build(); } public DoubleBinaryOperator combinator() { return combinator; } |