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


Java ObjectInspectorConverters.Converter方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
		throws UDFArgumentException {
	if (arguments.length != 1) {
		throw new UDFArgumentLengthException("The SplitAndCleanJSONArray takes only one argument");
	}
	converters = new ObjectInspectorConverters.Converter[arguments.length];
	for (int i = 0; i < arguments.length; i++) {
		 converters[i] = ObjectInspectorConverters.getConverter(arguments[i], PrimitiveObjectInspectorFactory.writableStringObjectInspector);
	}
	return ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableStringObjectInspector);
}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:13,代码来源:SplitAndCleanJSONArray.java

示例7: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
  throws UDFArgumentException {
  converters = new ObjectInspectorConverters.Converter[arguments.length];

  for (int ii = 0; ii < arguments.length; ++ii) {
    if (ii == 0) {
      arrayOI = (ListObjectInspector)ObjectInspectorUtils
          .getStandardObjectInspector(arguments[ii]);
    }
    converters[ii] = ObjectInspectorConverters.getConverter(arguments[ii], arrayOI);
  }
  return arrayOI;
}
 
开发者ID:brndnmtthws,项目名称:facebook-hive-udfs,代码行数:15,代码来源:UDFArrayConcat.java

示例8: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] parameters) throws UDFArgumentException {

    // argument check
    if (parameters.length < 1) {
        throw new UDFArgumentTypeException(parameters.length - 1,
                "At least one argument is expected.");
    }

    scriptParamPos = 0;
    if (parameters[0] instanceof WritableConstantStringObjectInspector) {
        // no hint of return type found
        returnOI = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
                PrimitiveObjectInspector.PrimitiveCategory.STRING);
    } else if (parameters.length >= 2 && parameters[1] instanceof WritableConstantStringObjectInspector) {
        scriptParamPos = 1;
        // 1st param is hint of return type
        returnOI = RubyScriptingUtils.resolveOI(parameters[0]);
    } else {
        throw new UDFArgumentTypeException(0, "Couldn't find argument containing ruby method/script");
    }

    rbScriptParam = RubyScriptingUtils.getScriptParam(parameters[scriptParamPos]);

    argsConverters = new ObjectInspectorConverters.Converter[parameters.length - scriptParamPos - 1];
    for (int i = 0; i < argsConverters.length; i++) {
        argsConverters[i] = ObjectInspectorConverters.getConverter(
                parameters[i + scriptParamPos + 1],
                RubyScriptingUtils.resolveOI(parameters[i + scriptParamPos + 1])
        );
    }

    initializeJRubyRuntime();

    StringBuilder sb = new StringBuilder();
    sb.append("initialized rb_exec. return type is ");
    sb.append(returnOI.getTypeName());
    if (mode == MODE.METHOD) {
        sb.append(", try to evaluate using method '");
        sb.append(evaluateMethod);
        sb.append("' defined in rb.script as:\n");
        sb.append(rbEnvScript);
    } else {
        sb.append(", try to evaluate using this scriptlet: ");
        sb.append(rbScriptParam);
    }
    LOG.info(sb.toString());

    return returnOI;
}
 
开发者ID:gree,项目名称:hive-ruby-scripting,代码行数:51,代码来源:GenericUDFRubyExec.java


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