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


Java ListObjectInspector类代码示例

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


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

示例1: isMonarchTypeSupported

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
public static boolean isMonarchTypeSupported(final ObjectInspector oi) {
  if (ObjectInspector.Category.PRIMITIVE.equals(oi.getCategory())) {
    /** handle primitive type definitions like decimal(20,20) or varchar(100) **/
    String typeStr = oi.getTypeName();
    final int argPos = typeStr.indexOf('(');
    if (argPos > 0) {
      typeStr = typeStr.substring(0, argPos);
    }
    return TYPE_HIVE_TO_MONARCH_MAP.containsKey(typeStr);
  } else if (oi instanceof ListObjectInspector) {
    ListObjectInspector loi = (ListObjectInspector)oi;
    return isMonarchTypeSupported(loi.getListElementObjectInspector());
  } else if (oi instanceof MapObjectInspector) {
    MapObjectInspector moi = (MapObjectInspector)oi;
    return isMonarchTypeSupported(moi.getMapKeyObjectInspector()) &&
      isMonarchTypeSupported(moi.getMapValueObjectInspector());
  } else if (oi instanceof StructObjectInspector) {
    return ((StructObjectInspector) oi).getAllStructFieldRefs().stream()
      .map(StructField::getFieldObjectInspector)
      .allMatch(MonarchPredicateHandler::isMonarchTypeSupported);
  } else if (oi instanceof UnionObjectInspector) {
    return ((UnionObjectInspector) oi).getObjectInspectors().stream()
      .allMatch(MonarchPredicateHandler::isMonarchTypeSupported);
  }
  return false;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:27,代码来源:MonarchPredicateHandler.java

示例2: readListOfOutputsFromTable

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
/**
* Read list of Bitcoin transaction outputs from a table in Hive in any format (e.g. ORC, Parquet)
*
* @param loi ObjectInspector for processing the Object containing a list
* @param listOfOutputsObject object containing the list of outputs to a Bitcoin Transaction
*
* @return a list of BitcoinTransactionOutputs 
*
*/

private List<BitcoinTransactionOutput> readListOfOutputsFromTable(ListObjectInspector loi, Object listOfOutputsObject) {
int listLength=loi.getListLength(listOfOutputsObject);
List<BitcoinTransactionOutput> result=new ArrayList<>(listLength);
StructObjectInspector listOfOutputsElementObjectInspector = (StructObjectInspector)loi.getListElementObjectInspector();
	for (int i=0;i<listLength;i++) {
		Object currentListOfOutputsObject = loi.getListElement(listOfOutputsObject,i);
		StructField valueSF = listOfOutputsElementObjectInspector.getStructFieldRef("value");
		StructField txoutscriptlengthSF = listOfOutputsElementObjectInspector.getStructFieldRef("txoutscriptlength");
		StructField txoutscriptSF = listOfOutputsElementObjectInspector.getStructFieldRef("txoutscript");
		if ((valueSF==null) || (txoutscriptlengthSF==null) || (txoutscriptSF==null)) {
			LOG.warn("Invalid BitcoinTransactionOutput detected at position "+i);
			return new ArrayList<>();
		}
		long currentValue=wloi.get(listOfOutputsElementObjectInspector.getStructFieldData(currentListOfOutputsObject,valueSF));	
		byte[] currentTxOutScriptLength=wboi.getPrimitiveJavaObject(listOfOutputsElementObjectInspector.getStructFieldData(currentListOfOutputsObject,txoutscriptlengthSF));
		byte[] currentTxOutScript=wboi.getPrimitiveJavaObject(listOfOutputsElementObjectInspector.getStructFieldData(currentListOfOutputsObject,txoutscriptSF));
		BitcoinTransactionOutput currentBitcoinTransactionOutput = new BitcoinTransactionOutput(currentValue,currentTxOutScriptLength,currentTxOutScript);
		result.add(currentBitcoinTransactionOutput);
	}
return result;
}
 
开发者ID:ZuInnoTe,项目名称:hadoopcryptoledger,代码行数:32,代码来源:BitcoinTransactionHashUDF.java

示例3: getByteBuffers

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
/**
 * This method currently supports BinarySet data type of DynamoDB
 */
public List<ByteBuffer> getByteBuffers(Object data, ObjectInspector objectInspector, String
    ddType) {
  ListObjectInspector listObjectInspector = (ListObjectInspector) objectInspector;
  List<?> dataList = listObjectInspector.getList(data);

  if (dataList == null) {
    return null;
  }

  ObjectInspector itemObjectInspector = listObjectInspector.getListElementObjectInspector();
  List<ByteBuffer> itemList = new ArrayList<ByteBuffer>();
  for (Object dataItem : dataList) {
    if (dataItem == null) {
      throw new RuntimeException("Null element found in list: " + dataList);
    }

    if (ddType.equals("BS")) {
      itemList.add(getByteBuffer(dataItem, itemObjectInspector));
    } else {
      throw new RuntimeException("Expecting BinarySet type: " + ddType);
    }
  }

  return itemList;
}
 
开发者ID:awslabs,项目名称:emr-dynamodb-connector,代码行数:29,代码来源:DynamoDBDataParser.java

示例4: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
@Override
public StructObjectInspector initialize(@Nonnull ObjectInspector[] argOIs)
        throws UDFArgumentException {
    if (argOIs.length != 4 && argOIs.length != 5) {
        throw new UDFArgumentException(this.getClass().getSimpleName()
                + " takes 4 or 5 arguments: string rowid, string[] features, string model_id,"
                + " array<byte> pred_model [, string options]: " + argOIs.length);
    } else {
        this.processOptions(argOIs);
        this.rowIdOI = HiveUtils.asStringOI(argOIs[0]);
        final ListObjectInspector listOI = HiveUtils.asListOI(argOIs[1]);
        final ObjectInspector elemOI = listOI.getListElementObjectInspector();
        this.featureListOI = listOI;
        this.featureElemOI = HiveUtils.asStringOI(elemOI);
        this.modelIdOI = HiveUtils.asStringOI(argOIs[2]);
        this.modelOI = HiveUtils.asBinaryOI(argOIs[3]);
        this.mapToModel = new HashMap<String, Booster>();
        this.rowBuffer = new HashMap<String, List<LabeledPointWithRowId>>();
        return getReturnOI();
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:22,代码来源:XGBoostPredictUDTF.java

示例5: getFeatureType

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
@Nonnull
private static FeatureType getFeatureType(@Nonnull ListObjectInspector featureListOI)
        throws UDFArgumentException {
    final ObjectInspector featureOI = featureListOI.getListElementObjectInspector();
    if (featureOI instanceof StringObjectInspector) {
        return FeatureType.STRING;
    } else if (featureOI instanceof IntObjectInspector) {
        return FeatureType.INT;
    } else if (featureOI instanceof LongObjectInspector) {
        return FeatureType.LONG;
    } else {
        throw new UDFArgumentException("Feature object inspector must be one of "
                + "[StringObjectInspector, IntObjectInspector, LongObjectInspector]: "
                + featureOI.toString());
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:17,代码来源:GeneralLearnerBaseUDTF.java

示例6: asStringList

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
@Nullable
public static List<String> asStringList(@Nonnull final DeferredObject arg,
        @Nonnull final ListObjectInspector listOI) throws HiveException {
    Object argObj = arg.get();
    if (argObj == null) {
        return null;
    }
    List<?> data = listOI.getList(argObj);
    int size = data.size();
    if (size == 0) {
        return Collections.emptyList();
    }
    final String[] ary = new String[size];
    for (int i = 0; i < size; i++) {
        Object o = data.get(i);
        if (o != null) {
            ary[i] = o.toString();
        }
    }
    return Arrays.asList(ary);
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:22,代码来源:HiveUtils.java

示例7: asStringArray

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
@Nullable
public static String[] asStringArray(@Nonnull final DeferredObject arg,
        @Nonnull final ListObjectInspector listOI) throws HiveException {
    Object argObj = arg.get();
    if (argObj == null) {
        return null;
    }
    List<?> data = listOI.getList(argObj);
    final int size = data.size();
    final String[] arr = new String[size];
    for (int i = 0; i < size; i++) {
        Object o = data.get(i);
        if (o != null) {
            arr[i] = o.toString();
        }
    }
    return arr;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:19,代码来源:HiveUtils.java

示例8: asLongArray

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
@Nonnull
public static long[] asLongArray(@Nullable final Object argObj,
        @Nonnull final ListObjectInspector listOI, @Nonnull PrimitiveObjectInspector elemOI) {
    if (argObj == null) {
        return null;
    }
    final int length = listOI.getListLength(argObj);
    final long[] ary = new long[length];
    for (int i = 0; i < length; i++) {
        Object o = listOI.getListElement(argObj, i);
        if (o == null) {
            continue;
        }
        ary[i] = PrimitiveObjectInspectorUtils.getLong(o, elemOI);
    }
    return ary;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:18,代码来源:HiveUtils.java

示例9: asFloatArray

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
@Nullable
public static float[] asFloatArray(@Nullable final Object argObj,
        @Nonnull final ListObjectInspector listOI,
        @Nonnull final PrimitiveObjectInspector elemOI, final boolean avoidNull)
        throws UDFArgumentException {
    if (argObj == null) {
        return null;
    }
    final int length = listOI.getListLength(argObj);
    final float[] ary = new float[length];
    for (int i = 0; i < length; i++) {
        Object o = listOI.getListElement(argObj, i);
        if (o == null) {
            if (avoidNull) {
                continue;
            }
            throw new UDFArgumentException("Found null at index " + i);
        }
        ary[i] = PrimitiveObjectInspectorUtils.getFloat(o, elemOI);
    }
    return ary;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:23,代码来源:HiveUtils.java

示例10: asDoubleArray

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
@Nullable
public static double[] asDoubleArray(@Nullable final Object argObj,
        @Nonnull final ListObjectInspector listOI,
        @Nonnull final PrimitiveObjectInspector elemOI, final boolean avoidNull)
        throws UDFArgumentException {
    if (argObj == null) {
        return null;
    }
    final int length = listOI.getListLength(argObj);
    final double[] ary = new double[length];
    for (int i = 0; i < length; i++) {
        Object o = listOI.getListElement(argObj, i);
        if (o == null) {
            if (avoidNull) {
                continue;
            }
            throw new UDFArgumentException("Found null at index " + i);
        }
        ary[i] = PrimitiveObjectInspectorUtils.getDouble(o, elemOI);
    }
    return ary;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:23,代码来源:HiveUtils.java

示例11: toDoubleArray

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
@Nonnull
public static void toDoubleArray(@Nullable final Object argObj,
        @Nonnull final ListObjectInspector listOI,
        @Nonnull final PrimitiveObjectInspector elemOI, @Nonnull final double[] out,
        final boolean avoidNull) throws UDFArgumentException {
    if (argObj == null) {
        return;
    }
    final int length = listOI.getListLength(argObj);
    if (out.length != length) {
        throw new UDFArgumentException("Dimension mismatched. Expected: " + out.length
                + ", Actual: " + length);
    }
    for (int i = 0; i < length; i++) {
        Object o = listOI.getListElement(argObj, i);
        if (o == null) {
            if (avoidNull) {
                continue;
            }
            throw new UDFArgumentException("Found null at index " + i);
        }
        out[i] = PrimitiveObjectInspectorUtils.getDouble(o, elemOI);
    }
    return;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:26,代码来源:HiveUtils.java

示例12: setBits

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
/**
 * @return the number of true bits
 */
@Nonnull
public static int setBits(@Nullable final Object argObj,
        @Nonnull final ListObjectInspector listOI,
        @Nonnull final PrimitiveObjectInspector elemOI, @Nonnull final BitSet bitset)
        throws UDFArgumentException {
    if (argObj == null) {
        return 0;
    }
    int count = 0;
    final int length = listOI.getListLength(argObj);
    for (int i = 0; i < length; i++) {
        final Object o = listOI.getListElement(argObj, i);
        if (o == null) {
            continue;
        }
        final int index = PrimitiveObjectInspectorUtils.getInt(o, elemOI);
        if (index < 0) {
            throw new UDFArgumentException("Negative index is not allowed: " + index);
        }
        bitset.set(index);
        count++;
    }
    return count;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:28,代码来源:HiveUtils.java

示例13: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
    if (argOIs.length != 4 && argOIs.length != 5) {
        throw new UDFArgumentException("_FUNC_ takes 4 or 5 arguments");
    }

    this.modelTypeOI = HiveUtils.asIntegerOI(argOIs[1]);
    this.stringOI = HiveUtils.asStringOI(argOIs[2]);
    ListObjectInspector listOI = HiveUtils.asListOI(argOIs[3]);
    this.featureListOI = listOI;
    ObjectInspector elemOI = listOI.getListElementObjectInspector();
    this.featureElemOI = HiveUtils.asDoubleCompatibleOI(elemOI);

    boolean classification = false;
    if (argOIs.length == 5) {
        classification = HiveUtils.getConstBoolean(argOIs[4]);
    }
    this.classification = classification;

    if (classification) {
        return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
    } else {
        return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:26,代码来源:TreePredictUDFv1.java

示例14: initialize

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的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

示例15: getEvaluator

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入依赖的package包/类
@Override
public GenericUDAFEvaluator getEvaluator(GenericUDAFParameterInfo info)
        throws SemanticException {
    final ObjectInspector[] OIs = info.getParameterObjectInspectors();

    if (OIs.length != 2) {
        throw new UDFArgumentLengthException("Specify two arguments: " + OIs.length);
    }
    if (!HiveUtils.isNumberListOI(OIs[0])) {
        throw new UDFArgumentTypeException(0,
            "Only array<number> type argument is acceptable but " + OIs[0].getTypeName()
                    + " was passed as `features`");
    }
    if (!HiveUtils.isListOI(OIs[1])
            || !HiveUtils.isIntegerOI(((ListObjectInspector) OIs[1]).getListElementObjectInspector())) {
        throw new UDFArgumentTypeException(1,
            "Only array<int> type argument is acceptable but " + OIs[1].getTypeName()
                    + " was passed as `labels`");
    }

    return new SignalNoiseRatioUDAFEvaluator();
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:23,代码来源:SignalNoiseRatioUDAF.java


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