@Override
  public Object evaluate(DeferredObject[] arguments) throws HiveException {
    if (arguments[0] == null) {
      return null;
    }
    Object input = arguments[0].get();
    if (input == null) {
      return null;
    }

    byte[] buf = inputOI.getPrimitiveJavaObject(input);
    if (buf == null || buf.length == 0) {
      return null;
    }
    NumDistinctValueEstimator numDV =
        NumDistinctValueEstimatorFactory.getNumDistinctValueEstimator(buf);
    result.set(numDV.estimateNumDistinctValues());
    return result;
  }
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