Search in sources :

Example 71 with CarbonMeasure

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.

the class CarbonUtil method getColumnSchemaList.

public static List<ColumnSchema> getColumnSchemaList(List<CarbonDimension> carbonDimensionsList, List<CarbonMeasure> carbonMeasureList) {
    List<ColumnSchema> wrapperColumnSchemaList = new ArrayList<ColumnSchema>();
    fillColumnSchemaListForComplexDims(carbonDimensionsList, wrapperColumnSchemaList);
    for (CarbonMeasure carbonMeasure : carbonMeasureList) {
        wrapperColumnSchemaList.add(carbonMeasure.getColumnSchema());
    }
    return wrapperColumnSchemaList;
}
Also used : CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)

Example 72 with CarbonMeasure

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.

the class BlockletIndexUtil method useMinMaxForBlockletPruning.

/**
 * Method to check whether to serialize min/max values to executor. Returns true if
 * filter column min/max is not cached in driver
 *
 * @param filterResolverTree
 * @param minMaxCacheColumns
 * @return
 */
public static boolean useMinMaxForBlockletPruning(FilterResolverIntf filterResolverTree, List<CarbonColumn> minMaxCacheColumns) {
    boolean serializeMinMax = false;
    if (null != minMaxCacheColumns) {
        Set<CarbonDimension> filterDimensions = new HashSet<>();
        Set<CarbonMeasure> filterMeasures = new HashSet<>();
        QueryUtil.getAllFilterDimensionsAndMeasures(filterResolverTree, filterDimensions, filterMeasures);
        // set flag to true if columns cached size is lesser than filter columns
        if (minMaxCacheColumns.size() < (filterDimensions.size() + filterMeasures.size())) {
            serializeMinMax = true;
        } else {
            // check if all the filter dimensions are cached
            for (CarbonDimension filterDimension : filterDimensions) {
                // cannot validate for complex columns
                if (filterDimension.isComplex()) {
                    continue;
                }
                if (!filterColumnExistsInMinMaxColumnList(minMaxCacheColumns, filterDimension)) {
                    serializeMinMax = true;
                    break;
                }
            }
            // check if all the filter measures are cached only if all filter dimensions are cached
            if (!serializeMinMax) {
                for (CarbonMeasure filterMeasure : filterMeasures) {
                    if (!filterColumnExistsInMinMaxColumnList(minMaxCacheColumns, filterMeasure)) {
                        serializeMinMax = true;
                        break;
                    }
                }
            }
        }
    }
    return serializeMinMax;
}
Also used : CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) HashSet(java.util.HashSet)

Example 73 with CarbonMeasure

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure 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, String carbonDataDirectoryPath) {
    // for dynamic page size in write step if varchar columns exist
    List<CarbonDimension> allDimensions = carbonTable.getVisibleDimensions();
    CarbonColumn[] noDicAndComplexColumns = new CarbonColumn[segmentProperties.getNumberOfNoDictionaryDimension() + segmentProperties.getComplexDimensions().size()];
    int noDicAndComp = 0;
    List<DataType> noDictDataTypesList = new ArrayList<>();
    for (CarbonDimension dim : allDimensions) {
        if (dim.getDataType() != DataTypes.DATE) {
            noDicAndComplexColumns[noDicAndComp++] = new CarbonColumn(dim.getColumnSchema(), dim.getOrdinal(), dim.getSchemaOrdinal());
            noDictDataTypesList.add(dim.getDataType());
        }
    }
    CarbonFactDataHandlerModel carbonFactDataHandlerModel = new CarbonFactDataHandlerModel();
    carbonFactDataHandlerModel.setSchemaUpdatedTimeStamp(carbonTable.getTableLastUpdatedTime());
    carbonFactDataHandlerModel.setDatabaseName(loadModel.getDatabaseName());
    carbonFactDataHandlerModel.setTableName(tableName);
    carbonFactDataHandlerModel.setStoreLocation(tempStoreLocation);
    carbonFactDataHandlerModel.setSegmentProperties(segmentProperties);
    carbonFactDataHandlerModel.setSegmentId(loadModel.getSegmentId());
    List<ColumnSchema> wrapperColumnSchema = CarbonUtil.getColumnSchemaList(carbonTable.getVisibleDimensions(), carbonTable.getVisibleMeasures());
    carbonFactDataHandlerModel.setWrapperColumnSchema(wrapperColumnSchema);
    carbonFactDataHandlerModel.setComplexIndexMap(convertComplexDimensionToComplexIndexMap(segmentProperties, loadModel.getSerializationNullFormat()));
    DataType[] measureDataTypes = new DataType[segmentProperties.getMeasures().size()];
    int i = 0;
    for (CarbonMeasure msr : segmentProperties.getMeasures()) {
        measureDataTypes[i++] = msr.getDataType();
    }
    carbonFactDataHandlerModel.setMeasureDataType(measureDataTypes);
    carbonFactDataHandlerModel.setNoDictAndComplexColumns(noDicAndComplexColumns);
    carbonFactDataHandlerModel.setNoDictDataTypesList(noDictDataTypesList);
    CarbonUtil.checkAndCreateFolderWithPermission(carbonDataDirectoryPath);
    carbonFactDataHandlerModel.setCarbonDataDirectoryPath(carbonDataDirectoryPath);
    carbonFactDataHandlerModel.setBlockSizeInMB(carbonTable.getBlockSizeInMB());
    carbonFactDataHandlerModel.setColumnCompressor(loadModel.getColumnCompressor());
    carbonFactDataHandlerModel.tableSpec = new TableSpec(carbonTable, false);
    IndexWriterListener listener = new IndexWriterListener();
    listener.registerAllWriter(carbonTable, loadModel.getSegmentId(), CarbonTablePath.getShardName(CarbonTablePath.DataFileUtil.getTaskIdFromTaskNo(loadModel.getTaskNo()), carbonFactDataHandlerModel.getBucketId(), carbonFactDataHandlerModel.getTaskExtension(), String.valueOf(loadModel.getFactTimeStamp()), loadModel.getSegmentId()), segmentProperties);
    carbonFactDataHandlerModel.indexWriterlistener = listener;
    carbonFactDataHandlerModel.initNumberOfCores();
    carbonFactDataHandlerModel.setColumnLocalDictGenMap(CarbonUtil.getLocalDictionaryModel(carbonTable));
    carbonFactDataHandlerModel.sortScope = carbonTable.getSortScope();
    carbonFactDataHandlerModel.setMetrics(loadModel.getMetrics());
    return carbonFactDataHandlerModel;
}
Also used : TableSpec(org.apache.carbondata.core.datastore.TableSpec) CarbonColumn(org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension) CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) GenericDataType(org.apache.carbondata.processing.datatypes.GenericDataType) DataType(org.apache.carbondata.core.metadata.datatype.DataType) IndexWriterListener(org.apache.carbondata.processing.index.IndexWriterListener)

Example 74 with CarbonMeasure

use of org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure in project carbondata by apache.

the class CarbonDataProcessorUtil method getSchemaColumnNames.

/**
 * This method update the column Name
 *
 * @param schema
 */
public static Set<String> getSchemaColumnNames(CarbonDataLoadSchema schema) {
    Set<String> columnNames = new HashSet<String>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
    List<CarbonDimension> dimensions = schema.getCarbonTable().getVisibleDimensions();
    Map<String, String> properties = schema.getCarbonTable().getTableInfo().getFactTable().getTableProperties();
    String spatialProperty = properties.get(CarbonCommonConstants.SPATIAL_INDEX);
    spatialProperty = spatialProperty != null ? spatialProperty.trim() : null;
    for (CarbonDimension dimension : dimensions) {
        // skip the non-schema column
        if (!dimension.getColName().equalsIgnoreCase(spatialProperty)) {
            columnNames.add(dimension.getColName());
        }
    }
    List<CarbonMeasure> measures = schema.getCarbonTable().getVisibleMeasures();
    for (CarbonMeasure msr : measures) {
        columnNames.add(msr.getColName());
    }
    return columnNames;
}
Also used : CarbonMeasure(org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure) HashSet(java.util.HashSet) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Aggregations

CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)74 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)52 ArrayList (java.util.ArrayList)28 DataType (org.apache.carbondata.core.metadata.datatype.DataType)12 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)12 CarbonColumn (org.apache.carbondata.core.metadata.schema.table.column.CarbonColumn)11 HashSet (java.util.HashSet)8 ProjectionMeasure (org.apache.carbondata.core.scan.model.ProjectionMeasure)8 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)7 BlockExecutionInfo (org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo)5 ProjectionDimension (org.apache.carbondata.core.scan.model.ProjectionDimension)5 SerializableComparator (org.apache.carbondata.core.util.comparator.SerializableComparator)5 MeasureInfo (org.apache.carbondata.core.scan.executor.infos.MeasureInfo)4 DimColumnResolvedFilterInfo (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo)4 MeasureColumnResolvedFilterInfo (org.apache.carbondata.core.scan.filter.resolver.resolverinfo.MeasureColumnResolvedFilterInfo)4 BitSet (java.util.BitSet)3 LinkedHashSet (java.util.LinkedHashSet)3 Set (java.util.Set)3 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)3 QueryDimension (org.apache.carbondata.core.scan.model.QueryDimension)3