use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class JsonReaderTestCase method testOldMapStringToArrayOfInt.
@Test
public final void testOldMapStringToArrayOfInt() throws IOException {
InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{\"put\": \"id:unittest:testMapStringToArrayOfInt::whee\"," + " \"fields\": { \"actualMapStringToArrayOfInt\": [" + "{ \"key\": \"bamse\", \"value\": [1, 2, 3] }" + "]}}"));
JsonReader r = new JsonReader(types, rawDoc, parserFactory);
DocumentParseInfo parseInfo = r.parseDocument().get();
DocumentType docType = r.readDocumentType(parseInfo.documentId);
DocumentPut put = new DocumentPut(new Document(docType, parseInfo.documentId));
new VespaJsonDocumentReader().readPut(parseInfo.fieldsBuffer, put);
Document doc = put.getDocument();
FieldValue f = doc.getFieldValue("actualMapStringToArrayOfInt");
assertSame(MapFieldValue.class, f.getClass());
MapFieldValue<?, ?> m = (MapFieldValue<?, ?>) f;
Array<?> a = (Array<?>) m.get(new StringFieldValue("bamse"));
assertEquals(3, a.size());
assertEquals(new IntegerFieldValue(1), a.get(0));
assertEquals(new IntegerFieldValue(2), a.get(1));
assertEquals(new IntegerFieldValue(3), a.get(2));
}
use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class LocalAsyncSession method put.
@Override
public Result put(Document document, DocumentProtocol.Priority pri) {
long req = getNextRequestId();
try {
syncSession.put(new DocumentPut(document), pri);
addResponse(new DocumentResponse(req));
} catch (Exception e) {
addResponse(new DocumentResponse(req, document, e.getMessage(), false));
}
return new Result(req);
}
use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class MessageBusAsyncSession method put.
@Override
public Result put(Document document, DocumentProtocol.Priority pri) {
PutDocumentMessage msg = new PutDocumentMessage(new DocumentPut(document));
msg.setPriority(pri);
return send(msg);
}
use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class Call method unwrapSchemaMapping.
private void unwrapSchemaMapping(Processing processing) {
final List<DocumentOperation> documentOperations = processing.getDocumentOperations();
for (int i = 0; i < documentOperations.size(); i++) {
DocumentOperation documentOperation = documentOperations.get(i);
if (documentOperation instanceof DocumentPut) {
DocumentPut putOperation = (DocumentPut) documentOperation;
if (putOperation.getDocument() instanceof DocumentOperationWrapper) {
DocumentOperationWrapper proxy = (DocumentOperationWrapper) putOperation.getDocument();
documentOperations.set(i, new DocumentPut(putOperation, ((DocumentPut) proxy.getWrappedDocumentOperation()).getDocument()));
}
}
}
}
use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class Call method configDoc.
/**
* The Document object the proc should work on. Normally the one in arguments, but could be a proxy object
* if schema mapping or @Accesses is in effect.
*
* <p>
* public for testing
*/
public DocumentPut configDoc(DocumentProcessor docProc, DocumentPut documentPut) {
if (!docProc.getFieldMap().isEmpty() || docProc.hasAnnotations()) {
Document document = documentPut.getDocument();
document = new ProxyDocument(docProc, document, docProc.getDocMap(document.getDataType().getName()));
DocumentPut newDocumentPut = new DocumentPut(document);
newDocumentPut.setCondition(documentPut.getCondition());
documentPut = newDocumentPut;
}
return documentPut;
}
Aggregations