Search in sources :

Example 1 with ColumnType

use of org.apache.carbondata.core.datastore.ColumnType in project carbondata by apache.

the class TablePage method getColumnPage.

/**
 * return column page of specified column name
 */
public ColumnPage getColumnPage(String columnName) {
    int dictDimensionIndex = -1;
    int noDictDimensionIndex = -1;
    ColumnPage page = null;
    TableSpec spec = model.getTableSpec();
    int numDimensions = spec.getNumDimensions();
    for (int i = 0; i < numDimensions; i++) {
        ColumnType type = spec.getDimensionSpec(i).getColumnType();
        if ((type == ColumnType.GLOBAL_DICTIONARY) || (type == ColumnType.DIRECT_DICTIONARY)) {
            page = dictDimensionPages[++dictDimensionIndex];
        } else if (type == ColumnType.PLAIN_VALUE) {
            page = noDictDimensionPages[++noDictDimensionIndex];
        } else {
            // do not support datamap on complex column
            continue;
        }
        String fieldName = spec.getDimensionSpec(i).getFieldName();
        if (fieldName.equalsIgnoreCase(columnName)) {
            return page;
        }
    }
    int numMeasures = spec.getNumMeasures();
    for (int i = 0; i < numMeasures; i++) {
        String fieldName = spec.getMeasureSpec(i).getFieldName();
        if (fieldName.equalsIgnoreCase(columnName)) {
            return measurePages[i];
        }
    }
    throw new IllegalArgumentException("DataMap: must have '" + columnName + "' column in schema");
}
Also used : TableSpec(org.apache.carbondata.core.datastore.TableSpec) ColumnType(org.apache.carbondata.core.datastore.ColumnType) EncodedColumnPage(org.apache.carbondata.core.datastore.page.encoding.EncodedColumnPage) ComplexColumnPage(org.apache.carbondata.core.datastore.page.ComplexColumnPage) ColumnPage(org.apache.carbondata.core.datastore.page.ColumnPage)

Aggregations

ColumnType (org.apache.carbondata.core.datastore.ColumnType)1 TableSpec (org.apache.carbondata.core.datastore.TableSpec)1 ColumnPage (org.apache.carbondata.core.datastore.page.ColumnPage)1 ComplexColumnPage (org.apache.carbondata.core.datastore.page.ComplexColumnPage)1 EncodedColumnPage (org.apache.carbondata.core.datastore.page.encoding.EncodedColumnPage)1