Github user ravipesala commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2823#discussion_r226867984
--- Diff:
core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/adaptive/AdaptiveDeltaIntegralCodec.java
---
@@ -272,5 +295,169 @@ public double decodeDouble(double value) {
// this codec is for integer type only
throw new RuntimeException("internal error");
}
+
+ @Override
+ public void decodeAndFillVector(ColumnPage columnPage,
ColumnVectorInfo vectorInfo) {
+ CarbonColumnVector vector = vectorInfo.vector;
+ BitSet nullBits = columnPage.getNullBits();
+ DataType dataType = vector.getType();
+ DataType type = columnPage.getDataType();
+ int pageSize = columnPage.getPageSize();
+ BitSet deletedRows = vectorInfo.deletedRows;
+ vector = ColumnarVectorWrapperDirectFactory
+ .getDirectVectorWrapperFactory(vector, vectorInfo.invertedIndex,
nullBits, deletedRows);
+ fillVector(columnPage, vector, dataType, type, pageSize, vectorInfo);
+ if (deletedRows == null || deletedRows.isEmpty()) {
+ for (int i = nullBits.nextSetBit(0); i >= 0; i =
nullBits.nextSetBit(i + 1)) {
+ vector.putNull(i);
+ }
+ }
+ if (vector instanceof ConvertableVector) {
+ ((ConvertableVector) vector).convert();
+ }
+ }
+
+ private void fillVector(ColumnPage columnPage, CarbonColumnVector
vector, DataType dataType,
+ DataType type, int pageSize, ColumnVectorInfo vectorInfo) {
+ if (type == DataTypes.BOOLEAN || type == DataTypes.BYTE) {
+ byte[] byteData = columnPage.getByteData();
+ if (dataType == DataTypes.SHORT) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putShort(i, (short) (max - byteData[i]));
+ }
+ } else if (dataType == DataTypes.INT) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putInt(i, (int) (max - byteData[i]));
+ }
+ } else if (dataType == DataTypes.LONG) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putLong(i, (max - byteData[i]));
+ }
+ } else if (dataType == DataTypes.TIMESTAMP) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putLong(i, (max - byteData[i]) * 1000);
+ }
+ } else if (dataType == DataTypes.BOOLEAN) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putByte(i, (byte) (max - byteData[i]));
+ }
+ } else if (DataTypes.isDecimal(dataType)) {
+ DecimalConverterFactory.DecimalConverter decimalConverter =
vectorInfo.decimalConverter;
+ int precision = vectorInfo.measure.getMeasure().getPrecision();
+ for (int i = 0; i < pageSize; i++) {
+ BigDecimal decimal = decimalConverter.getDecimal(max -
byteData[i]);
+ vector.putDecimal(i, decimal, precision);
+ }
+ } else {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putDouble(i, (max - byteData[i]));
+ }
+ }
+ } else if (type == DataTypes.SHORT) {
+ short[] shortData = columnPage.getShortData();
+ if (dataType == DataTypes.SHORT) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putShort(i, (short) (max - shortData[i]));
+ }
+ } else if (dataType == DataTypes.INT) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putInt(i, (int) (max - shortData[i]));
+ }
+ } else if (dataType == DataTypes.LONG) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putLong(i, (max - shortData[i]));
+ }
+ } else if (dataType == DataTypes.TIMESTAMP) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putLong(i, (max - shortData[i]) * 1000);
+ }
+ } else if (DataTypes.isDecimal(dataType)) {
+ DecimalConverterFactory.DecimalConverter decimalConverter =
vectorInfo.decimalConverter;
+ int precision = vectorInfo.measure.getMeasure().getPrecision();
+ for (int i = 0; i < pageSize; i++) {
+ BigDecimal decimal = decimalConverter.getDecimal(max -
shortData[i]);
+ vector.putDecimal(i, decimal, precision);
+ }
+ } else {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putDouble(i, (max - shortData[i]));
+ }
+ }
+
+ } else if (type == DataTypes.SHORT_INT) {
+ int[] shortIntData = columnPage.getShortIntData();
+ if (dataType == DataTypes.INT) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putInt(i, (int) (max - shortIntData[i]));
+ }
+ } else if (dataType == DataTypes.LONG) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putLong(i, (max - shortIntData[i]));
+ }
+ } else if (dataType == DataTypes.TIMESTAMP) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putLong(i, (max - shortIntData[i]) * 1000);
+ }
+ } else if (DataTypes.isDecimal(dataType)) {
+ DecimalConverterFactory.DecimalConverter decimalConverter =
vectorInfo.decimalConverter;
+ int precision = vectorInfo.measure.getMeasure().getPrecision();
+ for (int i = 0; i < pageSize; i++) {
+ BigDecimal decimal = decimalConverter.getDecimal(max -
shortIntData[i]);
+ vector.putDecimal(i, decimal, precision);
+ }
+ } else {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putDouble(i, (max - shortIntData[i]));
+ }
+ }
+ } else if (type == DataTypes.INT) {
+ int[] intData = columnPage.getIntData();
+ if (dataType == DataTypes.INT) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putInt(i, (int) (max - intData[i]));
+ }
+ } else if (dataType == DataTypes.LONG) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putLong(i, (max - intData[i]));
+ }
+ } else if (dataType == DataTypes.TIMESTAMP) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putLong(i, (max - intData[i]) * 1000);
+ }
+ } else if (DataTypes.isDecimal(dataType)) {
+ DecimalConverterFactory.DecimalConverter decimalConverter =
vectorInfo.decimalConverter;
+ int precision = vectorInfo.measure.getMeasure().getPrecision();
+ for (int i = 0; i < pageSize; i++) {
+ BigDecimal decimal = decimalConverter.getDecimal(max -
intData[i]);
+ vector.putDecimal(i, decimal, precision);
+ }
+ } else {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putDouble(i, (max - intData[i]));
+ }
+ }
+ } else if (type == DataTypes.LONG) {
+ long[] longData = columnPage.getLongData();
+ if (dataType == DataTypes.LONG) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putLong(i, (max - longData[i]));
+ }
+ } else if (dataType == DataTypes.TIMESTAMP) {
+ for (int i = 0; i < pageSize; i++) {
+ vector.putLong(i, (max - longData[i]) * 1000);
+ }
+ } else if (DataTypes.isDecimal(dataType)) {
+ DecimalConverterFactory.DecimalConverter decimalConverter =
vectorInfo.decimalConverter;
+ int precision = vectorInfo.measure.getMeasure().getPrecision();
+ for (int i = 0; i < pageSize; i++) {
+ BigDecimal decimal = decimalConverter.getDecimal(max -
longData[i]);
+ vector.putDecimal(i, decimal, precision);
+ }
+ }
+ } else {
+ throw new RuntimeException("internal error: " + this.toString());
--- End diff --
ok
---