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


Java ObjectInspectorUtils.isConstantObjectInspector方法代码示例

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


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

示例1: getConstStringArray

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; //导入方法依赖的package包/类
@Nullable
public static String[] getConstStringArray(@Nonnull final ObjectInspector oi)
        throws UDFArgumentException {
    if (!ObjectInspectorUtils.isConstantObjectInspector(oi)) {
        throw new UDFArgumentException("argument must be a constant value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    ConstantObjectInspector constOI = (ConstantObjectInspector) oi;
    if (constOI.getCategory() != Category.LIST) {
        throw new UDFArgumentException("argument must be an array: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    final List<?> lst = (List<?>) constOI.getWritableConstantValue();
    if (lst == null) {
        return null;
    }
    final int size = lst.size();
    final String[] ary = new String[size];
    for (int i = 0; i < size; i++) {
        Object o = lst.get(i);
        if (o != null) {
            ary[i] = o.toString();
        }
    }
    return ary;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:27,代码来源:HiveUtils.java

示例2: getConstValue

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Nullable
public static <T extends Writable> T getConstValue(@Nonnull final ObjectInspector oi)
        throws UDFArgumentException {
    if (!ObjectInspectorUtils.isConstantObjectInspector(oi)) {
        throw new UDFArgumentException("argument must be a constant value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    ConstantObjectInspector constOI = (ConstantObjectInspector) oi;
    Object v = constOI.getWritableConstantValue();
    return (T) v;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:13,代码来源:HiveUtils.java

示例3: getConstDoubleArray

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; //导入方法依赖的package包/类
@Nullable
public static double[] getConstDoubleArray(@Nonnull final ObjectInspector oi)
        throws UDFArgumentException {
    if (!ObjectInspectorUtils.isConstantObjectInspector(oi)) {
        throw new UDFArgumentException("argument must be a constant value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    ConstantObjectInspector constOI = (ConstantObjectInspector) oi;
    if (constOI.getCategory() != Category.LIST) {
        throw new UDFArgumentException("argument must be an array: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    StandardConstantListObjectInspector listOI = (StandardConstantListObjectInspector) constOI;
    PrimitiveObjectInspector elemOI = HiveUtils.asDoubleCompatibleOI(listOI.getListElementObjectInspector());

    final List<?> lst = listOI.getWritableConstantValue();
    if (lst == null) {
        return null;
    }
    final int size = lst.size();
    final double[] ary = new double[size];
    for (int i = 0; i < size; i++) {
        Object o = lst.get(i);
        if (o == null) {
            ary[i] = Double.NaN;
        } else {
            ary[i] = PrimitiveObjectInspectorUtils.getDouble(o, elemOI);
        }
    }
    return ary;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:32,代码来源:HiveUtils.java

示例4: asConstantObjectInspector

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; //导入方法依赖的package包/类
@Nonnull
public static ConstantObjectInspector asConstantObjectInspector(
        @Nonnull final ObjectInspector oi) throws UDFArgumentException {
    if (!ObjectInspectorUtils.isConstantObjectInspector(oi)) {
        throw new UDFArgumentException("argument must be a constant value: "
                + TypeInfoUtils.getTypeInfoFromObjectInspector(oi));
    }
    return (ConstantObjectInspector) oi;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:10,代码来源:HiveUtils.java

示例5: isConstListOI

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; //导入方法依赖的package包/类
public static boolean isConstListOI(@Nonnull final ObjectInspector oi) {
    return ObjectInspectorUtils.isConstantObjectInspector(oi) && isListOI(oi);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:4,代码来源:HiveUtils.java

示例6: isConstString

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; //导入方法依赖的package包/类
public static boolean isConstString(@Nonnull final ObjectInspector oi) {
    return ObjectInspectorUtils.isConstantObjectInspector(oi) && isStringOI(oi);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:4,代码来源:HiveUtils.java

示例7: isConstInt

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; //导入方法依赖的package包/类
public static boolean isConstInt(@Nonnull final ObjectInspector oi) {
    return ObjectInspectorUtils.isConstantObjectInspector(oi) && isIntOI(oi);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:4,代码来源:HiveUtils.java

示例8: isConstInteger

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; //导入方法依赖的package包/类
public static boolean isConstInteger(@Nonnull final ObjectInspector oi) {
    return ObjectInspectorUtils.isConstantObjectInspector(oi) && isIntegerOI(oi);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:4,代码来源:HiveUtils.java

示例9: isConstBoolean

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; //导入方法依赖的package包/类
public static boolean isConstBoolean(@Nonnull final ObjectInspector oi) {
    return ObjectInspectorUtils.isConstantObjectInspector(oi) && isBooleanOI(oi);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:4,代码来源:HiveUtils.java

示例10: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils; //导入方法依赖的package包/类
@Override
public StructObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    final int numArgs = argOIs.length;
    if (numArgs < 4) {
        throw new UDFArgumentException(
            "each_top_k(int K, Object group, double cmpKey, *) takes at least 4 arguments: "
                    + numArgs);
    }

    this.argOIs = argOIs;
    this._constantK = ObjectInspectorUtils.isConstantObjectInspector(argOIs[0]);
    if (_constantK) {
        final int k = HiveUtils.getAsConstInt(argOIs[0]);
        if (k == 0) {
            throw new UDFArgumentException("k should not be 0");
        }
        this._queue = getQueue(k);
    } else {
        this.kOI = HiveUtils.asIntCompatibleOI(argOIs[0]);
        this._prevK = 0;
    }

    this.prevGroupOI = ObjectInspectorUtils.getStandardObjectInspector(argOIs[1],
        ObjectInspectorCopyOption.DEFAULT);
    this.cmpKeyOI = HiveUtils.asDoubleCompatibleOI(argOIs[2]);

    this._tuple = null;
    this._previousGroup = null;

    final ArrayList<String> fieldNames = new ArrayList<String>(numArgs);
    final ArrayList<ObjectInspector> fieldOIs = new ArrayList<ObjectInspector>(numArgs);
    fieldNames.add("rank");
    fieldOIs.add(PrimitiveObjectInspectorFactory.writableIntObjectInspector);
    fieldNames.add("key");
    fieldOIs.add(PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
    for (int i = 3; i < numArgs; i++) {
        fieldNames.add("c" + (i - 2));
        ObjectInspector rawOI = argOIs[i];
        ObjectInspector retOI = ObjectInspectorUtils.getStandardObjectInspector(rawOI,
            ObjectInspectorCopyOption.DEFAULT);
        fieldOIs.add(retOI);
    }
    return ObjectInspectorFactory.getStandardStructObjectInspector(fieldNames, fieldOIs);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:45,代码来源:EachTopKUDTF.java


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