1+ /*
2+ * Copyright 2018 The Feast Authors
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ *
16+ */
17+
118package feast .ingestion .transform ;
219
320import com .google .common .base .Preconditions ;
1532import org .apache .beam .sdk .values .PCollection ;
1633import org .apache .beam .sdk .values .PInput ;
1734
35+ import java .util .ArrayList ;
36+ import java .util .Arrays ;
37+ import java .util .List ;
38+
1839import static com .google .common .base .Preconditions .checkArgument ;
1940
2041public class FeatureRowKafkaIO {
2142
2243 static final String KAFKA_TYPE = "kafka" ;
2344
45+
46+ /**
47+ * Transform for reading {@link feast.types.FeatureRowProto.FeatureRow FeatureRow}
48+ * proto messages from kafka one or more kafka topics.
49+ *
50+ */
2451 public static Read read (ImportSpec importSpec ) {
2552 return new Read (importSpec );
2653 }
@@ -43,14 +70,16 @@ public PCollection<FeatureRow> expand(PInput input) {
4370 Preconditions .checkArgument (
4471 !Strings .isNullOrEmpty (bootstrapServer ), "kafka bootstrap server must be set" );
4572
46- String topic = importSpec .getOptionsMap ().get ("topic " );
73+ String topics = importSpec .getOptionsMap ().get ("topics " );
4774
4875 Preconditions .checkArgument (
49- !Strings .isNullOrEmpty (topic ), "kafka topic must be set" );
76+ !Strings .isNullOrEmpty (topics ), "kafka topic(s) must be set" );
77+
78+ List <String > topicsList = new ArrayList <>(Arrays .asList (topics .split ("," )));
5079
5180 KafkaIO .Read <FeatureRowKey , FeatureRow > kafkaIOReader = KafkaIO .<FeatureRowKey , FeatureRow >read ()
5281 .withBootstrapServers (bootstrapServer )
53- .withTopic ( topic )
82+ .withTopics ( topicsList )
5483 .withKeyDeserializer (FeatureRowKeyDeserializer .class )
5584 .withValueDeserializer (FeatureRowDeserializer .class );
5685
0 commit comments