Sha256: 64d2cf1d321f61059552ec2d7feefabd03bcabbe995d23b0df838b6134de5892
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
package org.embulk.output.kafka; import org.embulk.spi.Column; import org.embulk.spi.ColumnVisitor; import org.embulk.spi.PageReader; public abstract class KafkaOutputColumnVisitor implements ColumnVisitor { KafkaOutputPlugin.PluginTask task; PageReader pageReader; public Object recordKey = null; public String topicName = null; public KafkaOutputColumnVisitor(KafkaOutputPlugin.PluginTask task, PageReader pageReader) { this.task = task; this.pageReader = pageReader; } void setRecordKey(Column column, Object value) { if (task.getKeyColumnName().isPresent() && task.getKeyColumnName().get().equals(column.getName())) { recordKey = value; } } void setTopicName(Column column, String value) { if (task.getTopicColumn().isPresent() && task.getTopicColumn().get().equals(column.getName())) { topicName = value; } } boolean isIgnoreColumn(Column column) { return task.getIgnoreColumns().stream().anyMatch(name -> name.equals(column.getName())); } @Override public void longColumn(Column column) { if (!pageReader.isNull(column)) { setRecordKey(column, pageReader.getLong(column)); } } @Override public void doubleColumn(Column column) { if (!pageReader.isNull(column)) { setRecordKey(column, pageReader.getDouble(column)); } } @Override public void stringColumn(Column column) { if (!pageReader.isNull(column)) { setRecordKey(column, pageReader.getString(column)); setTopicName(column, pageReader.getString(column)); } } }
Version data entries
2 entries across 2 versions & 1 rubygems