<commit_before>package kr.jm.utils.kafka;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import kafka.javaapi.producer.Producer;
import kafka.producer.KeyedMessage;
import kafka.producer.ProducerConfig;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class KafkaProducer {
	private Producer<String, String> producer;
	private String topic;
	private ObjectMapper jsonMapper = new ObjectMapper();

	public KafkaProducer(Properties kafkaProducerProperties, String topic) {
		this.topic = topic;
		this.producer = new Producer<String, String>(new ProducerConfig(
				kafkaProducerProperties));
	}

	public void sendJsonStringFromObject(String key, Object object)
			throws Exception {
		producer.send(buildKeyedMessage(key, object));
	}

	private KeyedMessage<String, String> buildKeyedMessage(String key,
			Object object) throws JsonProcessingException {
		return new KeyedMessage<String, String>(topic, key,
				jsonMapper.writeValueAsString(object));
	}

	public void sendJsonStringFromObject(Object object) throws Exception {
		producer.send(buildKeyedMessage(object));
	}

	private KeyedMessage<String, String> buildKeyedMessage(Object object)
			throws JsonProcessingException {
		return new KeyedMessage<String, String>(topic,
				jsonMapper.writeValueAsString(object));
	}

	public void sendJsonStringFromObject(String key, List<Object> objectList)
			throws Exception {
		List<KeyedMessage<String, String>> keyedMessageList = new ArrayList<KeyedMessage<String, String>>();
		for (Object object : objectList)
			keyedMessageList.add(buildKeyedMessage(key, object));
		producer.send(keyedMessageList);
	}

	public void sendJsonStringFromObject(List<Object> objectList)
			throws Exception {
		List<KeyedMessage<String, String>> keyedMessageList = new ArrayList<KeyedMessage<String, String>>();
		for (Object object : objectList)
			keyedMessageList.add(buildKeyedMessage(object));
		producer.send(keyedMessageList);
	}

	public void close() {
		producer.close();		
	}

}
<commit_msg>refactoring<commit_after>package kr.jm.utils.kafka;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import kafka.javaapi.producer.Producer;
import kafka.producer.KeyedMessage;
import kafka.producer.ProducerConfig;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class KafkaProducer {
	private Producer<String, String> producer;
	private String topic;
	private ObjectMapper jsonMapper = new ObjectMapper();

	public KafkaProducer(Properties kafkaProducerProperties, String topic) {
		this.topic = topic;
		this.producer = new Producer<String, String>(new ProducerConfig(
				kafkaProducerProperties));
	}

	public void sendJsonStringFromObject(String key, Object object)
			throws Exception {
		producer.send(buildKeyedMessage(key, object));
	}

	private KeyedMessage<String, String> buildKeyedMessage(String key,
			Object object) throws JsonProcessingException {
		return new KeyedMessage<String, String>(topic, key,
				jsonMapper.writeValueAsString(object));
	}

	public void sendJsonStringFromObject(Object object) throws Exception {
		producer.send(buildKeyedMessage(object));
	}

	private KeyedMessage<String, String> buildKeyedMessage(Object object)
			throws JsonProcessingException {
		return new KeyedMessage<String, String>(topic,
				jsonMapper.writeValueAsString(object));
	}

	public void sendJsonStringFromObject(String key, List<Object> objectList)
			throws Exception {
		List<KeyedMessage<String, String>> keyedMessageList = new ArrayList<KeyedMessage<String, String>>();
		for (Object object : objectList)
			keyedMessageList.add(buildKeyedMessage(key, object));
		producer.send(keyedMessageList);
	}

	public void sendJsonStringFromObject(List<Object> objectList)
			throws Exception {
		List<KeyedMessage<String, String>> keyedMessageList = new ArrayList<KeyedMessage<String, String>>();
		for (Object object : objectList)
			keyedMessageList.add(buildKeyedMessage(object));
		producer.send(keyedMessageList);
	}

	public void close() {
		producer.close();
	}

}

{'fraction_non_alphanumeric': 0.09512428298279159, 'fraction_numerical': 0.0, 'mean_word_length': 6.329246935201401, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '3101890', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1213, 'n_words': 266}