class CsvLineProcessorBlock extends PipelineBlock<String, String[]> {
    /** Empty string array. */
    public static final String[] EMPTY_STR_ARRAY = new String[0];

    /** Field delimiter pattern. */
    private final char fldDelim;

    /** Quote character. */
    private final char quoteChars;

    /** Null string. */
    private final String nullString;

    /** Trim field string content. */
    private final boolean trim;

    /** Lines count. */
    private int line = 0;

    /** Symbol count. */
    private int symbol = 0;

    /**
     * Creates a CSV line parser.
     */
    public CsvLineProcessorBlock(BulkLoadCsvFormat format) {
        this.fldDelim = format.fieldSeparator().toString().charAt(0);
        this.quoteChars = format.quoteChars().charAt(0);
        this.nullString = format.nullString();
        this.trim = format.trim();
    }

    /**
     * {@inheritDoc}
     */
    @Override public void accept(String input, boolean isLastPortion) throws IgniteCheckedException {<FILL_FUNCTION_BODY>}

    /**
     *
     * @param fields row fields.
     * @param fieldVal field value.
     */
    private void addField(List<String> fields, StringBuilder fieldVal, boolean quoted) {
        final String val = trim ? fieldVal.toString().trim() : fieldVal.toString();

        fields.add(val.equals(nullString) ? null : val);
    }

    /**
     *
     */
    private enum ReaderState {
        /** */
        IDLE,

        /** */
        UNQUOTED,

        /** */
        QUOTED
    }
}

        List<String> fields = new ArrayList<>();

        StringBuilder curField = new StringBuilder(256);

        ReaderState state = ReaderState.IDLE;

        final int length = input.length();
        int copy = 0;
        int cur = 0;
        int prev = -1;
        int copyStart = 0;

        boolean quotesMatched = true;

        line++;
        symbol = 0;

        while (true) {
            if (cur == length) {
                if (!quotesMatched)
                    throw new IgniteCheckedException(new SQLException("Unmatched quote found at the end of line "
                        + line + ", symbol " + symbol));

                if (copy > 0)
                    curField.append(input, copyStart, copyStart + copy);

                addField(fields, curField, prev == quoteChars);

                break;
            }

            final char c = input.charAt(cur++);
            symbol++;

            if (state == ReaderState.QUOTED) {
                if (c == quoteChars) {
                    state = ReaderState.IDLE;
                    quotesMatched = !quotesMatched;

                    if (copy > 0) {
                        curField.append(input, copyStart, copyStart + copy);

                        copy = 0;
                    }

                    copyStart = cur;
                }
                else
                    copy++;
            }
            else {
                if (c == fldDelim) {
                    if (copy > 0) {
                        curField.append(input, copyStart, copyStart + copy);

                        copy = 0;
                    }

                    addField(fields, curField, prev == quoteChars);

                    curField = new StringBuilder();
                    copyStart = cur;

                    state = ReaderState.IDLE;
                }
                else if (c == quoteChars && state != ReaderState.UNQUOTED) {
                    state = ReaderState.QUOTED;

                    quotesMatched = !quotesMatched;

                    if (prev == quoteChars)
                        copy++;
                    else
                        copyStart = cur;
                }
                else {
                    if (c == quoteChars) {
                        if (state == ReaderState.UNQUOTED)
                            throw new IgniteCheckedException(
                                new SQLException("Unexpected quote in the field, line " + line
                                    + ", symbol " + symbol));

                        quotesMatched = !quotesMatched;
                    }

                    copy++;

                    if (state == ReaderState.IDLE)
                        state = ReaderState.UNQUOTED;
                }
            }

            prev = c;
        }

        nextBlock.accept(fields.toArray(EMPTY_STR_ARRAY), isLastPortion);
    
<methods>public abstract void accept(java.lang.String, boolean) throws org.apache.ignite.IgniteCheckedException,public PipelineBlock<java.lang.String[],N> append(PipelineBlock<java.lang.String[],N>) <variables>PipelineBlock<java.lang.String[],?> nextBlock