Search in sources :

Example 1 with AbstractRowProcessor

use of com.univocity.parsers.common.processor.AbstractRowProcessor in project mapping-benchmark by arnaudroger.

the class UnivocityCsvParserBenchmark method parseCsv.

@Benchmark
public void parseCsv(Blackhole blackhole, CsvParam csvParam) throws IOException {
    CsvParserSettings settings = new CsvParserSettings();
    // turning off features enabled by default
    settings.setIgnoreLeadingWhitespaces(false);
    settings.setIgnoreTrailingWhitespaces(false);
    settings.setSkipEmptyLines(false);
    settings.setColumnReorderingEnabled(false);
    settings.setReadInputOnSeparateThread(false);
    settings.setRowProcessor(new AbstractRowProcessor() {

        @Override
        public void rowProcessed(String[] row, ParsingContext context) {
            blackhole.consume(row);
        }
    });
    com.univocity.parsers.csv.CsvParser parser = new com.univocity.parsers.csv.CsvParser(settings);
    try (Reader reader = csvParam.getReader()) {
        parser.parse(reader);
    }
}
Also used : ParsingContext(com.univocity.parsers.common.ParsingContext) AbstractRowProcessor(com.univocity.parsers.common.processor.AbstractRowProcessor) Reader(java.io.Reader) CsvParserSettings(com.univocity.parsers.csv.CsvParserSettings) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 2 with AbstractRowProcessor

use of com.univocity.parsers.common.processor.AbstractRowProcessor in project mapping-benchmark by arnaudroger.

the class UnivocityConcurrentCsvParserBenchmark method parseCsv.

@Benchmark
public void parseCsv(Blackhole blackhole) throws IOException {
    CsvParserSettings settings = new CsvParserSettings();
    // turning off features enabled by default
    settings.setIgnoreLeadingWhitespaces(false);
    settings.setIgnoreTrailingWhitespaces(false);
    settings.setSkipEmptyLines(false);
    settings.setColumnReorderingEnabled(false);
    settings.setReadInputOnSeparateThread(true);
    settings.setRowProcessor(new AbstractRowProcessor() {

        @Override
        public void rowProcessed(String[] row, ParsingContext context) {
            blackhole.consume(row);
        }
    });
    com.univocity.parsers.csv.CsvParser parser = new com.univocity.parsers.csv.CsvParser(settings);
    try (Reader reader = CsvParam.getSingleThreadedReader(quotes, nbRows)) {
        parser.parse(reader);
    }
}
Also used : ParsingContext(com.univocity.parsers.common.ParsingContext) AbstractRowProcessor(com.univocity.parsers.common.processor.AbstractRowProcessor) Reader(java.io.Reader) CsvParserSettings(com.univocity.parsers.csv.CsvParserSettings) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Aggregations

ParsingContext (com.univocity.parsers.common.ParsingContext)2 AbstractRowProcessor (com.univocity.parsers.common.processor.AbstractRowProcessor)2 CsvParserSettings (com.univocity.parsers.csv.CsvParserSettings)2 Reader (java.io.Reader)2 Benchmark (org.openjdk.jmh.annotations.Benchmark)2