Java Code Examples for org.apache.hadoop.hive.serde2.objectinspector.StandardListObjectInspector#getListElement()

The following examples show how to use org.apache.hadoop.hive.serde2.objectinspector.StandardListObjectInspector#getListElement() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
void merge(int size, @Nonnull Object posterioriObj,
        @Nonnull StandardListObjectInspector posterioriOI) throws HiveException {

    if (size != _k) {
        if (_k == -1) {
            this._k = size;
            this._posteriori = new double[size];
        } else {
            throw new HiveException(
                "Mismatch in the number of elements: _k=" + _k + ", size=" + size);
        }
    }

    final double[] posteriori = _posteriori;
    final DoubleObjectInspector doubleOI =
            PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    for (int i = 0, len = _k; i < len; i++) {
        Object o2 = posterioriOI.getListElement(posterioriObj, i);
        posteriori[i] += doubleOI.get(o2);
    }
}
 
Example 2
void merge(final int o_size, @Nonnull final Object o_sum, @Nonnull final Object o_count,
        @Nonnull final StandardListObjectInspector sumOI,
        @Nonnull final StandardListObjectInspector countOI) throws HiveException {
    final WritableDoubleObjectInspector sumElemOI =
            PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    final WritableLongObjectInspector countElemOI =
            PrimitiveObjectInspectorFactory.writableLongObjectInspector;

    if (o_size != _size) {
        if (_size == -1) {
            init(o_size);
        } else {
            throw new HiveException("Mismatch in the number of elements");
        }
    }
    final double[] sum = _sum;
    final long[] count = _count;
    for (int i = 0, len = _size; i < len; i++) {
        Object sum_e = sumOI.getListElement(o_sum, i);
        sum[i] += sumElemOI.get(sum_e);
        Object count_e = countOI.getListElement(o_count, i);
        count[i] += countElemOI.get(count_e);
    }
}
 
Example 3
void merge(final double o_ret, @Nullable final Object o_sumVjXj,
        @Nullable final Object o_sumV2X2,
        @Nonnull final StandardListObjectInspector sumVjXjOI,
        @Nonnull final StandardListObjectInspector sumV2X2OI) throws HiveException {
    this.ret += o_ret;
    if (o_sumVjXj == null) {
        return;
    }

    if (o_sumV2X2 == null) {//sanity check
        throw new HiveException("o_sumV2X2 should not be null");
    }

    final int factors = sumVjXjOI.getListLength(o_sumVjXj);
    if (sumVjXj == null) {
        this.sumVjXj = new double[factors];
        this.sumV2X2 = new double[factors];
    } else if (sumVjXj.length != factors) {//sanity check
        throw new HiveException("Mismatch in the number of factors");
    }

    final WritableDoubleObjectInspector doubleOI =
            PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
    for (int f = 0; f < factors; f++) {
        Object o1 = sumVjXjOI.getListElement(o_sumVjXj, f);
        Object o2 = sumV2X2OI.getListElement(o_sumV2X2, f);
        double d1 = doubleOI.get(o1);
        double d2 = doubleOI.get(o2);
        sumVjXj[f] += d1;
        sumV2X2[f] += d2;
    }
}