protected void initialize(MongoDBSession session) {
if (dataFileName != null) {
SchemaImpl schema = new SchemaImpl(collection, null);
schema.addField(sourceField, StringType.INSTANCE, null, 0, Collections.emptySet());
schema.addField(targetField, StringType.INSTANCE, null, 0, Collections.emptySet());
Consumer<Map<String, Object>> loader = map -> {
Document doc = MongoDBSerializationHelper.fieldMapToBson(map);
MongoCollection<Document> coll = getCollection(session);
if (coll.countDocuments(doc) == 0) {
coll.insertOne(doc);
}
};
DirectoryCSVLoader.loadData(dataFileName, BaseDirectoryDescriptor.DEFAULT_DATA_FILE_CHARACTER_SEPARATOR,
schema, loader);
}
}