当前位置: 首页>>代码示例>>Java>>正文


Java ObjectInspectorConverters.getConverter方法代码示例

本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.getConverter方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectInspectorConverters.getConverter方法的具体用法?Java ObjectInspectorConverters.getConverter怎么用?Java ObjectInspectorConverters.getConverter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters的用法示例。


在下文中一共展示了ObjectInspectorConverters.getConverter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: obtainIntConverter

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
public static void obtainIntConverter(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
    PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
    PrimitiveCategory inputType = inOi.getPrimitiveCategory();
    switch (inputType) {
        case BYTE:
        case SHORT:
        case INT:
        case VOID:
            break;
        default:
            throw new UDFArgumentTypeException(i, "_FUNC_ only takes INT/SHORT/BYTE types as "
                    + getArgOrder(i) + " argument, got " + inputType);
    }

    Converter converter = ObjectInspectorConverters.getConverter(arguments[i],
        PrimitiveObjectInspectorFactory.writableIntObjectInspector);
    converters[i] = converter;
    inputTypes[i] = inputType;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:21,代码来源:BackportUtils.java

示例2: obtainLongConverter

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
public static void obtainLongConverter(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
    PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
    PrimitiveCategory inputType = inOi.getPrimitiveCategory();
    switch (inputType) {
        case BYTE:
        case SHORT:
        case INT:
        case LONG:
            break;
        default:
            throw new UDFArgumentTypeException(i,
                "_FUNC_ only takes LONG/INT/SHORT/BYTE types as " + getArgOrder(i)
                        + " argument, got " + inputType);
    }

    Converter converter = ObjectInspectorConverters.getConverter(arguments[i],
        PrimitiveObjectInspectorFactory.writableIntObjectInspector);
    converters[i] = converter;
    inputTypes[i] = inputType;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:22,代码来源:BackportUtils.java

示例3: obtainDateConverter

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
public static void obtainDateConverter(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
    PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
    PrimitiveCategory inputType = inOi.getPrimitiveCategory();
    ObjectInspector outOi;
    switch (inputType) {
        case STRING:
        case VARCHAR:
        case CHAR:
            outOi = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
            break;
        case TIMESTAMP:
        case DATE:
        case VOID:
            outOi = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
            break;
        default:
            throw new UDFArgumentTypeException(i,
                "_FUNC_ only takes STRING_GROUP or DATE_GROUP types as " + getArgOrder(i)
                        + " argument, got " + inputType);
    }
    converters[i] = ObjectInspectorConverters.getConverter(inOi, outOi);
    inputTypes[i] = inputType;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:25,代码来源:BackportUtils.java

示例4: obtainTimestampConverter

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
public static void obtainTimestampConverter(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
    PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
    PrimitiveCategory inputType = inOi.getPrimitiveCategory();
    ObjectInspector outOi;
    switch (inputType) {
        case STRING:
        case VARCHAR:
        case CHAR:
        case TIMESTAMP:
        case DATE:
            break;
        default:
            throw new UDFArgumentTypeException(i,
                "_FUNC_ only takes STRING_GROUP or DATE_GROUP types as " + getArgOrder(i)
                        + " argument, got " + inputType);
    }
    outOi = PrimitiveObjectInspectorFactory.writableTimestampObjectInspector;
    converters[i] = ObjectInspectorConverters.getConverter(inOi, outOi);
    inputTypes[i] = inputType;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:22,代码来源:BackportUtils.java

示例5: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
  if (arguments.length != 2) {
    throw new UDFArgumentLengthException(
        "The function COUNTRY(ip, geolocfile) takes exactly 2 arguments.");
  }

  converters = new ObjectInspectorConverters.Converter[arguments.length];
  for (int i = 0; i < arguments.length; i++) {
    converters[i] = ObjectInspectorConverters.getConverter(arguments[i],
        PrimitiveObjectInspectorFactory.javaStringObjectInspector);
  }

  return PrimitiveObjectInspectorFactory
      .getPrimitiveJavaObjectInspector(PrimitiveObjectInspector.PrimitiveCategory.STRING);
}
 
开发者ID:Hanmourang,项目名称:hiped2,代码行数:17,代码来源:Geoloc.java

示例6: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
  throws UDFArgumentException {
  if (arguments.length != 2) {
    throw new UDFArgumentLengthException("SAMPLE expects two arguments.");
  }

  if (!arguments[0].getCategory().equals(Category.PRIMITIVE)) {
    throw new UDFArgumentTypeException(0, "SAMPLE expects an INTEGER as its first argument");
  }

  int_converter = ObjectInspectorConverters.getConverter(arguments[0],
                                                         PrimitiveObjectInspectorFactory.writableIntObjectInspector);

  if (!arguments[1].getCategory().equals(Category.LIST)) {
    throw new UDFArgumentTypeException(1, "SAMPLE expects an ARRAY as its second argument");
  }

  arrayOI = (ListObjectInspector)arguments[1];
  return arguments[1];
}
 
开发者ID:brndnmtthws,项目名称:facebook-hive-udfs,代码行数:22,代码来源:UDFSample.java

示例7: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
  throws UDFArgumentException {
  if (arguments.length != 2 && arguments.length != 3) {
    throw new UDFArgumentLengthException("Expected 2 or 3 inputs, got " +
        arguments.length);
  }
 
  int_converter1 = ObjectInspectorConverters.getConverter(arguments[1],
                                                         PrimitiveObjectInspectorFactory.writableIntObjectInspector);

  if (arguments.length == 3) {
    int_converter2 = ObjectInspectorConverters.getConverter(arguments[2],
                                                            PrimitiveObjectInspectorFactory.writableIntObjectInspector);
  }

  arrayOI = (ListObjectInspector) arguments[0];
  return ObjectInspectorUtils.getStandardObjectInspector(arrayOI);
}
 
开发者ID:brndnmtthws,项目名称:facebook-hive-udfs,代码行数:20,代码来源:UDFArraySlice.java

示例8: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
  if (arguments.length != 2) {
    throw new UDFArgumentLengthException(
        "The function COUNTRY(ip, geolocfile) takes exactly 2 arguments.");
  }
  /*
* create covert used in evaluate method to convert all the arguments from their
* native type into java String
*/
  converters = new ObjectInspectorConverters.Converter[arguments.length];
  for (int i = 0; i < arguments.length; i++) {
  	
    converters[i] = ObjectInspectorConverters.getConverter(arguments[i],
        PrimitiveObjectInspectorFactory.javaStringObjectInspector);
  }

  return PrimitiveObjectInspectorFactory
      .getPrimitiveJavaObjectInspector(PrimitiveObjectInspector.PrimitiveCategory.STRING);
}
 
开发者ID:willddy,项目名称:bigdata_pattern,代码行数:21,代码来源:GeolocUDF.java

示例9: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
  if (arguments.length != 4) {
    throw new UDFArgumentException("parseDate takes four arguments");
  }

  converters = new ObjectInspectorConverters.Converter[arguments.length];
  for (int i = 0; i < arguments.length; i++) {
    converters[i] = ObjectInspectorConverters
      .getConverter(arguments[i], PrimitiveObjectInspectorFactory.writableStringObjectInspector);
  }

  return ObjectInspectorFactory.getStandardStructObjectInspector(Arrays.asList("year", "month", "day", "epoch"), Arrays
      .<ObjectInspector>asList(
              PrimitiveObjectInspectorFactory.javaIntObjectInspector,
              PrimitiveObjectInspectorFactory.javaIntObjectInspector,
              PrimitiveObjectInspectorFactory.javaIntObjectInspector,
              PrimitiveObjectInspectorFactory.javaLongObjectInspector));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:20,代码来源:DateParseUDF.java

示例10: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
  if (arguments.length != argLength) {
    throw new UDFArgumentException("compareLocationInterpretation takes 9 arguments");
  }

  converters = new ObjectInspectorConverters.Converter[arguments.length];
  for (int i = 0; i < arguments.length; i++) {
    converters[i] = ObjectInspectorConverters
      .getConverter(arguments[i], PrimitiveObjectInspectorFactory.writableStringObjectInspector);
  }

  return ObjectInspectorFactory
    .getStandardStructObjectInspector(Arrays.asList("decimallatitude", "decimallongitude", "countrycode"), Arrays
      .<ObjectInspector>asList(PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector,
              PrimitiveObjectInspectorFactory.javaStringObjectInspector));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:18,代码来源:ReinterpretLocationUDF.java

示例11: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
  if (arguments.length != 4) {
    throw new UDFArgumentException("parseCoordinates takes four arguments");
  }

  converters = new ObjectInspectorConverters.Converter[arguments.length];
  for (int i = 0; i < arguments.length; i++) {
    converters[i] = ObjectInspectorConverters
      .getConverter(arguments[i], PrimitiveObjectInspectorFactory.writableStringObjectInspector);
  }

  return ObjectInspectorFactory
    .getStandardStructObjectInspector(Arrays.asList("latitude", "longitude", "country"), Arrays
      .<ObjectInspector>asList(PrimitiveObjectInspectorFactory.javaDoubleObjectInspector,
        PrimitiveObjectInspectorFactory.javaDoubleObjectInspector,
        PrimitiveObjectInspectorFactory.javaStringObjectInspector));
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:19,代码来源:CoordinateCountryParseUDF.java

示例12: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
  if (arguments.length < 2) {
    throw new UDFArgumentLengthException(getFuncName() + " requires at least 2 arguments, got "
      + arguments.length);
  }
  if (arguments[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
    throw new UDFArgumentException(getFuncName() + " only takes primitive types, got "
      + arguments[0].getTypeName());
  }

  argumentOIs = arguments;
  converters = new Converter[arguments.length];

  TypeInfo commonInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[0]);

  for (int i = 1; i < arguments.length; i++) {
    PrimitiveTypeInfo currInfo = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[i]);

    commonInfo = FunctionRegistry.getCommonClassForComparison(
      commonInfo, currInfo);
  }

  resultOI = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(
    (commonInfo == null) ?
      TypeInfoFactory.doubleTypeInfo : commonInfo);

  for (int i = 0; i < arguments.length; i++) {
    converters[i] = ObjectInspectorConverters.getConverter(arguments[i], resultOI);
  }

  return resultOI;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:34,代码来源:GenericUDFBaseNwayCompare.java

示例13: obtainStringConverter

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
public static void obtainStringConverter(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
    PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
    PrimitiveCategory inputType = inOi.getPrimitiveCategory();

    Converter converter = ObjectInspectorConverters.getConverter(arguments[i],
        PrimitiveObjectInspectorFactory.writableStringObjectInspector);
    converters[i] = converter;
    inputTypes[i] = inputType;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:11,代码来源:BackportUtils.java

示例14: obtainDoubleConverter

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
public static void obtainDoubleConverter(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
    PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
    PrimitiveCategory inputType = inOi.getPrimitiveCategory();
    Converter converter = ObjectInspectorConverters.getConverter(arguments[i],
        PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
    converters[i] = converter;
    inputTypes[i] = inputType;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:10,代码来源:BackportUtils.java

示例15: obtainBinaryConverter

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
public static void obtainBinaryConverter(ObjectInspector[] arguments, int i,
        PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
    PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
    PrimitiveCategory inputType = inOi.getPrimitiveCategory();

    Converter converter = ObjectInspectorConverters.getConverter(arguments[i],
        PrimitiveObjectInspectorFactory.writableBinaryObjectInspector);
    converters[i] = converter;
    inputTypes[i] = inputType;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:11,代码来源:BackportUtils.java


注:本文中的org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.getConverter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。