use of org.neo4j.unsafe.impl.batchimport.input.UnexpectedEndOfInputException in project neo4j by neo4j.
the class InputEntityDeserializer method deserializeNextFromSource.
private boolean deserializeNextFromSource() throws IOException {
Header.Entry[] entries = header.entries();
if (entries.length == 0) {
return false;
}
int fieldIndex = 0;
try {
for (; fieldIndex < entries.length; fieldIndex++) {
// Seek the next value
if (!data.seek(mark, delimiter)) {
if (fieldIndex > 0) {
throw new UnexpectedEndOfInputException("Near " + mark);
}
// We're just at the end
return false;
}
// Extract it, type according to our header
Header.Entry entry = entries[fieldIndex];
if (entry.type() != Type.IGNORE) {
Object value = data.tryExtract(mark, entry.extractor()) ? entry.extractor().value() : null;
deserialization.handle(entry, value);
}
if (mark.isEndOfLine()) {
// We're at the end of the line, break and return an entity with what we have.
break;
}
}
return true;
} catch (final RuntimeException e) {
String stringValue = null;
try {
Extractors extractors = new Extractors('?');
if (data.tryExtract(mark, extractors.string())) {
stringValue = extractors.string().value();
}
} catch (Exception e1) {
// OK
}
String message = format("ERROR in input" + "%n data source: %s" + "%n in field: %s" + "%n for header: %s" + "%n raw field value: %s" + "%n original error: %s", data, entries[fieldIndex] + ":" + (fieldIndex + 1), header, stringValue != null ? stringValue : "??", e.getMessage());
if (e instanceof InputException) {
throw Exceptions.withMessage(e, message);
}
throw new InputException(message, e);
}
}
Aggregations