use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class JoinerDocumentProcessor method process.
@Override
public Progress process(Processing processing) {
if (!doProcessOuterDocument(processing.getVariable(contextFieldName), documentTypeName)) {
return Progress.DONE;
}
DocumentPut outerDoc = (DocumentPut) processing.getVariable(contextFieldName);
@SuppressWarnings("unchecked") Array<Document> innerDocuments = (Array<Document>) outerDoc.getDocument().getFieldValue(arrayFieldName);
if (innerDocuments == null) {
@SuppressWarnings("unchecked") Array<Document> empty = (Array<Document>) outerDoc.getDocument().getDataType().getField(arrayFieldName).getDataType().createFieldValue();
innerDocuments = empty;
}
for (DocumentOperation op : processing.getDocumentOperations()) {
if (op instanceof DocumentPut) {
innerDocuments.add(((DocumentPut) op).getDocument());
} else {
log.log(LogLevel.DEBUG, "Skipping: " + op);
}
}
processing.getDocumentOperations().clear();
processing.getDocumentOperations().add(outerDoc);
processing.removeVariable(contextFieldName);
return Progress.DONE;
}
use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class JsonReaderTestCase method createPutWithoutTensor.
private DocumentPut createPutWithoutTensor() {
InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("[ { \"put\": \"" + TENSOR_DOC_ID + "\", \"fields\": { } } ]"));
JsonReader reader = new JsonReader(types, rawDoc, parserFactory);
return (DocumentPut) reader.next();
}
use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class JsonReaderTestCase method controlBasicFeed.
protected void controlBasicFeed(JsonReader r) {
DocumentOperation d = r.next();
Document doc = ((DocumentPut) d).getDocument();
smokeTestDoc(doc);
d = r.next();
DocumentUpdate update = (DocumentUpdate) d;
checkSimpleArrayAdd(update);
d = r.next();
DocumentRemove remove = (DocumentRemove) d;
assertEquals("smoke", remove.getId().getDocType());
assertNull(r.next());
}
use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class JsonReaderTestCase method smokeTest.
@Test
public final void smokeTest() throws IOException {
InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{\"put\": \"id:unittest:smoke::whee\"," + " \"fields\": { \"something\": \"smoketest\"," + " \"nalle\": \"bamse\"}}"));
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);
smokeTestDoc(put.getDocument());
}
use of com.yahoo.document.DocumentPut in project vespa by vespa-engine.
the class JsonReaderTestCase method docIdLookaheadTest.
@Test
public final void docIdLookaheadTest() throws IOException {
InputStream rawDoc = new ByteArrayInputStream(Utf8.toBytes("{" + " \"fields\": { \"something\": \"smoketest\"," + " \"nalle\": \"bamse\"}," + "\"put\": \"id:unittest:smoke::whee\"" + "}"));
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);
smokeTestDoc(put.getDocument());
}
Aggregations