org.apache.orc.storage.common.type.HiveDecimal Java Examples

The following examples show how to use org.apache.orc.storage.common.type.HiveDecimal. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenericOrcWriter.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
public void addValue(int rowId, BigDecimal data, ColumnVector output) {
  // TODO: validate precision and scale from schema
  if (data == null) {
    output.noNulls = false;
    output.isNull[rowId] = true;
  } else {
    output.isNull[rowId] = false;
    ((DecimalColumnVector) output).vector[rowId].set(HiveDecimal.create(data, false));
  }
}
 
Example #2
Source File: SparkOrcWriter.java    From iceberg with Apache License 2.0 5 votes vote down vote up
@Override
public void addValue(int rowId, int column, SpecializedGetters data,
                     ColumnVector output) {
  if (data.isNullAt(column)) {
    output.noNulls = false;
    output.isNull[rowId] = true;
  } else {
    output.isNull[rowId] = false;
    ((DecimalColumnVector) output).vector[rowId].set(
        HiveDecimal.create(data.getDecimal(column, precision, scale)
            .toJavaBigDecimal()));
  }
}
 
Example #3
Source File: SparkOrcWriter.java    From iceberg with Apache License 2.0 5 votes vote down vote up
public void addValue(int rowId, int column, SpecializedGetters data,
                     ColumnVector output) {
  if (data.isNullAt(column)) {
    output.noNulls = false;
    output.isNull[rowId] = true;
  } else {
    output.isNull[rowId] = false;
    ((DecimalColumnVector) output).vector[rowId].set(
        HiveDecimal.create(data.getDecimal(column, precision, scale)
            .toJavaBigDecimal()));
  }
}
 
Example #4
Source File: AbstractOrcNoHiveVector.java    From flink with Apache License 2.0 5 votes vote down vote up
private static DecimalColumnVector createDecimalVector(int batchSize, int precision, int scale, Object value) {
	DecimalColumnVector dv = new DecimalColumnVector(batchSize, precision, scale);
	if (value == null) {
		dv.noNulls = false;
		dv.isNull[0] = true;
		dv.isRepeating = true;
	} else {
		dv.set(0, value instanceof HiveDecimal ?
				(HiveDecimal) value :
				HiveDecimal.create((BigDecimal) value));
		dv.isRepeating = true;
		dv.isNull[0] = false;
	}
	return dv;
}