Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move CsvMapper and Schema creation to constructor #4941

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading