當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。