public boolean isOverflow()

in tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/UniformRangePartition.java [122:206]


  public boolean isOverflow(int colId, Datum last, BigDecimal inc, SortSpec [] sortSpecs) {
    Column column = sortSpecs[colId].getSortKey();
    BigDecimal candidate;
    boolean overflow = false;

    switch (column.getDataType().getType()) {
      case BIT: {
        if (sortSpecs[colId].isAscending()) {
          candidate = inc.add(new BigDecimal(last.asByte()));
          return new BigDecimal(range.getEnd().get(colId).asByte()).compareTo(candidate) < 0;
        } else {
          candidate = new BigDecimal(last.asByte()).subtract(inc);
          return candidate.compareTo(new BigDecimal(range.getEnd().get(colId).asByte())) < 0;
        }
      }
      case CHAR: {
        if (sortSpecs[colId].isAscending()) {
          candidate = inc.add(new BigDecimal((int)last.asChar()));
          return new BigDecimal((int)range.getEnd().get(colId).asChar()).compareTo(candidate) < 0;
        } else {
          candidate = new BigDecimal((int)last.asChar()).subtract(inc);
          return candidate.compareTo(new BigDecimal((int)range.getEnd().get(colId).asChar())) < 0;
        }
      }
      case INT2: {
        if (sortSpecs[colId].isAscending()) {
          candidate = inc.add(new BigDecimal(last.asInt2()));
          return new BigDecimal(range.getEnd().get(colId).asInt2()).compareTo(candidate) < 0;
        } else {
          candidate = new BigDecimal(last.asInt2()).subtract(inc);
          return candidate.compareTo(new BigDecimal(range.getEnd().get(colId).asInt2())) < 0;
        }
      }
      case DATE:
      case INT4: {
        if (sortSpecs[colId].isAscending()) {
          candidate = inc.add(new BigDecimal(last.asInt4()));
          return new BigDecimal(range.getEnd().get(colId).asInt4()).compareTo(candidate) < 0;
        } else {
          candidate = new BigDecimal(last.asInt4()).subtract(inc);
          return candidate.compareTo(new BigDecimal(range.getEnd().get(colId).asInt4())) < 0;
        }
      }
      case TIME:
      case TIMESTAMP:
      case INT8: {
        if (sortSpecs[colId].isAscending()) {
          candidate = inc.add(new BigDecimal(last.asInt8()));
          return new BigDecimal(range.getEnd().get(colId).asInt8()).compareTo(candidate) < 0;
        } else {
          candidate = new BigDecimal(last.asInt8()).subtract(inc);
          return candidate.compareTo(new BigDecimal(range.getEnd().get(colId).asInt8())) < 0;
        }
      }
      case FLOAT4: {
        if (sortSpecs[colId].isAscending()) {
          candidate = inc.add(new BigDecimal(last.asFloat4()));
          return new BigDecimal(range.getEnd().get(colId).asFloat4()).compareTo(candidate) < 0;
        } else {
          candidate = new BigDecimal(last.asFloat4()).subtract(inc);
          return candidate.compareTo(new BigDecimal(range.getEnd().get(colId).asFloat4())) < 0;
        }
      }
      case FLOAT8: {
        if (sortSpecs[colId].isAscending()) {
          candidate = inc.add(new BigDecimal(last.asFloat8()));
          return new BigDecimal(range.getEnd().get(colId).asFloat8()).compareTo(candidate) < 0;
        } else {
          candidate = new BigDecimal(last.asFloat8()).subtract(inc);
          return candidate.compareTo(new BigDecimal(range.getEnd().get(colId).asFloat8())) < 0;
        }

      }
      case TEXT: {
        if (sortSpecs[colId].isAscending()) {
          candidate = inc.add(new BigDecimal((int)(last.asChars().charAt(0))));
          return new BigDecimal(range.getEnd().get(colId).asChars().charAt(0)).compareTo(candidate) < 0;
        } else {
          candidate = new BigDecimal((int)(last.asChars().charAt(0))).subtract(inc);
          return candidate.compareTo(new BigDecimal(range.getEnd().get(colId).asChars().charAt(0))) < 0;
        }
      }
    }
    return overflow;
  }