<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.flink.table.examples.java.connectors;

import org.apache.flink.api.common.serialization.DeserializationSchema;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.table.connector.ChangelogMode;
import org.apache.flink.table.connector.format.DecodingFormat;
import org.apache.flink.table.connector.source.DynamicTableSource;
import org.apache.flink.table.connector.source.DynamicTableSource.DataStructureConverter;
import org.apache.flink.table.data.RowData;
import org.apache.flink.table.types.DataType;
import org.apache.flink.table.types.logical.LogicalType;
import org.apache.flink.types.RowKind;

import java.util.List;

/**
 * The {@link ChangelogCsvFormat} is a decoding format that uses a {@link DeserializationSchema} during
 * runtime. It supports emitting {@code INSERT} and {@code DELETE} changes.
 */
public final class ChangelogCsvFormat implements DecodingFormat<DeserializationSchema<RowData>> {

	private final String columnDelimiter;

	public ChangelogCsvFormat(String columnDelimiter) {
		this.columnDelimiter = columnDelimiter;
	}

	@Override
	@SuppressWarnings("unchecked")
	public DeserializationSchema<RowData> createRuntimeDecoder(DynamicTableSource.Context context, DataType producedDataType) {
		// create type information for the DeserializationSchema
		final TypeInformation<RowData> producedTypeInfo = (TypeInformation<RowData>) context.createTypeInformation(producedDataType);

		// most of the code in DeserializationSchema will not work on internal data structures
    	// create a converter for conversion at the end
		final DataStructureConverter converter = context.createDataStructureConverter(producedDataType);

		// use logical types during runtime for parsing
		final List<LogicalType> parsingTypes = producedDataType.getLogicalType().getChildren();

		// create runtime class
		return new ChangelogCsvDeserializer(parsingTypes, converter, producedTypeInfo, columnDelimiter);
	}

	@Override
	public ChangelogMode getChangelogMode() {
		// define that this format can produce INSERT and DELETE rows
		return ChangelogMode.newBuilder()
			.addContainedKind(RowKind.INSERT)
			.addContainedKind(RowKind.DELETE)
			.build();
	}<commit_msg>[hotfix][examples-table] Fix indention in ChangelogCsvFormat<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.flink.table.examples.java.connectors;

import org.apache.flink.api.common.serialization.DeserializationSchema;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.table.connector.ChangelogMode;
import org.apache.flink.table.connector.format.DecodingFormat;
import org.apache.flink.table.connector.source.DynamicTableSource;
import org.apache.flink.table.connector.source.DynamicTableSource.DataStructureConverter;
import org.apache.flink.table.data.RowData;
import org.apache.flink.table.types.DataType;
import org.apache.flink.table.types.logical.LogicalType;
import org.apache.flink.types.RowKind;

import java.util.List;

/**
 * The {@link ChangelogCsvFormat} is a decoding format that uses a {@link DeserializationSchema} during
 * runtime. It supports emitting {@code INSERT} and {@code DELETE} changes.
 */
public final class ChangelogCsvFormat implements DecodingFormat<DeserializationSchema<RowData>> {

	private final String columnDelimiter;

	public ChangelogCsvFormat(String columnDelimiter) {
		this.columnDelimiter = columnDelimiter;
	}

	@Override
	@SuppressWarnings("unchecked")
	public DeserializationSchema<RowData> createRuntimeDecoder(DynamicTableSource.Context context, DataType producedDataType) {
		// create type information for the DeserializationSchema
		final TypeInformation<RowData> producedTypeInfo = (TypeInformation<RowData>) context.createTypeInformation(producedDataType);

		// most of the code in DeserializationSchema will not work on internal data structures
		// create a converter for conversion at the end
		final DataStructureConverter converter = context.createDataStructureConverter(producedDataType);

		// use logical types during runtime for parsing
		final List<LogicalType> parsingTypes = producedDataType.getLogicalType().getChildren();

		// create runtime class
		return new ChangelogCsvDeserializer(parsingTypes, converter, producedTypeInfo, columnDelimiter);
	}

	@Override
	public ChangelogMode getChangelogMode() {
		// define that this format can produce INSERT and DELETE rows
		return ChangelogMode.newBuilder()
			.addContainedKind(RowKind.INSERT)
			.addContainedKind(RowKind.DELETE)
			.build();
	}
{'fraction_non_alphanumeric': 0.07833876221498372, 'fraction_numerical': 0.0013029315960912053, 'mean_word_length': 5.311408016443988, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '540461', 'n_tokens_mistral': 1685, 'n_tokens_neox': 1630, 'n_words': 520}