Java Code Examples for org.apache.spark.sql.types.Decimal#apply()
The following examples show how to use
org.apache.spark.sql.types.Decimal#apply() .
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: FlightArrowColumnVector.java From flight-spark-source with Apache License 2.0 | 5 votes |
@Override final Decimal getDecimal(int rowId, int precision, int scale) { if (isNullAt(rowId)) { return null; } return Decimal.apply(accessor.getObject(rowId), precision, scale); }
Example 2
Source File: ArrowVectorAccessors.java From iceberg with Apache License 2.0 | 5 votes |
@Override final Decimal getDecimal(int rowId, int precision, int scale) { int dictId = offsetVector.get(rowId); if (cache[dictId] == null) { cache[dictId] = Decimal.apply( new BigInteger(parquetDictionary.decodeToBinary(dictId).getBytes()).longValue(), precision, scale); } return cache[dictId]; }
Example 3
Source File: ArrowVectorAccessors.java From iceberg with Apache License 2.0 | 5 votes |
@Override final Decimal getDecimal(int rowId, int precision, int scale) { int dictId = offsetVector.get(rowId); if (cache[dictId] == null) { cache[dictId] = Decimal.apply(parquetDictionary.decodeToLong(dictId), precision, scale); } return cache[dictId]; }
Example 4
Source File: ArrowVectorAccessors.java From iceberg with Apache License 2.0 | 5 votes |
@Override final Decimal getDecimal(int rowId, int precision, int scale) { int dictId = offsetVector.get(rowId); if (cache[dictId] == null) { cache[dictId] = Decimal.apply(parquetDictionary.decodeToInt(dictId), precision, scale); } return cache[dictId]; }
Example 5
Source File: RowDataReader.java From iceberg with Apache License 2.0 | 5 votes |
private static Object convertConstant(Type type, Object value) { if (value == null) { return null; } switch (type.typeId()) { case DECIMAL: return Decimal.apply((BigDecimal) value); case STRING: if (value instanceof Utf8) { Utf8 utf8 = (Utf8) value; return UTF8String.fromBytes(utf8.getBytes(), 0, utf8.getByteLength()); } return UTF8String.fromString(value.toString()); case FIXED: if (value instanceof byte[]) { return value; } else if (value instanceof GenericData.Fixed) { return ((GenericData.Fixed) value).bytes(); } return ByteBuffers.toByteArray((ByteBuffer) value); case BINARY: return ByteBuffers.toByteArray((ByteBuffer) value); default: } return value; }
Example 6
Source File: ArrowVectorAccessors.java From iceberg with Apache License 2.0 | 4 votes |
@Override final Decimal getDecimal(int rowId, int precision, int scale) { return Decimal.apply(vector.getObject(rowId), precision, scale); }
Example 7
Source File: SparkParquetReaders.java From iceberg with Apache License 2.0 | 4 votes |
@Override public Decimal read(Decimal ignored) { return Decimal.apply(column.nextInteger(), precision, scale); }
Example 8
Source File: SparkParquetReaders.java From iceberg with Apache License 2.0 | 4 votes |
@Override public Decimal read(Decimal ignored) { return Decimal.apply(column.nextLong(), precision, scale); }
Example 9
Source File: SparkValueReaders.java From iceberg with Apache License 2.0 | 4 votes |
@Override public Decimal read(Decoder decoder, Object reuse) throws IOException { byte[] bytes = bytesReader.read(decoder, null); return Decimal.apply(new BigDecimal(new BigInteger(bytes), scale)); }
Example 10
Source File: StructInternalRow.java From iceberg with Apache License 2.0 | 4 votes |
@Override public Decimal getDecimal(int ordinal, int precision, int scale) { return Decimal.apply(struct.get(ordinal, BigDecimal.class)); }
Example 11
Source File: SparkParquetReaders.java From iceberg with Apache License 2.0 | 4 votes |
@Override public Decimal read(Decimal ignored) { return Decimal.apply(column.nextInteger(), precision, scale); }
Example 12
Source File: SparkParquetReaders.java From iceberg with Apache License 2.0 | 4 votes |
@Override public Decimal read(Decimal ignored) { return Decimal.apply(column.nextLong(), precision, scale); }
Example 13
Source File: SparkValueReaders.java From iceberg with Apache License 2.0 | 4 votes |
@Override public Decimal read(Decoder decoder, Object reuse) throws IOException { byte[] bytes = bytesReader.read(decoder, null); return Decimal.apply(new BigDecimal(new BigInteger(bytes), scale)); }