use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project vespa by vespa-engine.
the class DocumentParser method handleIdentLevelTwo.
private void handleIdentLevelTwo(DocumentParseInfo documentParseInfo) {
try {
JsonToken currentToken = parser.getCurrentToken();
// "fields" opens a dictionary and is therefore on level two which might be surprising.
if (currentToken == JsonToken.START_OBJECT && FIELDS.equals(parser.getCurrentName())) {
documentParseInfo.fieldsBuffer.bufferObject(currentToken, parser);
processIndent();
}
} catch (IOException e) {
throw new RuntimeException("Got IO exception while parsing document", e);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project vespa by vespa-engine.
the class DocumentParser method handleIdentLevelOne.
private void handleIdentLevelOne(DocumentParseInfo documentParseInfo, boolean docIdAndOperationIsSetExternally) throws IOException {
JsonToken currentToken = parser.getCurrentToken();
if (currentToken == JsonToken.VALUE_TRUE || currentToken == JsonToken.VALUE_FALSE) {
try {
if (CREATE_IF_NON_EXISTENT.equals(parser.getCurrentName())) {
documentParseInfo.create = Optional.ofNullable(parser.getBooleanValue());
return;
}
} catch (IOException e) {
throw new RuntimeException("Got IO exception while parsing document", e);
}
}
if ((currentToken == JsonToken.VALUE_TRUE || currentToken == JsonToken.VALUE_FALSE) && CREATE_IF_NON_EXISTENT.equals(parser.getCurrentName())) {
documentParseInfo.create = Optional.of(currentToken == JsonToken.VALUE_TRUE);
} else if (currentToken == JsonToken.VALUE_STRING && CONDITION.equals(parser.getCurrentName())) {
documentParseInfo.condition = Optional.of(parser.getText());
} else if (currentToken == JsonToken.VALUE_STRING) {
// as well.
if (!docIdAndOperationIsSetExternally) {
documentParseInfo.operationType = operationNameToOperationType(parser.getCurrentName());
documentParseInfo.documentId = new DocumentId(parser.getText());
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project vespa by vespa-engine.
the class TokenBuffer method next.
public JsonToken next() {
buffer.removeFirst();
Token t = buffer.peekFirst();
if (t == null) {
return null;
}
updateNesting(t.token);
return t.token;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project vespa by vespa-engine.
the class MapReader method fillMapFromArray.
@SuppressWarnings({ "rawtypes", "cast", "unchecked" })
public static void fillMapFromArray(TokenBuffer buffer, MapFieldValue parent) {
JsonToken token = buffer.currentToken();
int initNesting = buffer.nesting();
expectArrayStart(token);
token = buffer.next();
DataType keyType = parent.getDataType().getKeyType();
DataType valueType = parent.getDataType().getValueType();
while (buffer.nesting() >= initNesting) {
FieldValue key = null;
FieldValue value = null;
expectObjectStart(token);
token = buffer.next();
for (int i = 0; i < 2; ++i) {
if (MAP_KEY.equals(buffer.currentName())) {
key = readSingleValue(buffer, keyType);
} else if (MAP_VALUE.equals(buffer.currentName())) {
value = readSingleValue(buffer, valueType);
}
token = buffer.next();
}
Preconditions.checkState(key != null && value != null, "Missing key or value for map entry.");
parent.put(key, value);
expectObjectEnd(token);
// array end or next entry
token = buffer.next();
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project vespa by vespa-engine.
the class MapReader method fillMapFromObject.
@SuppressWarnings({ "rawtypes", "cast", "unchecked" })
public static void fillMapFromObject(TokenBuffer buffer, MapFieldValue parent) {
JsonToken token = buffer.currentToken();
int initNesting = buffer.nesting();
expectObjectStart(token);
token = buffer.next();
DataType keyType = parent.getDataType().getKeyType();
DataType valueType = parent.getDataType().getValueType();
while (buffer.nesting() >= initNesting) {
FieldValue key = readAtomic(buffer.currentName(), keyType);
FieldValue value = readSingleValue(buffer, valueType);
Preconditions.checkState(key != null && value != null, "Missing key or value for map entry.");
parent.put(key, value);
token = buffer.next();
}
expectObjectEnd(token);
}
Aggregations