eolivelli commented on a change in pull request #9448:
URL: https://github.com/apache/pulsar/pull/9448#discussion_r585640943



##########
File path: 
pulsar-io/kafka/src/main/java/org/apache/pulsar/io/kafka/KafkaAbstractSource.java
##########
@@ -151,18 +153,32 @@ public void start() {
         runnerThread.start();
     }
 
-    public abstract V extractValue(ConsumerRecord<String, byte[]> record);
+    public Object extractValue(ConsumerRecord<Object, Object> consumerRecord) {
+        return consumerRecord.value();
+    }
 
+    public Optional<String> extractKey(ConsumerRecord<Object, Object> 
consumerRecord) {
+        // we are currently supporting only String keys
+        return Optional.ofNullable((String) consumerRecord.key());

Review comment:
       This is only a transient situation.
   Because we want to prepare the way to deal with non String keys.
   IIRC is was a @sijie's request to introduce this 'extractKey' method in 
order to make it clear the direction we are taking 

##########
File path: 
pulsar-io/kafka/src/main/java/org/apache/pulsar/io/kafka/KafkaAbstractSource.java
##########
@@ -151,18 +153,32 @@ public void start() {
         runnerThread.start();
     }
 
-    public abstract V extractValue(ConsumerRecord<String, byte[]> record);
+    public Object extractValue(ConsumerRecord<Object, Object> consumerRecord) {
+        return consumerRecord.value();
+    }
 
+    public Optional<String> extractKey(ConsumerRecord<Object, Object> 
consumerRecord) {
+        // we are currently supporting only String keys
+        return Optional.ofNullable((String) consumerRecord.key());
+    }
+
+    public abstract Schema<V> extractSchema(ConsumerRecord<Object, Object> 
consumerRecord);
+
+    @Slf4j
     static private class KafkaRecord<V> implements Record<V> {

Review comment:
       (see previous answer)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to