use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class MockReader method read.
@Override
public void read(Operation operation) throws Exception {
if (finished) {
return;
}
byte whatToDo = stream.getNextOperation();
DocumentId id = new DocumentId("id:banana:banana::doc1");
DocumentType docType = new DocumentType("banana");
switch(whatToDo) {
case 0:
finished = true;
break;
case 1:
Document doc = new Document(docType, id);
operation.setDocument(doc);
break;
case 2:
operation.setRemove(id);
break;
case 3:
operation.setDocumentUpdate(new DocumentUpdate(docType, id));
break;
case 4:
throw new RuntimeException("boom");
}
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class SchemaMappingAndAccessesTest method testMappedDocUpdateAPI.
public void testMappedDocUpdateAPI() {
Document doc = getDoc();
DocumentType type = doc.getDataType();
DocumentUpdate dud = new DocumentUpdate(type, new DocumentId("doc:map:test:1"));
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.getFieldUpdates(), dud.getFieldUpdates());
assertEquals(pup.getDocumentType(), dud.getDocumentType());
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());
assertEquals(pup.applyTo(doc), dud);
assertEquals(doc.getFieldValue("title").getWrappedValue(), "something");
assertEquals(pup, dud);
assertEquals(pup.hashCode(), dud.hashCode());
assertEquals(pup.toString(), dud.toString());
assertEquals(pup.size(), dud.size());
assertEquals(pup.getWrappedDocumentOperation().getId().toString(), "doc:map:test:1");
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class DocumentScriptTestCase method newFieldUpdate.
private static DocumentUpdate newFieldUpdate(FieldValue documentFieldValue, FieldValue extraFieldValue) {
DocumentType type = newDocumentType();
DocumentUpdate update = new DocumentUpdate(type, "doc:scheme:");
if (documentFieldValue != null) {
update.addFieldUpdate(FieldUpdate.createAssign(type.getField("documentField"), documentFieldValue));
}
if (extraFieldValue != null) {
update.addFieldUpdate(FieldUpdate.createAssign(type.getField("extraField"), extraFieldValue));
}
return update;
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class DocumentScriptTestCase method newPathUpdate.
private static DocumentUpdate newPathUpdate(FieldValue documentFieldValue, FieldValue extraFieldValue) {
DocumentType type = newDocumentType();
DocumentUpdate update = new DocumentUpdate(type, "doc:scheme:");
if (documentFieldValue != null) {
update.addFieldPathUpdate(new AssignFieldPathUpdate(type, "documentField", documentFieldValue));
}
if (extraFieldValue != null) {
update.addFieldPathUpdate(new AssignFieldPathUpdate(type, "extraField", extraFieldValue));
}
return update;
}
use of com.yahoo.document.DocumentUpdate in project vespa by vespa-engine.
the class DocumentScriptTestCase method processFieldUpdate.
private static ValueUpdate<?> processFieldUpdate(FieldValue fieldValue) {
DocumentType docType = new DocumentType("myDocumentType");
docType.addField("myField", fieldValue.getDataType());
DocumentUpdate update = new DocumentUpdate(docType, "doc:scheme:");
update.addFieldUpdate(FieldUpdate.createAssign(docType.getField("myField"), fieldValue));
update = newScript(docType).execute(ADAPTER_FACTORY, update);
return update.getFieldUpdate("myField").getValueUpdate(0);
}
Aggregations