use of org.apache.carbondata.core.datastore.page.statistics.DummyStatsCollector in project carbondata by apache.
the class ComplexColumnPage method initialize.
/**
* below method will be used to initialize the column page of complex type
* @param columnToDictMap dictionary map
* @param pageSize number of records
*/
public void initialize(Map<String, LocalDictionaryGenerator> columnToDictMap, int pageSize, String columnCompressor) {
DataType dataType;
for (int i = 0; i < this.columnPages.length; i++) {
LocalDictionaryGenerator localDictionaryGenerator = columnToDictMap.get(complexColumnInfoList.get(i).getColumnNames());
TableSpec.ColumnSpec spec = getColumnSpec(i, localDictionaryGenerator);
if (null == localDictionaryGenerator) {
dataType = complexColumnInfoList.get(i).getColumnDataTypes();
if (isColumnPageBasedOnDataType(i)) {
// no dictionary primitive types need adaptive encoding,
// hence store as actual value instead of byte array
this.columnPages[i] = ColumnPage.newPage(new ColumnPageEncoderMeta(spec, dataType, columnCompressor), pageSize);
this.columnPages[i].setStatsCollector(PrimitivePageStatsCollector.newInstance(dataType));
} else {
this.columnPages[i] = ColumnPage.newPage(new ColumnPageEncoderMeta(spec, DataTypes.BYTE_ARRAY, columnCompressor), pageSize);
this.columnPages[i].setStatsCollector(new DummyStatsCollector());
}
} else {
this.columnPages[i] = ColumnPage.newLocalDictPage(new ColumnPageEncoderMeta(spec, DataTypes.BYTE_ARRAY, columnCompressor), pageSize, localDictionaryGenerator, true);
this.columnPages[i].setStatsCollector(new DummyStatsCollector());
}
}
}
use of org.apache.carbondata.core.datastore.page.statistics.DummyStatsCollector in project carbondata by apache.
the class PageLevelDictionary method getLocalDictionaryChunkForBlocklet.
/**
* Below method will be used to get the local dictionary chunk for writing
* @TODO Support for numeric data type dictionary exclude columns
* @return encoded local dictionary chunk
* @throws IOException
* in case of problem in encoding
*/
public LocalDictionaryChunk getLocalDictionaryChunkForBlocklet() throws IOException {
// TODO support for actual data type dictionary ColumnSPEC
ColumnType columnType = ColumnType.PLAIN_VALUE;
boolean isVarcharType = false;
int lvSize = CarbonCommonConstants.SHORT_SIZE_IN_BYTE;
if (DataTypes.VARCHAR == dataType) {
columnType = ColumnType.PLAIN_LONG_VALUE;
lvSize = CarbonCommonConstants.INT_SIZE_IN_BYTE;
isVarcharType = true;
}
TableSpec.ColumnSpec spec = TableSpec.ColumnSpec.newInstance(columnName, DataTypes.BYTE_ARRAY, columnType);
ColumnPage dictionaryColumnPage = ColumnPage.newPage(new ColumnPageEncoderMeta(spec, DataTypes.BYTE_ARRAY, columnCompressor), usedDictionaryValues.cardinality());
// TODO support data type specific stats collector for numeric data types
dictionaryColumnPage.setStatsCollector(new DummyStatsCollector());
int rowId = 0;
ByteBuffer byteBuffer = null;
for (int i = usedDictionaryValues.nextSetBit(0); i >= 0; i = usedDictionaryValues.nextSetBit(i + 1)) {
if (!isComplexTypePrimitive) {
dictionaryColumnPage.putData(rowId++, localDictionaryGenerator.getDictionaryKeyBasedOnValue(i));
} else {
byte[] dictionaryKeyBasedOnValue = localDictionaryGenerator.getDictionaryKeyBasedOnValue(i);
byteBuffer = ByteBuffer.allocate(lvSize + dictionaryKeyBasedOnValue.length);
if (!isVarcharType) {
byteBuffer.putShort((short) dictionaryKeyBasedOnValue.length);
} else {
byteBuffer.putInt(dictionaryKeyBasedOnValue.length);
}
byteBuffer.put(dictionaryKeyBasedOnValue);
dictionaryColumnPage.putData(rowId++, byteBuffer.array());
}
}
// creating a encoder
ColumnPageEncoder encoder = new DirectCompressCodec(DataTypes.BYTE_ARRAY).createEncoder(null);
// get encoded dictionary values
LocalDictionaryChunk localDictionaryChunk = encoder.encodeDictionary(dictionaryColumnPage);
// set compressed dictionary values
localDictionaryChunk.setDictionary_values(CompressorFactory.getInstance().getCompressor(columnCompressor).compressByte(usedDictionaryValues.toByteArray()));
// free the dictionary page memory
dictionaryColumnPage.freeMemory();
return localDictionaryChunk;
}
Aggregations