pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] srkukarni commented on a change in pull request #4028: Functions should make use of Schema Types that are available
Date Thu, 11 Apr 2019 22:46:03 GMT
srkukarni commented on a change in pull request #4028: Functions should make use of Schema
Types that are available 
URL: https://github.com/apache/pulsar/pull/4028#discussion_r274693700
 
 

 ##########
 File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/source/TopicSchema.java
 ##########
 @@ -126,30 +139,63 @@ private static SchemaType getDefaultSchemaType(Class<?> clazz)
{
     @SuppressWarnings("unchecked")
     private static <T> Schema<T> newSchemaInstance(Class<T> clazz, SchemaType
type) {
         switch (type) {
-        case NONE:
-            return (Schema<T>) Schema.BYTES;
+            case NONE:
+                return (Schema<T>) Schema.BYTES;
 
-        case AUTO_CONSUME:
-        case AUTO:
-            return (Schema<T>) Schema.AUTO_CONSUME();
+            case AUTO_CONSUME:
+            case AUTO:
+                return (Schema<T>) Schema.AUTO_CONSUME();
 
-        case STRING:
-            return (Schema<T>) Schema.STRING;
+            case STRING:
+                return (Schema<T>) Schema.STRING;
 
-        case AVRO:
-            return AvroSchema.of(SchemaDefinition.<T>builder().withPojo(clazz).build());
+            case AVRO:
+                return AvroSchema.of(SchemaDefinition.<T>builder().withPojo(clazz).build());
 
-        case JSON:
-            return JSONSchema.of(SchemaDefinition.<T>builder().withPojo(clazz).build());
+            case JSON:
+                return JSONSchema.of(SchemaDefinition.<T>builder().withPojo(clazz).build());
 
-        case KEY_VALUE:
-            return (Schema<T>)Schema.KV_BYTES();
+            case BOOLEAN:
+                return (Schema<T>) Schema.BOOL;
 
-        case PROTOBUF:
-            return ProtobufSchema.ofGenericClass(clazz, Collections.emptyMap());
+            case INT8:
+                return (Schema<T>) Schema.INT8;
 
-        default:
-            throw new RuntimeException("Unsupported schema type" + type);
+            case INT16:
+                return (Schema<T>) Schema.INT16;
+
+            case INT32:
+                return (Schema<T>) Schema.INT32;
+
+            case INT64:
+                return (Schema<T>) Schema.INT64;
+
+            case FLOAT:
+                return (Schema<T>) Schema.FLOAT;
+
+            case DOUBLE:
+                return (Schema<T>) Schema.DOUBLE;
+
+            case DATE:
+                return (Schema<T>) Schema.DATE;
+
+            case TIME:
+                return (Schema<T>) Schema.TIME;
+
+            case TIMESTAMP:
+                return (Schema<T>) Schema.TIMESTAMP;
+
+            case KEY_VALUE:
+                return (Schema<T>)Schema.KV_BYTES();
+
+            case PROTOBUF:
+                return ProtobufSchema.ofGenericClass(clazz, Collections.emptyMap());
+
+            case BYTES:
 
 Review comment:
   removed AUTO_PUBLISH since that case would not arise.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message