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


Java PrimitiveObjectInspectorFactory.writableStringObjectInspector方法代码示例

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


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

示例1: initialize

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

  checkArgPrimitive(arguments, 0);
  checkArgPrimitive(arguments, 1);

  checkArgGroups(arguments, 0, inputTypes, STRING_GROUP, DATE_GROUP, VOID_GROUP);
  checkArgGroups(arguments, 1, inputTypes, STRING_GROUP, VOID_GROUP);

  obtainDateConverter(arguments, 0, inputTypes, converters);
  obtainStringConverter(arguments, 1, inputTypes, converters);

  if (arguments[1] instanceof ConstantObjectInspector) {
    String dayOfWeek = getConstantStringValue(arguments, 1);
    isDayOfWeekConst = true;
    dayOfWeekIntConst = getIntDayOfWeek(dayOfWeek);
  }

  ObjectInspector outputOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
  return outputOI;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:23,代码来源:GenericUDFNextDay.java

示例2: initialize

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

  checkArgPrimitive(arguments, 0);
  checkArgPrimitive(arguments, 1);

  checkArgGroups(arguments, 0, inputTypes, STRING_GROUP, DATE_GROUP, VOID_GROUP);
  checkArgGroups(arguments, 1, inputTypes, NUMERIC_GROUP, VOID_GROUP);

  obtainDateConverter(arguments, 0, inputTypes, converters);
  obtainIntConverter(arguments, 1, inputTypes, converters);

  if (arguments[1] instanceof ConstantObjectInspector) {
    numMonthsConst = getConstantIntValue(arguments, 1);
    isNumMonthsConst = true;
  }

  ObjectInspector outputOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
  return outputOI;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:22,代码来源:GenericUDFAddMonths.java

示例3: obtainDateConverter

import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的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: testEvaluateOneRow

import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Test
public void testEvaluateOneRow() throws IOException, HiveException {
    SmartcnUDF udf = new SmartcnUDF();
    ObjectInspector[] argOIs = new ObjectInspector[1];
    // line
    argOIs[0] = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
    udf.initialize(argOIs);

    DeferredObject[] args = new DeferredObject[1];
    args[0] = new DeferredObject() {
        public Text get() throws HiveException {
            return new Text("Smartcn为Apache2.0协议的开源中文分词系统,Java语言编写,修改的中科院计算所ICTCLAS分词系统。");
        }

        @Override
        public void prepare(int arg) throws HiveException {}
    };
    List<Text> tokens = udf.evaluate(args);
    Assert.assertNotNull(tokens);
    udf.close();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:22,代码来源:SmartcnUDFTest.java

示例5: testEvaluateOneRow

import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Test
public void testEvaluateOneRow() throws IOException, HiveException {
    KuromojiUDF udf = new KuromojiUDF();
    ObjectInspector[] argOIs = new ObjectInspector[1];
    // line
    argOIs[0] = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
    udf.initialize(argOIs);

    DeferredObject[] args = new DeferredObject[1];
    args[0] = new DeferredObject() {
        public Text get() throws HiveException {
            return new Text("クロモジのJapaneseAnalyzerを使ってみる。テスト。");
        }

        @Override
        public void prepare(int arg) throws HiveException {}
    };
    List<Text> tokens = udf.evaluate(args);
    Assert.assertNotNull(tokens);
    Assert.assertEquals(5, tokens.size());
    udf.close();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:23,代码来源:KuromojiUDFTest.java

示例6: initialize

import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 3 && argOIs.length != 4) {
        throw new UDFArgumentException("_FUNC_ takes 3 or 4 arguments: " + argOIs.length);
    }
    if (argOIs.length == 4) {
        String opts = HiveUtils.getConstString(argOIs[3]);
        processOptions(opts);
    }

    this.latOI = HiveUtils.asDoubleCompatibleOI(argOIs[0]);
    this.lonOI = HiveUtils.asDoubleCompatibleOI(argOIs[1]);
    this.zoomOI = HiveUtils.asIntegerOI(argOIs[2]);

    this.result = new Text();
    return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:18,代码来源:MapURLUDF.java

示例7: initialize

import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(@Nonnull ObjectInspector[] argOIs)
        throws UDFArgumentException {
    if (argOIs.length != 1 && argOIs.length != 2) {
        throw new UDFArgumentLengthException(
            "The feature_hashing function takes 1 or 2 arguments: " + argOIs.length);
    }
    ObjectInspector argOI0 = argOIs[0];
    this._listOI = HiveUtils.isListOI(argOI0) ? (ListObjectInspector) argOI0 : null;

    if (argOIs.length == 2) {
        String opts = HiveUtils.getConstString(argOIs[1]);
        processOptions(opts);
    }

    if (_listOI == null) {
        return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
    } else {
        return ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableStringObjectInspector);
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:22,代码来源:FeatureHashingUDF.java

示例8: getObjectInspector

import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
private ObjectInspector getObjectInspector(final TypeInfo typeInfo) {
    if (typeInfo.equals(TypeInfoFactory.doubleTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.booleanTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.floatTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.intTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.longTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.stringTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.timestampTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableTimestampObjectInspector;
    } else if (typeInfo.equals(TypeInfoFactory.dateTypeInfo)) {
        return PrimitiveObjectInspectorFactory.writableDateObjectInspector;
    } else {
        throw new UnsupportedOperationException("Unknown field type: " + typeInfo);
    }
}
 
开发者ID:shunfei,项目名称:indexr,代码行数:22,代码来源:ArrayWritableObjectInspector.java

示例9: initialize

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

  checkArgPrimitive(arguments, 0);
  checkArgPrimitive(arguments, 1);

  // the function should support both short date and full timestamp format
  // time part of the timestamp should not be skipped
  checkArgGroups(arguments, 0, tsInputTypes, STRING_GROUP, DATE_GROUP);
  checkArgGroups(arguments, 0, dtInputTypes, STRING_GROUP, DATE_GROUP);

  checkArgGroups(arguments, 1, tsInputTypes, STRING_GROUP);

  obtainTimestampConverter(arguments, 0, tsInputTypes, tsConverters);
  obtainDateConverter(arguments, 0, dtInputTypes, dtConverters);

  if (arguments[1] instanceof ConstantObjectInspector) {
    String fmtStr = getConstantStringValue(arguments, 1);
    if (fmtStr != null) {
      try {
        formatter = new SimpleDateFormat(fmtStr);
      } catch (IllegalArgumentException e) {
        // ignore
      }
    }
  } else {
    throw new UDFArgumentTypeException(1, getFuncName() + " only takes constant as "
        + getArgOrder(1) + " argument");
  }

  ObjectInspector outputOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
  return outputOI;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:35,代码来源:GenericUDFDateFormat.java

示例10: initialize

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

  checkArgPrimitive(arguments, 0);
  checkArgPrimitive(arguments, 1);
  checkArgPrimitive(arguments, 2);

  checkArgGroups(arguments, 0, inputTypes, STRING_GROUP);
  checkArgGroups(arguments, 1, inputTypes, STRING_GROUP);
  checkArgGroups(arguments, 2, inputTypes, NUMERIC_GROUP);

  obtainStringConverter(arguments, 0, inputTypes, converters);
  obtainStringConverter(arguments, 1, inputTypes, converters);
  obtainIntConverter(arguments, 2, inputTypes, converters);

  if (arguments[1] instanceof ConstantObjectInspector) {
    delimConst = getConstantStringValue(arguments, 1);
    isDelimConst = true;
  }

  if (arguments[2] instanceof ConstantObjectInspector) {
    countConst = getConstantIntValue(arguments, 2);
    isCountConst = true;
  }

  ObjectInspector outputOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
  return outputOI;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:30,代码来源:GenericUDFSubstringIndex.java

示例11: initialize

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

  checkArgPrimitive(arguments, 0);
  checkArgPrimitive(arguments, 1);

  // the function should support both string and binary input types
  checkArgGroups(arguments, 0, inputTypes, STRING_GROUP, BINARY_GROUP);
  checkArgGroups(arguments, 1, inputTypes, NUMERIC_GROUP);

  if (PrimitiveObjectInspectorUtils.getPrimitiveGrouping(inputTypes[0]) == STRING_GROUP) {
    obtainStringConverter(arguments, 0, inputTypes, converters);
    isStr = true;
  } else {
    obtainBinaryConverter(arguments, 0, inputTypes, converters);
    isStr = false;
  }

  if (arguments[1] instanceof ConstantObjectInspector) {
    Integer lenObj = getConstantIntValue(arguments, 1);
    if (lenObj != null) {
      int len = lenObj.intValue();
      if (len == 0) {
        len = 256;
      }
      try {
        digest = MessageDigest.getInstance("SHA-" + len);
      } catch (NoSuchAlgorithmException e) {
        // ignore
      }
    }
  } else {
    throw new UDFArgumentTypeException(1, getFuncName() + " only takes constant as "
        + getArgOrder(1) + " argument");
  }

  ObjectInspector outputOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
  return outputOI;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:41,代码来源:GenericUDFSha2.java

示例12: initialize

import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
  if (arguments.length != 1) {
    throw new UDFArgumentLengthException(getFuncName() + " requires 1 argument, got "
        + arguments.length);
  }
  checkIfPrimitive(arguments, 0, "1st");

  checkIfStringGroup(arguments, 0, "1st");

  getStringConverter(arguments, 0, "1st");

  ObjectInspector outputOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
  return outputOI;
}
 
开发者ID:myui,项目名称:hive-udf-backports,代码行数:16,代码来源:GenericUDFSoundex.java

示例13: newObjectInspectorFromHiveType

import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
private static ObjectInspector newObjectInspectorFromHiveType(final ASTNode type) {
	// matching by token names, because token IDs (which are static final) drastically change between versions.
	switch (type.getToken().getText()) {
		case "TOK_STRING":
			return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
		case "TOK_INT":
			return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
		case "TOK_DOUBLE":
			return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
		case "TOK_FLOAT":
			return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
		case "TOK_BIGINT":
			return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
		case "TOK_BOOLEAN": {
			return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
		}
		case "TOK_STRUCT": {
			final ASTNode tabColList = (ASTNode) type.getChild(0);
			final List<String> names = new ArrayList<>();
			final List<ObjectInspector> ois = new ArrayList<>();
			for (final Node tabCol : tabColList.getChildren()) {
				final ASTNode a = (ASTNode) tabCol;
				names.add(a.getChild(0).toString());
				ois.add(newObjectInspectorFromHiveType((ASTNode) a.getChild(1)));
			}
			return ObjectInspectorFactory.getStandardStructObjectInspector(names, ois);
		}
		case "TOK_MAP": {
			final ObjectInspector keyType = newObjectInspectorFromHiveType((ASTNode) type.getChild(0));
			final ObjectInspector valueType = newObjectInspectorFromHiveType((ASTNode) type.getChild(1));
			return ObjectInspectorFactory.getStandardMapObjectInspector(keyType, valueType);
		}
		case "TOK_LIST": {
			final ObjectInspector itemType = newObjectInspectorFromHiveType((ASTNode) type.getChild(0));
			return ObjectInspectorFactory.getStandardListObjectInspector(itemType);
		}
		default:
			throw new IllegalArgumentException("unsupported type: " + type.toStringTree());
	}
}
 
开发者ID:CyberAgent,项目名称:hive-jq-udtf,代码行数:41,代码来源:ObjectInspectors.java

示例14: testEvaluateInvalidUserDictURL

import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Test(expected = UDFArgumentException.class)
public void testEvaluateInvalidUserDictURL() throws IOException, HiveException {
    KuromojiUDF udf = new KuromojiUDF();
    ObjectInspector[] argOIs = new ObjectInspector[5];
    // line
    argOIs[0] = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
    // mode
    PrimitiveTypeInfo stringType = new PrimitiveTypeInfo();
    stringType.setTypeName("string");
    argOIs[1] = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
        stringType, null);
    // stopWords
    argOIs[2] = ObjectInspectorFactory.getStandardConstantListObjectInspector(
        PrimitiveObjectInspectorFactory.writableStringObjectInspector, null);
    // stopTags
    argOIs[3] = ObjectInspectorFactory.getStandardConstantListObjectInspector(
        PrimitiveObjectInspectorFactory.writableStringObjectInspector, null);
    // userDictUrl
    argOIs[4] = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(
        stringType, new Text("http://google.com/"));
    udf.initialize(argOIs);

    DeferredObject[] args = new DeferredObject[1];
    args[0] = new DeferredObject() {
        public Text get() throws HiveException {
            return new Text("クロモジのJapaneseAnalyzerを使ってみる。テスト。");
        }

        @Override
        public void prepare(int arg) throws HiveException {}
    };

    List<Text> tokens = udf.evaluate(args);
    Assert.assertNotNull(tokens);

    udf.close();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:38,代码来源:KuromojiUDFTest.java

示例15: testSerializeByKryo

import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Test
public void testSerializeByKryo() throws UDFArgumentException {
    final KuromojiUDF udf = new KuromojiUDF();
    ObjectInspector[] argOIs = new ObjectInspector[1];
    argOIs[0] = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
    udf.initialize(argOIs);

    Kryo kryo = new Kryo();
    kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
    Output output = new Output(1024 * 16);
    kryo.writeObject(output, udf);
    output.close();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:14,代码来源:KuromojiUDFTest.java


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