aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-09-14 15:39:58 +0200
committerGitHub <noreply@github.com>2018-09-14 15:39:58 +0200
commite2a3037dac822e51e02f228f07d233d034eeb8a4 (patch)
tree947c3286bee01a7e500c118d01a3250bb2bcbd46
parente0e654e144726e50265fccc3fb8085c6273b1a44 (diff)
Revert "Do not expose fieldupdates as a list. Hide implementation details ins…"
-rw-r--r--docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocumentUpdate.java13
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/ProcessingUpdateTestCase.java10
-rw-r--r--docproc/src/test/java/com/yahoo/docproc/proxy/SchemaMappingAndAccessesTest.java9
-rw-r--r--docprocs/src/main/java/com/yahoo/docprocs/indexing/DocumentScript.java11
-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
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentUpdate.java116
-rw-r--r--document/src/main/java/com/yahoo/document/json/DocumentUpdateJsonSerializer.java7
-rw-r--r--document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer42.java2
-rw-r--r--document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializerHead.java2
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java54
-rw-r--r--document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java8
-rw-r--r--document/src/test/java/com/yahoo/vespaxmlparser/UriParserTestCase.java4
-rwxr-xr-xdocument/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java44
-rw-r--r--indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/SimpleAdapterFactory.java2
-rw-r--r--indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentToPathUpdateTestCase.java16
-rw-r--r--indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentToValueUpdateTestCase.java44
-rw-r--r--indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentUpdateTestCase.java6
-rw-r--r--indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/GuardTestCase.java6
-rw-r--r--vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java2
20 files changed, 153 insertions, 226 deletions
diff --git a/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocumentUpdate.java b/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocumentUpdate.java
index 517f44cb983..a0516a62bd9 100644
--- a/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocumentUpdate.java
+++ b/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocumentUpdate.java
@@ -10,7 +10,6 @@ import com.yahoo.document.Field;
import com.yahoo.document.serialization.DocumentUpdateWriter;
import com.yahoo.document.update.FieldUpdate;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -19,7 +18,6 @@ import java.util.Map;
*
* @author vegardh
*/
-// TODO Vespa 7 Remove all deprecated methods
public class ProxyDocumentUpdate extends DocumentUpdate implements DocumentOperationWrapper {
private DocumentUpdate docU;
@@ -43,12 +41,10 @@ public class ProxyDocumentUpdate extends DocumentUpdate implements DocumentOpera
@Override
public FieldUpdate getFieldUpdate(Field field) {
- return docU.getFieldUpdate(field);
+ return getFieldUpdate(field.getName());
}
@Override
- @Deprecated
- @SuppressWarnings( "deprecation" )
public FieldUpdate getFieldUpdate(int index) {
return docU.getFieldUpdate(index);
}
@@ -64,15 +60,10 @@ public class ProxyDocumentUpdate extends DocumentUpdate implements DocumentOpera
}
@Override
- @Deprecated
- @SuppressWarnings( "deprecation" )
public List<FieldUpdate> getFieldUpdates() {
return docU.getFieldUpdates();
}
- @Override
- public Collection<FieldUpdate> fieldUpdates() {
- return docU.fieldUpdates();
- }
+
@Override
public DocumentId getId() {
return docU.getId();
diff --git a/docproc/src/test/java/com/yahoo/docproc/ProcessingUpdateTestCase.java b/docproc/src/test/java/com/yahoo/docproc/ProcessingUpdateTestCase.java
index a89dbfcc782..9a3a29e55b1 100644
--- a/docproc/src/test/java/com/yahoo/docproc/ProcessingUpdateTestCase.java
+++ b/docproc/src/test/java/com/yahoo/docproc/ProcessingUpdateTestCase.java
@@ -37,10 +37,8 @@ public class ProcessingUpdateTestCase {
@Test
public void testProcessingUpdates() {
DocumentType articleType = new DocumentType("article");
- Field bodyField = new Field("body", DataType.STRING, true);
- Field titleField = new Field("title", DataType.STRING, true);
- articleType.addField(bodyField);
- articleType.addField(titleField);
+ articleType.addField(new Field("body", DataType.STRING, true));
+ articleType.addField(new Field("title", DataType.STRING, true));
dtm = new DocumentTypeManager();
dtm.registerDocumentType(articleType);
@@ -71,12 +69,12 @@ public class ProcessingUpdateTestCase {
assertEquals(new StringFieldValue("body blah blah blah "), first.getFieldValue("title"));
DocumentUpdate second = (DocumentUpdate) operations.get(1);
- FieldUpdate firstUpd = second.getFieldUpdate(bodyField);
+ FieldUpdate firstUpd = second.getFieldUpdate(0);
assertEquals(ValueUpdate.ValueUpdateClassID.ASSIGN, firstUpd.getValueUpdate(0).getValueUpdateClassID());
assertEquals(new StringFieldValue("this is the updated body of the article, blahdi blahdi blahdi"), firstUpd.getValueUpdate(0)
.getValue());
- FieldUpdate secondUpd = second.getFieldUpdate(titleField);
+ FieldUpdate secondUpd = second.getFieldUpdate(1);
assertEquals(ValueUpdate.ValueUpdateClassID.ASSIGN, secondUpd.getValueUpdate(0).getValueUpdateClassID());
assertEquals(new StringFieldValue("body blahdi blahdi blahdi "), secondUpd.getValueUpdate(0).getValue());
}
diff --git a/docproc/src/test/java/com/yahoo/docproc/proxy/SchemaMappingAndAccessesTest.java b/docproc/src/test/java/com/yahoo/docproc/proxy/SchemaMappingAndAccessesTest.java
index e6de3190156..05a03480173 100644
--- a/docproc/src/test/java/com/yahoo/docproc/proxy/SchemaMappingAndAccessesTest.java
+++ b/docproc/src/test/java/com/yahoo/docproc/proxy/SchemaMappingAndAccessesTest.java
@@ -328,17 +328,16 @@ public class SchemaMappingAndAccessesTest {
Document doc = getDoc();
DocumentType type = doc.getDataType();
DocumentUpdate dud = new DocumentUpdate(type, new DocumentId("doc:map:test:1"));
- com.yahoo.document.Field title = type.getField("title");
- FieldUpdate assignSingle = FieldUpdate.createAssign(title, new StringFieldValue("something"));
+ FieldUpdate assignSingle = FieldUpdate.createAssign(type.getField("title"), new StringFieldValue("something"));
Map<String, String> fieldMap = new HashMap<>();
fieldMap.put("t", "title");
fieldMap.put("a", "artist");
ProxyDocumentUpdate pup = new ProxyDocumentUpdate(dud, fieldMap);
pup.addFieldUpdate(assignSingle);
- assertEquals(pup.fieldUpdates().toString(), dud.fieldUpdates().toString());
+ assertEquals(pup.getFieldUpdates(), dud.getFieldUpdates());
assertEquals(pup.getDocumentType(), dud.getDocumentType());
- assertEquals(pup.getFieldUpdate(title).size(), 1);
- assertEquals(pup.getFieldUpdate(title), dud.fieldUpdates().iterator().next());
+ assertEquals(pup.getFieldUpdate(new com.yahoo.document.Field("title")).size(), 1);
+ assertEquals(pup.getFieldUpdate(0), dud.getFieldUpdate(0));
assertEquals(pup.getFieldUpdate("title"), dud.getFieldUpdate("title"));
assertEquals(pup.getId(), dud.getId());
assertEquals(pup.getType(), dud.getType());
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);
diff --git a/document/src/main/java/com/yahoo/document/DocumentUpdate.java b/document/src/main/java/com/yahoo/document/DocumentUpdate.java
index 8a743e58490..ad93942c1c0 100644
--- a/document/src/main/java/com/yahoo/document/DocumentUpdate.java
+++ b/document/src/main/java/com/yahoo/document/DocumentUpdate.java
@@ -13,12 +13,9 @@ import com.yahoo.document.update.ValueUpdate;
import com.yahoo.io.GrowableByteBuffer;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
/**
@@ -40,8 +37,6 @@ import java.util.Optional;
* @see com.yahoo.document.update.FieldUpdate
* @see com.yahoo.document.update.ValueUpdate
*/
-//TODO Vespa 7 Remove all deprecated methods
-
public class DocumentUpdate extends DocumentOperation implements Iterable<FieldPathUpdate> {
//see src/vespa/document/util/identifiableid.h
@@ -49,7 +44,6 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
private DocumentId docId;
private List<FieldUpdate> fieldUpdates;
- private final Map<Integer, FieldUpdate> id2FieldUpdateMap;
private List<FieldPathUpdate> fieldPathUpdates;
private DocumentType documentType;
private Optional<Boolean> createIfNonExistent = Optional.empty();
@@ -61,7 +55,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
* @param docType the document type that this update is valid for
*/
public DocumentUpdate(DocumentType docType, DocumentId docId) {
- this(docType, docId, new HashMap<>());
+ this(docType, docId, new ArrayList<FieldUpdate>());
}
/**
@@ -71,7 +65,6 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
docId = null;
documentType = null;
fieldUpdates = new ArrayList<>();
- id2FieldUpdateMap = new HashMap<>();
fieldPathUpdates = new ArrayList<>();
reader.read(this);
}
@@ -86,11 +79,10 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
this(docType, new DocumentId(docId));
}
- private DocumentUpdate(DocumentType docType, DocumentId docId, Map<Integer, FieldUpdate> id2fieldUpdateMap) {
+ private DocumentUpdate(DocumentType docType, DocumentId docId, List<FieldUpdate> fieldUpdates) {
this.docId = docId;
this.documentType = docType;
- this.fieldUpdates = new ArrayList<>(id2fieldUpdateMap.values());
- id2FieldUpdateMap = id2fieldUpdateMap;
+ this.fieldUpdates = fieldUpdates;
this.fieldPathUpdates = new ArrayList<>();
}
@@ -122,7 +114,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
public DocumentUpdate applyTo(Document doc) {
verifyType(doc);
- for (FieldUpdate fieldUpdate : id2FieldUpdateMap.values()) {
+ for (FieldUpdate fieldUpdate : fieldUpdates) {
fieldUpdate.applyTo(doc);
}
for (FieldPathUpdate fieldPathUpdate : fieldPathUpdates) {
@@ -140,9 +132,8 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
public DocumentUpdate prune(Document doc) {
verifyType(doc);
- for (Iterator<Map.Entry<Integer, FieldUpdate>> iter = id2FieldUpdateMap.entrySet().iterator(); iter.hasNext();) {
- Map.Entry<Integer, FieldUpdate> entry = iter.next();
- FieldUpdate update = entry.getValue();
+ for (Iterator<FieldUpdate> iter = fieldUpdates.iterator(); iter.hasNext();) {
+ FieldUpdate update = iter.next();
if (!update.isEmpty()) {
ValueUpdate last = update.getValueUpdate(update.size() - 1);
if (last instanceof AssignValueUpdate) {
@@ -171,42 +162,20 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
* Get an unmodifiable list of all field updates that this document update specifies.
*
* @return a list of all FieldUpdates in this DocumentUpdate
- * @deprecated Use fieldUpdates() instead.
*/
- @Deprecated
public List<FieldUpdate> getFieldUpdates() {
return Collections.unmodifiableList(fieldUpdates);
}
/**
- * Get an unmodifiable collection of all field updates that this document update specifies.
- *
- * @return a collection of all FieldUpdates in this DocumentUpdate
- */
- public Collection<FieldUpdate> fieldUpdates() {
- return Collections.unmodifiableCollection(id2FieldUpdateMap.values());
- }
-
- /**
* Get an unmodifiable list of all field path updates this document update specifies.
*
* @return Returns a list of all field path updates in this document update.
- * @deprecated Use fieldPathUpdates() instead.
*/
- @Deprecated
public List<FieldPathUpdate> getFieldPathUpdates() {
return Collections.unmodifiableList(fieldPathUpdates);
}
- /**
- * Get an unmodifiable collection of all field path updates that this document update specifies.
- *
- * @return a collection of all FieldPathUpdates in this DocumentUpdate
- */
- public Collection<FieldPathUpdate> fieldPathUpdates() {
- return Collections.unmodifiableCollection(fieldPathUpdates);
- }
-
/** Returns the type of the document this updates
*
* @return The documentype of the document
@@ -229,9 +198,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
* @param index the index of the FieldUpdate to return
* @return the FieldUpdate at the specified index
* @throws IndexOutOfBoundsException if index is out of range
- * @deprecated use getFieldUpdate(Field field) instead.
*/
- @Deprecated
public FieldUpdate getFieldUpdate(int index) {
return fieldUpdates.get(index);
}
@@ -243,20 +210,9 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
* @param upd the FieldUpdate to be stored at the specified position
* @return the FieldUpdate previously at the specified position
* @throws IndexOutOfBoundsException if index is out of range
- * @deprecated Use removeFieldUpdate/addFieldUpdate instead
*/
- @Deprecated
public FieldUpdate setFieldUpdate(int index, FieldUpdate upd) {
- FieldUpdate old = fieldUpdates.get(index);
- if (old.getField().equals(upd.getField())) {
- fieldUpdates.set(index, upd);
- id2FieldUpdateMap.put(upd.getField().getId(), upd);
- } else {
- throw new IllegalArgumentException("You can not replace a FieldUpdate for field '" + old.getField() +
- "' with an update for field '" + upd.getField() + "'");
- }
-
- return old;
+ return fieldUpdates.set(index, upd);
}
/**
@@ -266,13 +222,12 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
* @return the update for the field, or null if that field has no update in this
*/
public FieldUpdate getFieldUpdate(Field field) {
- return getFieldUpdateById(field.getId());
+ return getFieldUpdate(field.getName());
}
/** Removes all field updates from the list for field updates. */
public void clearFieldUpdates() {
fieldUpdates.clear();
- id2FieldUpdateMap.clear();
}
/**
@@ -282,34 +237,27 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
* @return the update for the field, or null if that field has no update in this
*/
public FieldUpdate getFieldUpdate(String fieldName) {
- for (FieldUpdate fieldUpdate : id2FieldUpdateMap.values()) {
- if (fieldUpdate.getField().getName().equals(fieldName))
+ for (FieldUpdate fieldUpdate : fieldUpdates) {
+ if (fieldUpdate.getField().getName().equals(fieldName)) {
return fieldUpdate;
+ }
}
return null;
}
- private FieldUpdate getFieldUpdateById(Integer fieldId) {
- return id2FieldUpdateMap.get(fieldId);
- }
/**
* Assigns the field updates of this document update.
* This document update receives ownership of the list - it can not be subsequently used
- * by the caller.
+ * by the caller. The list may not be unmodifiable.
*
* @param fieldUpdates the new list of updates of this
* @throws NullPointerException if the argument passed is null
- * @deprecated Iterate and use addFieldUpdate instead
*/
- @Deprecated
- public void setFieldUpdates(Collection<FieldUpdate> fieldUpdates) {
+ public void setFieldUpdates(List<FieldUpdate> fieldUpdates) {
if (fieldUpdates == null) {
throw new NullPointerException("The field updates of a document update can not be null");
}
- fieldUpdates.clear();
- for (FieldUpdate fieldUpdate : fieldUpdates) {
- addFieldUpdate(fieldUpdate);
- }
+ this.fieldUpdates = fieldUpdates;
}
/**
@@ -318,7 +266,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
* @return the size of the List of FieldUpdates
*/
public int size() {
- return id2FieldUpdateMap.size();
+ return fieldUpdates.size();
}
/**
@@ -331,17 +279,17 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
* field.
*/
public DocumentUpdate addFieldUpdate(FieldUpdate update) {
- Integer fieldId = update.getField().getId();
- if (documentType.getField(fieldId) == null) {
- throw new IllegalArgumentException("Document type '" + documentType.getName() + "' does not have field '" + update.getField().getName() + "'.");
+ String fieldName = update.getField().getName();
+ if (!documentType.hasField(fieldName)) {
+ throw new IllegalArgumentException("Document type '" + documentType.getName() + "' does not have field '" +
+ fieldName + "'.");
}
- FieldUpdate prevUpdate = getFieldUpdateById(fieldId);
+ FieldUpdate prevUpdate = getFieldUpdate(fieldName);
if (prevUpdate != update) {
if (prevUpdate != null) {
prevUpdate.addAll(update);
} else {
fieldUpdates.add(update);
- id2FieldUpdateMap.put(fieldId, update);
}
}
return this;
@@ -357,6 +305,12 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
return this;
}
+ // TODO: Remove this when we figure out correct behaviour.
+
+ public void addFieldUpdateNoCheck(FieldUpdate fieldUpdate) {
+ fieldUpdates.add(fieldUpdate);
+ }
+
/**
* Adds all the field- and field path updates of the given document update to this. If the given update refers to a
* different document or document type than this, this method throws an exception.
@@ -375,7 +329,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
if (!documentType.equals(update.documentType)) {
throw new IllegalArgumentException("Expected " + documentType + ", got " + update.documentType + ".");
}
- for (FieldUpdate fieldUpd : update.fieldUpdates()) {
+ for (FieldUpdate fieldUpd : update.fieldUpdates) {
addFieldUpdate(fieldUpd);
}
for (FieldPathUpdate pathUpd : update.fieldPathUpdates) {
@@ -389,17 +343,9 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
* @param index the index of the FieldUpdate to remove
* @return the FieldUpdate previously at the specified position
* @throws IndexOutOfBoundsException if index is out of range
- * @deprecated use removeFieldUpdate(Field field) instead.
*/
- @Deprecated
public FieldUpdate removeFieldUpdate(int index) {
- FieldUpdate prev = getFieldUpdate(index);
- fieldUpdates.remove(index);
- return removeFieldUpdate(prev.getField());
- }
-
- public FieldUpdate removeFieldUpdate(Field field) {
- return id2FieldUpdateMap.remove(field.getId());
+ return fieldUpdates.remove(index);
}
/**
@@ -439,7 +385,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
@Override
public int hashCode() {
int result = docId != null ? docId.hashCode() : 0;
- result = 31 * result + (id2FieldUpdateMap != null ? id2FieldUpdateMap.hashCode() : 0);
+ result = 31 * result + (fieldUpdates != null ? fieldUpdates.hashCode() : 0);
result = 31 * result + (fieldPathUpdates != null ? fieldPathUpdates.hashCode() : 0);
result = 31 * result + (documentType != null ? documentType.hashCode() : 0);
return result;
@@ -456,7 +402,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
string.append(": ");
string.append("[");
- for (Iterator<FieldUpdate> i = id2FieldUpdateMap.values().iterator(); i.hasNext();) {
+ for (Iterator<FieldUpdate> i = fieldUpdates.iterator(); i.hasNext();) {
FieldUpdate fieldUpdate = i.next();
string.append(fieldUpdate);
if (i.hasNext()) {
@@ -486,7 +432,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
* @return True if this update is empty.
*/
public boolean isEmpty() {
- return id2FieldUpdateMap.isEmpty() && fieldPathUpdates.isEmpty();
+ return fieldUpdates.isEmpty() && fieldPathUpdates.isEmpty();
}
/**
diff --git a/document/src/main/java/com/yahoo/document/json/DocumentUpdateJsonSerializer.java b/document/src/main/java/com/yahoo/document/json/DocumentUpdateJsonSerializer.java
index 6adae27cadc..b9b273d691f 100644
--- a/document/src/main/java/com/yahoo/document/json/DocumentUpdateJsonSerializer.java
+++ b/document/src/main/java/com/yahoo/document/json/DocumentUpdateJsonSerializer.java
@@ -47,7 +47,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
@@ -106,11 +105,11 @@ public class DocumentUpdateJsonSerializer
}
generator.writeObjectFieldStart("fields");
- for (FieldUpdate up : update.fieldUpdates()) {
+ for (FieldUpdate up : update.getFieldUpdates()) {
up.serialize(this);
}
- update.fieldPathUpdates().stream()
+ update.getFieldPathUpdates().stream()
.collect(Collectors.groupingBy(FieldPathUpdate::getFieldPath))
.forEach((fieldPath, fieldPathUpdates) ->
wrapIOException(() -> write(fieldPath, fieldPathUpdates, generator)));
@@ -121,7 +120,7 @@ public class DocumentUpdateJsonSerializer
});
}
- private void write(FieldPath fieldPath, Collection<FieldPathUpdate> fieldPathUpdates, JsonGenerator generator) throws IOException {
+ private void write(FieldPath fieldPath, List<FieldPathUpdate> fieldPathUpdates, JsonGenerator generator) throws IOException {
generator.writeObjectFieldStart(fieldPath.toString());
for (FieldPathUpdate update : fieldPathUpdates) {
diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer42.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer42.java
index 3f885844987..a048ea349eb 100644
--- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer42.java
+++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer42.java
@@ -472,7 +472,7 @@ public class VespaDocumentDeserializer42 extends VespaDocumentSerializer42 imple
for (int i = 0; i < size; i++) {
// TODO: Should use checked method, but doesn't work according to test now.
- update.addFieldUpdate(new FieldUpdate(this, update.getDocumentType(), serializationVersion));
+ update.addFieldUpdateNoCheck(new FieldUpdate(this, update.getDocumentType(), serializationVersion));
}
}
diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializerHead.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializerHead.java
index 4f8a26d3777..7bdc6fd5355 100644
--- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializerHead.java
+++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializerHead.java
@@ -29,7 +29,7 @@ public class VespaDocumentDeserializerHead extends VespaDocumentDeserializer42 {
for (int i = 0; i < size; i++) {
// TODO: Should use checked method, but doesn't work according to test now.
- update.addFieldUpdate(new FieldUpdate(this, update.getDocumentType(), 8));
+ update.addFieldUpdateNoCheck(new FieldUpdate(this, update.getDocumentType(), 8));
}
int sizeAndFlags = getInt(null);
diff --git a/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java b/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java
index 243102c17df..15319985591 100644
--- a/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java
@@ -1,19 +1,10 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document;
-import com.yahoo.document.datatypes.Array;
-import com.yahoo.document.datatypes.FloatFieldValue;
-import com.yahoo.document.datatypes.IntegerFieldValue;
-import com.yahoo.document.datatypes.StringFieldValue;
-import com.yahoo.document.datatypes.TensorFieldValue;
-import com.yahoo.document.datatypes.WeightedSet;
+import com.yahoo.document.datatypes.*;
import com.yahoo.document.fieldpathupdate.FieldPathUpdate;
-import com.yahoo.document.serialization.DocumentDeserializer;
-import com.yahoo.document.serialization.DocumentDeserializerFactory;
-import com.yahoo.document.serialization.DocumentSerializer;
-import com.yahoo.document.serialization.DocumentSerializerFactory;
-import com.yahoo.document.serialization.DocumentUpdateFlags;
-import com.yahoo.document.serialization.DocumentUpdateWriter;
+import com.yahoo.document.select.parser.ParseException;
+import com.yahoo.document.serialization.*;
import com.yahoo.document.update.AssignValueUpdate;
import com.yahoo.document.update.FieldUpdate;
import com.yahoo.document.update.ValueUpdate;
@@ -268,8 +259,8 @@ public class DocumentUpdateTestCase {
update.addFieldUpdate(FieldUpdate.createAssign(field, new IntegerFieldValue(1)));
update.addFieldUpdate(FieldUpdate.createAssign(field, new IntegerFieldValue(2)));
- assertEquals(1, update.fieldUpdates().size());
- FieldUpdate fieldUpdate = update.getFieldUpdate(field);
+ assertEquals(1, update.getFieldUpdates().size());
+ FieldUpdate fieldUpdate = update.getFieldUpdate(0);
assertNotNull(fieldUpdate);
assertEquals(field, fieldUpdate.getField());
assertEquals(2, fieldUpdate.getValueUpdates().size());
@@ -351,16 +342,13 @@ public class DocumentUpdateTestCase {
assertEquals(new DocumentId("doc:update:test"), upd.getId());
assertEquals(type, upd.getType());
- FieldUpdate serAssignFU = upd.getFieldUpdate(type.getField("intfield"));
+ FieldUpdate serAssignFU = upd.getFieldUpdate(0);
assertEquals(type.getField("intfield"), serAssignFU.getField());
ValueUpdate serAssign = serAssignFU.getValueUpdate(0);
assertEquals(ValueUpdate.ValueUpdateClassID.ASSIGN, serAssign.getValueUpdateClassID());
assertEquals(new IntegerFieldValue(4), serAssign.getValue());
- ValueUpdate serArith = serAssignFU.getValueUpdate(1);
- assertEquals(ValueUpdate.ValueUpdateClassID.ARITHMETIC, serArith.getValueUpdateClassID());
-
- FieldUpdate serAddFU = upd.getFieldUpdate(type.getField("arrayoffloatfield"));
+ FieldUpdate serAddFU = upd.getFieldUpdate(2);
assertEquals(type.getField("arrayoffloatfield"), serAddFU.getField());
ValueUpdate serAdd1 = serAddFU.getValueUpdate(0);
assertEquals(ValueUpdate.ValueUpdateClassID.ADD, serAdd1.getValueUpdateClassID());
@@ -375,7 +363,12 @@ public class DocumentUpdateTestCase {
FloatFieldValue addparam3 = (FloatFieldValue)serAdd3.getValue();
assertEquals(new FloatFieldValue(-1.00f), addparam3);
- FieldUpdate wsetFU = upd.getFieldUpdate(type.getField("wsfield"));
+ FieldUpdate arithFU = upd.getFieldUpdate(3);
+ assertEquals(type.getField("intfield"), serAssignFU.getField());
+ ValueUpdate serArith = arithFU.getValueUpdate(0);
+ assertEquals(ValueUpdate.ValueUpdateClassID.ARITHMETIC, serArith.getValueUpdateClassID());
+
+ FieldUpdate wsetFU = upd.getFieldUpdate(4);
assertEquals(type.getField("wsfield"), wsetFU.getField());
assertEquals(2, wsetFU.size());
ValueUpdate mapUpd = wsetFU.getValueUpdate(0);
@@ -427,8 +420,8 @@ public class DocumentUpdateTestCase {
barUpdate.addFieldUpdate(barField);
fooUpdate.addAll(barUpdate);
- assertEquals(1, fooUpdate.fieldUpdates().size());
- FieldUpdate fieldUpdate = fooUpdate.getFieldUpdate(field);
+ assertEquals(1, fooUpdate.getFieldUpdates().size());
+ FieldUpdate fieldUpdate = fooUpdate.getFieldUpdate(0);
assertNotNull(fieldUpdate);
assertEquals(field, fieldUpdate.getField());
assertEquals(2, fieldUpdate.getValueUpdates().size());
@@ -472,7 +465,6 @@ public class DocumentUpdateTestCase {
}
@Test
- @SuppressWarnings("deprecation")
public void testFieldUpdatesInDocUp() {
DocumentType t1 = new DocumentType("doo");
Field f1 = new Field("field1", DataType.STRING);
@@ -501,6 +493,14 @@ public class DocumentUpdateTestCase {
assertSame(fu1, documentUpdate.getFieldUpdate(f1));
+ assertSame(fu1, documentUpdate.getFieldUpdate(0));
+ assertSame(fu2, documentUpdate.getFieldUpdate(1));
+
+ documentUpdate.setFieldUpdate(0, fu2);
+ documentUpdate.setFieldUpdate(1, fu1);
+ assertEquals(2, documentUpdate.size());
+ assertSame(fu1, documentUpdate.getFieldUpdate(1));
+ assertSame(fu2, documentUpdate.getFieldUpdate(0));
try {
documentUpdate.setFieldUpdates(null);
@@ -515,12 +515,12 @@ public class DocumentUpdateTestCase {
documentUpdate.setFieldUpdates(fus);
assertEquals(2, documentUpdate.size());
- assertSame(fu1, documentUpdate.getFieldUpdate(fu1.getField()));
- assertSame(fu2, documentUpdate.getFieldUpdate(fu2.getField()));
+ assertSame(fu1, documentUpdate.getFieldUpdate(0));
+ assertSame(fu2, documentUpdate.getFieldUpdate(1));
- documentUpdate.removeFieldUpdate(fu2.getField());
+ documentUpdate.removeFieldUpdate(1);
assertEquals(1, documentUpdate.size());
- assertSame(fu1, documentUpdate.getFieldUpdate(fu1.getField()));
+ assertSame(fu1, documentUpdate.getFieldUpdate(0));
documentUpdate.toString();
diff --git a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
index 32f63e6c0b3..1fd45cb07c4 100644
--- a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
+++ b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java
@@ -292,8 +292,8 @@ public class JsonReaderTestCase {
+ "\"skuggsjaa\": {"
+ "\"assign\": { \"sandra\": \"person\","
+ " \"cloud\": \"another person\"}}}}");
- assertEquals(1, put.fieldUpdates().size());
- FieldUpdate fu = put.fieldUpdates().iterator().next();
+ assertEquals(1, put.getFieldUpdates().size());
+ FieldUpdate fu = put.getFieldUpdate(0);
assertEquals(1, fu.getValueUpdates().size());
ValueUpdate vu = fu.getValueUpdate(0);
assertTrue(vu instanceof AssignValueUpdate);
@@ -315,8 +315,8 @@ public class JsonReaderTestCase {
+ " \"fields\": { "
+ "\"skuggsjaa\": {"
+ "\"assign\": { }}}}");
- assertEquals(1, put.fieldUpdates().size());
- FieldUpdate fu = put.fieldUpdates().iterator().next();
+ assertEquals(1, put.getFieldUpdates().size());
+ FieldUpdate fu = put.getFieldUpdate(0);
assertEquals(1, fu.getValueUpdates().size());
ValueUpdate vu = fu.getValueUpdate(0);
assertTrue(vu instanceof AssignValueUpdate);
diff --git a/document/src/test/java/com/yahoo/vespaxmlparser/UriParserTestCase.java b/document/src/test/java/com/yahoo/vespaxmlparser/UriParserTestCase.java
index dcdea0975ad..ea954f0da40 100644
--- a/document/src/test/java/com/yahoo/vespaxmlparser/UriParserTestCase.java
+++ b/document/src/test/java/com/yahoo/vespaxmlparser/UriParserTestCase.java
@@ -46,8 +46,8 @@ public class UriParserTestCase {
DocumentUpdate upd = nextUpdate(it);
assertNotNull(upd);
- assertEquals(1, upd.fieldUpdates().size());
- FieldUpdate fieldUpd = upd.fieldUpdates().iterator().next();
+ assertEquals(1, upd.getFieldUpdates().size());
+ FieldUpdate fieldUpd = upd.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_arr"), fieldUpd.getField());
assertEquals(1, fieldUpd.getValueUpdates().size());
diff --git a/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java b/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java
index 1aad59f4c56..4c64f7c35cb 100755
--- a/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java
+++ b/document/src/test/java/com/yahoo/vespaxmlparser/VespaXMLReaderTestCase.java
@@ -5,7 +5,6 @@ import com.yahoo.document.*;
import com.yahoo.document.datatypes.*;
import com.yahoo.document.fieldpathupdate.AddFieldPathUpdate;
import com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate;
-import com.yahoo.document.fieldpathupdate.FieldPathUpdate;
import com.yahoo.document.fieldpathupdate.RemoveFieldPathUpdate;
import com.yahoo.document.serialization.DeserializationException;
import com.yahoo.document.update.AddValueUpdate;
@@ -17,7 +16,6 @@ import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayInputStream;
-import java.util.Iterator;
import java.util.List;
import static org.junit.Assert.*;
@@ -689,105 +687,103 @@ public class VespaXMLReaderTestCase {
DocumentUpdate docUpdate = op.getDocumentUpdate();
- assertEquals(20, docUpdate.fieldPathUpdates().size());
+ assertEquals(20, docUpdate.getFieldPathUpdates().size());
- Iterator<FieldPathUpdate> updates = docUpdate.fieldPathUpdates().iterator();
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(0);
assertEquals("url", ass.getOriginalFieldPath());
assertEquals(new StringFieldValue("assignUrl"), ass.getNewValue());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(1);
assertEquals("title", ass.getOriginalFieldPath());
assertEquals(new StringFieldValue("assignTitle"), ass.getNewValue());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(2);
assertEquals("last_downloaded", ass.getOriginalFieldPath());
assertEquals("1", ass.getExpression());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(3);
assertEquals("value_long", ass.getOriginalFieldPath());
assertEquals("2", ass.getExpression());
}
- updates.next(); // Skip number 5
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(5);
assertEquals("stringarr", ass.getOriginalFieldPath());
assertEquals("[assignString1, assignString2]", ass.getNewValue().toString());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(6);
assertEquals("intarr", ass.getOriginalFieldPath());
assertEquals("[3, 4]", ass.getNewValue().toString());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(7);
assertEquals("longarr", ass.getOriginalFieldPath());
assertEquals("[5, 6]", ass.getNewValue().toString());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(8);
assertEquals("bytearr", ass.getOriginalFieldPath());
assertEquals("[7, 8]", ass.getNewValue().toString());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(9);
assertEquals("floatarr", ass.getOriginalFieldPath());
assertEquals("[9.0, 10.0]", ass.getNewValue().toString());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(10);
assertEquals("weightedsetint", ass.getOriginalFieldPath());
WeightedSet set = (WeightedSet)ass.getNewValue();
assertEquals(Integer.valueOf(11), set.get(new IntegerFieldValue(11)));
assertEquals(Integer.valueOf(12), set.get(new IntegerFieldValue(12)));
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(11);
assertEquals("weightedsetstring", ass.getOriginalFieldPath());
WeightedSet set = (WeightedSet)ass.getNewValue();
assertEquals(Integer.valueOf(13), set.get(new StringFieldValue("assign13")));
assertEquals(Integer.valueOf(14), set.get(new StringFieldValue("assign14")));
}
{
- AddFieldPathUpdate ass = (AddFieldPathUpdate)updates.next();
+ AddFieldPathUpdate ass = (AddFieldPathUpdate)docUpdate.getFieldPathUpdates().get(12);
assertEquals("stringarr", ass.getOriginalFieldPath());
assertEquals("[addString1, addString2]", ass.getNewValues().toString());
}
{
- AddFieldPathUpdate ass = (AddFieldPathUpdate)updates.next();
+ AddFieldPathUpdate ass = (AddFieldPathUpdate)docUpdate.getFieldPathUpdates().get(13);
assertEquals("longarr", ass.getOriginalFieldPath());
assertEquals("[5]", ass.getNewValues().toString());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(14);
assertEquals("weightedsetint{13}", ass.getOriginalFieldPath());
assertEquals("13", ass.getExpression());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(15);
assertEquals("weightedsetint{14}", ass.getOriginalFieldPath());
assertEquals("14", ass.getExpression());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(16);
assertEquals("weightedsetstring{add13}", ass.getOriginalFieldPath());
assertEquals("1", ass.getExpression());
}
{
- AssignFieldPathUpdate ass = (AssignFieldPathUpdate)updates.next();
+ AssignFieldPathUpdate ass = (AssignFieldPathUpdate)docUpdate.getFieldPathUpdates().get(17);
assertEquals("weightedsetstring{assign13}", ass.getOriginalFieldPath());
assertEquals("130", ass.getExpression());
}
{
- RemoveFieldPathUpdate ass = (RemoveFieldPathUpdate)updates.next();
+ RemoveFieldPathUpdate ass = (RemoveFieldPathUpdate)docUpdate.getFieldPathUpdates().get(18);
assertEquals("weightedsetstring{assign14}", ass.getOriginalFieldPath());
}
{
- RemoveFieldPathUpdate ass = (RemoveFieldPathUpdate)updates.next();
+ RemoveFieldPathUpdate ass = (RemoveFieldPathUpdate)docUpdate.getFieldPathUpdates().get(19);
assertEquals("bytearr", ass.getOriginalFieldPath());
}
Document doc = new Document(manager.getDocumentType("news"), new DocumentId("doc:test:test:test"));
diff --git a/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/SimpleAdapterFactory.java b/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/SimpleAdapterFactory.java
index 2ccd8abffda..252f6c5bd12 100644
--- a/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/SimpleAdapterFactory.java
+++ b/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/SimpleAdapterFactory.java
@@ -57,7 +57,7 @@ public class SimpleAdapterFactory implements AdapterFactory {
ret.add(new IdentityFieldPathUpdateAdapter(fieldUpd, newDocumentAdapter(complete, true)));
}
}
- for (FieldUpdate fieldUpd : upd.fieldUpdates()) {
+ for (FieldUpdate fieldUpd : upd.getFieldUpdates()) {
Field field = fieldUpd.getField();
for (ValueUpdate valueUpd : fieldUpd.getValueUpdates()) {
if (FieldUpdateHelper.isComplete(field, valueUpd)) {
diff --git a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentToPathUpdateTestCase.java b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentToPathUpdateTestCase.java
index 3c5eb9ea1c5..459f3ce827c 100644
--- a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentToPathUpdateTestCase.java
+++ b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentToPathUpdateTestCase.java
@@ -29,8 +29,8 @@ public class DocumentToPathUpdateTestCase {
DocumentUpdate docUpd = new FieldPathUpdateAdapter(new SimpleDocumentAdapter(null, doc), upd).getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldPathUpdates().size());
- assertNotNull(upd = docUpd.fieldPathUpdates().iterator().next());
+ assertEquals(1, docUpd.getFieldPathUpdates().size());
+ assertNotNull(upd = docUpd.getFieldPathUpdates().get(0));
assertTrue(upd instanceof AssignFieldPathUpdate);
assertEquals("my_int", upd.getOriginalFieldPath());
@@ -49,8 +49,8 @@ public class DocumentToPathUpdateTestCase {
DocumentUpdate docUpd = new FieldPathUpdateAdapter(new SimpleDocumentAdapter(null, doc), upd).getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldPathUpdates().size());
- assertNotNull(upd = docUpd.fieldPathUpdates().iterator().next());
+ assertEquals(1, docUpd.getFieldPathUpdates().size());
+ assertNotNull(upd = docUpd.getFieldPathUpdates().get(0));
assertTrue(upd instanceof AssignFieldPathUpdate);
assertEquals("my_str", upd.getOriginalFieldPath());
@@ -77,8 +77,8 @@ public class DocumentToPathUpdateTestCase {
DocumentUpdate docUpd = new FieldPathUpdateAdapter(new SimpleDocumentAdapter(null, doc), upd).getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldPathUpdates().size());
- assertNotNull(upd = docUpd.fieldPathUpdates().iterator().next());
+ assertEquals(1, docUpd.getFieldPathUpdates().size());
+ assertNotNull(upd = docUpd.getFieldPathUpdates().get(0));
assertTrue(upd instanceof AssignFieldPathUpdate);
assertEquals("a", upd.getOriginalFieldPath());
@@ -103,8 +103,8 @@ public class DocumentToPathUpdateTestCase {
DocumentUpdate docUpd = new FieldPathUpdateAdapter(new SimpleDocumentAdapter(null, doc), upd).getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldPathUpdates().size());
- assertNotNull(upd = docUpd.fieldPathUpdates().iterator().next());
+ assertEquals(1, docUpd.getFieldPathUpdates().size());
+ assertNotNull(upd = docUpd.getFieldPathUpdates().get(0));
assertTrue(upd instanceof AssignFieldPathUpdate);
assertEquals("a.b", upd.getOriginalFieldPath());
diff --git a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentToValueUpdateTestCase.java b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentToValueUpdateTestCase.java
index 83947b5f64d..de090163b7b 100644
--- a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentToValueUpdateTestCase.java
+++ b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentToValueUpdateTestCase.java
@@ -40,8 +40,8 @@ public class DocumentToValueUpdateTestCase {
UpdateAdapter adapter = FieldUpdateAdapter.fromPartialUpdate(new SimpleDocumentAdapter(null, doc), valueUpd);
DocumentUpdate docUpd = adapter.getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldUpdates().size());
- assertEquals("my_int", docUpd.fieldUpdates().iterator().next().getField().getName());
+ assertEquals(1, docUpd.getFieldUpdates().size());
+ assertEquals("my_int", docUpd.getFieldUpdate(0).getField().getName());
}
@Test
@@ -56,9 +56,9 @@ public class DocumentToValueUpdateTestCase {
UpdateAdapter adapter = FieldUpdateAdapter.fromPartialUpdate(new SimpleDocumentAdapter(null, doc), valueUpd);
DocumentUpdate docUpd = adapter.getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldUpdates().size());
+ assertEquals(1, docUpd.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpd.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpd.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_int"), fieldUpd.getField());
@@ -80,9 +80,9 @@ public class DocumentToValueUpdateTestCase {
UpdateAdapter adapter = FieldUpdateAdapter.fromPartialUpdate(new SimpleDocumentAdapter(null, doc), valueUpd);
DocumentUpdate docUpd = adapter.getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldUpdates().size());
+ assertEquals(1, docUpd.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpd.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpd.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_int"), fieldUpd.getField());
@@ -103,9 +103,9 @@ public class DocumentToValueUpdateTestCase {
UpdateAdapter adapter = FieldUpdateAdapter.fromPartialUpdate(new SimpleDocumentAdapter(null, doc), valueUpd);
DocumentUpdate docUpd = adapter.getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldUpdates().size());
+ assertEquals(1, docUpd.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpd.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpd.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_str"), fieldUpd.getField());
@@ -136,9 +136,9 @@ public class DocumentToValueUpdateTestCase {
UpdateAdapter adapter = FieldUpdateAdapter.fromPartialUpdate(new SimpleDocumentAdapter(null, doc), valueUpd);
DocumentUpdate docUpd = adapter.getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldUpdates().size());
+ assertEquals(1, docUpd.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpd.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpd.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("a"), fieldUpd.getField());
@@ -166,9 +166,9 @@ public class DocumentToValueUpdateTestCase {
UpdateAdapter adapter = FieldUpdateAdapter.fromPartialUpdate(new SimpleDocumentAdapter(null, doc), valueUpd);
DocumentUpdate docUpd = adapter.getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldUpdates().size());
+ assertEquals(1, docUpd.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpd.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpd.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_arr"), fieldUpd.getField());
@@ -196,9 +196,9 @@ public class DocumentToValueUpdateTestCase {
UpdateAdapter adapter = FieldUpdateAdapter.fromPartialUpdate(new SimpleDocumentAdapter(null, doc), valueUpd);
DocumentUpdate docUpd = adapter.getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldUpdates().size());
+ assertEquals(1, docUpd.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpd.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpd.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_arr"), fieldUpd.getField());
@@ -231,9 +231,9 @@ public class DocumentToValueUpdateTestCase {
UpdateAdapter adapter = FieldUpdateAdapter.fromPartialUpdate(new SimpleDocumentAdapter(null, doc), valueUpd);
DocumentUpdate docUpd = adapter.getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldUpdates().size());
+ assertEquals(1, docUpd.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpd.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpd.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("a"), fieldUpd.getField());
@@ -261,9 +261,9 @@ public class DocumentToValueUpdateTestCase {
UpdateAdapter adapter = FieldUpdateAdapter.fromPartialUpdate(new SimpleDocumentAdapter(null, doc), valueUpd);
DocumentUpdate docUpd = adapter.getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldUpdates().size());
+ assertEquals(1, docUpd.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpd.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpd.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_wset"), fieldUpd.getField());
@@ -294,9 +294,9 @@ public class DocumentToValueUpdateTestCase {
UpdateAdapter adapter = FieldUpdateAdapter.fromPartialUpdate(new SimpleDocumentAdapter(null, doc), valueUpd);
DocumentUpdate docUpd = adapter.getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldUpdates().size());
+ assertEquals(1, docUpd.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpd.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpd.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_wset"), fieldUpd.getField());
@@ -326,9 +326,9 @@ public class DocumentToValueUpdateTestCase {
UpdateAdapter adapter = FieldUpdateAdapter.fromPartialUpdate(new SimpleDocumentAdapter(null, doc), valueUpd);
DocumentUpdate docUpd = adapter.getOutput();
assertNotNull(docUpd);
- assertEquals(1, docUpd.fieldUpdates().size());
+ assertEquals(1, docUpd.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpd.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpd.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_wset"), fieldUpd.getField());
diff --git a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentUpdateTestCase.java b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentUpdateTestCase.java
index dc8ffcd8d10..bdb8dbedf78 100644
--- a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentUpdateTestCase.java
+++ b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/DocumentUpdateTestCase.java
@@ -32,10 +32,10 @@ public class DocumentUpdateTestCase {
docUpdate = Expression.execute(Expression.fromString("input my_str | for_each { to_pos } | index my_pos"), docUpdate);
assertNotNull(docUpdate);
- assertEquals(0, docUpdate.fieldPathUpdates().size());
- assertEquals(1, docUpdate.fieldUpdates().size());
+ assertEquals(0, docUpdate.getFieldPathUpdates().size());
+ assertEquals(1, docUpdate.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpdate.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpdate.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_pos"), fieldUpd.getField());
assertEquals(1, fieldUpd.getValueUpdates().size());
diff --git a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/GuardTestCase.java b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/GuardTestCase.java
index 63a2cc66a97..033034fed1f 100644
--- a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/GuardTestCase.java
+++ b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/GuardTestCase.java
@@ -72,10 +72,10 @@ public class GuardTestCase {
docUpdate.addFieldUpdate(FieldUpdate.createAssign(docType.getField("my_str"), new StringFieldValue("69")));
assertNotNull(docUpdate = Expression.execute(Expression.fromString("guard { input my_str | to_int | attribute my_lng }"), docUpdate));
- assertEquals(0, docUpdate.fieldPathUpdates().size());
- assertEquals(1, docUpdate.fieldUpdates().size());
+ assertEquals(0, docUpdate.getFieldPathUpdates().size());
+ assertEquals(1, docUpdate.getFieldUpdates().size());
- FieldUpdate fieldUpd = docUpdate.fieldUpdates().iterator().next();
+ FieldUpdate fieldUpd = docUpdate.getFieldUpdate(0);
assertNotNull(fieldUpd);
assertEquals(docType.getField("my_lng"), fieldUpd.getField());
assertEquals(1, fieldUpd.getValueUpdates().size());
diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java
index 237a7d21aef..297576f1bef 100644
--- a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java
+++ b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java
@@ -36,7 +36,7 @@ public class MockedOperationHandler implements OperationHandler {
@Override
public void update(RestUri restUri, VespaXMLFeedReader.Operation data, Optional<String> route) throws RestApiException {
log.append("UPDATE: " + data.getDocumentUpdate().getId());
- log.append(data.getDocumentUpdate().fieldUpdates().toString());
+ log.append(data.getDocumentUpdate().getFieldUpdates().toString());
if (data.getDocumentUpdate().getCreateIfNonExistent()) {
log.append("[CREATE IF NON EXISTENT IS TRUE]");
}