Package org.apache.drill.exec.ref.values

Examples of org.apache.drill.exec.ref.values.NumericValue


     
      for(int i =0; i < args.length; i++){
        final DataValue v = args[i].eval();
//        logger.debug("DataValue {}", v);
        if(Types.isNumericType(v.getDataType())){
          NumericValue n = v.getAsNumeric();
          NumericType nt = n.getNumericType();
//          logger.debug("Numeric Type: {}", nt);
          if(isFloating || nt == NumericType.FLOAT || nt == NumericType.DOUBLE){
            if(!isFloating){
              d = l;
              isFloating = true;
            }
            d *= n.getAsDouble();
          }else{
            l *= n.getAsLong();
          }
         
        }else{
          throw new RecordException(String.format("Unable to multiply a value of  %s.", v), null);
        }
      }
     
      NumericValue out = null;
      if(isFloating){
        out = new ScalarValues.DoubleScalar(d);
      }else{
        out = new ScalarValues.LongScalar(l);
      }
View Full Code Here


  }

  @Override
  public void addRecord() {
    DataValue dv = child.eval();
    NumericValue v = dv.getAsNumeric();
    if (integer) {
     
      switch (v.getNumericType()) {
      case DOUBLE:
      case FLOAT:
        integer = false;
        d = l; // loss of precision
        d += v.getAsDouble();
        break;
      case INT:
      case LONG:
        l += v.getAsLong();
        return;
      default:
        throw new UnsupportedOperationException();
      }
    }else{
      switch (v.getNumericType()) {
      case DOUBLE:
      case FLOAT:
      case INT:
      case LONG:
        integer = false;
        d += v.getAsDouble();
        return;
      default:
        throw new UnsupportedOperationException();
      }
     
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.ref.values.NumericValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.