当前位置: 首页>>代码示例>>Java>>正文


Java HiveDecimalWritable类代码示例

本文整理汇总了Java中org.apache.hadoop.hive.serde2.io.HiveDecimalWritable的典型用法代码示例。如果您正苦于以下问题:Java HiveDecimalWritable类的具体用法?Java HiveDecimalWritable怎么用?Java HiveDecimalWritable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HiveDecimalWritable类属于org.apache.hadoop.hive.serde2.io包,在下文中一共展示了HiveDecimalWritable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPrimitiveWritableObject

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
@Override
public HiveDecimalWritable getPrimitiveWritableObject(Object o) {
<#if mode == "Optional">
  if (o == null) {
    return null;
  }
  final NullableDecimal38SparseHolder h = (NullableDecimal38SparseHolder) o;
<#else>
  final Decimal38SparseHolder h = (Decimal38SparseHolder) o;
</#if>
  return new HiveDecimalWritable(
      HiveDecimal.create(DecimalUtility.getBigDecimalFromSparse(h.buffer, h.start, h.nDecimalDigits, h.scale)));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:14,代码来源:ObjectInspectors.java

示例2: getPrimitiveWritableObject

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
@Override
public HiveDecimalWritable getPrimitiveWritableObject(Object o) {
<#if mode == "Optional">
  if (o == null) {
    return null;
  }
  final NullableDecimalHolder h = (NullableDecimalHolder) o;
<#else>
  final DecimalHolder h = (DecimalHolder) o;
</#if>
  return new HiveDecimalWritable(
      HiveDecimal.create(DecimalUtility.getBigDecimalFromArrowBuf(h.buffer, h.start, h.scale)));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:14,代码来源:ObjectInspectors.java

示例3: toComparable

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
static Comparable<?> toComparable(PrimitiveCategory category, Object literal) {
  String stringLiteral;
  switch (category) {
  case STRING:
    return new Text((String) literal);
  case BOOLEAN:
    return new BooleanWritable((Boolean) literal);
  case BYTE:
    return new ByteWritable(((Long) literal).byteValue());
  case SHORT:
    return new ShortWritable(((Long) literal).shortValue());
  case INT:
    return new IntWritable(((Long) literal).intValue());
  case LONG:
    return new LongWritable((Long) literal);
  case FLOAT:
    return new FloatWritable(((Double) literal).floatValue());
  case DOUBLE:
    return new DoubleWritable((Double) literal);
  case TIMESTAMP:
    return new TimestampWritable((Timestamp) literal);
  case DATE:
    return (DateWritable) literal;
  case CHAR:
    stringLiteral = (String) literal;
    return new HiveCharWritable(new HiveChar(stringLiteral, stringLiteral.length()));
  case VARCHAR:
    stringLiteral = (String) literal;
    return new HiveVarcharWritable(new HiveVarchar(stringLiteral, stringLiteral.length()));
  case DECIMAL:
    return new HiveDecimalWritable(HiveDecimal.create((BigDecimal) literal));
  default:
    throw new IllegalArgumentException("Unsupported category: " + category);
  }
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:36,代码来源:EvaluatorFactory.java

示例4: toWritableObjectInternal

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
@Override
protected Object toWritableObjectInternal(Object value) throws UnexpectedTypeException {
  if (value instanceof String) {
    value = HiveDecimal.create((String) value);
  } else if (value instanceof BigDecimal) {
    value = HiveDecimal.create((BigDecimal) value);
  }
  return new HiveDecimalWritable((HiveDecimal) value);
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:10,代码来源:CascadingConverterFactory.java

示例5: decimalWritable

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
@Test
public void decimalWritable() throws UnexpectedTypeException {
  Converter converter = getConverter(TypeInfoFactory.getDecimalTypeInfo(2, 1));
  HiveDecimal hiveDecimal = HiveDecimal.create("2.1");
  assertThat(converter.toWritableObject("2.1"), is((Object) new HiveDecimalWritable(hiveDecimal)));
  assertThat(converter.toWritableObject(new BigDecimal("2.1")), is((Object) new HiveDecimalWritable(hiveDecimal)));
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:8,代码来源:CascadingConverterFactoryTest.java

示例6: compareDecimalcolumn

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
static void compareDecimalcolumn(ColumnVector oneDecimalColumn, boolean[] isNull,
                                  long currentBatchRow, Vec h2oFrame, Long startRowIndex) {
  HiveDecimalWritable[] oneColumn= ((DecimalColumnVector) oneDecimalColumn).vector;
  long frameRowIndex = startRowIndex;

  for (int rowIndex = 0; rowIndex < currentBatchRow; rowIndex++) {
    if (isNull[rowIndex])
      assertEquals("Na is found: ", true, h2oFrame.isNA(frameRowIndex));
    else
      assertEquals("Decimal elements should equal: ", Double.parseDouble(oneColumn[rowIndex].toString()),
                   h2oFrame.at(frameRowIndex), EPSILON);

    frameRowIndex++;
  }
}
 
开发者ID:h2oai,项目名称:h2o-3,代码行数:16,代码来源:OrcTestUtils.java

示例7: getPrimitiveWritableObject

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
@Override
public HiveDecimalWritable getPrimitiveWritableObject(Object o) {
    if (o instanceof BigDecimal) {
        return o == null ? null : new HiveDecimalWritable(HiveDecimal.create((BigDecimal)o));
    } else { // BigInteger
        return o == null ? null : new HiveDecimalWritable(HiveDecimal.create((BigInteger)o));
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:9,代码来源:OrcUtils.java

示例8: testDecimal

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
@Test
public void testDecimal() {
    assertEquals("\"1\"", hiveTypeToJson(new MyHiveType(new HiveDecimalWritable(HiveDecimal.create(BigDecimal.ONE)),
            decimalTypeInfo)));
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:6,代码来源:HiveTypeToJsonTest.java

示例9: readBigDecimal

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
private static BigDecimal readBigDecimal(HiveDecimalWritable hiveDecimalWritable) {
	HiveDecimal hiveDecimal = hiveDecimalWritable.getHiveDecimal();
	return hiveDecimal.bigDecimalValue();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:OrcUtils.java

示例10: castLiteral

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
Object castLiteral(Serializable literal) {

			switch (literalType) {
				case LONG:
					if (literal instanceof Byte) {
						return new Long((Byte) literal);
					} else if (literal instanceof Short) {
						return new Long((Short) literal);
					} else if (literal instanceof Integer) {
						return new Long((Integer) literal);
					} else if (literal instanceof Long) {
						return literal;
					} else {
						throw new IllegalArgumentException("A predicate on a LONG column requires an integer " +
							"literal, i.e., Byte, Short, Integer, or Long.");
					}
				case FLOAT:
					if (literal instanceof Float) {
						return new Double((Float) literal);
					} else if (literal instanceof Double) {
						return literal;
					} else if (literal instanceof BigDecimal) {
						return ((BigDecimal) literal).doubleValue();
					} else {
						throw new IllegalArgumentException("A predicate on a FLOAT column requires a floating " +
							"literal, i.e., Float or Double.");
					}
				case STRING:
					if (literal instanceof String) {
						return literal;
					} else {
						throw new IllegalArgumentException("A predicate on a STRING column requires a floating " +
							"literal, i.e., Float or Double.");
					}
				case BOOLEAN:
					if (literal instanceof Boolean) {
						return literal;
					} else {
						throw new IllegalArgumentException("A predicate on a BOOLEAN column requires a Boolean literal.");
					}
				case DATE:
					if (literal instanceof Date) {
						return literal;
					} else {
						throw new IllegalArgumentException("A predicate on a DATE column requires a java.sql.Date literal.");
					}
				case TIMESTAMP:
					if (literal instanceof Timestamp) {
						return literal;
					} else {
						throw new IllegalArgumentException("A predicate on a TIMESTAMP column requires a java.sql.Timestamp literal.");
					}
				case DECIMAL:
					if (literal instanceof BigDecimal) {
						return new HiveDecimalWritable(HiveDecimal.create((BigDecimal) literal));
					} else {
						throw new IllegalArgumentException("A predicate on a DECIMAL column requires a BigDecimal literal.");
					}
				default:
					throw new IllegalArgumentException("Unknown literal type " + literalType);
			}
		}
 
开发者ID:axbaretto,项目名称:flink,代码行数:63,代码来源:OrcRowInputFormat.java

示例11: toWritableObjectInternal

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
@Override
protected Object toWritableObjectInternal(Object value) throws UnexpectedTypeException {
  return new HiveDecimalWritable((HiveDecimal) value);
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:5,代码来源:DefaultConverterFactory.java

示例12: toJavaObjectInternal

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
@Override
protected Object toJavaObjectInternal(Object value) throws UnexpectedTypeException {
  return ((HiveDecimalWritable) value).getHiveDecimal();
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:5,代码来源:DefaultConverterFactory.java

示例13: decimalJava

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
@Test
public void decimalJava() throws UnexpectedTypeException {
  Converter converter = getConverter(TypeInfoFactory.getDecimalTypeInfo(2, 1));
  HiveDecimal hiveDecimal = HiveDecimal.create("2.1");
  assertThat(converter.toJavaObject(new HiveDecimalWritable(hiveDecimal)), is((Object) hiveDecimal));
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:7,代码来源:DefaultConverterFactoryTest.java

示例14: decimalWritable

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
@Test
public void decimalWritable() throws UnexpectedTypeException {
  Converter converter = getConverter(TypeInfoFactory.getDecimalTypeInfo(2, 1));
  HiveDecimal hiveDecimal = HiveDecimal.create("2.1");
  assertThat(converter.toWritableObject(hiveDecimal), is((Object) new HiveDecimalWritable(hiveDecimal)));
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:7,代码来源:DefaultConverterFactoryTest.java

示例15: decimalTypical

import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void decimalTypical() {
  assertThat(toComparable(DECIMAL, new BigDecimal("0.0")),
      is((Comparable) new HiveDecimalWritable(HiveDecimal.create(new BigDecimal("0.0")))));
}
 
开发者ID:HotelsDotCom,项目名称:corc,代码行数:7,代码来源:EvaluatorFactoryTest.java


注:本文中的org.apache.hadoop.hive.serde2.io.HiveDecimalWritable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。