use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class SegmentTaskIndexStoreTest method getDataFileFooters.
private List<DataFileFooter> getDataFileFooters() {
SegmentInfo segmentInfo = new SegmentInfo();
DataFileFooter footer = new DataFileFooter();
ColumnSchema columnSchema = new ColumnSchema();
BlockletInfo blockletInfo = new BlockletInfo();
List<DataFileFooter> footerList = new ArrayList<DataFileFooter>();
List<ColumnSchema> columnSchemaList = new ArrayList<ColumnSchema>();
columnSchema.setColumnName("employeeName");
columnSchemaList.add(new ColumnSchema());
footer.setSegmentInfo(segmentInfo);
footer.setColumnInTable(columnSchemaList);
footer.setBlockletList(Arrays.asList(blockletInfo));
footerList.add(footer);
return footerList;
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class BlockIndexTest method testBuild.
@Test
public void testBuild() {
segmentInfo = new SegmentInfo();
new MockUp<BlockletBTreeBuilder>() {
@Mock
public void build(BTreeBuilderInfo segmentBuilderInfos) {
}
};
int expectedValue = 0;
BlockIndex blockIndex = new BlockIndex();
columnSchema.setColumnName("employeeName");
columnSchemaList.add(new ColumnSchema());
footer.setSegmentInfo(segmentInfo);
footer.setColumnInTable(columnSchemaList);
footer.setBlockletList(Arrays.asList(blockletInfo));
footerList.add(footer);
blockIndex.buildIndex(footerList);
assertEquals(footerList.get(0).getNumberOfRows(), expectedValue);
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class CarbonFactDataHandlerModel method getCarbonFactDataHandlerModel.
/**
* This method will create a model object for carbon fact data handler
*
* @param loadModel
* @return
*/
public static CarbonFactDataHandlerModel getCarbonFactDataHandlerModel(CarbonLoadModel loadModel, CarbonTable carbonTable, SegmentProperties segmentProperties, String tableName, String tempStoreLocation) {
CarbonFactDataHandlerModel carbonFactDataHandlerModel = new CarbonFactDataHandlerModel();
carbonFactDataHandlerModel.setSchemaUpdatedTimeStamp(carbonTable.getTableLastUpdatedTime());
carbonFactDataHandlerModel.setDatabaseName(loadModel.getDatabaseName());
carbonFactDataHandlerModel.setTableName(tableName);
carbonFactDataHandlerModel.setMeasureCount(segmentProperties.getMeasures().size());
carbonFactDataHandlerModel.setStoreLocation(tempStoreLocation);
carbonFactDataHandlerModel.setDimLens(segmentProperties.getDimColumnsCardinality());
carbonFactDataHandlerModel.setSegmentProperties(segmentProperties);
carbonFactDataHandlerModel.setNoDictionaryCount(segmentProperties.getNumberOfNoDictionaryDimension());
carbonFactDataHandlerModel.setDimensionCount(segmentProperties.getDimensions().size() - carbonFactDataHandlerModel.getNoDictionaryCount());
List<ColumnSchema> wrapperColumnSchema = CarbonUtil.getColumnSchemaList(carbonTable.getDimensionByTableName(tableName), carbonTable.getMeasureByTableName(tableName));
carbonFactDataHandlerModel.setWrapperColumnSchema(wrapperColumnSchema);
// get the cardinality for all all the columns including no dictionary columns
int[] formattedCardinality = CarbonUtil.getFormattedCardinality(segmentProperties.getDimColumnsCardinality(), wrapperColumnSchema);
carbonFactDataHandlerModel.setColCardinality(formattedCardinality);
//TO-DO Need to handle complex types here .
Map<Integer, GenericDataType> complexIndexMap = new HashMap<Integer, GenericDataType>(segmentProperties.getComplexDimensions().size());
carbonFactDataHandlerModel.setComplexIndexMap(complexIndexMap);
DataType[] aggType = new DataType[segmentProperties.getMeasures().size()];
int i = 0;
for (CarbonMeasure msr : segmentProperties.getMeasures()) {
aggType[i++] = msr.getDataType();
}
carbonFactDataHandlerModel.setMeasureDataType(aggType);
String carbonDataDirectoryPath = CarbonDataProcessorUtil.checkAndCreateCarbonStoreLocation(loadModel.getStorePath(), loadModel.getDatabaseName(), tableName, loadModel.getPartitionId(), loadModel.getSegmentId());
carbonFactDataHandlerModel.setCarbonDataDirectoryPath(carbonDataDirectoryPath);
List<CarbonDimension> dimensionByTableName = loadModel.getCarbonDataLoadSchema().getCarbonTable().getDimensionByTableName(tableName);
boolean[] isUseInvertedIndexes = new boolean[dimensionByTableName.size()];
int index = 0;
for (CarbonDimension dimension : dimensionByTableName) {
isUseInvertedIndexes[index++] = dimension.isUseInvertedIndex();
}
carbonFactDataHandlerModel.setIsUseInvertedIndex(isUseInvertedIndexes);
carbonFactDataHandlerModel.setPrimitiveDimLens(segmentProperties.getDimColumnsCardinality());
carbonFactDataHandlerModel.setBlockSizeInMB(carbonTable.getBlockSizeInMB());
return carbonFactDataHandlerModel;
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class CarbonFactDataHandlerModel method createCarbonFactDataHandlerModel.
/**
* Create the model using @{@link CarbonDataLoadConfiguration}
*/
public static CarbonFactDataHandlerModel createCarbonFactDataHandlerModel(CarbonDataLoadConfiguration configuration, String storeLocation, int bucketId, int taskExtension) {
CarbonTableIdentifier identifier = configuration.getTableIdentifier().getCarbonTableIdentifier();
boolean[] isUseInvertedIndex = CarbonDataProcessorUtil.getIsUseInvertedIndex(configuration.getDataFields());
int[] dimLensWithComplex = configuration.getCardinalityFinder().getCardinality();
if (!configuration.isSortTable()) {
for (int i = 0; i < dimLensWithComplex.length; i++) {
if (dimLensWithComplex[i] != 0) {
dimLensWithComplex[i] = Integer.MAX_VALUE;
}
}
}
CarbonTable carbonTable = CarbonMetadata.getInstance().getCarbonTable(identifier.getDatabaseName() + CarbonCommonConstants.UNDERSCORE + identifier.getTableName());
List<ColumnSchema> wrapperColumnSchema = CarbonUtil.getColumnSchemaList(carbonTable.getDimensionByTableName(identifier.getTableName()), carbonTable.getMeasureByTableName(identifier.getTableName()));
int[] colCardinality = CarbonUtil.getFormattedCardinality(dimLensWithComplex, wrapperColumnSchema);
SegmentProperties segmentProperties = new SegmentProperties(wrapperColumnSchema, colCardinality);
int[] dimLens = configuration.calcDimensionLengths();
int dimensionCount = configuration.getDimensionCount();
int noDictionaryCount = configuration.getNoDictionaryCount();
int complexDimensionCount = configuration.getComplexColumnCount();
int measureCount = configuration.getMeasureCount();
int simpleDimsCount = dimensionCount - noDictionaryCount - complexDimensionCount;
int[] simpleDimsLen = new int[simpleDimsCount];
for (int i = 0; i < simpleDimsCount; i++) {
simpleDimsLen[i] = dimLens[i];
}
//To Set MDKey Index of each primitive type in complex type
int surrIndex = simpleDimsCount;
Iterator<Map.Entry<String, GenericDataType>> complexMap = CarbonDataProcessorUtil.getComplexTypesMap(configuration.getDataFields()).entrySet().iterator();
Map<Integer, GenericDataType> complexIndexMap = new HashMap<>(complexDimensionCount);
while (complexMap.hasNext()) {
Map.Entry<String, GenericDataType> complexDataType = complexMap.next();
complexDataType.getValue().setOutputArrayIndex(0);
complexIndexMap.put(simpleDimsCount, complexDataType.getValue());
simpleDimsCount++;
List<GenericDataType> primitiveTypes = new ArrayList<GenericDataType>();
complexDataType.getValue().getAllPrimitiveChildren(primitiveTypes);
for (GenericDataType eachPrimitive : primitiveTypes) {
eachPrimitive.setSurrogateIndex(surrIndex++);
}
}
CarbonDataFileAttributes carbonDataFileAttributes = new CarbonDataFileAttributes(Integer.parseInt(configuration.getTaskNo()), (Long) configuration.getDataLoadProperty(DataLoadProcessorConstants.FACT_TIME_STAMP));
String carbonDataDirectoryPath = getCarbonDataFolderLocation(configuration);
CarbonFactDataHandlerModel carbonFactDataHandlerModel = new CarbonFactDataHandlerModel();
carbonFactDataHandlerModel.setSchemaUpdatedTimeStamp(configuration.getSchemaUpdatedTimeStamp());
carbonFactDataHandlerModel.setDatabaseName(identifier.getDatabaseName());
carbonFactDataHandlerModel.setTableName(identifier.getTableName());
carbonFactDataHandlerModel.setMeasureCount(measureCount);
carbonFactDataHandlerModel.setStoreLocation(storeLocation);
carbonFactDataHandlerModel.setDimLens(dimLens);
carbonFactDataHandlerModel.setNoDictionaryCount(noDictionaryCount);
carbonFactDataHandlerModel.setDimensionCount(configuration.getDimensionCount() - noDictionaryCount);
carbonFactDataHandlerModel.setComplexIndexMap(complexIndexMap);
carbonFactDataHandlerModel.setSegmentProperties(segmentProperties);
carbonFactDataHandlerModel.setColCardinality(colCardinality);
carbonFactDataHandlerModel.setMeasureDataType(configuration.getMeasureDataType());
carbonFactDataHandlerModel.setWrapperColumnSchema(wrapperColumnSchema);
carbonFactDataHandlerModel.setPrimitiveDimLens(simpleDimsLen);
carbonFactDataHandlerModel.setCarbonDataFileAttributes(carbonDataFileAttributes);
carbonFactDataHandlerModel.setCarbonDataDirectoryPath(carbonDataDirectoryPath);
carbonFactDataHandlerModel.setIsUseInvertedIndex(isUseInvertedIndex);
carbonFactDataHandlerModel.setBlockSizeInMB(carbonTable.getBlockSizeInMB());
carbonFactDataHandlerModel.setComplexDimensionKeyGenerator(configuration.createKeyGeneratorForComplexDimension());
carbonFactDataHandlerModel.bucketId = bucketId;
carbonFactDataHandlerModel.segmentId = configuration.getSegmentId();
carbonFactDataHandlerModel.taskExtension = taskExtension;
return carbonFactDataHandlerModel;
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchema.
@Test
public void testFromWrapperToExternalColumnSchema() {
ColumnSchema wrapperColumnSchema = new ColumnSchema();
new MockUp<ColumnSchema>() {
@Mock
public List<Encoding> getEncodingList() {
return encodings;
}
@Mock
public int getSchemaOrdinal() {
return 1;
}
@Mock
public DataType getDataType() {
return DataType.BOOLEAN;
}
@Mock
public String getColumnName() {
return "columnName";
}
@Mock
public String getColumnUniqueId() {
return "1";
}
@Mock
public boolean isColumnar() {
return true;
}
@Mock
public boolean isDimensionColumn() {
return true;
}
@Mock
public int getColumnGroupId() {
return 1;
}
@Mock
public int getScale() {
return 1;
}
@Mock
public int getPrecision() {
return 1;
}
@Mock
public int getNumberOfChild() {
return 1;
}
@Mock
public byte[] getDefaultValue() {
return new byte[] { 1, 2 };
}
@Mock
public Map<String, String> getColumnProperties() {
return columnPropertyMap;
}
@Mock
public boolean isInvisible() {
return true;
}
@Mock
public String getColumnReferenceId() {
return "1";
}
};
org.apache.carbondata.format.ColumnSchema actualResult = thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
assertEquals(thriftColumnSchema, actualResult);
}
Aggregations