Skip to content

Commit

Permalink
[HOTFIX-compatibility] Handle Lazy loading with inverted index for Co…
Browse files Browse the repository at this point in the history
…lumnarVectorWrapperDirectWithInvertedIndex

Problem:
Create a store with 1.4 code with inverted index and read it with vector filling (latest master code).
below exception will be thrown from AbstractCarbonColumnarVector.
UnsupportedOperationException("Not allowed from here " + getClass().getName());

cause:
when the lazy loading with an inverted index,
getBlockDataType() was not implemented for ColumnarVectorWrapperDirectWithInvertedIndex.

So, Added implementation.

This closes #2870
  • Loading branch information
ajantha-bhat authored and kumarvishal09 committed Oct 31, 2018
1 parent bcf3e0f commit 94a4f83
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ public void decodeAndFillVector(ColumnPage columnPage, ColumnVectorInfo vectorIn
int shortInt = ByteUtil.valueOf3Bytes(shortIntPage, i * 3);
vector.putFloat(i, (max - shortInt) / floatFactor);
}
} else if (pageDataType == DataTypes.INT) {
int[] intData = columnPage.getIntPage();
for (int i = 0; i < pageSize; i++) {
vector.putFloat(i, (max - intData[i]) / floatFactor);
}
} else {
throw new RuntimeException("internal error: " + this.toString());
}
Expand All @@ -298,6 +303,11 @@ public void decodeAndFillVector(ColumnPage columnPage, ColumnVectorInfo vectorIn
for (int i = 0; i < pageSize; i++) {
vector.putDouble(i, (max - intData[i]) / factor);
}
} else if (pageDataType == DataTypes.LONG) {
long[] longData = columnPage.getLongPage();
for (int i = 0; i < pageSize; i++) {
vector.putDouble(i, (max - longData[i]) / factor);
}
} else {
throw new RuntimeException("Unsupported datatype : " + pageDataType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ public void decodeAndFillVector(ColumnPage columnPage, ColumnVectorInfo vectorIn
int shortInt = ByteUtil.valueOf3Bytes(shortIntPage, i * 3);
vector.putFloat(i, (shortInt / floatFactor));
}
} else if (pageDataType == DataTypes.INT) {
int[] intData = columnPage.getIntPage();
for (int i = 0; i < pageSize; i++) {
vector.putFloat(i, (intData[i] / floatFactor));
}
} else {
throw new RuntimeException("internal error: " + this.toString());
}
Expand All @@ -300,6 +305,11 @@ public void decodeAndFillVector(ColumnPage columnPage, ColumnVectorInfo vectorIn
for (int i = 0; i < pageSize; i++) {
vector.putDouble(i, (intData[i] / factor));
}
} else if (pageDataType == DataTypes.LONG) {
long[] longData = columnPage.getLongPage();
for (int i = 0; i < pageSize; i++) {
vector.putDouble(i, (longData[i] / factor));
}
} else {
throw new RuntimeException("Unsupported datatype : " + pageDataType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.math.BigDecimal;

import org.apache.carbondata.core.metadata.datatype.DataType;
import org.apache.carbondata.core.scan.result.vector.CarbonColumnVector;

/**
Expand Down Expand Up @@ -141,4 +142,9 @@ public void putBytes(int rowId, int count, byte[] src, int srcIndex) {
columnVector.putByte(invertedIndex[rowId++], src[i]);
}
}

@Override
public DataType getBlockDataType() {
return columnVector.getBlockDataType();
}
}

0 comments on commit 94a4f83

Please sign in to comment.