[ 
https://issues.apache.org/jira/browse/TAJO-1686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15132058#comment-15132058
 ] 

ASF GitHub Bot commented on TAJO-1686:
--------------------------------------

Github user jihoonson commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/929#discussion_r51850151
  
    --- Diff: 
tajo-common/src/main/java/org/apache/tajo/util/WritableTypeConverter.java ---
    @@ -0,0 +1,103 @@
    +/**
    + * 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.tajo.util;
    +
    +import org.apache.hadoop.io.*;
    +import org.apache.tajo.common.TajoDataTypes.Type;
    +import org.apache.tajo.common.TajoDataTypes.DataType;
    +import org.apache.tajo.datum.*;
    +import org.apache.tajo.exception.NotImplementedException;
    +import org.apache.tajo.exception.TajoRuntimeException;
    +import org.reflections.ReflectionUtils;
    +
    +import java.util.Set;
    +
    +public class WritableTypeConverter {
    +
    +  public static DataType convertWritableToTajoType(Class<? extends 
Writable> writableClass) {
    +    if (writableClass == null)
    +      return null;
    +
    +    DataType.Builder builder = DataType.newBuilder();
    +    Set<Class<?>> parents = 
ReflectionUtils.getAllSuperTypes(writableClass);
    +
    +    if (writableClass == ByteWritable.class || 
parents.contains(ByteWritable.class)) {
    +      return builder.setType(Type.INT1).build();
    +    }
    +    if (writableClass == ShortWritable.class || 
parents.contains(ShortWritable.class)) {
    +      return builder.setType(Type.INT2).build();
    +    }
    +    if (writableClass == IntWritable.class || 
parents.contains(IntWritable.class)) {
    +      return builder.setType(Type.INT4).build();
    +    }
    +    if (writableClass == LongWritable.class || 
parents.contains(LongWritable.class)) {
    +      return builder.setType(Type.INT8).build();
    +    }
    +    if (writableClass == Text.class || parents.contains(Text.class)) {
    +      return builder.setType(Type.TEXT).build();
    +    }
    +    if (writableClass == FloatWritable.class || 
parents.contains(FloatWritable.class)) {
    +      return builder.setType(Type.FLOAT4).build();
    +    }
    +    if (writableClass == DoubleWritable.class || 
parents.contains(DoubleWritable.class)) {
    +      return builder.setType(Type.FLOAT8).build();
    +    }
    +    if (writableClass == BytesWritable.class || 
parents.contains(BytesWritable.class)) {
    +      return builder.setType(Type.VARBINARY).build();
    +    }
    +
    +    throw new TajoRuntimeException(new 
NotImplementedException(writableClass.getSimpleName()));
    +  }
    +
    +  public static Writable convertDatum2Writable(Datum value) {
    +    switch(value.type()) {
    +      case INT1: return new ByteWritable(value.asByte());
    +      case INT2: return new ShortWritable(value.asInt2());
    +      case INT4: return new IntWritable(value.asInt4());
    +      case INT8: return new LongWritable(value.asInt8());
    +
    +      case FLOAT4: return new FloatWritable(value.asFloat4());
    +      case FLOAT8: return new DoubleWritable(value.asFloat8());
    +
    +      case TEXT: return new Text(value.asChars());
    +      case VARBINARY: return new BytesWritable(value.asByteArray());
    --- End diff --
    
    We need to support date, time, timestamp, and boolean types as well.


> Allow Tajo to use Hive UDF
> --------------------------
>
>                 Key: TAJO-1686
>                 URL: https://issues.apache.org/jira/browse/TAJO-1686
>             Project: Tajo
>          Issue Type: New Feature
>          Components: Function/UDF
>            Reporter: Jaehwa Jung
>            Assignee: Jongyoung Park
>
> Hive has been widely used in this area. Many users have maintained lots of 
> big tables through Hive metastore using HiveQL and UDFs. Currently, Tajo 
> provides own UDF and Hive users can implement their UDFs in Tajo. But if we 
> can wrap Hive UDF in Tajo, it seems that they would be able to use Tajo 
> easily for their analysis infrastructure.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to