@Override public void update(int ordinal, Object value) { if (value == null) { setNullAt(ordinal); } else { DataType dt = columns[ordinal].dataType(); if (dt instanceof BooleanType) { setBoolean(ordinal, (boolean) value); } else if (dt instanceof IntegerType) { setInt(ordinal, (int) value); } else if (dt instanceof ShortType) { setShort(ordinal, (short) value); } else if (dt instanceof LongType) { setLong(ordinal, (long) value); } else if (dt instanceof FloatType) { setFloat(ordinal, (float) value); } else if (dt instanceof DoubleType) { setDouble(ordinal, (double) value); } else if (dt instanceof DecimalType) { DecimalType t = (DecimalType) dt; Decimal d = Decimal.apply((BigDecimal) value, t.precision(), t.scale()); setDecimal(ordinal, d, t.precision()); } else { throw new UnsupportedOperationException("Datatype not supported " + dt); } } }
@Override protected void reserveInternal(int newCapacity) { if (this.resultArray != null || DecimalType.isByteArrayDecimalType(type)) { int[] newLengths = new int[newCapacity]; int[] newOffsets = new int[newCapacity]; DecimalType.is32BitDecimalType(type)) { if (intData == null || intData.length < newCapacity) { int[] newData = new int[newCapacity]; DecimalType.is64BitDecimalType(type)) { if (longData == null || longData.length < newCapacity) { long[] newData = new long[newCapacity];
DecimalType.is32BitDecimalType(type)) { if (intData == null || intData.length < newCapacity) { int[] newData = new int[newCapacity]; DecimalType.is64BitDecimalType(type)) { if (longData == null || longData.length < newCapacity) { long[] newData = new long[newCapacity];
public static boolean isFixedLength(DataType dt) { if (dt instanceof DecimalType) { return ((DecimalType) dt).precision() <= Decimal.MAX_LONG_DIGITS(); } else { return mutableFieldTypes.contains(dt); } }
return BigDecimal.valueOf((Long) item, ((DecimalType) type).scale()); } else if (item instanceof Double) { return BigDecimal.valueOf((Double) item).setScale(((DecimalType) type).scale(), RoundingMode.HALF_DOWN); } else if (item instanceof String) { return new BigDecimal((String) item).setScale(((DecimalType) type).scale(), RoundingMode.HALF_DOWN); } else if (item instanceof BigDecimal) { return item; } else if (item instanceof BigInteger) { return new BigDecimal((BigInteger) item, ((DecimalType) type).scale()); } else { throw new RuntimeException(String.format("Type[%s] - Invalid or unrecognized input format: %s", type, item));
protected boolean isArray() { return type instanceof ArrayType || type instanceof BinaryType || type instanceof StringType || DecimalType.isByteArrayDecimalType(type); }
private void readIntBatch(int rowId, int num, ColumnVector column) throws IOException { // This is where we implement support for the valid type conversions. // TODO: implement remaining type conversions if (column.dataType() == DataTypes.IntegerType || column.dataType() == DataTypes.DateType || DecimalType.is32BitDecimalType(column.dataType())) { defColumn.readIntegers( num, column, rowId, maxDefLevel, (VectorizedValuesReader) dataColumn); } else if (column.dataType() == DataTypes.ByteType) { defColumn.readBytes( num, column, rowId, maxDefLevel, (VectorizedValuesReader) dataColumn); } else if (column.dataType() == DataTypes.ShortType) { defColumn.readShorts( num, column, rowId, maxDefLevel, (VectorizedValuesReader) dataColumn); } else { throw new UnsupportedOperationException("Unimplemented type: " + column.dataType()); } }
private void readLongBatch(int rowId, int num, ColumnVector column) throws IOException { // This is where we implement support for the valid type conversions. if (column.dataType() == DataTypes.LongType || DecimalType.is64BitDecimalType(column.dataType())) { defColumn.readLongs( num, column, rowId, maxDefLevel, (VectorizedValuesReader) dataColumn); } else if (column.dataType() == DataTypes.TimestampType) { for (int i = 0; i < num; i++) { if (defColumn.readInteger() == maxDefLevel) { column.putLong(rowId + i, DateTimeUtils.fromMillis(dataColumn.readLong())); } else { column.putNull(rowId + i); } } } else { throw new UnsupportedOperationException("Unsupported conversion to: " + column.dataType()); } }
if (org.apache.carbondata.core.metadata.datatype.DataTypes.isDecimal(dataType)) { fields.add(new StructField(carbonColumn.getColumnName(), new DecimalType(carbonColumn.getPrecision(), carbonColumn.getScale()), true, Metadata.empty())); } else if (org.apache.carbondata.core.metadata.datatype.DataTypes.isStructType(dataType)) {
public static boolean isFixedLength(DataType dt) { if (dt instanceof DecimalType) { return ((DecimalType) dt).precision() <= Decimal.MAX_LONG_DIGITS(); } else { return mutableFieldTypes.contains(dt); } }
DecimalType.is32BitDecimalType(type)) { if (intData == null || intData.length < newCapacity) { int[] newData = new int[newCapacity]; DecimalType.is64BitDecimalType(type)) { if (longData == null || longData.length < newCapacity) { long[] newData = new long[newCapacity];
protected boolean isArray() { return type instanceof ArrayType || type instanceof BinaryType || type instanceof StringType || DecimalType.isByteArrayDecimalType(type); }
private void readIntBatch(int rowId, int num, WritableColumnVector column) throws IOException { // This is where we implement support for the valid type conversions. // TODO: implement remaining type conversions if (column.dataType() == DataTypes.IntegerType || column.dataType() == DataTypes.DateType || DecimalType.is32BitDecimalType(column.dataType())) { defColumn.readIntegers( num, column, rowId, maxDefLevel, (VectorizedValuesReader) dataColumn); } else if (column.dataType() == DataTypes.ByteType) { defColumn.readBytes( num, column, rowId, maxDefLevel, (VectorizedValuesReader) dataColumn); } else if (column.dataType() == DataTypes.ShortType) { defColumn.readShorts( num, column, rowId, maxDefLevel, (VectorizedValuesReader) dataColumn); } else { throw constructConvertNotSupportedException(descriptor, column); } }
private void readLongBatch(int rowId, int num, WritableColumnVector column) throws IOException { // This is where we implement support for the valid type conversions. if (column.dataType() == DataTypes.LongType || DecimalType.is64BitDecimalType(column.dataType()) || originalType == OriginalType.TIMESTAMP_MICROS) { defColumn.readLongs( num, column, rowId, maxDefLevel, (VectorizedValuesReader) dataColumn); } else if (originalType == OriginalType.TIMESTAMP_MILLIS) { for (int i = 0; i < num; i++) { if (defColumn.readInteger() == maxDefLevel) { column.putLong(rowId + i, DateTimeUtils.fromMillis(dataColumn.readLong())); } else { column.putNull(rowId + i); } } } else { throw constructConvertNotSupportedException(descriptor, column); } }
} else if (DataTypes.isDecimal(dataType)) { fields[msr.getOrdinal()] = new StructField(msr.getColumnName(), new DecimalType(msr.getMeasure().getPrecision(), msr.getMeasure().getScale()), true, null); } else {
@Override public void update(int ordinal, Object value) { if (value == null) { setNullAt(ordinal); } else { DataType dt = columns[ordinal].dataType(); if (dt instanceof BooleanType) { setBoolean(ordinal, (boolean) value); } else if (dt instanceof IntegerType) { setInt(ordinal, (int) value); } else if (dt instanceof ShortType) { setShort(ordinal, (short) value); } else if (dt instanceof LongType) { setLong(ordinal, (long) value); } else if (dt instanceof FloatType) { setFloat(ordinal, (float) value); } else if (dt instanceof DoubleType) { setDouble(ordinal, (double) value); } else if (dt instanceof DecimalType) { DecimalType t = (DecimalType) dt; setDecimal(ordinal, Decimal.apply((BigDecimal) value, t.precision(), t.scale()), t.precision()); } else { throw new UnsupportedOperationException("Datatype not supported " + dt); } } }
if (DecimalType.is32BitDecimalType(column.dataType())) { for (int i = 0; i < num; i++) { if (defColumn.readInteger() == maxDefLevel) { } else if (DecimalType.is64BitDecimalType(column.dataType())) { for (int i = 0; i < num; i++) { if (defColumn.readInteger() == maxDefLevel) { } else if (DecimalType.isByteArrayDecimalType(column.dataType())) { for (int i = 0; i < num; i++) { if (defColumn.readInteger() == maxDefLevel) {
public static boolean isFixedLength(DataType dt) { if (dt instanceof DecimalType) { return ((DecimalType) dt).precision() <= Decimal.MAX_LONG_DIGITS(); } else { return mutableFieldTypes.contains(dt); } }
@Override protected void reserveInternal(int newCapacity) { int oldCapacity = (nulls == 0L) ? 0 : capacity; if (this.resultArray != null) { this.lengthData = Platform.reallocateMemory(lengthData, oldCapacity * 4, newCapacity * 4); this.offsetData = Platform.reallocateMemory(offsetData, oldCapacity * 4, newCapacity * 4); } else if (type instanceof ByteType || type instanceof BooleanType) { this.data = Platform.reallocateMemory(data, oldCapacity, newCapacity); } else if (type instanceof ShortType) { this.data = Platform.reallocateMemory(data, oldCapacity * 2, newCapacity * 2); } else if (type instanceof IntegerType || type instanceof FloatType || type instanceof DateType || DecimalType.is32BitDecimalType(type)) { this.data = Platform.reallocateMemory(data, oldCapacity * 4, newCapacity * 4); } else if (type instanceof LongType || type instanceof DoubleType || DecimalType.is64BitDecimalType(type) || type instanceof TimestampType) { this.data = Platform.reallocateMemory(data, oldCapacity * 8, newCapacity * 8); } else if (resultStruct != null) { // Nothing to store. } else { throw new RuntimeException("Unhandled " + type); } this.nulls = Platform.reallocateMemory(nulls, oldCapacity, newCapacity); Platform.setMemory(nulls + oldCapacity, (byte)0, newCapacity - oldCapacity); capacity = newCapacity; } }
|| DecimalType.isByteArrayDecimalType(type)) { DataType childType; int childCapacity = capacity;