org.apache.hadoop.hive.metastore.api.Date.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(190)

本文整理了Java中org.apache.hadoop.hive.metastore.api.Date.<init>()方法的一些代码示例,展示了Date.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.<init>()方法的具体详情如下:
包路径:org.apache.hadoop.hive.metastore.api.Date
类名称:Date
方法名:<init>

Date.<init>介绍

[英]Performs a deep copy on other.
[中]在其他计算机上执行深度复制。

代码示例

代码示例来源:origin: apache/hive

public Date deepCopy() {
 return new Date(this);
}

代码示例来源:origin: prestodb/presto

public static Date toMetastoreDate(LocalDate date)
{
  return new Date(date.toEpochDay());
}

代码示例来源:origin: apache/drill

private Date readDateValue(String dateStr) {
  // try either yyyy-mm-dd, or integer representing days since epoch
  try {
   DateWritable writableVal = new DateWritable(java.sql.Date.valueOf(dateStr));
   return new Date(writableVal.getDays());
  } catch (IllegalArgumentException err) {
   // Fallback to integer parsing
   LOG.debug("Reading date value as days since epoch: " + dateStr);
   return new Date(Long.parseLong(dateStr));
  }
 }
}

代码示例来源:origin: apache/hive

private Date readDateValue(String dateStr) {
  // try either yyyy-mm-dd, or integer representing days since epoch
  try {
   DateWritableV2 writableVal = new DateWritableV2(org.apache.hadoop.hive.common.type.Date.valueOf(dateStr));
   return new Date(writableVal.getDays());
  } catch (IllegalArgumentException err) {
   // Fallback to integer parsing
   LOG.debug("Reading date value as days since epoch: {}", dateStr);
   return new Date(Long.parseLong(dateStr));
  }
 }
}

代码示例来源:origin: apache/hive

private Date genHighValue() {
 Date d = new Date(rand.nextInt(200));
 highVals.add(d);
 return d;
}

代码示例来源:origin: apache/hive

private Date genLowValue() {
 Date d = new Date(rand.nextInt(100) * -1);
 lowVals.add(d);
 return d;
}

代码示例来源:origin: apache/hive

/**
 * Performs a deep copy on <i>other</i>.
 */
public DateColumnStatsData(DateColumnStatsData other) {
 __isset_bitfield = other.__isset_bitfield;
 if (other.isSetLowValue()) {
  this.lowValue = new Date(other.lowValue);
 }
 if (other.isSetHighValue()) {
  this.highValue = new Date(other.highValue);
 }
 this.numNulls = other.numNulls;
 this.numDVs = other.numDVs;
 if (other.isSetBitVectors()) {
  this.bitVectors = org.apache.thrift.TBaseHelper.copyBinary(other.bitVectors);
 }
}

代码示例来源:origin: apache/hive

private Date getLowVal() {
 long min = Long.MAX_VALUE;
 for (Date d : lowVals) min = Math.min(min, d.getDaysSinceEpoch());
 return new Date(min);
}

代码示例来源:origin: apache/hive

private Date getHighVal() {
  long max = Long.MIN_VALUE;
  for (Date d : highVals) max = Math.max(max, d.getDaysSinceEpoch());
  return new Date(max);
 }
}

代码示例来源:origin: apache/hive

extrapolateDateData.setLowValue(new Date(lowValue));
extrapolateDateData.setHighValue(new Date(highValue));
extrapolateDateData.setNumNulls(numNulls);
extrapolateDateData.setNumDVs(ndv);

代码示例来源:origin: apache/hive

case 1: // LOW_VALUE
 if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
  struct.lowValue = new Date();
  struct.lowValue.read(iprot);
  struct.setLowValueIsSet(true);
case 2: // HIGH_VALUE
 if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
  struct.highValue = new Date();
  struct.highValue.read(iprot);
  struct.setHighValueIsSet(true);

代码示例来源:origin: apache/hive

@Override
 public void read(org.apache.thrift.protocol.TProtocol prot, DateColumnStatsData struct) throws org.apache.thrift.TException {
  TTupleProtocol iprot = (TTupleProtocol) prot;
  struct.numNulls = iprot.readI64();
  struct.setNumNullsIsSet(true);
  struct.numDVs = iprot.readI64();
  struct.setNumDVsIsSet(true);
  BitSet incoming = iprot.readBitSet(3);
  if (incoming.get(0)) {
   struct.lowValue = new Date();
   struct.lowValue.read(iprot);
   struct.setLowValueIsSet(true);
  }
  if (incoming.get(1)) {
   struct.highValue = new Date();
   struct.highValue.read(iprot);
   struct.setHighValueIsSet(true);
  }
  if (incoming.get(2)) {
   struct.bitVectors = iprot.readBinary();
   struct.setBitVectorsIsSet(true);
  }
 }
}

代码示例来源:origin: prestodb/presto

@Test
public void testDateStatsToColumnStatistics()
{
  DateColumnStatsData dateColumnStatsData = new DateColumnStatsData();
  dateColumnStatsData.setLowValue(new Date(1000));
  dateColumnStatsData.setHighValue(new Date(2000));
  dateColumnStatsData.setNumNulls(1);
  dateColumnStatsData.setNumDVs(20);
  ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", DATE_TYPE_NAME, dateStats(dateColumnStatsData));
  HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(1000));
  assertEquals(actual.getIntegerStatistics(), Optional.empty());
  assertEquals(actual.getDoubleStatistics(), Optional.empty());
  assertEquals(actual.getDecimalStatistics(), Optional.empty());
  assertEquals(actual.getDateStatistics(), Optional.of(new DateStatistics(Optional.of(LocalDate.ofEpochDay(1000)), Optional.of(LocalDate.ofEpochDay(2000)))));
  assertEquals(actual.getBooleanStatistics(), Optional.empty());
  assertEquals(actual.getMaxValueSizeInBytes(), OptionalLong.empty());
  assertEquals(actual.getTotalSizeInBytes(), OptionalLong.empty());
  assertEquals(actual.getNullsCount(), OptionalLong.of(1));
  assertEquals(actual.getDistinctValuesCount(), OptionalLong.of(19));
}

代码示例来源:origin: apache/hive

private static void unpackDateStats(ObjectInspector oi, Object o, String fName, ColumnStatisticsObj statsObj) {
 if (fName.equals("countnulls")) {
  long v = ((LongObjectInspector) oi).get(o);
  statsObj.getStatsData().getDateStats().setNumNulls(v);
 } else if (fName.equals("numdistinctvalues")) {
  long v = ((LongObjectInspector) oi).get(o);
  statsObj.getStatsData().getDateStats().setNumDVs(v);
 } else if (fName.equals("max")) {
  DateWritableV2 v = ((DateObjectInspector) oi).getPrimitiveWritableObject(o);
  statsObj.getStatsData().getDateStats().setHighValue(new Date(v.getDays()));
 } else if (fName.equals("min")) {
  DateWritableV2 v = ((DateObjectInspector) oi).getPrimitiveWritableObject(o);
  statsObj.getStatsData().getDateStats().setLowValue(new Date(v.getDays()));
 } else if (fName.equals("ndvbitvector")) {
  PrimitiveObjectInspector poi = (PrimitiveObjectInspector) oi;
  byte[] buf = ((BinaryObjectInspector) poi).getPrimitiveJavaObject(o);
  statsObj.getStatsData().getDateStats().setBitVectors(buf);
  ;
 }
}

代码示例来源:origin: apache/drill

private void unpackDateStats(ObjectInspector oi, Object o, String fName,
  ColumnStatisticsObj statsObj) {
 if (fName.equals("countnulls")) {
  long v = ((LongObjectInspector) oi).get(o);
  statsObj.getStatsData().getDateStats().setNumNulls(v);
 } else if (fName.equals("numdistinctvalues")) {
  long v = ((LongObjectInspector) oi).get(o);
  statsObj.getStatsData().getDateStats().setNumDVs(v);
 } else if (fName.equals("max")) {
  DateWritable v = ((DateObjectInspector) oi).getPrimitiveWritableObject(o);
  statsObj.getStatsData().getDateStats().setHighValue(new Date(v.getDays()));
 } else if (fName.equals("min")) {
  DateWritable v = ((DateObjectInspector) oi).getPrimitiveWritableObject(o);
  statsObj.getStatsData().getDateStats().setLowValue(new Date(v.getDays()));
 } else if (fName.equals("ndvbitvector")) {
  PrimitiveObjectInspector poi = (PrimitiveObjectInspector) oi;
  String v = ((StringObjectInspector) poi).getPrimitiveJavaObject(o);
  statsObj.getStatsData().getDateStats().setBitVectors(v);;
 }
}

代码示例来源:origin: apache/hive

dateStats.setNumNulls(MetastoreDirectSqlUtils.extractSqlLong(nulls));
if (lhigh != null) {
 dateStats.setHighValue(new Date(MetastoreDirectSqlUtils.extractSqlLong(lhigh)));
 dateStats.setLowValue(new Date(MetastoreDirectSqlUtils.extractSqlLong(llow)));

代码示例来源:origin: apache/hive

dateStats.setNumNulls(MetastoreDirectSqlUtils.extractSqlLong(nulls));
if (lhigh != null) {
 dateStats.setHighValue(new Date(MetastoreDirectSqlUtils.extractSqlLong(lhigh)));
 dateStats.setLowValue(new Date(MetastoreDirectSqlUtils.extractSqlLong(llow)));

代码示例来源:origin: apache/hive

Long highValue = mStatsObj.getLongHighValue();
if (highValue != null) {
 dateStats.setHighValue(new Date(highValue));
 dateStats.setLowValue(new Date(lowValue));

代码示例来源:origin: apache/hive

Long highValue = mStatsObj.getLongHighValue();
if (highValue != null) {
 dateStats.setHighValue(new Date(highValue));
 dateStats.setLowValue(new Date(lowValue));

代码示例来源:origin: com.facebook.presto.hive/hive-apache

private Date readDateValue(String dateStr) {
  // try either yyyy-mm-dd, or integer representing days since epoch
  try {
   DateWritable writableVal = new DateWritable(java.sql.Date.valueOf(dateStr));
   return new Date(writableVal.getDays());
  } catch (IllegalArgumentException err) {
   // Fallback to integer parsing
   LOG.debug("Reading date value as days since epoch: " + dateStr);
   return new Date(Long.parseLong(dateStr));
  }
 }
}

相关文章