[ https://issues.apache.org/jira/browse/STORM-1914?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15341567#comment-15341567 ]
ASF GitHub Bot commented on STORM-1914: --------------------------------------- Github user abhishekagarwal87 commented on a diff in the pull request: https://github.com/apache/storm/pull/1501#discussion_r67848494 --- Diff: external/storm-kafka/src/jvm/org/apache/storm/kafka/bolt/selector/FieldIndexTopicSelector.java --- @@ -0,0 +1,52 @@ +/** + * 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.storm.kafka.bolt.selector; + +import org.apache.storm.tuple.Tuple; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Using field index select topic name from tuple . + * When the field index out of limit ,message will write to default topic. + */ +public class FieldIndexTopicSelector implements KafkaTopicSelector { + private static final Logger LOG = LoggerFactory.getLogger(FieldNameTopicSelector.class); + + private final int fieldIndex; + private final String defaultTopicName; + + public FieldIndexTopicSelector(int fieldIndex, String defaultTopicName) { + this.fieldIndex = fieldIndex; + this.defaultTopicName = defaultTopicName; + } + + public FieldIndexTopicSelector(int fieldIndex) { + this(fieldIndex, "default"); + } + + @Override + public String getTopic(Tuple tuple) { + if (tuple.size() - 1 >= fieldIndex) { + return tuple.getString(fieldIndex); + } else { + LOG.warn("Field Index " + fieldIndex + " Out of bound . Use default topic " + defaultTopicName); --- End diff -- "Use default topic" --> "Using default topic" > Storm Kafka Field Topic Selector > -------------------------------- > > Key: STORM-1914 > URL: https://issues.apache.org/jira/browse/STORM-1914 > Project: Apache Storm > Issue Type: New Feature > Components: storm-kafka > Affects Versions: 1.0.0, 1.0.1, 1.0.2 > Reporter: darion yaphet > Assignee: darion yaphet > > Support field name and field index to select which kafka topic will used as a > downstream . -- This message was sent by Atlassian JIRA (v6.3.4#6332)