srkukarni commented on a change in pull request #2397: Integrate Functions with 
Schema
URL: https://github.com/apache/incubator-pulsar/pull/2397#discussion_r211389789
 
 

 ##########
 File path: 
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
 ##########
 @@ -621,12 +617,49 @@ protected FunctionDetails convert(FunctionConfig 
functionConfig)
 
             // Setup source
             SourceSpec.Builder sourceSpecBuilder = SourceSpec.newBuilder();
-            Map<String, String> topicToSerDeClassNameMap = new HashMap<>();
-            
topicToSerDeClassNameMap.putAll(functionConfig.getCustomSerdeInputs());
-            functionConfig.getInputs().forEach(v -> 
topicToSerDeClassNameMap.put(v, ""));
-            
sourceSpecBuilder.putAllTopicsToSerDeClassName(topicToSerDeClassNameMap);
-            if (StringUtils.isNotBlank(functionConfig.getTopicsPattern())) {
-                
sourceSpecBuilder.setTopicsPattern(functionConfig.getTopicsPattern());
+            if (functionConfig.getInputs() != null) {
+                functionConfig.getInputs().forEach((topicName -> {
+                    sourceSpecBuilder.putInputSpecs(topicName,
+                            ConsumerSpec.newBuilder()
+                                    .setIsRegexPattern(false)
+                                    .build());
+                }));
+            }
+            if (functionConfig.getTopicsPattern() != null && 
!functionConfig.getTopicsPattern().isEmpty()) {
+                
sourceSpecBuilder.putInputSpecs(functionConfig.getTopicsPattern(),
+                        ConsumerSpec.newBuilder()
+                                .setIsRegexPattern(true)
+                                .build());
+            }
+            if (functionConfig.getCustomSerdeInputs() != null) {
+                functionConfig.getCustomSerdeInputs().forEach((topicName, 
serdeClassName) -> {
+                    sourceSpecBuilder.putInputSpecs(topicName,
+                            ConsumerSpec.newBuilder()
+                                    .setSerdeClassName(serdeClassName)
+                                    .setIsRegexPattern(false)
+                                    .build());
+                });
+            }
+            if (functionConfig.getCustomSchemaInputs() != null) {
+                functionConfig.getCustomSchemaInputs().forEach((topicName, 
schemaType) -> {
+                    sourceSpecBuilder.putInputSpecs(topicName,
+                            ConsumerSpec.newBuilder()
+                                    .setSchemaType(schemaType)
+                                    .setIsRegexPattern(false)
+                                    .build());
+                });
+            }
+            if (functionConfig.getInputSpecs() != null) {
+                functionConfig.getInputSpecs().forEach((topicName, 
consumerConf) -> {
+                    ConsumerSpec.Builder bldr = ConsumerSpec.newBuilder()
+                            .setIsRegexPattern(consumerConf.isRegexPattern());
+                    if (consumerConf.getSchemaType() != null && 
!consumerConf.getSchemaType().isEmpty()) {
+                        bldr.setSchemaType(consumerConf.getSchemaType());
+                    } else if (consumerConf.getSerdeClassName() != null && 
!consumerConf.getSerdeClassName().isEmpty()) {
 
 Review comment:
   fixed

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to