You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/07/02 05:17:59 UTC

[GitHub] [pulsar] sijie commented on a change in pull request #6968: Fixes #6929 KeyValue schema supports nested generics type

sijie commented on a change in pull request #6968:
URL: https://github.com/apache/pulsar/pull/6968#discussion_r448753907



##########
File path: pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Schema.java
##########
@@ -369,4 +369,35 @@ default void configureSchemaInfo(String topic, String componentName,
     static GenericSchema<GenericRecord> generic(SchemaInfo schemaInfo) {
         return DefaultImplementation.getGenericSchema(schemaInfo);
     }
+
+    static Schema getDefaultSchema(Class<?> clazz) {
+        if (Byte[].class.equals(clazz)) {
+            return Schema.BYTES;
+        } else if (ByteBuffer.class.equals(clazz)) {
+            return Schema.BYTEBUFFER;
+        } else if (String.class.equals(clazz)) {
+            return Schema.STRING;
+        } else if (Byte.class.equals(clazz)) {
+            return Schema.INT8;
+        } else if (Short.class.equals(clazz)) {
+            return Schema.INT16;
+        } else if (Integer.class.equals(clazz)) {
+            return Schema.INT32;
+        } else if (Long.class.equals(clazz)) {
+            return Schema.INT64;
+        } else if (Boolean.class.equals(clazz)) {
+            return Schema.BOOL;
+        } else if (Float.class.equals(clazz)) {
+            return Schema.FLOAT;
+        } else if (Double.class.equals(clazz)) {
+            return Schema.DOUBLE;
+        } else if (Date.class.equals(clazz)) {
+            return Schema.DATE;
+        } else if (Time.class.equals(clazz)) {
+            return Schema.TIME;
+        } else if (Timestamp.class.equals(clazz)) {
+            return Schema.TIMESTAMP;
+        }
+        throw new IllegalArgumentException("Schema class type is incorrect");

Review comment:
       How does this handle a POJO class?




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