<commit_before>package io.teknek.kafka;

import java.util.Map;
import java.util.Properties;

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

import io.teknek.model.ITuple;
import io.teknek.model.Operator;

public class KafkaOutputOperator extends Operator {

  public static final String TOPIC = "kafka.output.topic";
  public static final String ZOOKEEPER_CONNECT = "kafka.output.zookeeper.connect";
  public static final String METADATA_BROKER_LIST = "kafka.output.metadata.broker.list";
  public static final String KEY_FIELD = "kafka.output.key.field";
  public static final String MESSAGE_FIELD = "kafka.output.message.field";
  
  Producer<byte [], byte[]> producer = null;
  
  @Override
  public void setProperties(Map<String, Object> properties) {
    super.setProperties(properties);
    Properties producerProps = new Properties();
    //producerProps.put("serializer.class", "kafka.serializer.StringEncoder");
    producerProps.put("zookeeper.connect", (String) properties.get(ZOOKEEPER_CONNECT));
    producerProps.setProperty("batch.size", "1");
    producerProps.setProperty("producer.type", "async");
    producerProps.put("metadata.broker.list", (String) properties.get(METADATA_BROKER_LIST));
    ProducerConfig producerConfig = new ProducerConfig(producerProps);
    producer = new Producer<byte[], byte []>(producerConfig);
  }

  @Override
  public void handleTuple(ITuple t) {
    producer.send(new KeyedMessage<byte[], byte[]>((String) properties.get(TOPIC),
            (byte[])t.getField(KEY_FIELD),
            (byte[]) t.getField(MESSAGE_FIELD)));   
  }

}
<commit_msg>little cleanup<commit_after>package io.teknek.kafka;

import java.util.Map;
import java.util.Properties;

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

import io.teknek.model.ITuple;
import io.teknek.model.Operator;

public class KafkaOutputOperator extends Operator {

  public static final String TOPIC = "kafka.output.topic";
  public static final String ZOOKEEPER_CONNECT = "kafka.output.zookeeper.connect";
  public static final String METADATA_BROKER_LIST = "kafka.output.metadata.broker.list";
  public static final String KEY_FIELD = "kafka.output.key.field";
  public static final String MESSAGE_FIELD = "kafka.output.message.field";
  
  Producer<byte [], byte[]> producer = null;
  
  @Override
  public void setProperties(Map<String, Object> properties) {
    super.setProperties(properties);
    Properties producerProps = new Properties();
    producerProps.put("zookeeper.connect", (String) properties.get(ZOOKEEPER_CONNECT));
    producerProps.setProperty("batch.size", "1");
    producerProps.setProperty("producer.type", "async");
    producerProps.put("metadata.broker.list", (String) properties.get(METADATA_BROKER_LIST));
    ProducerConfig producerConfig = new ProducerConfig(producerProps);
    producer = new Producer<byte[], byte []>(producerConfig);
  }

  @Override
  public void handleTuple(ITuple t) {
    producer.send(new KeyedMessage<byte[], byte[]>((String) properties.get(TOPIC),
            (byte[]) t.getField(KEY_FIELD),
            (byte[]) t.getField(MESSAGE_FIELD)));   
  }

}

{'fraction_non_alphanumeric': 0.12303906490310673, 'fraction_numerical': 0.0006151953245155337, 'mean_word_length': 5.011090573012939, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7059780', 'n_tokens_mistral': 1009, 'n_tokens_neox': 1007, 'n_words': 198}