Skip to content

Commit

Permalink
Move CsvMapper and Schema creation to constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
dinujoh committed Sep 11, 2024
1 parent 400713b commit ed4cea8
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class CsvProcessor extends AbstractProcessor<Record<Event>, Record<Event>

private final ExpressionEvaluator expressionEvaluator;

private final CsvMapper mapper;
private final CsvSchema schema;

@DataPrepperPluginConstructor
public CsvProcessor(final PluginMetrics pluginMetrics,
final CsvProcessorConfig config,
Expand All @@ -61,13 +64,12 @@ public CsvProcessor(final PluginMetrics pluginMetrics,
String.format("csv_when value of %s is not a valid expression statement. " +
"See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax.", config.getCsvWhen()));
}
this.mapper = createCsvMapper();
this.schema = createCsvSchema();
}

@Override
public Collection<Record<Event>> doExecute(final Collection<Record<Event>> records) {
final CsvMapper mapper = createCsvMapper();
final CsvSchema schema = createCsvSchema();

for (final Record<Event> record : records) {

final Event event = record.getData();
Expand Down

0 comments on commit ed4cea8

Please sign in to comment.