Search in sources :

Example 1 with EWAHCompressedBitmap

use of javaewah.EWAHCompressedBitmap in project hive by apache.

the class GenericUDFEWAHBitmapEmpty method evaluate.

@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
    assert (arguments.length == 1);
    Object b = arguments[0].get();
    ListObjectInspector lloi = (ListObjectInspector) bitmapOI;
    int length = lloi.getListLength(b);
    ArrayList<LongWritable> bitmapArray = new ArrayList<LongWritable>();
    for (int i = 0; i < length; i++) {
        long l = PrimitiveObjectInspectorUtils.getLong(lloi.getListElement(b, i), (PrimitiveObjectInspector) lloi.getListElementObjectInspector());
        bitmapArray.add(new LongWritable(l));
    }
    BitmapObjectInput bitmapObjIn = new BitmapObjectInput(bitmapArray);
    EWAHCompressedBitmap bitmap = new EWAHCompressedBitmap();
    try {
        bitmap.readExternal(bitmapObjIn);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    // Add return true only if bitmap is all zeros.
    return new BooleanWritable(!bitmap.iterator().hasNext());
}
Also used : BitmapObjectInput(org.apache.hadoop.hive.ql.index.bitmap.BitmapObjectInput) BooleanWritable(org.apache.hadoop.io.BooleanWritable) ListObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector) EWAHCompressedBitmap(javaewah.EWAHCompressedBitmap) ArrayList(java.util.ArrayList) LongWritable(org.apache.hadoop.io.LongWritable) IOException(java.io.IOException)

Example 2 with EWAHCompressedBitmap

use of javaewah.EWAHCompressedBitmap in project hive by apache.

the class AbstractGenericUDFEWAHBitmapBop method wordArrayToBitmap.

protected EWAHCompressedBitmap wordArrayToBitmap(Object b) {
    ListObjectInspector lloi = (ListObjectInspector) b1OI;
    int length = lloi.getListLength(b);
    ArrayList<LongWritable> bitmapArray = new ArrayList<LongWritable>();
    for (int i = 0; i < length; i++) {
        long l = PrimitiveObjectInspectorUtils.getLong(lloi.getListElement(b, i), (PrimitiveObjectInspector) lloi.getListElementObjectInspector());
        bitmapArray.add(new LongWritable(l));
    }
    BitmapObjectInput bitmapObjIn = new BitmapObjectInput(bitmapArray);
    EWAHCompressedBitmap bitmap = new EWAHCompressedBitmap();
    try {
        bitmap.readExternal(bitmapObjIn);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return bitmap;
}
Also used : BitmapObjectInput(org.apache.hadoop.hive.ql.index.bitmap.BitmapObjectInput) ListObjectInspector(org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector) EWAHCompressedBitmap(javaewah.EWAHCompressedBitmap) ArrayList(java.util.ArrayList) LongWritable(org.apache.hadoop.io.LongWritable) IOException(java.io.IOException)

Example 3 with EWAHCompressedBitmap

use of javaewah.EWAHCompressedBitmap in project hive by apache.

the class AbstractGenericUDFEWAHBitmapBop method evaluate.

@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
    assert (arguments.length == 2);
    Object b1 = arguments[0].get();
    Object b2 = arguments[1].get();
    EWAHCompressedBitmap bitmap1 = wordArrayToBitmap(b1);
    EWAHCompressedBitmap bitmap2 = wordArrayToBitmap(b2);
    EWAHCompressedBitmap bitmapAnd = bitmapBop(bitmap1, bitmap2);
    BitmapObjectOutput bitmapObjOut = new BitmapObjectOutput();
    try {
        bitmapAnd.writeExternal(bitmapObjOut);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    ret.clear();
    List<LongWritable> retList = bitmapToWordArray(bitmapAnd);
    for (LongWritable l : retList) {
        ret.add(l);
    }
    return ret;
}
Also used : BitmapObjectOutput(org.apache.hadoop.hive.ql.index.bitmap.BitmapObjectOutput) EWAHCompressedBitmap(javaewah.EWAHCompressedBitmap) IOException(java.io.IOException) LongWritable(org.apache.hadoop.io.LongWritable)

Aggregations

IOException (java.io.IOException)3 EWAHCompressedBitmap (javaewah.EWAHCompressedBitmap)3 LongWritable (org.apache.hadoop.io.LongWritable)3 ArrayList (java.util.ArrayList)2 BitmapObjectInput (org.apache.hadoop.hive.ql.index.bitmap.BitmapObjectInput)2 ListObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector)2 BitmapObjectOutput (org.apache.hadoop.hive.ql.index.bitmap.BitmapObjectOutput)1 BooleanWritable (org.apache.hadoop.io.BooleanWritable)1