@Override
  public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments[0].getCategory() != Category.PRIMITIVE) {
      throw new UDFArgumentTypeException(0,
          "ndv_compute_bitvector input only takes primitive types, got " + arguments[0].getTypeName());
    }
    PrimitiveObjectInspector objectInspector = (PrimitiveObjectInspector) arguments[0];
    if (objectInspector.getPrimitiveCategory() != PrimitiveCategory.BINARY) {
      throw new UDFArgumentTypeException(0,
          "ndv_compute_bitvector input only takes BINARY type, got " + arguments[0].getTypeName());
    }
    inputOI = (BinaryObjectInspector) arguments[0];
    return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
  }
GenericUDFNDVComputeBitVector. The ndv_compute_bit_vector function can be used on top of
compute_bit_vector aggregate function to extract an estimate of the ndv from it.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFNDVComputeBitVector.java