Package org.apache.hadoop.hive.metastore.api

Examples of org.apache.hadoop.hive.metastore.api.Decimal


    }
  }

  private static Decimal createThriftDecimal(String s) {
    BigDecimal d = new BigDecimal(s);
    return new Decimal(ByteBuffer.wrap(d.unscaledValue().toByteArray()), (short)d.scale());
  }
View Full Code Here


      statsObj.getStatsData().getDecimalStats().setLowValue(convertToThriftDecimal(d));
    }
  }

  private Decimal convertToThriftDecimal(HiveDecimal d) {
    return new Decimal(ByteBuffer.wrap(d.unscaledValue().toByteArray()), (short)d.scale());
  }
View Full Code Here

    }
  }

  private static Decimal createThriftDecimal(String s) {
    BigDecimal d = new BigDecimal(s);
    return new Decimal(ByteBuffer.wrap(d.unscaledValue().toByteArray()), (short)d.scale());
  }
View Full Code Here

      cs.setAvgColLen(JavaDataModel.get().lengthOfTimestamp());
    } else if (colType.startsWith(serdeConstants.DECIMAL_TYPE_NAME)) {
      cs.setAvgColLen(JavaDataModel.get().lengthOfDecimal());
      cs.setCountDistint(csd.getDecimalStats().getNumDVs());
      cs.setNumNulls(csd.getDecimalStats().getNumNulls());
      Decimal val = csd.getDecimalStats().getHighValue();
      BigDecimal maxVal = HiveDecimal.
          create(new BigInteger(val.getUnscaled()), val.getScale()).bigDecimalValue();
      val = csd.getDecimalStats().getLowValue();
      BigDecimal minVal = HiveDecimal.
          create(new BigInteger(val.getUnscaled()), val.getScale()).bigDecimalValue();
      cs.setRange(minVal, maxVal);
    } else if (colType.equalsIgnoreCase(serdeConstants.DATE_TYPE_NAME)) {
      cs.setAvgColLen(JavaDataModel.get().lengthOfDate());
    } else {
      // Columns statistics for complex datatypes are not supported yet
View Full Code Here

      statsObj.getStatsData().getDecimalStats().setLowValue(convertToThriftDecimal(d));
    }
  }

  private Decimal convertToThriftDecimal(HiveDecimal d) {
    return new Decimal(ByteBuffer.wrap(d.unscaledValue().toByteArray()), (short)d.scale());
  }
View Full Code Here

          decimalStats.setNumNulls(Long.parseLong(value));
        } else if (fName.equals("numDVs")) {
          decimalStats.setNumDVs(Long.parseLong(value));
        } else if (fName.equals("lowValue")) {
          BigDecimal d = new BigDecimal(value);
          decimalStats.setLowValue(new Decimal(ByteBuffer.wrap(d
              .unscaledValue().toByteArray()), (short) d.scale()));
        } else if (fName.equals("highValue")) {
          BigDecimal d = new BigDecimal(value);
          decimalStats.setHighValue(new Decimal(ByteBuffer.wrap(d
              .unscaledValue().toByteArray()), (short) d.scale()));
        } else {
          throw new SemanticException("Unknown stat");
        }
      }
View Full Code Here

              * (rightBorderInd - minInd) / (maxInd - minInd)));
        } else if (colStatTypes[colStatIndex] == ColStatType.Double) {
          return (Double) ((Double) min[0] + (((Double) max[0] - (Double) min[0])
              * (rightBorderInd - minInd) / (maxInd - minInd)));
        } else {
          Decimal dmax = (Decimal) max[0];
          BigDecimal bdmax = new BigDecimal(dmax.toString());
          double doublemax = bdmax.doubleValue();
          Decimal dmin = (Decimal) min[0];
          BigDecimal bdmin = new BigDecimal(dmin.toString());
          double doublemin = bdmin.doubleValue();
          double ret = doublemin + (doublemax - doublemin)
              * (rightBorderInd - minInd) / (maxInd - minInd);
          return createThriftDecimal(String.valueOf(ret));
        }
      } else {
        // left border is the max
        if (colStatTypes[colStatIndex] == ColStatType.Long) {
          return (Long) ((Long) min[0] + ((Long) max[0] - (Long) min[0])
              * minInd / (minInd - maxInd));
        } else if (colStatTypes[colStatIndex] == ColStatType.Double) {
          return (Double) ((Double) min[0] + ((Double) max[0] - (Double) min[0])
              * minInd / (maxInd - minInd));
        } else {
          Decimal dmax = (Decimal) max[0];
          BigDecimal bdmax = new BigDecimal(dmax.toString());
          double doublemax = bdmax.doubleValue();
          Decimal dmin = (Decimal) min[0];
          BigDecimal bdmin = new BigDecimal(dmin.toString());
          double doublemin = bdmin.doubleValue();
          double ret = doublemin + (doublemax - doublemin) * minInd
              / (maxInd - minInd);
          return createThriftDecimal(String.valueOf(ret));
        }
      }
    } else {
      if (minInd < maxInd) {
        // left border is the min
        if (colStatTypes[colStatIndex] == ColStatType.Long) {
          Long ret = (Long) max[0] - ((Long) max[0] - (Long) min[0]) * maxInd
              / (maxInd - minInd);
          return ret;
        } else if (colStatTypes[colStatIndex] == ColStatType.Double) {
          Double ret = (Double) max[0] - ((Double) max[0] - (Double) min[0])
              * maxInd / (maxInd - minInd);
          return ret;
        } else {
          Decimal dmax = (Decimal) max[0];
          BigDecimal bdmax = new BigDecimal(dmax.toString());
          double doublemax = bdmax.doubleValue();
          Decimal dmin = (Decimal) min[0];
          BigDecimal bdmin = new BigDecimal(dmin.toString());
          double doublemin = bdmin.doubleValue();
          double ret = doublemax - (doublemax - doublemin) * maxInd
              / (maxInd - minInd);
          return createThriftDecimal(String.valueOf(ret));

        }
      } else {
        // right border is the min
        if (colStatTypes[colStatIndex] == ColStatType.Long) {
          Long ret = (Long) max[0] - ((Long) max[0] - (Long) min[0])
              * (rightBorderInd - maxInd) / (minInd - maxInd);
          return ret;
        } else if (colStatTypes[colStatIndex] == ColStatType.Double) {
          Double ret = (Double) max[0] - ((Double) max[0] - (Double) min[0])
              * (rightBorderInd - maxInd) / (minInd - maxInd);
          return ret;
        } else {
          Decimal dmax = (Decimal) max[0];
          BigDecimal bdmax = new BigDecimal(dmax.toString());
          double doublemax = bdmax.doubleValue();
          Decimal dmin = (Decimal) min[0];
          BigDecimal bdmin = new BigDecimal(dmin.toString());
          double doublemin = bdmin.doubleValue();
          double ret = doublemax - (doublemax - doublemin)
              * (rightBorderInd - maxInd) / (minInd - maxInd);
          return createThriftDecimal(String.valueOf(ret));
        }
View Full Code Here

    }
  }

  private static Decimal createThriftDecimal(String s) {
    BigDecimal d = new BigDecimal(s);
    return new Decimal(ByteBuffer.wrap(d.unscaledValue().toByteArray()),
        (short) d.scale());
  }
View Full Code Here

      statsObj.getStatsData().getDecimalStats().setLowValue(convertToThriftDecimal(d));
    }
  }

  private Decimal convertToThriftDecimal(HiveDecimal d) {
    return new Decimal(ByteBuffer.wrap(d.unscaledValue().toByteArray()), (short)d.scale());
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.metastore.api.Decimal

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.