/**
   * @param auop
   * @param mb
   * @return
   * @throws DMLRuntimeException
   */
  private static double replaceUnaryAggregate(AggUnaryOp auop, MatrixBlock mb)
      throws DMLRuntimeException {
    // setup stats reporting if necessary
    boolean REPORT_STATS = (DMLScript.STATISTICS && REPORT_LITERAL_REPLACE_OPS_STATS);
    long t0 = REPORT_STATS ? System.nanoTime() : 0;

    // compute required unary aggregate
    double val = Double.MAX_VALUE;
    switch (auop.getOp()) {
      case SUM:
        val = mb.sum();
        break;
      case SUM_SQ:
        val = mb.sumSq();
        break;
      case MIN:
        val = mb.min();
        break;
      case MAX:
        val = mb.max();
        break;
      default:
        throw new DMLRuntimeException("Unsupported unary aggregate replacement: " + auop.getOp());
    }

    // report statistics if necessary
    if (REPORT_STATS) {
      long t1 = System.nanoTime();
      Statistics.maintainCPHeavyHitters("rlit", t1 - t0);
    }

    return val;
  }
Esempio n. 2
0
  @Override
  public boolean compare(Hop that) {
    if (!(that instanceof AggUnaryOp)) return false;

    AggUnaryOp that2 = (AggUnaryOp) that;
    return (_op == that2._op
        && _direction == that2._direction
        && _maxNumThreads == that2._maxNumThreads
        && getInput().get(0) == that2.getInput().get(0));
  }
  /**
   * @param auop
   * @return
   */
  private static boolean isReplaceableUnaryAggregate(AggUnaryOp auop) {
    boolean cdir = (auop.getDirection() == Direction.RowCol);
    boolean cop =
        (auop.getOp() == AggOp.SUM
            || auop.getOp() == AggOp.SUM_SQ
            || auop.getOp() == AggOp.MIN
            || auop.getOp() == AggOp.MAX);

    return cdir && cop;
  }
Esempio n. 4
0
  @Override
  public Object clone() throws CloneNotSupportedException {
    AggUnaryOp ret = new AggUnaryOp();

    // copy generic attributes
    ret.clone(this, false);

    // copy specific attributes
    ret._op = _op;
    ret._direction = _direction;
    ret._maxNumThreads = _maxNumThreads;

    return ret;
  }