/** * It computes the value cardinality of a tuple range. * * @return */ public static BigDecimal computeCardinalityForAllColumns( Schema schema, TupleRange range, boolean inclusive) { Tuple start = range.getStart(); Tuple end = range.getEnd(); Column col; BigDecimal cardinality = new BigDecimal(1); BigDecimal columnCard; for (int i = 0; i < schema.getColumnNum(); i++) { col = schema.getColumn(i); columnCard = computeCardinality(col.getDataType(), start.get(i), end.get(i), inclusive); if (new BigDecimal(0).compareTo(columnCard) < 0) { cardinality = cardinality.multiply(columnCard); } } return cardinality; }
@Override public int compare(TupleRange left, TupleRange right) { return -(left.compareTo(right)); }