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


Java ListObjectInspector.getListElement方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: merge

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
void merge(@Nonnull final Object partial, @Nonnull final StructObjectInspector mergeOI,
        @Nonnull final StructField[] fields, @Nonnull final ListObjectInspector[] fieldOIs) {
    Preconditions.checkArgument(fields.length == fieldOIs.length);

    final int numFields = fieldOIs.length;
    if (identifiers == null) {
        this.identifiers = new Identifier[numFields];
    }
    Preconditions.checkArgument(fields.length == identifiers.length);

    for (int i = 0; i < numFields; i++) {
        Identifier<Writable> id = identifiers[i];
        if (id == null) {
            id = new Identifier<>(1);
            identifiers[i] = id;
        }
        final Object fieldData = mergeOI.getStructFieldData(partial, fields[i]);
        final ListObjectInspector fieldOI = fieldOIs[i];
        for (int j = 0, size = fieldOI.getListLength(fieldData); j < size; j++) {
            Object o = fieldOI.getListElement(fieldData, j);
            Preconditions.checkNotNull(o);
            id.valueOf((Writable) o);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:27,代码来源:OnehotEncodingUDAF.java

示例8: evaluate

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入方法依赖的package包/类
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
    ret.clear();

    for (int i = 0; i < arguments.length; i++) {
        final Object arrayObject = arguments[i].get();
        if (arrayObject == null) {
            continue;
        }

        final ListObjectInspector arrayOI = (ListObjectInspector) argumentOIs[i];
        final int arraylength = arrayOI.getListLength(arrayObject);
        for (int j = 0; j < arraylength; j++) {
            Object rawObj = arrayOI.getListElement(arrayObject, j);
            ObjectInspector elemOI = arrayOI.getListElementObjectInspector();
            Object obj = ObjectInspectorUtils.copyToStandardObject(rawObj, elemOI);
            ret.add(obj);
        }
    }

    return ret;
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:23,代码来源:ArrayConcatUDF.java

示例9: doIterate

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入方法依赖的package包/类
void doIterate(@Nonnull final Object tuple, @Nonnull ListObjectInspector listOI,
        @Nonnull PrimitiveObjectInspector elemOI) throws HiveException {
    final int size = listOI.getListLength(tuple);
    if (_size == -1) {
        init(size);
    }
    if (size != _size) {// a corner case
        throw new HiveException("Mismatch in the number of elements at tuple: "
                + tuple.toString());
    }
    final double[] sum = _sum;
    final long[] count = _count;
    for (int i = 0, len = size; i < len; i++) {
        Object o = listOI.getListElement(tuple, i);
        if (o != null) {
            double v = PrimitiveObjectInspectorUtils.getDouble(o, elemOI);
            sum[i] += v;
            count[i] += 1L;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:22,代码来源:ArrayAvgGenericUDAF.java

示例10: readListOfInputsFromTable

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

private List<BitcoinTransactionInput> readListOfInputsFromTable(ListObjectInspector loi, Object listOfInputsObject) {
int listLength=loi.getListLength(listOfInputsObject);
List<BitcoinTransactionInput> result = new ArrayList<>(listLength);
StructObjectInspector listOfInputsElementObjectInspector = (StructObjectInspector)loi.getListElementObjectInspector();
for (int i=0;i<listLength;i++) {
	Object currentlistofinputsObject = loi.getListElement(listOfInputsObject,i);
	StructField prevtransactionhashSF = listOfInputsElementObjectInspector.getStructFieldRef("prevtransactionhash");
	StructField previoustxoutindexSF = listOfInputsElementObjectInspector.getStructFieldRef("previoustxoutindex");
	StructField txinscriptlengthSF = listOfInputsElementObjectInspector.getStructFieldRef("txinscriptlength");
	StructField txinscriptSF = listOfInputsElementObjectInspector.getStructFieldRef("txinscript");
	StructField seqnoSF = listOfInputsElementObjectInspector.getStructFieldRef("seqno");
	boolean prevFieldsNull = (prevtransactionhashSF==null) || (previoustxoutindexSF==null);
	boolean inFieldsNull = (txinscriptlengthSF==null) || (txinscriptSF==null);
	boolean otherAttribNull = seqnoSF==null;
	if (prevFieldsNull || inFieldsNull  || otherAttribNull) {
		LOG.warn("Invalid BitcoinTransactionInput detected at position "+i);
		return new ArrayList<>();
	}
	byte[] currentPrevTransactionHash = wboi.getPrimitiveJavaObject(listOfInputsElementObjectInspector.getStructFieldData(currentlistofinputsObject,prevtransactionhashSF));
	long currentPreviousTxOutIndex = wloi.get(listOfInputsElementObjectInspector.getStructFieldData(currentlistofinputsObject,previoustxoutindexSF));
	byte[] currentTxInScriptLength= wboi.getPrimitiveJavaObject(listOfInputsElementObjectInspector.getStructFieldData(currentlistofinputsObject,txinscriptlengthSF));
	byte[] currentTxInScript= wboi.getPrimitiveJavaObject(listOfInputsElementObjectInspector.getStructFieldData(currentlistofinputsObject,txinscriptSF));
	long currentSeqNo = wloi.get(listOfInputsElementObjectInspector.getStructFieldData(currentlistofinputsObject,seqnoSF));
	BitcoinTransactionInput currentBitcoinTransactionInput = new BitcoinTransactionInput(currentPrevTransactionHash,currentPreviousTxOutIndex,currentTxInScriptLength,currentTxInScript,currentSeqNo);
	result.add(currentBitcoinTransactionInput);
}
return result;
}
 
开发者ID:ZuInnoTe,项目名称:hadoopcryptoledger,代码行数:39,代码来源:BitcoinTransactionHashUDF.java

示例11: readListOfBitcoinScriptWitnessFromTable

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

private List<BitcoinScriptWitnessItem> readListOfBitcoinScriptWitnessFromTable(ListObjectInspector loi, Object listOfScriptWitnessItemObject) {
int listLength=loi.getListLength(listOfScriptWitnessItemObject);
List<BitcoinScriptWitnessItem> result = new ArrayList<>(listLength);
StructObjectInspector listOfScriptwitnessItemElementObjectInspector = (StructObjectInspector)loi.getListElementObjectInspector();
for (int i=0;i<listLength;i++) {
	Object currentlistofscriptwitnessitemObject = loi.getListElement(listOfScriptWitnessItemObject,i);
	StructField stackitemcounterSF = listOfScriptwitnessItemElementObjectInspector.getStructFieldRef("stackitemcounter");
	StructField scriptwitnesslistSF = listOfScriptwitnessItemElementObjectInspector.getStructFieldRef("scriptwitnesslist");
	boolean scriptwitnessitemNull = (stackitemcounterSF==null) || (scriptwitnesslistSF==null) ; 
	if (scriptwitnessitemNull) {
		LOG.warn("Invalid BitcoinScriptWitnessItem detected at position "+i);
		return new ArrayList<>();
	}
	byte[] stackItemCounter = wboi.getPrimitiveJavaObject(listOfScriptwitnessItemElementObjectInspector.getStructFieldData(currentlistofscriptwitnessitemObject,stackitemcounterSF));
	Object listofscriptwitnessObject =  soi.getStructFieldData(currentlistofscriptwitnessitemObject,scriptwitnesslistSF);
	ListObjectInspector loiScriptWitness=(ListObjectInspector)scriptwitnesslistSF.getFieldObjectInspector();
	StructObjectInspector listOfScriptwitnessElementObjectInspector = (StructObjectInspector)loiScriptWitness.getListElementObjectInspector();
	int listWitnessLength = 	loiScriptWitness.getListLength(listofscriptwitnessObject);
	List<BitcoinScriptWitness> currentScriptWitnessList = new ArrayList<>(listWitnessLength);
	for (int j=0;j<listWitnessLength;j++) {
		Object currentlistofscriptwitnessObject = loi.getListElement(listofscriptwitnessObject,j);
		
		StructField witnessscriptlengthSF = listOfScriptwitnessElementObjectInspector.getStructFieldRef("witnessscriptlength");
		StructField witnessscriptSF = listOfScriptwitnessElementObjectInspector.getStructFieldRef("witnessscript");
		boolean scriptwitnessNull = (witnessscriptlengthSF==null)  || (witnessscriptSF==null);
		if (scriptwitnessNull) {
			LOG.warn("Invalid BitcoinScriptWitness detected at position "+j+ "for BitcoinScriptWitnessItem "+i);
			return new ArrayList<>();
		}
		byte[] scriptWitnessLength = wboi.getPrimitiveJavaObject(listOfScriptwitnessElementObjectInspector.getStructFieldData(currentlistofscriptwitnessObject,witnessscriptlengthSF));
		byte[] scriptWitness = wboi.getPrimitiveJavaObject(listOfScriptwitnessElementObjectInspector.getStructFieldData(currentlistofscriptwitnessObject,witnessscriptSF));
		currentScriptWitnessList.add(new BitcoinScriptWitness(scriptWitnessLength,scriptWitness));
	}
	BitcoinScriptWitnessItem currentBitcoinScriptWitnessItem = new BitcoinScriptWitnessItem(stackItemCounter,currentScriptWitnessList);
	result.add(currentBitcoinScriptWitnessItem);
}
return result;
}
 
开发者ID:ZuInnoTe,项目名称:hadoopcryptoledger,代码行数:49,代码来源:BitcoinTransactionHashSegwitUDF.java

示例12: iterate

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入方法依赖的package包/类
void iterate(final double Wj, final double Xj, @Nonnull final Object Vif,
        @Nonnull final ListObjectInspector vOI,
        @Nonnull final PrimitiveObjectInspector vElemOI) throws HiveException {
    this.ret += (Wj * Xj);

    final int factors = vOI.getListLength(Vif);
    if (factors < 1) {
        throw new HiveException("# of Factor should be more than 0: " + factors);
    }

    if (sumVjXj == null) {
        this.sumVjXj = new double[factors];
        this.sumV2X2 = new double[factors];
    } else if (sumVjXj.length != factors) {
        throw new HiveException("Mismatch in the number of factors");
    }

    for (int f = 0; f < factors; f++) {
        Object o = vOI.getListElement(Vif, f);
        if (o == null) {
            throw new HiveException("Vj" + f + " should not be null");
        }
        double v = PrimitiveObjectInspectorUtils.getDouble(o, vElemOI);
        double vx = v * Xj;

        sumVjXj[f] += vx;
        sumV2X2[f] += (vx * vx);
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:30,代码来源:FMPredictGenericUDAF.java

示例13: parseFeatures

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入方法依赖的package包/类
@Nullable
public static Feature[] parseFeatures(@Nonnull final Object arg,
        @Nonnull final ListObjectInspector listOI, @Nullable final Feature[] probes,
        final boolean asIntFeature) throws HiveException {
    if (arg == null) {
        return null;
    }

    final int length = listOI.getListLength(arg);
    final Feature[] ary;
    if (probes != null && probes.length == length) {
        ary = probes;
    } else {
        ary = new Feature[length];
    }

    int j = 0;
    for (int i = 0; i < length; i++) {
        Object o = listOI.getListElement(arg, i);
        if (o == null) {
            continue;
        }
        String s = o.toString();
        Feature f = ary[j];
        if (f == null) {
            f = parseFeature(s, asIntFeature);
        } else {
            parseFeature(s, f, asIntFeature);
        }
        ary[j] = f;
        j++;
    }
    if (j == length) {
        return ary;
    } else {
        Feature[] dst = new Feature[j];
        System.arraycopy(ary, 0, dst, 0, j);
        return dst;
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:41,代码来源:Feature.java

示例14: parseFFMFeatures

import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; //导入方法依赖的package包/类
@Nullable
public static Feature[] parseFFMFeatures(@Nonnull final Object arg,
        @Nonnull final ListObjectInspector listOI, @Nullable final Feature[] probes,
        final int numFeatures, final int numFields) throws HiveException {
    if (arg == null) {
        return null;
    }

    final int length = listOI.getListLength(arg);
    final Feature[] ary;
    if (probes != null && probes.length == length) {
        ary = probes;
    } else {
        ary = new Feature[length];
    }

    int j = 0;
    for (int i = 0; i < length; i++) {
        Object o = listOI.getListElement(arg, i);
        if (o == null) {
            continue;
        }
        String s = o.toString();
        Feature f = ary[j];
        if (f == null) {
            f = parseFFMFeature(s, numFeatures, numFields);
        } else {
            parseFFMFeature(s, f, numFeatures, numFields);
        }
        ary[j] = f;
        j++;
    }
    if (j == length) {
        return ary;
    } else {
        Feature[] dst = new Feature[j];
        System.arraycopy(ary, 0, dst, 0, j);
        return dst;
    }
}
 
开发者ID:apache,项目名称:incubator-hivemall,代码行数:41,代码来源:Feature.java


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