pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] sijie commented on a change in pull request #4022: Making use of builtin schemas for primitive types
Date Thu, 11 Apr 2019 06:05:19 GMT
sijie commented on a change in pull request #4022: Making use of builtin schemas for primitive
types
URL: https://github.com/apache/pulsar/pull/4022#discussion_r274248555
 
 

 ##########
 File path: pulsar-sql/presto-pulsar/src/main/java/org/apache/pulsar/sql/presto/PrimitiveSchemaHandler.java
 ##########
 @@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.sql.presto;
+
+import io.airlift.log.Logger;
+import org.apache.pulsar.shade.io.netty.buffer.ByteBuf;
+import org.apache.pulsar.shade.io.netty.util.concurrent.FastThreadLocal;
+
+public abstract class PrimitiveSchemaHandler implements SchemaHandler {
 
 Review comment:
   I don't think you need to reimplement all the primitive schema handler. 
   
   the schema handler should just wrap pulsar schema. reimplementing deserialization will
cause inconsistent as time goes.
   
   ```
   public class PrimitiveSchemaHandler<T> implements SchemaHandler {
   
       private static final Logger log = Logger.get(PrimitiveSchemaHandler.class);
   
       private final Schema<T> schema;
   
       public PrimitiveSchemaHandler(Schema<T> schema) {
           this.schema = schema;
       }
   
       @Override
       public Object deserialize(ByteBuf payload) {
           // we need to convert a direct mem buffer into a byte[].
           byte[] data = ByteBufUtil.getBytes(payload);
           return schema.decode(data);
       }
   
       @Override
       public Object extractField(int index, Object currentRecord) {
           return currentRecord;
       }
   }
   ```
   
   

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