summaryrefslogtreecommitdiffstats
path: root/docprocs
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-09-18 12:54:21 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2018-10-25 20:23:16 +0200
commit85b08b29cc2bc6355fb896ee63786b01beebeba5 (patch)
tree6146a6e12b4bdce08ed62a4dd384f95e71f375a2 /docprocs
parent6a6f6f8f6695ff8f39132303ca460665882ccaf6 (diff)
Use hashmap for faster access.
Diffstat (limited to 'docprocs')
-rw-r--r--docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java4
-rw-r--r--docprocs/src/test/java/com/yahoo/docprocs/indexing/DocumentScriptTestCase.java12
-rw-r--r--docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java11
3 files changed, 13 insertions, 14 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 a2321e912e1..4905f3d9dad 100644
--- a/docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java
+++ b/docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java
@@ -51,13 +51,13 @@ public class DocumentScript {
}
public DocumentUpdate execute(AdapterFactory adapterFactory, DocumentUpdate update) {
- for (FieldUpdate fieldUpdate : update.getFieldUpdates()) {
+ for (FieldUpdate fieldUpdate : update.fieldUpdates()) {
requireThatFieldIsDeclaredInDocument(fieldUpdate.getField());
for (ValueUpdate<?> valueUpdate : fieldUpdate.getValueUpdates()) {
removeAnyLinguisticsSpanTree(valueUpdate);
}
}
- for (FieldPathUpdate fieldUpdate : update.getFieldPathUpdates()) {
+ for (FieldPathUpdate fieldUpdate : update.fieldPathUpdates()) {
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 a47762bfbf3..cfaee10a07d 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.getFieldPathUpdates().size());
- return update.getFieldPathUpdates().get(0);
+ assertEquals(1, update.fieldPathUpdates().size());
+ return update.fieldPathUpdates().iterator().next();
}
}
@@ -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.getFieldPathUpdates().size());
- assertEquals(0, update.getFieldUpdates().size());
- assertTrue(update.getFieldPathUpdates().get(0) instanceof AssignFieldPathUpdate);
- AssignFieldPathUpdate assignUpdate = (AssignFieldPathUpdate)update.getFieldPathUpdates().get(0);
+ 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("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 cef020cd828..5979672524d 100644
--- a/docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java
+++ b/docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java
@@ -13,7 +13,6 @@ 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;
@@ -63,15 +62,15 @@ public class IndexingProcessorTestCase {
assertTrue(output instanceof DocumentUpdate);
DocumentUpdate docUpdate = (DocumentUpdate) output;
- assertEquals(3, docUpdate.getFieldUpdates().size());
+ assertEquals(3, docUpdate.fieldUpdates().size());
{
- FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(0);
+ FieldUpdate fieldUpdate = docUpdate.getFieldUpdate("song");
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(1);
+ fieldUpdate = docUpdate.getFieldUpdate("title");
assertEquals("title", fieldUpdate.getField().getName());
assertEquals(1, fieldUpdate.getValueUpdates().size());
valueUpdate = fieldUpdate.getValueUpdate(0);
@@ -80,14 +79,14 @@ public class IndexingProcessorTestCase {
}
{
- FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(1);
+ FieldUpdate fieldUpdate = docUpdate.getFieldUpdate("title");
ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0);
assertEquals("title", fieldUpdate.getField().getName());
assertTrue(valueUpdate instanceof AssignValueUpdate);
assertEquals(new StringFieldValue("69"), valueUpdate.getValue());
}
{
- FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(2);
+ FieldUpdate fieldUpdate = docUpdate.getFieldUpdate("isbn");
ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0);
assertEquals("isbn", fieldUpdate.getField().getName());
assertTrue(valueUpdate instanceof AssignValueUpdate);