in tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/RangePartitionAlgorithm.java [58:149]
public static BigDecimal computeCardinality(DataType dataType, Datum start, Datum end,
boolean inclusive, boolean isAscending) {
BigDecimal columnCard;
switch (dataType.getType()) {
case BOOLEAN:
columnCard = new BigDecimal(2);
break;
case CHAR:
if (isAscending) {
columnCard = new BigDecimal(end.asChar() - start.asChar());
} else {
columnCard = new BigDecimal(start.asChar() - end.asChar());
}
break;
case BIT:
if (isAscending) {
columnCard = new BigDecimal(end.asByte() - start.asByte());
} else {
columnCard = new BigDecimal(start.asByte() - end.asByte());
}
break;
case INT2:
if (isAscending) {
columnCard = new BigDecimal(end.asInt2() - start.asInt2());
} else {
columnCard = new BigDecimal(start.asInt2() - end.asInt2());
}
break;
case INT4:
if (isAscending) {
columnCard = new BigDecimal(end.asInt4() - start.asInt4());
} else {
columnCard = new BigDecimal(start.asInt4() - end.asInt4());
}
break;
case INT8:
if (isAscending) {
columnCard = new BigDecimal(end.asInt8() - start.asInt8());
} else {
columnCard = new BigDecimal(start.asInt8() - end.asInt8());
}
break;
case FLOAT4:
if (isAscending) {
columnCard = new BigDecimal(end.asInt4() - start.asInt4());
} else {
columnCard = new BigDecimal(start.asInt4() - end.asInt4());
}
break;
case FLOAT8:
if (isAscending) {
columnCard = new BigDecimal(end.asInt8() - start.asInt8());
} else {
columnCard = new BigDecimal(start.asInt8() - end.asInt8());
}
break;
case TEXT:
if (isAscending) {
columnCard = new BigDecimal(end.asChars().charAt(0) - start.asChars().charAt(0));
} else {
columnCard = new BigDecimal(start.asChars().charAt(0) - end.asChars().charAt(0));
}
break;
case DATE:
if (isAscending) {
columnCard = new BigDecimal(end.asInt4() - start.asInt4());
} else {
columnCard = new BigDecimal(start.asInt4() - end.asInt4());
}
break;
case TIME:
case TIMESTAMP:
if (isAscending) {
columnCard = new BigDecimal(end.asInt8() - start.asInt8());
} else {
columnCard = new BigDecimal(start.asInt8() - end.asInt8());
}
break;
case INET4:
if (isAscending) {
columnCard = new BigDecimal(end.asInt4() - start.asInt4());
} else {
columnCard = new BigDecimal(start.asInt4() - end.asInt4());
}
break;
default:
throw new UnsupportedOperationException(dataType + " is not supported yet");
}
return inclusive ? columnCard.add(new BigDecimal(1)) : columnCard;
}