Search in sources :

Example 1 with DocumentParser

use of com.yahoo.document.json.document.DocumentParser in project vespa by vespa-engine.

the class JsonReader method readSingleDocument.

/**
 * Reads a single operation. The operation is not expected to be part of an array.
 * @param operationType the type of operation (update or put)
 * @param docIdString document ID.
 * @return the document
 */
public DocumentOperation readSingleDocument(DocumentParser.SupportedOperation operationType, String docIdString) {
    DocumentId docId = new DocumentId(docIdString);
    final DocumentParseInfo documentParseInfo;
    try {
        DocumentParser documentParser = new DocumentParser(parser);
        documentParseInfo = documentParser.parse(Optional.of(docId)).get();
    } catch (IOException e) {
        state = END_OF_FEED;
        throw new RuntimeException(e);
    }
    documentParseInfo.operationType = operationType;
    VespaJsonDocumentReader vespaJsonDocumentReader = new VespaJsonDocumentReader();
    DocumentOperation operation = vespaJsonDocumentReader.createDocumentOperation(getDocumentTypeFromString(documentParseInfo.documentId.getDocType(), typeManager), documentParseInfo);
    operation.setCondition(TestAndSetCondition.fromConditionString(documentParseInfo.condition));
    return operation;
}
Also used : DocumentParser(com.yahoo.document.json.document.DocumentParser) DocumentOperation(com.yahoo.document.DocumentOperation) DocumentId(com.yahoo.document.DocumentId) IOException(java.io.IOException) DocumentParseInfo(com.yahoo.document.json.readers.DocumentParseInfo) VespaJsonDocumentReader(com.yahoo.document.json.readers.VespaJsonDocumentReader)

Aggregations

DocumentId (com.yahoo.document.DocumentId)1 DocumentOperation (com.yahoo.document.DocumentOperation)1 DocumentParser (com.yahoo.document.json.document.DocumentParser)1 DocumentParseInfo (com.yahoo.document.json.readers.DocumentParseInfo)1 VespaJsonDocumentReader (com.yahoo.document.json.readers.VespaJsonDocumentReader)1 IOException (java.io.IOException)1