use of com.marklogic.client.io.marker.AbstractWriteHandle in project components by Talend.
the class MarkLogicWriter method write.
@Override
public void write(Object indexedRecordDatum) throws IOException {
if (indexedRecordDatum == null || !(indexedRecordDatum instanceof IndexedRecord)) {
return;
}
cleanWrites();
IndexedRecord indexedRecord = (IndexedRecord) indexedRecordDatum;
String docId = (String) indexedRecord.get(0);
Object docContent = indexedRecord.get(1);
try {
switch(properties.action.getValue()) {
case DELETE:
deleteRecord(docId);
break;
case PATCH:
patchRecord(docId, (String) docContent);
break;
case UPSERT:
AbstractWriteHandle genericHandle = prepareWriteHandle(docContent);
if (autoGenerateId) {
docId = generateDocId(genericHandle);
indexedRecord.put(0, docId);
}
upsertRecord(docId, genericHandle);
break;
}
handleSuccessRecord(indexedRecord);
} catch (Exception e) {
handleRejectRecord(indexedRecord, e);
}
result.totalCount++;
}
Aggregations