diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-09-18 10:34:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-18 10:34:25 +0200 |
commit | 688961517b28efd58f3b0a3505bfacb608664a8f (patch) | |
tree | 24b753af4d53b711f7de1dbcdfb29ad65a8f393d /docprocs | |
parent | 25a8bf88ab9a9dbe15c786772ab053ec74dea686 (diff) |
Revert "Revert "Revert "Do not expose fieldupdates as a list. Hide implementation details ins…"""
Diffstat (limited to 'docprocs')
3 files changed, 16 insertions, 18 deletions
diff --git a/docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java b/docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java index 4905f3d9dad..f25603deee9 100644 --- a/docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java +++ b/docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java @@ -9,6 +9,7 @@ import com.yahoo.document.datatypes.Array; import com.yahoo.document.datatypes.FieldValue; import com.yahoo.document.datatypes.MapFieldValue; import com.yahoo.document.datatypes.StringFieldValue; +import com.yahoo.document.datatypes.Struct; import com.yahoo.document.datatypes.StructuredFieldValue; import com.yahoo.document.datatypes.WeightedSet; import com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate; @@ -19,11 +20,7 @@ import com.yahoo.document.update.ValueUpdate; import com.yahoo.vespa.indexinglanguage.AdapterFactory; import com.yahoo.vespa.indexinglanguage.expressions.Expression; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; +import java.util.*; /** * @author Simon Thoresen Hult @@ -51,13 +48,13 @@ public class DocumentScript { } public DocumentUpdate execute(AdapterFactory adapterFactory, DocumentUpdate update) { - for (FieldUpdate fieldUpdate : update.fieldUpdates()) { + for (FieldUpdate fieldUpdate : update.getFieldUpdates()) { requireThatFieldIsDeclaredInDocument(fieldUpdate.getField()); for (ValueUpdate<?> valueUpdate : fieldUpdate.getValueUpdates()) { removeAnyLinguisticsSpanTree(valueUpdate); } } - for (FieldPathUpdate fieldUpdate : update.fieldPathUpdates()) { + for (FieldPathUpdate fieldUpdate : update.getFieldPathUpdates()) { requireThatFieldIsDeclaredInDocument(fieldUpdate.getFieldPath().get(0).getFieldRef()); if (fieldUpdate instanceof AssignFieldPathUpdate) { removeAnyLinguisticsSpanTree(((AssignFieldPathUpdate)fieldUpdate).getFieldValue()); diff --git a/docprocs/src/test/java/com/yahoo/docprocs/indexing/DocumentScriptTestCase.java b/docprocs/src/test/java/com/yahoo/docprocs/indexing/DocumentScriptTestCase.java index cfaee10a07d..a47762bfbf3 100644 --- a/docprocs/src/test/java/com/yahoo/docprocs/indexing/DocumentScriptTestCase.java +++ b/docprocs/src/test/java/com/yahoo/docprocs/indexing/DocumentScriptTestCase.java @@ -187,8 +187,8 @@ public class DocumentScriptTestCase { FieldPathUpdate executeWithUpdateAndExpectFieldPath(String fieldName, FieldPathUpdate updateIn) { DocumentUpdate update = executeWithUpdate(fieldName, updateIn); - assertEquals(1, update.fieldPathUpdates().size()); - return update.fieldPathUpdates().iterator().next(); + assertEquals(1, update.getFieldPathUpdates().size()); + return update.getFieldPathUpdates().get(0); } } @@ -229,10 +229,10 @@ public class DocumentScriptTestCase { StringFieldValue newTitleValue = new StringFieldValue("iron moose 4, moose with a vengeance"); DocumentUpdate update = f.executeWithUpdate("structfield", new AssignFieldPathUpdate(f.type, "structfield.title", newTitleValue)); - assertEquals(1, update.fieldPathUpdates().size()); - assertEquals(0, update.fieldUpdates().size()); - assertTrue(update.fieldPathUpdates().iterator().next() instanceof AssignFieldPathUpdate); - AssignFieldPathUpdate assignUpdate = (AssignFieldPathUpdate)update.fieldPathUpdates().iterator().next(); + assertEquals(1, update.getFieldPathUpdates().size()); + assertEquals(0, update.getFieldUpdates().size()); + assertTrue(update.getFieldPathUpdates().get(0) instanceof AssignFieldPathUpdate); + AssignFieldPathUpdate assignUpdate = (AssignFieldPathUpdate)update.getFieldPathUpdates().get(0); assertEquals("structfield.title", assignUpdate.getOriginalFieldPath()); assertEquals(newTitleValue, assignUpdate.getFieldValue()); } diff --git a/docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java b/docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java index 5979672524d..cef020cd828 100644 --- a/docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java +++ b/docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java @@ -13,6 +13,7 @@ import com.yahoo.document.datatypes.StringFieldValue; import com.yahoo.document.update.AssignValueUpdate; import com.yahoo.document.update.FieldUpdate; import com.yahoo.document.update.ValueUpdate; +import com.yahoo.language.Linguistics; import com.yahoo.language.simple.SimpleLinguistics; import com.yahoo.vespa.configdefinition.IlscriptsConfig; import org.junit.Test; @@ -62,15 +63,15 @@ public class IndexingProcessorTestCase { assertTrue(output instanceof DocumentUpdate); DocumentUpdate docUpdate = (DocumentUpdate) output; - assertEquals(3, docUpdate.fieldUpdates().size()); + assertEquals(3, docUpdate.getFieldUpdates().size()); { - FieldUpdate fieldUpdate = docUpdate.getFieldUpdate("song"); + FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(0); assertEquals("song", fieldUpdate.getField().getName()); assertEquals(1, fieldUpdate.getValueUpdates().size()); ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0); assertTrue(valueUpdate instanceof AssignValueUpdate); assertEquals(new StringFieldValue("isbnmarker"), valueUpdate.getValue()); - fieldUpdate = docUpdate.getFieldUpdate("title"); + fieldUpdate = docUpdate.getFieldUpdate(1); assertEquals("title", fieldUpdate.getField().getName()); assertEquals(1, fieldUpdate.getValueUpdates().size()); valueUpdate = fieldUpdate.getValueUpdate(0); @@ -79,14 +80,14 @@ public class IndexingProcessorTestCase { } { - FieldUpdate fieldUpdate = docUpdate.getFieldUpdate("title"); + FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(1); ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0); assertEquals("title", fieldUpdate.getField().getName()); assertTrue(valueUpdate instanceof AssignValueUpdate); assertEquals(new StringFieldValue("69"), valueUpdate.getValue()); } { - FieldUpdate fieldUpdate = docUpdate.getFieldUpdate("isbn"); + FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(2); ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0); assertEquals("isbn", fieldUpdate.getField().getName()); assertTrue(valueUpdate instanceof AssignValueUpdate); |