use of com.yahoo.document.json.JsonReaderException in project vespa by vespa-engine.
the class StructReader method fillStruct.
public static void fillStruct(TokenBuffer buffer, StructuredFieldValue parent) {
// do note the order of initializing initNesting and token is relevant for empty docs
int initNesting = buffer.nesting();
buffer.next();
while (buffer.nesting() >= initNesting) {
Field f = getField(buffer, parent);
try {
FieldValue v = readSingleValue(buffer, f.getDataType());
parent.setFieldValue(f, v);
buffer.next();
} catch (IllegalArgumentException e) {
throw new JsonReaderException(f, e);
}
}
}
use of com.yahoo.document.json.JsonReaderException in project vespa by vespa-engine.
the class VespaJsonDocumentReader method createDocumentOperation.
public DocumentOperation createDocumentOperation(DocumentType documentType, DocumentParseInfo documentParseInfo) {
final DocumentOperation documentOperation;
try {
switch(documentParseInfo.operationType) {
case PUT:
documentOperation = new DocumentPut(new Document(documentType, documentParseInfo.documentId));
readPut(documentParseInfo.fieldsBuffer, (DocumentPut) documentOperation);
verifyEndState(documentParseInfo.fieldsBuffer, JsonToken.END_OBJECT);
break;
case REMOVE:
documentOperation = new DocumentRemove(documentParseInfo.documentId);
break;
case UPDATE:
documentOperation = new DocumentUpdate(documentType, documentParseInfo.documentId);
readUpdate(documentParseInfo.fieldsBuffer, (DocumentUpdate) documentOperation);
verifyEndState(documentParseInfo.fieldsBuffer, JsonToken.END_OBJECT);
break;
default:
throw new IllegalStateException("Implementation out of sync with itself. This is a bug.");
}
} catch (JsonReaderException e) {
throw JsonReaderException.addDocId(e, documentParseInfo.documentId);
}
if (documentParseInfo.create.isPresent()) {
if (!(documentOperation instanceof DocumentUpdate)) {
throw new RuntimeException("Could not set create flag on non update operation.");
}
DocumentUpdate update = (DocumentUpdate) documentOperation;
update.setCreateIfNonExistent(documentParseInfo.create.get());
}
return documentOperation;
}
Aggregations