use of com.yahoo.document.update.FieldUpdate in project vespa by vespa-engine.
the class VespaDocumentSerializerHead method write.
@Override
public void write(DocumentUpdate update) {
update.getId().serialize(this);
update.getDocumentType().serialize(this);
putInt(null, update.getFieldUpdates().size());
for (FieldUpdate up : update.getFieldUpdates()) {
up.serialize(this);
}
DocumentUpdateFlags flags = new DocumentUpdateFlags();
flags.setCreateIfNonExistent(update.getCreateIfNonExistent());
putInt(null, flags.injectInto(update.getFieldPathUpdates().size()));
for (FieldPathUpdate up : update.getFieldPathUpdates()) {
up.serialize(this);
}
}
use of com.yahoo.document.update.FieldUpdate in project vespa by vespa-engine.
the class SimpleAdapterFactoryTestCase method requireThatFieldUpdateCanHaveManyPartialUpdatesForOneField.
@Test
public void requireThatFieldUpdateCanHaveManyPartialUpdatesForOneField() {
DocumentType docType = new DocumentType("my_type");
DocumentUpdate docUpdate = new DocumentUpdate(docType, "doc:foo:1");
Field field = new Field("my_int", DataType.INT);
docType.addField(field);
FieldUpdate fieldUpdate = FieldUpdate.create(field);
fieldUpdate.addValueUpdate(ValueUpdate.createIncrement(1));
fieldUpdate.addValueUpdate(ValueUpdate.createIncrement(2));
fieldUpdate.addValueUpdate(ValueUpdate.createIncrement(4));
docUpdate.addFieldUpdate(fieldUpdate);
SimpleAdapterFactory factory = new SimpleAdapterFactory();
List<UpdateAdapter> adapters = factory.newUpdateAdapterList(docUpdate);
assertEquals(4, adapters.size());
UpdateAdapter adapter = adapters.get(0);
assertNotNull(adapter);
assertEquals(new IntegerFieldValue(1), adapter.getInputValue("my_int"));
assertNotNull(adapter = adapters.get(1));
assertEquals(new IntegerFieldValue(2), adapter.getInputValue("my_int"));
assertNotNull(adapter = adapters.get(2));
assertEquals(new IntegerFieldValue(4), adapter.getInputValue("my_int"));
assertNotNull(adapter = adapters.get(3));
// always add an adapter for complete updates
assertNull(adapter.getInputValue("my_int"));
}
Aggregations