Search in sources :

Example 6 with FastBitSet

use of javolution.util.FastBitSet in project hive by apache.

the class GroupByOperator method process.

@Override
public void process(Object row, int tag) throws HiveException {
    firstRow = false;
    ObjectInspector rowInspector = inputObjInspectors[0];
    // Total number of input rows is needed for hash aggregation only
    if (hashAggr) {
        numRowsInput++;
        // if hash aggregation is not behaving properly, disable it
        if (numRowsInput == numRowsCompareHashAggr) {
            numRowsCompareHashAggr += groupbyMapAggrInterval;
            long numRowsProcessed = groupingSetsPresent ? numRowsInput * groupingSets.size() : numRowsInput;
            // map-side aggregation should reduce the entries by at-least half
            if (numRowsHashTbl > numRowsProcessed * minReductionHashAggr) {
                LOG.warn("Disable Hash Aggr: #hash table = " + numRowsHashTbl + " #numRowsInput = " + numRowsInput + " reduction = " + 1.0 * (numRowsHashTbl / numRowsProcessed) + " minReduction = " + minReductionHashAggr + " groupingSetsPresent = " + groupingSetsPresent + " numRowsProcessed = " + numRowsProcessed);
                flushHashTable(true);
                hashAggr = false;
            } else {
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Hash Aggr Enabled: #hash table = " + numRowsHashTbl + " #numRowsInput = " + numRowsInput + " reduction = " + 1.0 * (numRowsHashTbl / numRowsProcessed) + " minReduction = " + minReductionHashAggr + " groupingSetsPresent = " + groupingSetsPresent + " numRowsProcessed = " + numRowsProcessed);
                }
            }
        }
    }
    try {
        countAfterReport++;
        newKeys.getNewKey(row, rowInspector);
        if (groupingSetsPresent) {
            Object[] newKeysArray = newKeys.getKeyArray();
            Object[] cloneNewKeysArray = new Object[newKeysArray.length];
            System.arraycopy(newKeysArray, 0, cloneNewKeysArray, 0, groupingSetsPosition);
            for (int groupingSetPos = 0; groupingSetPos < groupingSets.size(); groupingSetPos++) {
                Arrays.fill(newKeysArray, 0, groupingSetsPosition, null);
                FastBitSet bitset = groupingSetsBitSet[groupingSetPos];
                // Some keys need to be left to null corresponding to that grouping set.
                for (int keyPos = bitset.nextClearBit(0); keyPos < groupingSetsPosition; keyPos = bitset.nextClearBit(keyPos + 1)) {
                    newKeysArray[keyPos] = cloneNewKeysArray[keyPos];
                }
                newKeysArray[groupingSetsPosition] = newKeysGroupingSets[groupingSetPos];
                processKey(row, rowInspector);
            }
        } else {
            processKey(row, rowInspector);
        }
    } catch (HiveException e) {
        throw e;
    } catch (Exception e) {
        throw new HiveException(e);
    }
}
Also used : ObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector) StructObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector) LazyStringObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive.LazyStringObjectInspector) LazyBinaryObjectInspector(org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive.LazyBinaryObjectInspector) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) UnionObject(org.apache.hadoop.hive.serde2.objectinspector.UnionObject) FastBitSet(javolution.util.FastBitSet) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException)

Example 7 with FastBitSet

use of javolution.util.FastBitSet in project hive by apache.

the class FMSketchUtils method readBitVector.

private static FastBitSet readBitVector(InputStream in) throws IOException {
    FastBitSet fastBitSet = new FastBitSet();
    fastBitSet.clear();
    for (int i = 0; i < 4; i++) {
        byte b = (byte) in.read();
        for (int j = 0; j < 8; j++) {
            if ((b & (1 << j)) != 0) {
                fastBitSet.set(j + 8 * i);
            }
        }
    }
    return fastBitSet;
}
Also used : FastBitSet(javolution.util.FastBitSet)

Aggregations

FastBitSet (javolution.util.FastBitSet)7 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)2 LazyBinaryObjectInspector (org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive.LazyBinaryObjectInspector)2 LazyStringObjectInspector (org.apache.hadoop.hive.serde2.lazy.objectinspector.primitive.LazyStringObjectInspector)2 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)2 ManagementFactory (java.lang.management.ManagementFactory)1 MemoryMXBean (java.lang.management.MemoryMXBean)1 Field (java.lang.reflect.Field)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Configuration (org.apache.hadoop.conf.Configuration)1 TimestampTZ (org.apache.hadoop.hive.common.type.TimestampTZ)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1