本文整理匯總了Java中org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.getPrimitiveCategory方法的典型用法代碼示例。如果您正苦於以下問題:Java PrimitiveObjectInspector.getPrimitiveCategory方法的具體用法?Java PrimitiveObjectInspector.getPrimitiveCategory怎麽用?Java PrimitiveObjectInspector.getPrimitiveCategory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector
的用法示例。
在下文中一共展示了PrimitiveObjectInspector.getPrimitiveCategory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRangeExecuter
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
public static IExpressionNode getRangeExecuter( boolean invert , final PrimitiveObjectInspector minPrimitiveObjectInspector , final PrimitiveObjectInspector maxPrimitiveObjectInspector , final IExtractNode targetColumn ){
switch( minPrimitiveObjectInspector.getPrimitiveCategory() ){
case STRING:
String minStr = ( (WritableConstantStringObjectInspector)minPrimitiveObjectInspector ).getWritableConstantValue().toString();
String maxStr = ( (WritableConstantStringObjectInspector)maxPrimitiveObjectInspector ).getWritableConstantValue().toString();
IFilter filter = new RangeStringCompareFilter( minStr , true , maxStr , true , invert );
return new ExecuterNode( targetColumn , filter );
case BYTE:
return getNumberRangeExecuter( invert , new ByteObj( ( (WritableConstantByteObjectInspector)minPrimitiveObjectInspector ).getWritableConstantValue().get() ) , new ByteObj( ( (WritableConstantByteObjectInspector)maxPrimitiveObjectInspector ).getWritableConstantValue().get() ) , targetColumn );
case SHORT:
return getNumberRangeExecuter( invert , new ShortObj( ( (WritableConstantShortObjectInspector)minPrimitiveObjectInspector ).getWritableConstantValue().get() ) , new ShortObj( ( (WritableConstantShortObjectInspector)maxPrimitiveObjectInspector ).getWritableConstantValue().get() ) , targetColumn );
case INT:
return getNumberRangeExecuter( invert , new IntegerObj( ( (WritableConstantIntObjectInspector)minPrimitiveObjectInspector ).getWritableConstantValue().get() ) , new IntegerObj( ( (WritableConstantIntObjectInspector)maxPrimitiveObjectInspector ).getWritableConstantValue().get() ) , targetColumn );
case LONG:
return getNumberRangeExecuter( invert , new LongObj( ( (WritableConstantLongObjectInspector)minPrimitiveObjectInspector ).getWritableConstantValue().get() ) , new LongObj( ( (WritableConstantLongObjectInspector)maxPrimitiveObjectInspector ).getWritableConstantValue().get() ) , targetColumn );
case FLOAT:
return getNumberRangeExecuter( invert , new FloatObj( ( (WritableConstantFloatObjectInspector)minPrimitiveObjectInspector ).getWritableConstantValue().get() ) , new FloatObj( ( (WritableConstantFloatObjectInspector)maxPrimitiveObjectInspector ).getWritableConstantValue().get() ) , targetColumn );
case DOUBLE:
return getNumberRangeExecuter( invert , new DoubleObj( ( (WritableConstantDoubleObjectInspector)minPrimitiveObjectInspector ).getWritableConstantValue().get() ) , new DoubleObj( ( (WritableConstantDoubleObjectInspector)maxPrimitiveObjectInspector ).getWritableConstantValue().get() ) , targetColumn );
default:
return null;
}
}
示例2: obtainIntConverter
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的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;
}
示例3: obtainLongConverter
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的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;
}
示例4: obtainDateConverter
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的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;
}
示例5: obtainTimestampConverter
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的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;
}
示例6: isNumberOI
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
public static boolean isNumberOI(@Nonnull final ObjectInspector argOI) {
if (argOI.getCategory() != Category.PRIMITIVE) {
return false;
}
final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI;
switch (oi.getPrimitiveCategory()) {
case SHORT:
case INT:
case LONG:
case FLOAT:
case DOUBLE:
case DECIMAL:
case BYTE:
//case TIMESTAMP:
return true;
default:
return false;
}
}
示例7: asIntCompatibleOI
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
@Nonnull
public static PrimitiveObjectInspector asIntCompatibleOI(@Nonnull final ObjectInspector argOI)
throws UDFArgumentTypeException {
if (argOI.getCategory() != Category.PRIMITIVE) {
throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
+ argOI.getTypeName() + " is passed.");
}
final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI;
switch (oi.getPrimitiveCategory()) {
case INT:
case SHORT:
case LONG:
case FLOAT:
case DOUBLE:
case DECIMAL:
case BOOLEAN:
case BYTE:
case STRING:
break;
default:
throw new UDFArgumentTypeException(0, "Unxpected type '" + argOI.getTypeName()
+ "' is passed.");
}
return oi;
}
示例8: asLongCompatibleOI
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
@Nonnull
public static PrimitiveObjectInspector asLongCompatibleOI(@Nonnull final ObjectInspector argOI)
throws UDFArgumentTypeException {
if (argOI.getCategory() != Category.PRIMITIVE) {
throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
+ argOI.getTypeName() + " is passed.");
}
final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI;
switch (oi.getPrimitiveCategory()) {
case LONG:
case INT:
case SHORT:
case BYTE:
case BOOLEAN:
case FLOAT:
case DOUBLE:
case DECIMAL:
case STRING:
case TIMESTAMP:
break;
default:
throw new UDFArgumentTypeException(0, "Unxpected type '" + argOI.getTypeName()
+ "' is passed.");
}
return oi;
}
示例9: asIntegerOI
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
@Nonnull
public static PrimitiveObjectInspector asIntegerOI(@Nonnull final ObjectInspector argOI)
throws UDFArgumentTypeException {
if (argOI.getCategory() != Category.PRIMITIVE) {
throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
+ argOI.getTypeName() + " is passed.");
}
final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI;
switch (oi.getPrimitiveCategory()) {
case INT:
case SHORT:
case LONG:
case BYTE:
break;
default:
throw new UDFArgumentTypeException(0, "Unxpected type '" + argOI.getTypeName()
+ "' is passed.");
}
return oi;
}
示例10: asDoubleCompatibleOI
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
@Nonnull
public static PrimitiveObjectInspector asDoubleCompatibleOI(@Nonnull final ObjectInspector argOI)
throws UDFArgumentTypeException {
if (argOI.getCategory() != Category.PRIMITIVE) {
throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
+ argOI.getTypeName() + " is passed.");
}
final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI;
switch (oi.getPrimitiveCategory()) {
case BYTE:
case SHORT:
case INT:
case LONG:
case FLOAT:
case DOUBLE:
case DECIMAL:
case STRING:
case TIMESTAMP:
break;
default:
throw new UDFArgumentTypeException(0,
"Only numeric or string type arguments are accepted but " + argOI.getTypeName()
+ " is passed.");
}
return oi;
}
示例11: asFloatingPointOI
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
@Nonnull
public static PrimitiveObjectInspector asFloatingPointOI(@Nonnull final ObjectInspector argOI)
throws UDFArgumentTypeException {
if (argOI.getCategory() != Category.PRIMITIVE) {
throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
+ argOI.getTypeName() + " is passed.");
}
final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI;
switch (oi.getPrimitiveCategory()) {
case FLOAT:
case DOUBLE:
case DECIMAL:
break;
default:
throw new UDFArgumentTypeException(0,
"Only numeric or string type arguments are accepted but " + argOI.getTypeName()
+ " is passed.");
}
return oi;
}
示例12: asNumberOI
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
@Nonnull
public static PrimitiveObjectInspector asNumberOI(@Nonnull final ObjectInspector argOI)
throws UDFArgumentTypeException {
if (argOI.getCategory() != Category.PRIMITIVE) {
throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
+ argOI.getTypeName() + " is passed.");
}
final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI;
switch (oi.getPrimitiveCategory()) {
case BYTE:
case SHORT:
case INT:
case LONG:
case FLOAT:
case DOUBLE:
case DECIMAL:
break;
default:
throw new UDFArgumentTypeException(0,
"Only numeric or string type arguments are accepted but " + argOI.getTypeName()
+ " is passed.");
}
return oi;
}
示例13: validateFeatureOI
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
private static void validateFeatureOI(@Nonnull ObjectInspector argOI)
throws UDFArgumentException {
if (!HiveUtils.isPrimitiveOI(argOI)) {
throw new UDFArgumentException(
"_FUNC_ expects integer type or string for `feature` but got "
+ argOI.getTypeName());
}
final PrimitiveObjectInspector oi = (PrimitiveObjectInspector) argOI;
switch (oi.getPrimitiveCategory()) {
case INT:
case SHORT:
case LONG:
case BYTE:
case STRING:
break;
default: {
throw new UDFArgumentException(
"_FUNC_ expects integer type or string for `feature` but got "
+ argOI.getTypeName());
}
}
}
示例14: createPrimitive
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
private static Writable createPrimitive(Object obj, PrimitiveObjectInspector inspector)
throws SerDeException {
if (obj == null) {
return null;
}
switch (inspector.getPrimitiveCategory()) {
case DOUBLE:
return new DoubleWritable(((DoubleObjectInspector) inspector).get(obj));
case FLOAT:
return new FloatWritable(((FloatObjectInspector) inspector).get(obj));
case INT:
return new IntWritable(((IntObjectInspector) inspector).get(obj));
case LONG:
return new LongWritable(((LongObjectInspector) inspector).get(obj));
case STRING:
return new Text(((StringObjectInspector) inspector).getPrimitiveJavaObject(obj));
case DATE:
return ((DateObjectInspector) inspector).getPrimitiveWritableObject(obj);
case TIMESTAMP:
return ((TimestampObjectInspector) inspector).getPrimitiveWritableObject(obj);
default:
throw new SerDeException("Can't serialize primitive : " + inspector.getPrimitiveCategory());
}
}
示例15: hasDateType
import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; //導入方法依賴的package包/類
static boolean hasDateType(ObjectInspector objectInspector)
{
if (objectInspector instanceof PrimitiveObjectInspector) {
PrimitiveObjectInspector primitiveInspector = (PrimitiveObjectInspector) objectInspector;
return primitiveInspector.getPrimitiveCategory() == PrimitiveCategory.DATE;
}
if (objectInspector instanceof ListObjectInspector) {
ListObjectInspector listInspector = (ListObjectInspector) objectInspector;
return hasDateType(listInspector.getListElementObjectInspector());
}
if (objectInspector instanceof MapObjectInspector) {
MapObjectInspector mapInspector = (MapObjectInspector) objectInspector;
return hasDateType(mapInspector.getMapKeyObjectInspector()) ||
hasDateType(mapInspector.getMapValueObjectInspector());
}
if (objectInspector instanceof StructObjectInspector) {
for (StructField field : ((StructObjectInspector) objectInspector).getAllStructFieldRefs()) {
if (hasDateType(field.getFieldObjectInspector())) {
return true;
}
}
return false;
}
throw new IllegalArgumentException("Unknown object inspector type " + objectInspector);
}