aboutsummaryrefslogtreecommitdiffstats
path: root/indexinglanguage/src/test
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-09-30 13:46:50 +0200
committerJon Bratseth <bratseth@gmail.com>2021-09-30 13:46:50 +0200
commit9fdcf8f92eaf3b47053fa2c131832dea1c792d0c (patch)
treec4d8f2a7c8297fce1b4b6f07a32ab0daeac35aaa /indexinglanguage/src/test
parent1bc2cca4b527bb9a5a8c67744b0796c9fafbe024 (diff)
Pass destination
This allows embedders to switch on it to enable bucket testing and similar.
Diffstat (limited to 'indexinglanguage/src/test')
-rw-r--r--indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptTestCase.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptTestCase.java b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptTestCase.java
index 188426b1a06..e0c0a9faba8 100644
--- a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptTestCase.java
+++ b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptTestCase.java
@@ -104,12 +104,14 @@ public class ScriptTestCase {
TensorType tensorType = TensorType.fromSpec("tensor(d[4])");
var expression = Expression.fromString("input myText | embed | attribute 'myTensor'",
new SimpleLinguistics(),
- new MockEncoder());
+ new MockEmbedder("myDocument.myTensor"));
SimpleTestAdapter adapter = new SimpleTestAdapter();
adapter.createField(new Field("myText", DataType.STRING));
- adapter.createField(new Field("myTensor", new TensorDataType(tensorType)));
+ var tensorField = new Field("myTensor", new TensorDataType(tensorType));
+ adapter.createField(tensorField);
adapter.setValue("myText", new StringFieldValue("input text"));
+ expression.setStatementOutput(new DocumentType("myDocument"), tensorField);
// Necessary to resolve output type
VerificationContext verificationContext = new VerificationContext(adapter);
@@ -119,21 +121,27 @@ public class ScriptTestCase {
context.setValue(new StringFieldValue("input text"));
expression.execute(context);
assertNotNull(context);
- //assertTrue(context.getOutputType() instanceof TensorDataType);
assertTrue(adapter.values.containsKey("myTensor"));
assertEquals(Tensor.from(tensorType, "[7,3,0,0]"),
((TensorFieldValue)adapter.values.get("myTensor")).getTensor().get());
}
- private static class MockEncoder implements Embedder {
+ private static class MockEmbedder implements Embedder {
+
+ private final String expectedDestination;
+
+ public MockEmbedder(String expectedDestination) {
+ this.expectedDestination = expectedDestination;
+ }
@Override
- public List<Integer> embed(String text, Language language) {
+ public List<Integer> embed(String text, Language language, String destination) {
return null;
}
@Override
- public Tensor embed(String text, Language language, TensorType tensorType) {
+ public Tensor embed(String text, Language language, String destination, TensorType tensorType) {
+ assertEquals(expectedDestination, destination);
return Tensor.from(tensorType, "[7,3,0,0]");
}