carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipesala <...@git.apache.org>
Subject [GitHub] carbondata pull request #1136: [CARBONDATA-1268] Support encoding strategy f...
Date Sun, 23 Jul 2017 02:29:58 GMT
Github user ravipesala commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1136#discussion_r128908712
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/datastore/TableSpec.java ---
    @@ -25,197 +25,142 @@
     
     public class TableSpec {
     
    -  // contains name and type for each dimension
    -  private DimensionSpec dimensionSpec;
    -  // contains name and type for each measure
    -  private MeasureSpec measureSpec;
    +  // column spec for each dimension and measure
    +  private DimensionSpec[] dimensionSpec;
    +  private MeasureSpec[] measureSpec;
     
    -  public TableSpec(List<CarbonDimension> dimensions, List<CarbonMeasure>
measures) {
    -    dimensionSpec = new DimensionSpec(dimensions);
    -    measureSpec = new MeasureSpec(measures);
    -  }
    +  // number of simple dimensions
    +  private int numSimpleDimensions;
     
    -  public DimensionSpec getDimensionSpec() {
    -    return dimensionSpec;
    -  }
    -
    -  public MeasureSpec getMeasureSpec() {
    -    return measureSpec;
    -  }
    -
    -  public class DimensionSpec {
    -
    -    // field name of each dimension, in schema order
    -    private String[] fieldName;
    -
    -    // encoding type of each dimension, in schema order
    -    private DimensionType[] types;
    -
    -    // number of simple dimensions
    -    private int numSimpleDimensions;
    -
    -    // number of complex dimensions
    -    private int numComplexDimensions;
    -
    -    // number of dimensions after complex column expansion
    -    private int numDimensionExpanded;
    -
    -    DimensionSpec(List<CarbonDimension> dimensions) {
    -      // first calculate total number of columnar field considering column group and
complex column
    -      numDimensionExpanded = 0;
    -      numSimpleDimensions = 0;
    -      numComplexDimensions = 0;
    -      boolean inColumnGroup = false;
    -      for (CarbonDimension dimension : dimensions) {
    -        if (dimension.isColumnar()) {
    -          if (inColumnGroup) {
    -            inColumnGroup = false;
    -          }
    -          if (dimension.isComplex()) {
    -            numDimensionExpanded += dimension.getNumDimensionsExpanded();
    -            numComplexDimensions++;
    -          } else {
    -            numDimensionExpanded++;
    -            numSimpleDimensions++;
    -          }
    -        } else {
    -          // column group
    -          if (!inColumnGroup) {
    -            inColumnGroup = true;
    -            numDimensionExpanded++;
    -            numSimpleDimensions++;
    -          }
    +  public TableSpec(List<CarbonDimension> dimensions, List<CarbonMeasure>
measures) {
    +    // first calculate total number of columnar field considering column group and complex
column
    +    numSimpleDimensions = 0;
    +    for (CarbonDimension dimension : dimensions) {
    +      if (dimension.isColumnar()) {
    +        if (!dimension.isComplex()) {
    +          numSimpleDimensions++;
             }
    +      } else {
    +        throw new UnsupportedOperationException("column group is not supported");
           }
    +    }
    +    dimensionSpec = new DimensionSpec[dimensions.size()];
    +    measureSpec = new MeasureSpec[measures.size()];
    +    addDimensions(dimensions);
    +    addMeasures(measures);
    +  }
     
    -      // then extract dimension name and type for each column
    -      fieldName = new String[numDimensionExpanded];
    -      types = new DimensionType[numDimensionExpanded];
    -      inColumnGroup = false;
    -      int index = 0;
    -      for (CarbonDimension dimension : dimensions) {
    -        if (dimension.isColumnar()) {
    -          if (inColumnGroup) {
    -            inColumnGroup = false;
    -          }
    -          if (dimension.isComplex()) {
    -            int count = addDimension(index, dimension);
    -            index += count;
    -          } else if (dimension.getDataType() == DataType.TIMESTAMP ||
    -                     dimension.getDataType() == DataType.DATE) {
    -            addSimpleDimension(index++, dimension.getColName(), DimensionType.DIRECT_DICTIONARY);
    -          } else if (dimension.isGlobalDictionaryEncoding()) {
    -            addSimpleDimension(index++, dimension.getColName(), DimensionType.GLOBAL_DICTIONARY);
    -          } else {
    -            addSimpleDimension(index++, dimension.getColName(), DimensionType.PLAIN_VALUE);
    -          }
    +  private void addDimensions(List<CarbonDimension> dimensions) {
    +    int dimIndex = 0;
    +    for (int i = 0; i < dimensions.size(); i++) {
    +      CarbonDimension dimension = dimensions.get(i);
    +      if (dimension.isColumnar()) {
    +        if (dimension.isComplex()) {
    +          DimensionSpec spec = new DimensionSpec(DimensionType.COMPLEX, dimension);
    +          dimensionSpec[dimIndex++] = spec;
    +        } else if (dimension.getDataType() == DataType.TIMESTAMP ||
    --- End diff --
    
    it is better to check the encoding types rather than datatype.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message