use of org.apache.hadoop.hive.ql.index.bitmap.BitmapObjectInput 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());
}
use of org.apache.hadoop.hive.ql.index.bitmap.BitmapObjectInput 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;
}
Aggregations