[
https://issues.apache.org/jira/browse/BEAM-3925?focusedWorklogId=95652&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-95652
]
ASF GitHub Bot logged work on BEAM-3925:
----------------------------------------
Author: ASF GitHub Bot
Created on: 26/Apr/18 17:24
Start Date: 26/Apr/18 17:24
Worklog Time Spent: 10m
Work Description: pupamanyu commented on a change in pull request #5141:
[BEAM-3925] Allow ValueProvider for KafkaIO so that we can create Beam
Templates using KafkaIO
URL: https://github.com/apache/beam/pull/5141#discussion_r184469522
##########
File path:
sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaIO.java
##########
@@ -336,22 +347,38 @@
* of how the partitions are distributed among the splits.
*/
public Read<K, V> withTopic(String topic) {
- return withTopics(ImmutableList.of(topic));
+ return
withTopics(commaSeparatedStrings(ValueProvider.StaticValueProvider.of(topic)));
+ }
+
+ /**
+ * Like above but with a {@link ValueProvider ValueProvider<String>}.
+ */
+ public Read<K, V> withTopic(ValueProvider<String> topic) {
+ return withTopics(commaSeparatedStrings(topic));
}
/**
- * Sets a list of topics to read from. All the partitions from each
- * of the topics are read.
+ * Sets a list of topics to read from with a {@link List
List<String>}.
+ * All the partitions from each of the topics are read.
*
* <p>See {@link KafkaUnboundedSource#split(int, PipelineOptions)} for
description
* of how the partitions are distributed among the splits.
*/
public Read<K, V> withTopics(List<String> topics) {
- checkState(
- getTopicPartitions().isEmpty(), "Only topics or topicPartitions can
be set, not both");
- return toBuilder().setTopics(ImmutableList.copyOf(topics)).build();
+ return withTopics(ValueProvider.StaticValueProvider.of(topics));
}
+ /**
+ * Like above but with a {@link ValueProvider
ValueProvider<List<String>>}.
+ *
+ */
+ public Read<K, V> withTopics(ValueProvider<List<String>> topics) {
+ checkArgument(
+ getTopicPartitions().isAccessible(),
Review comment:
I am new to Guava, I wanted to check if getTopicPartitions() is not provided
because Topics and TopicPartitions are mutually exclusive options. I need to do
this validation at graph time if possible. Can you please guide me?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 95652)
Time Spent: 4h 50m (was: 4h 40m)
> Allow ValueProvider for KafkaIO
> -------------------------------
>
> Key: BEAM-3925
> URL: https://issues.apache.org/jira/browse/BEAM-3925
> Project: Beam
> Issue Type: Improvement
> Components: sdk-java-core
> Reporter: Sameer Abhyankar
> Assignee: Pramod Upamanyu
> Priority: Major
> Time Spent: 4h 50m
> Remaining Estimate: 0h
>
> Add ValueProvider support for the various methods in KafkaIO. This would
> allow us to use KafkaIO in reusable pipeline templates.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)